Google OR-Tools v9.12
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
ortools.constraint_solver.pywrapcp.RoutingDimension Class Reference
Inheritance diagram for ortools.constraint_solver.pywrapcp.RoutingDimension:

Public Member Functions

 __init__ (self, *args, **kwargs)
 
 model (self)
 
 GetTransitValue (self, from_index, to_index, vehicle)
 
 GetTransitValueFromClass (self, from_index, to_index, vehicle_class)
 
 CumulVar (self, index)
 
 TransitVar (self, index)
 
 FixedTransitVar (self, index)
 
 SlackVar (self, index)
 
 SetCumulVarRange (self, index, min, max)
 
 GetCumulVarMin (self, index)
 
 GetCumulVarMax (self, index)
 
 SetSpanUpperBoundForVehicle (self, upper_bound, vehicle)
 
 SetSpanCostCoefficientForVehicle (self, coefficient, vehicle)
 
 SetSpanCostCoefficientForAllVehicles (self, coefficient)
 
 SetSlackCostCoefficientForVehicle (self, coefficient, vehicle)
 
 SetSlackCostCoefficientForAllVehicles (self, coefficient)
 
 SetGlobalSpanCostCoefficient (self, coefficient)
 
 SetCumulVarSoftUpperBound (self, index, upper_bound, coefficient)
 
 HasCumulVarSoftUpperBound (self, index)
 
 GetCumulVarSoftUpperBound (self, index)
 
 GetCumulVarSoftUpperBoundCoefficient (self, index)
 
 SetCumulVarSoftLowerBound (self, index, lower_bound, coefficient)
 
 HasCumulVarSoftLowerBound (self, index)
 
 GetCumulVarSoftLowerBound (self, index)
 
 GetCumulVarSoftLowerBoundCoefficient (self, index)
 
 SetBreakIntervalsOfVehicle (self, breaks, vehicle, node_visit_transits)
 
 SetBreakDistanceDurationOfVehicle (self, distance, duration, vehicle)
 
 InitializeBreaks (self)
 
 HasBreakConstraints (self)
 
 GetPreTravelEvaluatorOfVehicle (self, vehicle)
 
 GetPostTravelEvaluatorOfVehicle (self, vehicle)
 
 base_dimension (self)
 
 ShortestTransitionSlack (self, node)
 
 name (self)
 
 SetPickupToDeliveryLimitFunctionForPair (self, limit_function, pair_index)
 
 HasPickupToDeliveryLimits (self)
 
 AddNodePrecedence (self, first_node, second_node, offset)
 
 GetSpanUpperBoundForVehicle (self, vehicle)
 
 GetSpanCostCoefficientForVehicle (self, vehicle)
 
 GetSlackCostCoefficientForVehicle (self, vehicle)
 
 global_span_cost_coefficient (self)
 
 GetGlobalOptimizerOffset (self)
 
 GetLocalOptimizerOffsetForVehicle (self, vehicle)
 
 SetSoftSpanUpperBoundForVehicle (self, bound_cost, vehicle)
 
 HasSoftSpanUpperBounds (self)
 
 GetSoftSpanUpperBoundForVehicle (self, vehicle)
 
 SetQuadraticCostSoftSpanUpperBoundForVehicle (self, bound_cost, vehicle)
 
 HasQuadraticCostSoftSpanUpperBounds (self)
 
 GetQuadraticCostSoftSpanUpperBoundForVehicle (self, vehicle)
 

Properties

 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 

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 6446 of file pywrapcp.py.

Constructor & Destructor Documentation

◆ __init__()

ortools.constraint_solver.pywrapcp.RoutingDimension.__init__ ( self,
* args,
** kwargs )

Definition at line 6471 of file pywrapcp.py.

Member Function Documentation

◆ AddNodePrecedence()

ortools.constraint_solver.pywrapcp.RoutingDimension.AddNodePrecedence ( self,
first_node,
second_node,
offset )

Definition at line 6721 of file pywrapcp.py.

◆ base_dimension()

ortools.constraint_solver.pywrapcp.RoutingDimension.base_dimension ( self)
Returns the parent in the dependency tree if any or nullptr otherwise.

Definition at line 6695 of file pywrapcp.py.

◆ CumulVar()

ortools.constraint_solver.pywrapcp.RoutingDimension.CumulVar ( self,
index )
    Get the cumul, transit and slack variables for the given node (given as
    int64_t var index).

Definition at line 6495 of file pywrapcp.py.

