Google OR-Tools v9.9
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
com.google.ortools.constraintsolver.RoutingDimension Class Reference

Public Member Functions

 RoutingDimension (long cPtr, boolean cMemoryOwn)
 
synchronized void delete ()
 
RoutingModel model ()
 
long getTransitValue (long from_index, long to_index, long vehicle)
 
long getTransitValueFromClass (long from_index, long to_index, long vehicle_class)
 
IntVar cumulVar (long index)
 
IntVar transitVar (long index)
 
IntVar fixedTransitVar (long index)
 
IntVar slackVar (long index)
 
IntVar[] cumuls ()
 
IntVar[] fixed_transits ()
 
IntVar[] transits ()
 
IntVar[] slacks ()
 
void setSpanUpperBoundForVehicle (long upper_bound, int vehicle)
 
void setSpanCostCoefficientForVehicle (long coefficient, int vehicle)
 
void setSpanCostCoefficientForAllVehicles (long coefficient)
 
void SetSlackCostCoefficientForVehicle (long coefficient, int vehicle)
 
void SetSlackCostCoefficientForAllVehicles (long coefficient)
 
void setGlobalSpanCostCoefficient (long coefficient)
 
void setCumulVarSoftUpperBound (long index, long upper_bound, long coefficient)
 
boolean hasCumulVarSoftUpperBound (long index)
 
long getCumulVarSoftUpperBound (long index)
 
long getCumulVarSoftUpperBoundCoefficient (long index)
 
void setCumulVarSoftLowerBound (long index, long lower_bound, long coefficient)
 
boolean hasCumulVarSoftLowerBound (long index)
 
long getCumulVarSoftLowerBound (long index)
 
long getCumulVarSoftLowerBoundCoefficient (long index)
 
void setBreakIntervalsOfVehicle (IntervalVar[] breaks, int vehicle, int pre_travel_evaluator, int post_travel_evaluator)
 
void setBreakIntervalsOfVehicle (IntervalVar[] breaks, int vehicle, long[] node_visit_transits)
 
void setBreakDistanceDurationOfVehicle (long distance, long duration, int vehicle)
 
void InitializeBreaks ()
 
boolean HasBreakConstraints ()
 
void setBreakIntervalsOfVehicle (IntervalVar[] breaks, int vehicle, long[] node_visit_transits, LongBinaryOperator delays)
 
IntervalVar[] getBreakIntervalsOfVehicle (int vehicle)
 
int GetPreTravelEvaluatorOfVehicle (int vehicle)
 
int GetPostTravelEvaluatorOfVehicle (int vehicle)
 
RoutingDimension base_dimension ()
 
long shortestTransitionSlack (long node)
 
String name ()
 
void setPickupToDeliveryLimitFunctionForPair (IntIntToLongFunction limit_function, int pair_index)
 
boolean hasPickupToDeliveryLimits ()
 
void addNodePrecedence (long first_node, long second_node, long offset)
 
long getSpanUpperBoundForVehicle (int vehicle)
 
long getSpanCostCoefficientForVehicle (int vehicle)
 
long GetSlackCostCoefficientForVehicle (int vehicle)
 
long getGlobalSpanCostCoefficient ()
 
long GetGlobalOptimizerOffset ()
 
long getLocalOptimizerOffsetForVehicle (int vehicle)
 
void setSoftSpanUpperBoundForVehicle (BoundCost bound_cost, int vehicle)
 
boolean hasSoftSpanUpperBounds ()
 
BoundCost getSoftSpanUpperBoundForVehicle (int vehicle)
 
void setQuadraticCostSoftSpanUpperBoundForVehicle (BoundCost bound_cost, int vehicle)
 
boolean hasQuadraticCostSoftSpanUpperBounds ()
 
BoundCost getQuadraticCostSoftSpanUpperBoundForVehicle (int vehicle)
 

Static Public Member Functions

static long getCPtr (RoutingDimension obj)
 
static long swigRelease (RoutingDimension obj)
 

Protected Member Functions

void finalize ()
 

Protected Attributes

transient boolean swigCMemOwn
 

Detailed Description

Dimensions represent quantities accumulated at nodes along the routes. They
represent quantities such as weights or volumes carried along the route, or
distance or times.

Quantities at a node are represented by "cumul" variables and the increase
or decrease of quantities between nodes are represented by "transit"
variables. These variables are linked as follows:

if j == next(i),
cumuls(j) = cumuls(i) + transits(i) + slacks(i) +
state_dependent_transits(i)

