Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::RoutingDimension Class Reference

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 3094 of file routing.h.

#include <routing.h>

Classes

struct  NodePrecedence

Public Types

enum class  PrecedenceStatus { kActive , kInactive , kInvalid }
typedef std::function< int64_t(int, int)> PickupToDeliveryLimitFunction

Public Member Functions

 RoutingDimension (const RoutingDimension &)=delete
RoutingDimensionoperator= (const RoutingDimension &)=delete
 ~RoutingDimension ()
RoutingModelmodel () const
 Returns the model on which the dimension was created.
int64_t GetTransitValue (int64_t from_index, int64_t to_index, int64_t vehicle) const
int64_t GetTransitValueFromClass (int64_t from_index, int64_t to_index, int64_t vehicle_class) const
operations_research::IntVarCumulVar (int64_t index) const
operations_research::IntVarTransitVar (int64_t index) const
operations_research::IntVarFixedTransitVar (int64_t index) const
operations_research::IntVarSlackVar (int64_t index) const
void SetCumulVarRange (int64_t index, int64_t min, int64_t max)
 Restricts the range of the cumul variable associated to index.
int64_t GetCumulVarMin (int64_t index) const
 Gets the current minimum of the cumul variable associated to index.
int64_t GetCumulVarMax (int64_t index) const
 Gets the current maximum of the cumul variable associated to index.
const std::vector< operations_research::IntVar * > & cumuls () const
const std::vector< operations_research::IntVar * > & fixed_transits () const
const std::vector< operations_research::IntVar * > & transits () const
const std::vector< operations_research::IntVar * > & slacks () const
const std::vector< SortedDisjointIntervalList > & forbidden_intervals () const
 Returns forbidden intervals for each node.
SortedDisjointIntervalList GetAllowedIntervalsInRange (int64_t index, int64_t min_value, int64_t max_value) const
 Returns allowed intervals for a given node in a given interval.
int64_t GetFirstPossibleGreaterOrEqualValueForNode (int64_t index, int64_t min_value) const
int64_t GetLastPossibleLessOrEqualValueForNode (int64_t index, int64_t max_value) const
const std::vector< int64_t > & vehicle_capacities () const
 Returns the capacities for all vehicles.
const RoutingModel::TransitCallback2transit_evaluator (int vehicle) const
const RoutingModel::TransitCallback2class_transit_evaluator (RoutingVehicleClassIndex vehicle_class) const
bool IsUnary () const
 Returns true iff all transit evaluators for this dimension are unary.
const RoutingModel::TransitCallback1GetUnaryTransitEvaluator (int vehicle) const
const RoutingModel::TransitCallback2GetBinaryTransitEvaluator (int vehicle) const
bool AreVehicleTransitsPositive (int vehicle) const
bool AllTransitEvaluatorSignsAreUnknown () const
RoutingModel::TransitEvaluatorSign GetTransitEvaluatorSign (int vehicle) const
int vehicle_to_class (int vehicle) const
int vehicle_to_cumul_dependent_class (int vehicle) const
void SetSpanUpperBoundForVehicle (int64_t upper_bound, int vehicle)
void SetSpanCostCoefficientForVehicle (int64_t coefficient, int vehicle)
void SetSpanCostCoefficientForAllVehicles (int64_t coefficient)
void SetSlackCostCoefficientForVehicle (int64_t coefficient, int vehicle)
void SetSlackCostCoefficientForAllVehicles (int64_t coefficient)
void SetGlobalSpanCostCoefficient (int64_t coefficient)
void SetCumulVarPiecewiseLinearCost (int64_t index, const PiecewiseLinearFunction &cost)
bool HasCumulVarPiecewiseLinearCost (int64_t index) const
const PiecewiseLinearFunctionGetCumulVarPiecewiseLinearCost (int64_t index) const
void SetCumulVarSoftUpperBound (int64_t index, int64_t upper_bound, int64_t coefficient)
bool HasCumulVarSoftUpperBound (int64_t index) const
int64_t GetCumulVarSoftUpperBound (int64_t index) const
int64_t GetCumulVarSoftUpperBoundCoefficient (int64_t index) const
void SetCumulVarSoftLowerBound (int64_t index, int64_t lower_bound, int64_t coefficient)
bool HasCumulVarSoftLowerBound (int64_t index) const
int64_t GetCumulVarSoftLowerBound (int64_t index) const
int64_t GetCumulVarSoftLowerBoundCoefficient (int64_t index) const
void SetBreakIntervalsOfVehicle (std::vector< IntervalVar * > breaks, int vehicle, int pre_travel_evaluator, int post_travel_evaluator)
void SetBreakIntervalsOfVehicle (std::vector< IntervalVar * > breaks, int vehicle, std::vector< int64_t > node_visit_transits)
void SetBreakDistanceDurationOfVehicle (int64_t distance, int64_t duration, int vehicle)
void InitializeBreaks ()
bool HasBreakConstraints () const
 Returns true if any break interval or break distance was defined.