◆ FixedTransitVar()

ortools.constraint_solver.pywrapcp.RoutingDimension.FixedTransitVar ( self,
index )

Definition at line 6505 of file pywrapcp.py.

◆ GetCumulVarMax()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetCumulVarMax ( self,
index )
Gets the current maximum of the cumul variable associated to index.

Definition at line 6523 of file pywrapcp.py.

◆ GetCumulVarMin()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetCumulVarMin ( self,
index )
Gets the current minimum of the cumul variable associated to index.

Definition at line 6519 of file pywrapcp.py.

◆ GetCumulVarSoftLowerBound()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetCumulVarSoftLowerBound ( self,
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 6632 of file pywrapcp.py.

◆ GetCumulVarSoftLowerBoundCoefficient()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetCumulVarSoftLowerBoundCoefficient ( self,
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 6640 of file pywrapcp.py.

◆ GetCumulVarSoftUpperBound()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetCumulVarSoftUpperBound ( self,
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 6595 of file pywrapcp.py.

◆ GetCumulVarSoftUpperBoundCoefficient()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetCumulVarSoftUpperBoundCoefficient ( self,
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 6603 of file pywrapcp.py.

◆ GetGlobalOptimizerOffset()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetGlobalOptimizerOffset ( self)

Definition at line 6736 of file pywrapcp.py.

◆ GetLocalOptimizerOffsetForVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetLocalOptimizerOffsetForVehicle ( self,
vehicle )

Definition at line 6739 of file pywrapcp.py.

◆ GetPostTravelEvaluatorOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetPostTravelEvaluatorOfVehicle ( self,
vehicle )

Definition at line 6692 of file pywrapcp.py.

◆ GetPreTravelEvaluatorOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetPreTravelEvaluatorOfVehicle ( self,
vehicle )

Definition at line 6689 of file pywrapcp.py.

◆ GetQuadraticCostSoftSpanUpperBoundForVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetQuadraticCostSoftSpanUpperBoundForVehicle ( self,
vehicle )

Definition at line 6765 of file pywrapcp.py.

◆ GetSlackCostCoefficientForVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetSlackCostCoefficientForVehicle ( self,
vehicle )

Definition at line 6730 of file pywrapcp.py.

◆ GetSoftSpanUpperBoundForVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetSoftSpanUpperBoundForVehicle ( self,
vehicle )

Definition at line 6752 of file pywrapcp.py.

◆ GetSpanCostCoefficientForVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetSpanCostCoefficientForVehicle ( self,
vehicle )

Definition at line 6727 of file pywrapcp.py.

◆ GetSpanUpperBoundForVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetSpanUpperBoundForVehicle ( self,
vehicle )

Definition at line 6724 of file pywrapcp.py.

◆ GetTransitValue()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetTransitValue ( self,
from_index,
to_index,
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 6480 of file pywrapcp.py.

◆ GetTransitValueFromClass()

ortools.constraint_solver.pywrapcp.RoutingDimension.GetTransitValueFromClass ( self,
from_index,
to_index,
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 6488 of file pywrapcp.py.

◆ global_span_cost_coefficient()

ortools.constraint_solver.pywrapcp.RoutingDimension.global_span_cost_coefficient ( self)

Definition at line 6733 of file pywrapcp.py.

◆ HasBreakConstraints()

ortools.constraint_solver.pywrapcp.RoutingDimension.HasBreakConstraints ( self)
Returns true if any break interval or break distance was defined.

Definition at line 6685 of file pywrapcp.py.

◆ HasCumulVarSoftLowerBound()

ortools.constraint_solver.pywrapcp.RoutingDimension.HasCumulVarSoftLowerBound ( self,
index )
    Returns true if a soft lower bound has been set for a given variable
    index.

Definition at line 6625 of file pywrapcp.py.

◆ HasCumulVarSoftUpperBound()

ortools.constraint_solver.pywrapcp.RoutingDimension.HasCumulVarSoftUpperBound ( self,
index )
    Returns true if a soft upper bound has been set for a given variable
    index.

Definition at line 6588 of file pywrapcp.py.

◆ HasPickupToDeliveryLimits()

ortools.constraint_solver.pywrapcp.RoutingDimension.HasPickupToDeliveryLimits ( self)

Definition at line 6718 of file pywrapcp.py.

◆ HasQuadraticCostSoftSpanUpperBounds()

ortools.constraint_solver.pywrapcp.RoutingDimension.HasQuadraticCostSoftSpanUpperBounds ( self)

Definition at line 6762 of file pywrapcp.py.

◆ HasSoftSpanUpperBounds()

ortools.constraint_solver.pywrapcp.RoutingDimension.HasSoftSpanUpperBounds ( self)

Definition at line 6749 of file pywrapcp.py.

◆ InitializeBreaks()

ortools.constraint_solver.pywrapcp.RoutingDimension.InitializeBreaks ( self)
    Sets up vehicle_break_intervals_, vehicle_break_distance_duration_,
    pre_travel_evaluators and post_travel_evaluators.

Definition at line 6678 of file pywrapcp.py.

◆ model()

ortools.constraint_solver.pywrapcp.RoutingDimension.model ( self)
Returns the model on which the dimension was created.

Definition at line 6476 of file pywrapcp.py.

◆ name()

ortools.constraint_solver.pywrapcp.RoutingDimension.name ( self)
Returns the name of the dimension.

Definition at line 6711 of file pywrapcp.py.

◆ SetBreakDistanceDurationOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetBreakDistanceDurationOfVehicle ( self,
distance,
duration,
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 6669 of file pywrapcp.py.

◆ SetBreakIntervalsOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetBreakIntervalsOfVehicle ( self,
breaks,
vehicle,
node_visit_transits )
    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.
    Deprecated, sets pre_travel(i, j) = node_visit_transit[i].

Definition at line 6648 of file pywrapcp.py.

◆ SetCumulVarRange()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetCumulVarRange ( self,
index,
min,
max )
    Some functions to allow users to use the interface without knowing about
    the underlying CP model.
    Restricts the range of the cumul variable associated to index.

Definition at line 6511 of file pywrapcp.py.

◆ SetCumulVarSoftLowerBound()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetCumulVarSoftLowerBound ( self,
index,
lower_bound,
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 6611 of file pywrapcp.py.

◆ SetCumulVarSoftUpperBound()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetCumulVarSoftUpperBound ( self,
index,
upper_bound,
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 6575 of file pywrapcp.py.

◆ SetGlobalSpanCostCoefficient()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetGlobalSpanCostCoefficient ( self,
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 6564 of file pywrapcp.py.

◆ SetPickupToDeliveryLimitFunctionForPair()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetPickupToDeliveryLimitFunctionForPair ( self,
limit_function,
pair_index )

Definition at line 6715 of file pywrapcp.py.

◆ SetQuadraticCostSoftSpanUpperBoundForVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetQuadraticCostSoftSpanUpperBoundForVehicle ( self,
bound_cost,
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 6755 of file pywrapcp.py.

◆ SetSlackCostCoefficientForAllVehicles()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetSlackCostCoefficientForAllVehicles ( self,
coefficient )

Definition at line 6561 of file pywrapcp.py.

◆ SetSlackCostCoefficientForVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetSlackCostCoefficientForVehicle ( self,
coefficient,
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 6549 of file pywrapcp.py.

◆ SetSoftSpanUpperBoundForVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetSoftSpanUpperBoundForVehicle ( self,
bound_cost,
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 6742 of file pywrapcp.py.

◆ SetSpanCostCoefficientForAllVehicles()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetSpanCostCoefficientForAllVehicles ( self,
coefficient )

Definition at line 6546 of file pywrapcp.py.

◆ SetSpanCostCoefficientForVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetSpanCostCoefficientForVehicle ( self,
coefficient,
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 6535 of file pywrapcp.py.

◆ SetSpanUpperBoundForVehicle()

ortools.constraint_solver.pywrapcp.RoutingDimension.SetSpanUpperBoundForVehicle ( self,
upper_bound,
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 6527 of file pywrapcp.py.

◆ ShortestTransitionSlack()

ortools.constraint_solver.pywrapcp.RoutingDimension.ShortestTransitionSlack ( self,
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 6699 of file pywrapcp.py.

◆ SlackVar()

ortools.constraint_solver.pywrapcp.RoutingDimension.SlackVar ( self,
index )

Definition at line 6508 of file pywrapcp.py.

◆ TransitVar()

ortools.constraint_solver.pywrapcp.RoutingDimension.TransitVar ( self,
index )

Definition at line 6502 of file pywrapcp.py.

Property Documentation

◆ thisown

ortools.constraint_solver.pywrapcp.RoutingDimension.thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
static

Definition at line 6469 of file pywrapcp.py.


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