where slack is a positive slack variable (can represent waiting times for
a time dimension), and state_dependent_transits is a non-purely functional
version of transits_. Favour transits over state_dependent_transits when
possible, because purely functional callbacks allow more optimisations and
make the model faster and easier to solve.
for a given vehicle, it is passed as an external vector, it would be better
to have this information here.

Definition at line 36 of file RoutingDimension.java.

Constructor & Destructor Documentation

◆ RoutingDimension()

com.google.ortools.constraintsolver.RoutingDimension.RoutingDimension ( long cPtr,
boolean cMemoryOwn )

Definition at line 40 of file RoutingDimension.java.

Member Function Documentation

◆ addNodePrecedence()

void com.google.ortools.constraintsolver.RoutingDimension.addNodePrecedence ( long first_node,
long second_node,
long offset )

Definition at line 392 of file RoutingDimension.java.

◆ base_dimension()

RoutingDimension com.google.ortools.constraintsolver.RoutingDimension.base_dimension ( )

Returns the parent in the dependency tree if any or nullptr otherwise.

Definition at line 359 of file RoutingDimension.java.

◆ cumuls()

IntVar[] com.google.ortools.constraintsolver.RoutingDimension.cumuls ( )

Like CumulVar(), TransitVar(), SlackVar() but return the whole variable
vectors instead (indexed by int64_t var index).

Definition at line 129 of file RoutingDimension.java.

◆ cumulVar()

IntVar com.google.ortools.constraintsolver.RoutingDimension.cumulVar ( long index)

Get the cumul, transit and slack variables for the given node (given as
int64_t var index).

Definition at line 105 of file RoutingDimension.java.

◆ delete()

synchronized void com.google.ortools.constraintsolver.RoutingDimension.delete ( )

Definition at line 66 of file RoutingDimension.java.

◆ finalize()

void com.google.ortools.constraintsolver.RoutingDimension.finalize ( )
protected

Definition at line 62 of file RoutingDimension.java.

◆ fixed_transits()

IntVar[] com.google.ortools.constraintsolver.RoutingDimension.fixed_transits ( )

Definition at line 133 of file RoutingDimension.java.

◆ fixedTransitVar()

IntVar com.google.ortools.constraintsolver.RoutingDimension.fixedTransitVar ( long index)

Definition at line 115 of file RoutingDimension.java.

◆ getBreakIntervalsOfVehicle()

IntervalVar[] com.google.ortools.constraintsolver.RoutingDimension.getBreakIntervalsOfVehicle ( int vehicle)

Returns the break intervals set by SetBreakIntervalsOfVehicle().

Definition at line 344 of file RoutingDimension.java.

◆ getCPtr()

static long com.google.ortools.constraintsolver.RoutingDimension.getCPtr ( RoutingDimension obj)
static

Definition at line 45 of file RoutingDimension.java.

◆ getCumulVarSoftLowerBound()

long com.google.ortools.constraintsolver.RoutingDimension.getCumulVarSoftLowerBound ( long index)

Returns the soft lower bound of a cumul variable for a given variable
index. The "hard" lower bound of the variable is returned if no soft lower
bound has been set.

Definition at line 267 of file RoutingDimension.java.

◆ getCumulVarSoftLowerBoundCoefficient()

long com.google.ortools.constraintsolver.RoutingDimension.getCumulVarSoftLowerBoundCoefficient ( long index)

Returns the cost coefficient of the soft lower bound of a cumul variable
for a given variable index. If no soft lower bound has been set, 0 is
returned.

Definition at line 276 of file RoutingDimension.java.

◆ getCumulVarSoftUpperBound()

long com.google.ortools.constraintsolver.RoutingDimension.getCumulVarSoftUpperBound ( long index)

Returns the soft upper bound of a cumul variable for a given variable
index. The "hard" upper bound of the variable is returned if no soft upper
bound has been set.

Definition at line 226 of file RoutingDimension.java.

◆ getCumulVarSoftUpperBoundCoefficient()

long com.google.ortools.constraintsolver.RoutingDimension.getCumulVarSoftUpperBoundCoefficient ( long index)

Returns the cost coefficient of the soft upper bound of a cumul variable
for a given variable index. If no soft upper bound has been set, 0 is
returned.

Definition at line 235 of file RoutingDimension.java.

◆ GetGlobalOptimizerOffset()

long com.google.ortools.constraintsolver.RoutingDimension.GetGlobalOptimizerOffset ( )

Definition at line 412 of file RoutingDimension.java.

◆ getGlobalSpanCostCoefficient()