void SetBreakIntervalsOfVehicle (std::vector< IntervalVar * > breaks, int vehicle, std::vector< int64_t > node_visit_transits, std::function< int64_t(int64_t, int64_t)> delays)
const std::vector< IntervalVar * > & GetBreakIntervalsOfVehicle (int vehicle) const
 Returns the break intervals set by SetBreakIntervalsOfVehicle().
const std::vector< std::pair< int64_t, int64_t > > & GetBreakDistanceDurationOfVehicle (int vehicle) const
int GetPreTravelEvaluatorOfVehicle (int vehicle) const
 !defined(SWIGPYTHON)
int GetPostTravelEvaluatorOfVehicle (int vehicle) const
const RoutingDimensionbase_dimension () const
 Returns the parent in the dependency tree if any or nullptr otherwise.
int64_t ShortestTransitionSlack (int64_t node) const
operations_research::RoutingDimensionIndex index () const
 Returns the index of the dimension in the model.
const std::string & name () const
 Returns the name of the dimension.
const ReverseArcListGraph< int, int > & GetPathPrecedenceGraph () const
 Accessors.
void SetPickupToDeliveryLimitFunctionForPair (PickupToDeliveryLimitFunction limit_function, int pair_index)
bool HasPickupToDeliveryLimits () const
int64_t GetPickupToDeliveryLimitForPair (int pair_index, int pickup_alternative_index, int delivery_alternative_index) const
void AddNodePrecedence (NodePrecedence precedence)
const std::vector< NodePrecedence > & GetNodePrecedences () const
void AddNodePrecedence (int64_t first_node, int64_t second_node, int64_t offset, NodePrecedence::PerformedConstraint performed_constraint=NodePrecedence::PerformedConstraint::kFirstAndSecondIndependent)
int64_t GetSpanUpperBoundForVehicle (int vehicle) const
const std::vector< int64_t > & vehicle_span_upper_bounds () const
int64_t GetSpanCostCoefficientForVehicle (int vehicle) const
int64_t GetSpanCostCoefficientForVehicleClass (RoutingVehicleClassIndex vehicle_class) const
const std::vector< int64_t > & vehicle_span_cost_coefficients () const
const std::vector< int64_t > & vehicle_slack_cost_coefficients () const
int64_t GetSlackCostCoefficientForVehicle (int vehicle) const
int64_t GetSlackCostCoefficientForVehicleClass (RoutingVehicleClassIndex vehicle_class) const
int64_t global_span_cost_coefficient () const
int64_t GetGlobalOptimizerOffset () const
int64_t GetLocalOptimizerOffsetForVehicle (int vehicle) const
void SetSoftSpanUpperBoundForVehicle (BoundCost bound_cost, int vehicle)
bool HasSoftSpanUpperBounds () const
BoundCost GetSoftSpanUpperBoundForVehicle (int vehicle) const
void SetQuadraticCostSoftSpanUpperBoundForVehicle (BoundCost bound_cost, int vehicle)
bool HasQuadraticCostSoftSpanUpperBounds () const
BoundCost GetQuadraticCostSoftSpanUpperBoundForVehicle (int vehicle) const

Static Public Member Functions

static PrecedenceStatus GetPrecedenceStatus (bool first_unperformed, bool second_unperformed, NodePrecedence::PerformedConstraint performed_constraint)

Friends

class RoutingModel
class RoutingModelInspector

Member Typedef Documentation

◆ PickupToDeliveryLimitFunction

Limits, in terms of maximum difference between the cumul variables, between the pickup and delivery alternatives belonging to a single pickup/delivery pair in the RoutingModel. The indices passed to the function respectively correspond to the position of the pickup in the vector of pickup alternatives, and delivery position in the delivery alternatives for this pickup/delivery pair. These limits should only be set when each node index appears in at most one pickup/delivery pair, i.e. each pickup (delivery) index is in a single pickup/delivery pair.first (pair.second).

Definition at line 3450 of file routing.h.

Member Enumeration Documentation

◆ PrecedenceStatus

Returns the status of a precedence based on the performed constraint and the performed status of the first and second node of a precedence.

Enumerator
kActive 
kInactive 
kInvalid 

Definition at line 3486 of file routing.h.

Constructor & Destructor Documentation

◆ RoutingDimension()

operations_research::RoutingDimension::RoutingDimension ( const RoutingDimension & )
delete

◆ ~RoutingDimension()

operations_research::RoutingDimension::~RoutingDimension ( )

Definition at line 6685 of file routing.cc.

Member Function Documentation

◆ AddNodePrecedence() [1/2]

void operations_research::RoutingDimension::AddNodePrecedence ( int64_t first_node,
int64_t second_node,
int64_t offset,
NodePrecedence::PerformedConstraint performed_constraint = NodePrecedence::PerformedConstraint::kFirstAndSecondIndependent )
inline

Definition at line 3523 of file routing.h.

◆ AddNodePrecedence() [2/2]

void operations_research::RoutingDimension::AddNodePrecedence ( NodePrecedence precedence)
inline

Definition at line 3478 of file routing.h.

◆ AllTransitEvaluatorSignsAreUnknown()

bool operations_research::RoutingDimension::AllTransitEvaluatorSignsAreUnknown ( ) const

Definition at line 7253 of file routing.cc.

◆ AreVehicleTransitsPositive()

bool operations_research::RoutingDimension::AreVehicleTransitsPositive ( int vehicle) const
inline

Returns true iff the transit evaluator of 'vehicle' is positive for all arcs.

Definition at line 3247 of file routing.h.

◆ base_dimension()

const RoutingDimension * operations_research::RoutingDimension::base_dimension ( ) const
inline

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

Definition at line 3417 of file routing.h.

◆ class_transit_evaluator()

const RoutingModel::TransitCallback2 & operations_research::RoutingDimension::class_transit_evaluator ( RoutingVehicleClassIndex vehicle_class) const
inline

Returns the callback evaluating the transit value between two node indices for a given vehicle class.

Definition at line 3215 of file routing.h.

◆ cumuls()

const std::vector< operations_research::IntVar * > & operations_research::RoutingDimension::cumuls ( ) const
inline

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

Definition at line 3146 of file routing.h.

◆ CumulVar()

operations_research::IntVar * operations_research::RoutingDimension::CumulVar ( int64_t index) const
inline

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

Definition at line 3117 of file routing.h.

◆ fixed_transits()

const std::vector< operations_research::IntVar * > & operations_research::RoutingDimension::fixed_transits ( ) const
inline

Definition at line 3149 of file routing.h.

◆ FixedTransitVar()

operations_research::IntVar * operations_research::RoutingDimension::FixedTransitVar ( int64_t index) const
inline

Definition at line 3123 of file routing.h.

◆ forbidden_intervals()

const std::vector< SortedDisjointIntervalList > & operations_research::RoutingDimension::forbidden_intervals ( ) const
inline

Returns forbidden intervals for each node.

Definition at line 3160 of file routing.h.

◆ GetAllowedIntervalsInRange()

SortedDisjointIntervalList operations_research::RoutingDimension::GetAllowedIntervalsInRange ( int64_t index,
int64_t min_value,
int64_t max_value ) const

Returns allowed intervals for a given node in a given interval.

Definition at line 7263 of file routing.cc.

◆ GetBinaryTransitEvaluator()

const RoutingModel::TransitCallback2 & operations_research::RoutingDimension::GetBinaryTransitEvaluator ( int vehicle) const
inline

Definition at line 3240 of file routing.h.

◆ GetBreakDistanceDurationOfVehicle()

const std::vector< std::pair< int64_t, int64_t > > & operations_research::RoutingDimension::GetBreakDistanceDurationOfVehicle ( int vehicle) const

Returns the pairs (distance, duration) specified by break distance constraints.

Definition at line 7656 of file routing.cc.

◆ GetBreakIntervalsOfVehicle()