long com.google.ortools.constraintsolver.RoutingDimension.getGlobalSpanCostCoefficient ( )

Definition at line 408 of file RoutingDimension.java.

◆ getLocalOptimizerOffsetForVehicle()

long com.google.ortools.constraintsolver.RoutingDimension.getLocalOptimizerOffsetForVehicle ( int vehicle)

Definition at line 416 of file RoutingDimension.java.

◆ GetPostTravelEvaluatorOfVehicle()

int com.google.ortools.constraintsolver.RoutingDimension.GetPostTravelEvaluatorOfVehicle ( int vehicle)

Definition at line 352 of file RoutingDimension.java.

◆ GetPreTravelEvaluatorOfVehicle()

int com.google.ortools.constraintsolver.RoutingDimension.GetPreTravelEvaluatorOfVehicle ( int vehicle)

Definition at line 348 of file RoutingDimension.java.

◆ getQuadraticCostSoftSpanUpperBoundForVehicle()

BoundCost com.google.ortools.constraintsolver.RoutingDimension.getQuadraticCostSoftSpanUpperBoundForVehicle ( int vehicle)

Definition at line 448 of file RoutingDimension.java.

◆ GetSlackCostCoefficientForVehicle()

long com.google.ortools.constraintsolver.RoutingDimension.GetSlackCostCoefficientForVehicle ( int vehicle)

Definition at line 404 of file RoutingDimension.java.

◆ getSoftSpanUpperBoundForVehicle()

BoundCost com.google.ortools.constraintsolver.RoutingDimension.getSoftSpanUpperBoundForVehicle ( int vehicle)

Definition at line 432 of file RoutingDimension.java.

◆ getSpanCostCoefficientForVehicle()

long com.google.ortools.constraintsolver.RoutingDimension.getSpanCostCoefficientForVehicle ( int vehicle)

Definition at line 400 of file RoutingDimension.java.

◆ getSpanUpperBoundForVehicle()

long com.google.ortools.constraintsolver.RoutingDimension.getSpanUpperBoundForVehicle ( int vehicle)

Definition at line 396 of file RoutingDimension.java.

◆ getTransitValue()

long com.google.ortools.constraintsolver.RoutingDimension.getTransitValue ( long from_index,
long to_index,
long vehicle )

Returns the transition value for a given pair of nodes (as var index);
this value is the one taken by the corresponding transit variable when
the 'next' variable for 'from_index' is bound to 'to_index'.

Definition at line 89 of file RoutingDimension.java.

◆ getTransitValueFromClass()

long com.google.ortools.constraintsolver.RoutingDimension.getTransitValueFromClass ( long from_index,
long to_index,
long vehicle_class )

Same as above but taking a vehicle class of the dimension instead of a
vehicle (the class of a vehicle can be obtained with vehicle_to_class()).

Definition at line 97 of file RoutingDimension.java.

◆ HasBreakConstraints()

boolean com.google.ortools.constraintsolver.RoutingDimension.HasBreakConstraints ( )

Returns true if any break interval or break distance was defined.

Definition at line 329 of file RoutingDimension.java.

◆ hasCumulVarSoftLowerBound()

boolean com.google.ortools.constraintsolver.RoutingDimension.hasCumulVarSoftLowerBound ( long index)

Returns true if a soft lower bound has been set for a given variable
index.

Definition at line 258 of file RoutingDimension.java.

◆ hasCumulVarSoftUpperBound()

boolean com.google.ortools.constraintsolver.RoutingDimension.hasCumulVarSoftUpperBound ( long index)

Returns true if a soft upper bound has been set for a given variable
index.

Definition at line 217 of file RoutingDimension.java.

◆ hasPickupToDeliveryLimits()

boolean com.google.ortools.constraintsolver.RoutingDimension.hasPickupToDeliveryLimits ( )

Definition at line 388 of file RoutingDimension.java.

◆ hasQuadraticCostSoftSpanUpperBounds()

boolean com.google.ortools.constraintsolver.RoutingDimension.hasQuadraticCostSoftSpanUpperBounds ( )

Definition at line 444 of file RoutingDimension.java.

◆ hasSoftSpanUpperBounds()

boolean com.google.ortools.constraintsolver.RoutingDimension.hasSoftSpanUpperBounds ( )

Definition at line 428 of file RoutingDimension.java.

◆ InitializeBreaks()

void com.google.ortools.constraintsolver.RoutingDimension.InitializeBreaks ( )

Sets up vehicle_break_intervals_, vehicle_break_distance_duration_,
pre_travel_evaluators and post_travel_evaluators.