const std::vector< IntervalVar * > & operations_research::RoutingDimension::GetBreakIntervalsOfVehicle ( int vehicle) const

Returns the break intervals set by SetBreakIntervalsOfVehicle().

Definition at line 7621 of file routing.cc.

◆ GetCumulVarMax()

int64_t operations_research::RoutingDimension::GetCumulVarMax ( int64_t index) const
inline

Gets the current maximum of the cumul variable associated to index.

Definition at line 3141 of file routing.h.

◆ GetCumulVarMin()

int64_t operations_research::RoutingDimension::GetCumulVarMin ( int64_t index) const
inline

Gets the current minimum of the cumul variable associated to index.

Definition at line 3139 of file routing.h.

◆ GetCumulVarPiecewiseLinearCost()

const PiecewiseLinearFunction * operations_research::RoutingDimension::GetCumulVarPiecewiseLinearCost ( int64_t index) const

Returns the piecewise linear cost of a cumul variable for a given variable index. The returned pointer has the same validity as this class.

Definition at line 7350 of file routing.cc.

◆ GetCumulVarSoftLowerBound()

int64_t operations_research::RoutingDimension::GetCumulVarSoftLowerBound ( int64_t index) const

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 7459 of file routing.cc.

◆ GetCumulVarSoftLowerBoundCoefficient()

int64_t operations_research::RoutingDimension::GetCumulVarSoftLowerBoundCoefficient ( int64_t index) const

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 7467 of file routing.cc.

◆ GetCumulVarSoftUpperBound()

int64_t operations_research::RoutingDimension::GetCumulVarSoftUpperBound ( int64_t index) const

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 7407 of file routing.cc.

◆ GetCumulVarSoftUpperBoundCoefficient()

int64_t operations_research::RoutingDimension::GetCumulVarSoftUpperBoundCoefficient ( int64_t index) const

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 7415 of file routing.cc.

◆ GetFirstPossibleGreaterOrEqualValueForNode()

int64_t operations_research::RoutingDimension::GetFirstPossibleGreaterOrEqualValueForNode ( int64_t index,
int64_t min_value ) const
inline

Returns the smallest value outside the forbidden intervals of node 'index' that is greater than or equal to a given 'min_value'.

min_value is in a forbidden interval.

min_value is not forbidden.

Definition at line 3168 of file routing.h.

◆ GetGlobalOptimizerOffset()

int64_t operations_research::RoutingDimension::GetGlobalOptimizerOffset ( ) const
inline

Definition at line 3582 of file routing.h.

◆ GetLastPossibleLessOrEqualValueForNode()

int64_t operations_research::RoutingDimension::GetLastPossibleLessOrEqualValueForNode ( int64_t index,
int64_t max_value ) const
inline

Returns the largest value outside the forbidden intervals of node 'index' that is less than or equal to a given 'max_value'.

Note
If this method is called with a max_value lower than the node's cumul min, it will return -1.

max_value is in a forbidden interval.

max_value is not forbidden.

Definition at line 3187 of file routing.h.

◆ GetLocalOptimizerOffsetForVehicle()

int64_t operations_research::RoutingDimension::GetLocalOptimizerOffsetForVehicle ( int vehicle) const
inline

Definition at line 3586 of file routing.h.

◆ GetNodePrecedences()

const std::vector< NodePrecedence > & operations_research::RoutingDimension::GetNodePrecedences ( ) const
inline

Definition at line 3481 of file routing.h.

◆ GetPathPrecedenceGraph()

const ReverseArcListGraph< int, int > & operations_research::RoutingDimension::GetPathPrecedenceGraph ( ) const
inline

Accessors.

Definition at line 3436 of file routing.h.

◆ GetPickupToDeliveryLimitForPair()

int64_t operations_research::RoutingDimension::GetPickupToDeliveryLimitForPair ( int pair_index,
int pickup_alternative_index,
int delivery_alternative_index ) const

Definition at line 7676 of file routing.cc.

◆ GetPostTravelEvaluatorOfVehicle()

int operations_research::RoutingDimension::GetPostTravelEvaluatorOfVehicle ( int vehicle) const

Definition at line 7634 of file routing.cc.

◆ GetPrecedenceStatus()

PrecedenceStatus operations_research::RoutingDimension::GetPrecedenceStatus ( bool first_unperformed,
bool second_unperformed,
NodePrecedence::PerformedConstraint performed_constraint )
inlinestatic

Definition at line 3491 of file routing.h.

◆ GetPreTravelEvaluatorOfVehicle()

int operations_research::RoutingDimension::GetPreTravelEvaluatorOfVehicle ( int vehicle) const

!defined(SWIGPYTHON)

Definition at line 7628 of file routing.cc.

◆ GetQuadraticCostSoftSpanUpperBoundForVehicle()

BoundCost operations_research::RoutingDimension::GetQuadraticCostSoftSpanUpperBoundForVehicle ( int vehicle) const
inline

Definition at line 3625 of file routing.h.

◆ GetSlackCostCoefficientForVehicle()

int64_t operations_research::RoutingDimension::GetSlackCostCoefficientForVehicle ( int vehicle) const
inline

Definition at line 3567 of file routing.h.

◆ GetSlackCostCoefficientForVehicleClass()

int64_t operations_research::RoutingDimension::GetSlackCostCoefficientForVehicleClass ( RoutingVehicleClassIndex vehicle_class) const
inline

Definition at line 3571 of file routing.h.

◆ GetSoftSpanUpperBoundForVehicle()

BoundCost operations_research::RoutingDimension::GetSoftSpanUpperBoundForVehicle ( int vehicle) const
inline

Definition at line 3606 of file routing.h.

◆ GetSpanCostCoefficientForVehicle()

int64_t operations_research::RoutingDimension::GetSpanCostCoefficientForVehicle ( int vehicle) const
inline

Definition at line 3546 of file routing.h.

◆ GetSpanCostCoefficientForVehicleClass()

int64_t operations_research::RoutingDimension::GetSpanCostCoefficientForVehicleClass ( RoutingVehicleClassIndex vehicle_class) const
inline

Definition at line 3550 of file routing.h.

◆ GetSpanUpperBoundForVehicle()

int64_t operations_research::RoutingDimension::GetSpanUpperBoundForVehicle ( int vehicle) const
inline

Definition at line 3538 of file routing.h.

◆ GetTransitEvaluatorSign()

RoutingModel::TransitEvaluatorSign operations_research::RoutingDimension::GetTransitEvaluatorSign ( int vehicle) const
inline

Definition at line 3253 of file routing.h.

◆ GetTransitValue()

int64_t operations_research::RoutingDimension::GetTransitValue ( int64_t from_index,
int64_t to_index,
int64_t vehicle ) const

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 7247 of file routing.cc.

◆ GetTransitValueFromClass()

int64_t operations_research::RoutingDimension::GetTransitValueFromClass ( int64_t from_index,
int64_t to_index,
int64_t vehicle_class ) const
inline

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 3110 of file routing.h.

◆ GetUnaryTransitEvaluator()

const RoutingModel::TransitCallback1 & operations_research::RoutingDimension::GetUnaryTransitEvaluator ( int vehicle) const
inline

Returns the unary callback evaluating the transit value between two node indices for a given vehicle. If the corresponding callback is not unary, returns a null callback.

Definition at line 3235 of file routing.h.

◆ global_span_cost_coefficient()

int64_t operations_research::RoutingDimension::global_span_cost_coefficient ( ) const
inline

Definition at line 3578 of file routing.h.

◆ HasBreakConstraints()

bool operations_research::RoutingDimension::HasBreakConstraints ( ) const

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

Definition at line 7617 of file routing.cc.

◆ HasCumulVarPiecewiseLinearCost()

bool operations_research::RoutingDimension::HasCumulVarPiecewiseLinearCost ( int64_t index) const

Returns true if a piecewise linear cost has been set for a given variable index.

Definition at line 7345 of file routing.cc.

◆ HasCumulVarSoftLowerBound()

bool operations_research::RoutingDimension::HasCumulVarSoftLowerBound ( int64_t index) const

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

Definition at line 7454 of file routing.cc.

◆ HasCumulVarSoftUpperBound()

bool operations_research::RoutingDimension::HasCumulVarSoftUpperBound ( int64_t index) const

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

Definition at line 7402 of file routing.cc.

◆ HasPickupToDeliveryLimits()

bool operations_research::RoutingDimension::HasPickupToDeliveryLimits ( ) const

Definition at line 7672 of file routing.cc.

◆ HasQuadraticCostSoftSpanUpperBounds()