Definition at line 322 of file RoutingDimension.java.

◆ model()

RoutingModel com.google.ortools.constraintsolver.RoutingDimension.model ( )

Returns the model on which the dimension was created.

Definition at line 79 of file RoutingDimension.java.

◆ name()

String com.google.ortools.constraintsolver.RoutingDimension.name ( )

Returns the name of the dimension.

Definition at line 380 of file RoutingDimension.java.

◆ setBreakDistanceDurationOfVehicle()

void com.google.ortools.constraintsolver.RoutingDimension.setBreakDistanceDurationOfVehicle ( long distance,
long duration,
int vehicle )

With breaks supposed to be consecutive, this forces the distance between
breaks of size at least minimum_break_duration to be at most distance.
This supposes that the time until route start and after route end are
infinite breaks.

Definition at line 314 of file RoutingDimension.java.

◆ setBreakIntervalsOfVehicle() [1/3]

void com.google.ortools.constraintsolver.RoutingDimension.setBreakIntervalsOfVehicle ( IntervalVar[] breaks,
int vehicle,
int pre_travel_evaluator,
int post_travel_evaluator )

Sets the breaks for a given vehicle. Breaks are represented by
IntervalVars. They may interrupt transits between nodes and increase
the value of corresponding slack variables.
A break may take place before the start of a vehicle, after the end of
a vehicle, or during a travel i -> j.

In that case, the interval [break.Start(), break.End()) must be a subset
of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In
other words, a break may not overlap any node n's visit, given by
[CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)).
This formula considers post_travel(_, start) and pre_travel(end, _) to be
0; pre_travel will never be called on any (_, start) and post_travel will
never we called on any (end, _). If pre_travel_evaluator or
post_travel_evaluator is -1, it will be taken as a function that always
returns 0.

Definition at line 297 of file RoutingDimension.java.

◆ setBreakIntervalsOfVehicle() [2/3]

void com.google.ortools.constraintsolver.RoutingDimension.setBreakIntervalsOfVehicle ( IntervalVar[] breaks,
int vehicle,
long[] node_visit_transits )

Deprecated, sets pre_travel(i, j) = node_visit_transit[i].

Definition at line 304 of file RoutingDimension.java.

◆ setBreakIntervalsOfVehicle() [3/3]

void com.google.ortools.constraintsolver.RoutingDimension.setBreakIntervalsOfVehicle ( IntervalVar[] breaks,
int vehicle,
long[] node_visit_transits,
LongBinaryOperator delays )

Deprecated, sets pre_travel(i, j) = node_visit_transit[i]
and post_travel(i, j) = delays(i, j).

Definition at line 337 of file RoutingDimension.java.

◆ setCumulVarSoftLowerBound()

void com.google.ortools.constraintsolver.RoutingDimension.setCumulVarSoftLowerBound ( long index,
long lower_bound,
long coefficient )

Sets a soft lower bound to the cumul variable of a given variable index.
If the value of the cumul variable is less than the bound, a cost
proportional to the difference between this value and the bound is added
to the cost function of the model:
cumulVar > lower_bound -> cost = 0
cumulVar <= lower_bound -> cost = coefficient * (lower_bound -
cumulVar).
This is also handy to model earliness costs when the dimension represents
time.

Definition at line 250 of file RoutingDimension.java.

◆ setCumulVarSoftUpperBound()

void com.google.ortools.constraintsolver.RoutingDimension.setCumulVarSoftUpperBound ( long index,
long upper_bound,
long coefficient )

Sets a soft upper bound to the cumul variable of a given variable index.
If the value of the cumul variable is greater than the bound, a cost
proportional to the difference between this value and the bound is added
to the cost function of the model:
cumulVar <= upper_bound -> cost = 0
cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound)
This is also handy to model tardiness costs when the dimension represents
time.

Definition at line 209 of file RoutingDimension.java.

◆ setGlobalSpanCostCoefficient()

void com.google.ortools.constraintsolver.RoutingDimension.setGlobalSpanCostCoefficient ( long coefficient)

Sets a cost proportional to the global dimension span, that is the
difference between the largest value of route end cumul variables and
the smallest value of route start cumul variables.
In other words:
global_span_cost =
coefficient * (Max(dimension end value) - Min(dimension start value)).

Definition at line 195 of file RoutingDimension.java.

◆ setPickupToDeliveryLimitFunctionForPair()