bool operations_research::RoutingDimension::HasQuadraticCostSoftSpanUpperBounds ( ) const
inline

Definition at line 3622 of file routing.h.

◆ HasSoftSpanUpperBounds()

bool operations_research::RoutingDimension::HasSoftSpanUpperBounds ( ) const
inline

Definition at line 3603 of file routing.h.

◆ index()

operations_research::RoutingDimensionIndex operations_research::RoutingDimension::index ( ) const
inline

Returns the index of the dimension in the model.

Definition at line 3428 of file routing.h.

◆ InitializeBreaks()

void operations_research::RoutingDimension::InitializeBreaks ( )

Sets up vehicle_break_intervals_, vehicle_break_distance_duration_, pre_travel_evaluators and post_travel_evaluators.

Definition at line 7607 of file routing.cc.

◆ IsUnary()

bool operations_research::RoutingDimension::IsUnary ( ) const
inline

Returns true iff all transit evaluators for this dimension are unary.

Definition at line 3223 of file routing.h.

◆ model()

RoutingModel * operations_research::RoutingDimension::model ( ) const
inline

Returns the model on which the dimension was created.

Definition at line 3102 of file routing.h.

◆ name()

const std::string & operations_research::RoutingDimension::name ( ) const
inline

Returns the name of the dimension.

Definition at line 3432 of file routing.h.

◆ operator=()

RoutingDimension & operations_research::RoutingDimension::operator= ( const RoutingDimension & )
delete

◆ SetBreakDistanceDurationOfVehicle()

void operations_research::RoutingDimension::SetBreakDistanceDurationOfVehicle ( int64_t distance,
int64_t 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 7640 of file routing.cc.

◆ SetBreakIntervalsOfVehicle() [1/3]

void operations_research::RoutingDimension::SetBreakIntervalsOfVehicle ( std::vector< 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 7578 of file routing.cc.

◆ SetBreakIntervalsOfVehicle() [2/3]

void operations_research::RoutingDimension::SetBreakIntervalsOfVehicle ( std::vector< IntervalVar * > breaks,
int vehicle,
std::vector< int64_t > node_visit_transits )
Deprecated
sets pre_travel(i, j) = node_visit_transit[i].

Definition at line 7552 of file routing.cc.

◆ SetBreakIntervalsOfVehicle() [3/3]

void operations_research::RoutingDimension::SetBreakIntervalsOfVehicle ( std::vector< IntervalVar * > breaks,
int vehicle,
std::vector< int64_t > node_visit_transits,
std::function< int64_t(int64_t, int64_t)> delays )
Deprecated
sets pre_travel(i, j) = node_visit_transit[i] and post_travel(i, j) = delays(i, j).

Definition at line 7563 of file routing.cc.

◆ SetCumulVarPiecewiseLinearCost()

void operations_research::RoutingDimension::SetCumulVarPiecewiseLinearCost ( int64_t index,
const PiecewiseLinearFunction & cost )

Sets a piecewise linear cost on the cumul variable of a given variable index. If f is a piecewise linear function, the resulting cost at 'index' will be f(CumulVar(index)). As of 3/2017, only non-decreasing positive cost functions are supported.

Definition at line 7326 of file routing.cc.

◆ SetCumulVarRange()

void operations_research::RoutingDimension::SetCumulVarRange ( int64_t index,
int64_t min,
int64_t max )
inline

Restricts the range of the cumul variable associated to index.

Some functions to allow users to use the interface without knowing about the underlying CP model.

Definition at line 3135 of file routing.h.

◆ SetCumulVarSoftLowerBound()

void operations_research::RoutingDimension::SetCumulVarSoftLowerBound ( int64_t index,
int64_t lower_bound,
int64_t 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 7444 of file routing.cc.

◆ SetCumulVarSoftUpperBound()

void operations_research::RoutingDimension::SetCumulVarSoftUpperBound ( int64_t index,
int64_t upper_bound,
int64_t 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 7392 of file routing.cc.

◆ SetGlobalSpanCostCoefficient()

void operations_research::RoutingDimension::SetGlobalSpanCostCoefficient ( int64_t 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 7308 of file routing.cc.

◆ SetPickupToDeliveryLimitFunctionForPair()

void operations_research::RoutingDimension::SetPickupToDeliveryLimitFunctionForPair ( PickupToDeliveryLimitFunction limit_function,
int pair_index )

Definition at line 7662 of file routing.cc.

◆ SetQuadraticCostSoftSpanUpperBoundForVehicle()

void operations_research::RoutingDimension::SetQuadraticCostSoftSpanUpperBoundForVehicle ( BoundCost bound_cost,
int vehicle )
inline

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 3612 of file routing.h.

◆ SetSlackCostCoefficientForAllVehicles()

void operations_research::RoutingDimension::SetSlackCostCoefficientForAllVehicles ( int64_t coefficient)

Definition at line 7320 of file routing.cc.

◆ SetSlackCostCoefficientForVehicle()

void operations_research::RoutingDimension::SetSlackCostCoefficientForVehicle ( int64_t 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 7313 of file routing.cc.

◆ SetSoftSpanUpperBoundForVehicle()

void operations_research::RoutingDimension::SetSoftSpanUpperBoundForVehicle ( BoundCost bound_cost,
int vehicle )
inline

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

Definition at line 3596 of file routing.h.

◆ SetSpanCostCoefficientForAllVehicles()

void operations_research::RoutingDimension::SetSpanCostCoefficientForAllVehicles ( int64_t coefficient)

Definition at line 7302 of file routing.cc.

◆ SetSpanCostCoefficientForVehicle()

void operations_research::RoutingDimension::SetSpanCostCoefficientForVehicle ( int64_t 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 7294 of file routing.cc.

◆ SetSpanUpperBoundForVehicle()

void operations_research::RoutingDimension::SetSpanUpperBoundForVehicle ( int64_t upper_bound,
int vehicle )

!defined(SWIGCSHARP) && !defined(SWIGJAVA) !defined(SWIGPYTHON) 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 7286 of file routing.cc.

◆ ShortestTransitionSlack()

int64_t operations_research::RoutingDimension::ShortestTransitionSlack ( int64_t node) const

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 5632 of file routing_search.cc.

◆ slacks()

const std::vector< operations_research::IntVar * > & operations_research::RoutingDimension::slacks ( ) const
inline

Definition at line 3155 of file routing.h.

◆ SlackVar()

operations_research::IntVar * operations_research::RoutingDimension::SlackVar ( int64_t index) const
inline

Definition at line 3126 of file routing.h.

◆ transit_evaluator()

const RoutingModel::TransitCallback2 & operations_research::RoutingDimension::transit_evaluator ( int vehicle) const
inline

Returns the callback evaluating the transit value between two node indices for a given vehicle.

Definition at line 3208 of file routing.h.

◆ transits()

const std::vector< operations_research::IntVar * > & operations_research::RoutingDimension::transits ( ) const
inline

Definition at line 3152 of file routing.h.

◆ TransitVar()

operations_research::IntVar * operations_research::RoutingDimension::TransitVar ( int64_t index) const
inline

Definition at line 3120 of file routing.h.

◆ vehicle_capacities()

const std::vector< int64_t > & operations_research::RoutingDimension::vehicle_capacities ( ) const
inline

Returns the capacities for all vehicles.

Definition at line 3203 of file routing.h.

◆ vehicle_slack_cost_coefficients()

const std::vector< int64_t > & operations_research::RoutingDimension::vehicle_slack_cost_coefficients ( ) const
inline

Definition at line 3563 of file routing.h.

◆ vehicle_span_cost_coefficients()

const std::vector< int64_t > & operations_research::RoutingDimension::vehicle_span_cost_coefficients ( ) const
inline

Definition at line 3558 of file routing.h.

◆ vehicle_span_upper_bounds()

const std::vector< int64_t > & operations_research::RoutingDimension::vehicle_span_upper_bounds ( ) const
inline

Definition at line 3542 of file routing.h.

◆ vehicle_to_class()

int operations_research::RoutingDimension::vehicle_to_class ( int vehicle) const
inline

Definition at line 3258 of file routing.h.

◆ vehicle_to_cumul_dependent_class()

int operations_research::RoutingDimension::vehicle_to_cumul_dependent_class ( int vehicle) const
inline

Definition at line 3259 of file routing.h.

◆ RoutingModel

friend class RoutingModel
friend

Definition at line 3759 of file routing.h.

◆ RoutingModelInspector

friend class RoutingModelInspector
friend

Definition at line 3760 of file routing.h.


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