void com.google.ortools.constraintsolver.RoutingDimension.setPickupToDeliveryLimitFunctionForPair ( IntIntToLongFunction limit_function,
int pair_index )

Definition at line 384 of file RoutingDimension.java.

◆ setQuadraticCostSoftSpanUpperBoundForVehicle()

void com.google.ortools.constraintsolver.RoutingDimension.setQuadraticCostSoftSpanUpperBoundForVehicle ( BoundCost bound_cost,
int vehicle )

If the span of vehicle on this dimension is larger than bound,
the cost will be increased by cost * (span - bound)^2.

Definition at line 440 of file RoutingDimension.java.

◆ SetSlackCostCoefficientForAllVehicles()

void com.google.ortools.constraintsolver.RoutingDimension.SetSlackCostCoefficientForAllVehicles ( long coefficient)

Definition at line 183 of file RoutingDimension.java.

◆ SetSlackCostCoefficientForVehicle()

void com.google.ortools.constraintsolver.RoutingDimension.SetSlackCostCoefficientForVehicle ( long coefficient,
int vehicle )

Sets a cost proportional to the dimension total slack on a given vehicle,
or on all vehicles at once. "coefficient" must be nonnegative.
This is handy to model costs only proportional to idle time when the
dimension represents time.
The cost for a vehicle is
slack_cost = coefficient *
(dimension end value - dimension start value - total_transit).

Definition at line 179 of file RoutingDimension.java.

◆ setSoftSpanUpperBoundForVehicle()

void com.google.ortools.constraintsolver.RoutingDimension.setSoftSpanUpperBoundForVehicle ( BoundCost bound_cost,
int vehicle )

If the span of vehicle on this dimension is larger than bound,
the cost will be increased by cost * (span - bound).

Definition at line 424 of file RoutingDimension.java.

◆ setSpanCostCoefficientForAllVehicles()

void com.google.ortools.constraintsolver.RoutingDimension.setSpanCostCoefficientForAllVehicles ( long coefficient)

Definition at line 166 of file RoutingDimension.java.

◆ setSpanCostCoefficientForVehicle()

void com.google.ortools.constraintsolver.RoutingDimension.setSpanCostCoefficientForVehicle ( long coefficient,
int vehicle )

Sets a cost proportional to the dimension span on a given vehicle,
or on all vehicles at once. "coefficient" must be nonnegative.
This is handy to model costs proportional to idle time when the dimension
represents time.
The cost for a vehicle is
span_cost = coefficient * (dimension end value - dimension start value).

Definition at line 162 of file RoutingDimension.java.

◆ setSpanUpperBoundForVehicle()

void com.google.ortools.constraintsolver.RoutingDimension.setSpanUpperBoundForVehicle ( long upper_bound,
int vehicle )

Sets an upper bound on the dimension span on a given vehicle. This is the
preferred way to limit the "length" of the route of a vehicle according to
a dimension.

Definition at line 150 of file RoutingDimension.java.

◆ shortestTransitionSlack()

long com.google.ortools.constraintsolver.RoutingDimension.shortestTransitionSlack ( long node)

It makes sense to use the function only for self-dependent dimension.
For such dimensions the value of the slack of a node determines the
transition cost of the next transit. Provided that

  1. cumul[node] is fixed,
  2. next[node] and next[next[node]] (if exists) are fixed,
    the value of slack[node] for which cumul[next[node]] + transit[next[node]]
    is minimized can be found in O(1) using this function.

Definition at line 373 of file RoutingDimension.java.

◆ slacks()

IntVar[] com.google.ortools.constraintsolver.RoutingDimension.slacks ( )

Definition at line 141 of file RoutingDimension.java.

◆ slackVar()

IntVar com.google.ortools.constraintsolver.RoutingDimension.slackVar ( long index)

Definition at line 120 of file RoutingDimension.java.

◆ swigRelease()

static long com.google.ortools.constraintsolver.RoutingDimension.swigRelease ( RoutingDimension obj)
static

Definition at line 49 of file RoutingDimension.java.

◆ transits()

IntVar[] com.google.ortools.constraintsolver.RoutingDimension.transits ( )

Definition at line 137 of file RoutingDimension.java.

◆ transitVar()

IntVar com.google.ortools.constraintsolver.RoutingDimension.transitVar ( long index)

Definition at line 110 of file RoutingDimension.java.

Member Data Documentation

◆ swigCMemOwn

transient boolean com.google.ortools.constraintsolver.RoutingDimension.swigCMemOwn
protected

Definition at line 38 of file RoutingDimension.java.


The documentation for this class was generated from the following file: