Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
ortools.constraint_solver.pywrapcp.RoutingModel Class Reference

Detailed Description

Definition at line 4916 of file pywrapcp.py.

Inheritance diagram for ortools.constraint_solver.pywrapcp.RoutingModel:

Public Member Functions

 __init__ (self, *args)
 RegisterUnaryTransitVector (self, values)
 RegisterUnaryTransitCallback (self, *args)
 RegisterTransitMatrix (self, values)
 RegisterTransitCallback (self, *args)
 RegisterCumulDependentTransitCallback (self, callback)
 TransitCallback (self, callback_index)
 UnaryTransitCallbackOrNull (self, callback_index)
 CumulDependentTransitCallback (self, callback_index)
 AddDimension (self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name)
 AddDimensionWithVehicleTransits (self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name)
 AddDimensionWithVehicleCapacity (self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
 AddDimensionWithVehicleTransitAndCapacity (self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
 AddDimensionWithCumulDependentVehicleTransitAndCapacity (self, fixed_evaluator_indices, cumul_dependent_evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
 AddConstantDimensionWithSlack (self, value, capacity, slack_max, fix_start_cumul_to_zero, name)
 AddConstantDimension (self, value, capacity, fix_start_cumul_to_zero, name)
 AddVectorDimension (self, values, capacity, fix_start_cumul_to_zero, name)
 AddMatrixDimension (self, values, capacity, fix_start_cumul_to_zero, name)
 GetAllDimensionNames (self)
 GetDimensions (self)
 GetDimensionsWithSoftOrSpanCosts (self)
 GetUnaryDimensions (self)
 GetDimensionsWithGlobalCumulOptimizers (self)
 GetDimensionsWithLocalCumulOptimizers (self)
 HasGlobalCumulOptimizer (self, dimension)
 HasLocalCumulOptimizer (self, dimension)
 GetMutableGlobalCumulLPOptimizer (self, dimension)
 GetMutableGlobalCumulMPOptimizer (self, dimension)
 GetMutableLocalCumulLPOptimizer (self, dimension)
 GetMutableLocalCumulMPOptimizer (self, dimension)
 HasDimension (self, dimension_name)
 GetDimensionOrDie (self, dimension_name)
 GetMutableDimension (self, dimension_name)
 SetPrimaryConstrainedDimension (self, dimension_name)
 GetPrimaryConstrainedDimension (self)
 GetResourceGroup (self, rg_index)
 GetDimensionResourceGroupIndices (self, dimension)
 GetDimensionResourceGroupIndex (self, dimension)
 AddDisjunction (self, *args)
 GetDisjunctionIndices (self, index)
 GetDisjunctionPenalty (self, index)
 GetDisjunctionMaxCardinality (self, index)
 GetDisjunctionPenaltyCostBehavior (self, index)
 GetNumberOfDisjunctions (self)
 HasMandatoryDisjunctions (self)
 HasMaxCardinalityConstrainedDisjunctions (self)
 GetPerfectBinaryDisjunctions (self)
 IgnoreDisjunctionsAlreadyForcedToZero (self)
 AddSoftSameVehicleConstraint (self, indices, cost)
 GetNumberOfSoftSameVehicleConstraints (self)
 GetSoftSameVehicleIndices (self, index)
 GetSoftSameVehicleCost (self, index)
 SetAllowedVehiclesForIndex (self, vehicles, index)
 IsVehicleAllowedForIndex (self, vehicle, index)
 AddPickupAndDelivery (self, pickup, delivery)
 AddPickupAndDeliverySets (self, pickup_disjunction, delivery_disjunction)
 GetPickupPosition (self, node_index)
 GetDeliveryPosition (self, node_index)
 IsPickup (self, node_index)
 IsDelivery (self, node_index)
 SetPickupAndDeliveryPolicyOfAllVehicles (self, policy)
 SetPickupAndDeliveryPolicyOfVehicle (self, policy, vehicle)
 GetPickupAndDeliveryPolicyOfVehicle (self, vehicle)
 GetNumOfSingletonNodes (self)
 GetFirstMatchingPickupDeliverySibling (self, node, is_match)
 SetVisitType (self, index, type, type_policy)
 GetVisitType (self, index)
 GetSingleNodesOfType (self, type)
 GetPairIndicesOfType (self, type)
 GetVisitTypePolicy (self, index)
 GetNumberOfVisitTypes (self)
 AddHardTypeIncompatibility (self, type1, type2)
 AddTemporalTypeIncompatibility (self, type1, type2)
 GetHardTypeIncompatibilitiesOfType (self, type)
 GetTemporalTypeIncompatibilitiesOfType (self, type)
 HasHardTypeIncompatibilities (self)
 HasTemporalTypeIncompatibilities (self)
 AddSameVehicleRequiredTypeAlternatives (self, dependent_type, required_type_alternatives)
 AddRequiredTypeAlternativesWhenAddingType (self, dependent_type, required_type_alternatives)
 AddRequiredTypeAlternativesWhenRemovingType (self, dependent_type, required_type_alternatives)
 GetSameVehicleRequiredTypeAlternativesOfType (self, type)
 GetRequiredTypeAlternativesWhenAddingType (self, type)
 GetRequiredTypeAlternativesWhenRemovingType (self, type)
 HasSameVehicleTypeRequirements (self)
 HasTemporalTypeRequirements (self)
 HasTypeRegulations (self)
 UnperformedPenalty (self, var_index)
 UnperformedPenaltyOrValue (self, default_value, var_index)
 GetDepot (self)
 SetMaximumNumberOfActiveVehicles (self, max_active_vehicles)
 GetMaximumNumberOfActiveVehicles (self)
 SetArcCostEvaluatorOfAllVehicles (self, evaluator_index)
 SetArcCostEvaluatorOfVehicle (self, evaluator_index, vehicle)
 SetFixedCostOfAllVehicles (self, cost)
 SetFixedCostOfVehicle (self, cost, vehicle)
 GetFixedCostOfVehicle (self, vehicle)
 SetPathEnergyCostOfVehicle (self, force, distance, cost_per_unit, vehicle)
 SetPathEnergyCostsOfVehicle (self, force, distance, threshold, cost_per_unit_below_threshold, cost_per_unit_above_threshold, vehicle)
 SetAmortizedCostFactorsOfAllVehicles (self, linear_cost_factor, quadratic_cost_factor)
 SetAmortizedCostFactorsOfVehicle (self, linear_cost_factor, quadratic_cost_factor, vehicle)
 GetAmortizedLinearCostFactorOfVehicles (self)
 GetAmortizedQuadraticCostFactorOfVehicles (self)
 GetRouteCost (self, route)
 SetVehicleUsedWhenEmpty (self, is_used, vehicle)
 IsVehicleUsedWhenEmpty (self, vehicle)
 SetFirstSolutionEvaluator (self, evaluator)
 SetFirstSolutionHint (self, hint)
 GetFirstSolutionHint (self)
 AddLocalSearchOperator (self, ls_operator)
 AddSearchMonitor (self, monitor)
 AddEnterSearchCallback (self, callback)
 AddAtSolutionCallback (self, callback, track_unchecked_neighbors=False)
 AddRestoreDimensionValuesResetCallback (self, callback)
 AddVariableMinimizedByFinalizer (self, var)
 AddVariableMaximizedByFinalizer (self, var)
 AddWeightedVariableMinimizedByFinalizer (self, var, cost)
 AddWeightedVariableMaximizedByFinalizer (self, var, cost)
 AddVariableTargetToFinalizer (self, var, target)
 AddWeightedVariableTargetToFinalizer (self, var, target, cost)
 CloseModel (self)
 CloseModelWithParameters (self, search_parameters)
 Solve (self, assignment=None)
 SolveWithParameters (self, search_parameters, solutions=None)
 SolveFromAssignmentWithParameters (self, assignment, search_parameters, solutions=None)
 FastSolveFromAssignmentWithParameters (self, assignment, search_parameters, check_solution_in_cp, touched=None)
 SolveFromAssignmentsWithParameters (self, assignments, search_parameters, solutions=None)
 SolveWithIteratedLocalSearch (self, search_parameters)
 SetAssignmentFromOtherModelAssignment (self, target_assignment, source_model, source_assignment)
 GetSubSolverStatistics (self)
 ComputeLowerBound (self)
 objective_lower_bound (self)
 status (self)
 search_stats (self)
 enable_deep_serialization (self)
 ApplyLocks (self, locks)
 ApplyLocksToAllVehicles (self, locks, close_routes)
 PreAssignment (self)
 MutablePreAssignment (self)
 WriteAssignment (self, file_name)
 ReadAssignment (self, file_name)
 RestoreAssignment (self, solution)
 ReadAssignmentFromRoutes (self, routes, ignore_inactive_indices)
 RoutesToAssignment (self, routes, ignore_inactive_indices, close_routes, assignment)
 AssignmentToRoutes (self, assignment, routes)
 CompactAssignment (self, assignment)
 CompactAndCheckAssignment (self, assignment)
 AddToAssignment (self, var)
 AddIntervalToAssignment (self, interval)
 PackCumulsOfOptimizerDimensionsFromAssignment (self, original_assignment, duration_limit, time_limit_was_reached=None)
 GetOrCreateNodeNeighborsByCostClass (self, *args)
 AddLocalSearchFilter (self, filter)
 Start (self, vehicle)
 End (self, vehicle)
 IsStart (self, index)
 IsEnd (self, index)
 VehicleIndex (self, index)
 Next (self, assignment, index)
 IsVehicleUsed (self, assignment, vehicle)
 NextVar (self, index)
 ActiveVar (self, index)
 ActiveVehicleVar (self, vehicle)
 VehicleRouteConsideredVar (self, vehicle)
 VehicleVar (self, index)
 ResourceVar (self, vehicle, resource_group)
 CostVar (self)
 GetArcCostForVehicle (self, from_index, to_index, vehicle)
 CostsAreHomogeneousAcrossVehicles (self)
 GetHomogeneousCost (self, from_index, to_index)
 GetArcCostForFirstSolution (self, from_index, to_index)
 GetArcCostForClass (self, from_index, to_index, cost_class_index)
 GetCostClassIndexOfVehicle (self, vehicle)
 HasVehicleWithCostClassIndex (self, cost_class_index)
 GetCostClassesCount (self)
 GetNonZeroCostClassesCount (self)
 GetVehicleClassIndexOfVehicle (self, vehicle)
 GetVehicleOfClass (self, vehicle_class)
 GetVehicleClassesCount (self)
 GetSameVehicleIndicesOfIndex (self, node)
 AddSameActivityGroup (self, nodes)
 GetSameActivityIndicesOfIndex (self, node)
 GetSameActivityGroupOfIndex (self, node)
 GetSameActivityGroups (self)
 GetSameActivityGroupsCount (self)
 GetSameActivityIndicesOfGroup (self, group)
 GetVehicleTypeContainer (self)
 ArcIsMoreConstrainedThanArc (self, _from, to1, to2)
 DebugOutputAssignment (self, solution_assignment, dimension_to_print)
 CheckIfAssignmentIsFeasible (self, assignment, call_at_solution_monitors)
 solver (self)
 CheckLimit (self, *args)
 RemainingTime (self)
 UpdateTimeLimit (self, time_limit)
 TimeBuffer (self)
 GetMutableCPSatInterrupt (self)
 GetMutableCPInterrupt (self)
 CancelSearch (self)
 nodes (self)
 vehicles (self)
 Size (self)
 GetNumberOfDecisionsInFirstSolution (self, search_parameters)
 GetNumberOfRejectsInFirstSolution (self, search_parameters)
 GetAutomaticFirstSolutionStrategy (self)
 IsMatchingModel (self)
 AreRoutesInterdependent (self, parameters)
 MakeGuidedSlackFinalizer (self, dimension, initializer)
 MakeSelfDependentDimensionFinalizer (self, dimension)
 GetPathsMetadata (self)
 GetVehiclesOfSameClass (self, start_end_index)
 GetSameVehicleClassArcs (self, from_index, to_index)

Static Public Attributes

 PICKUP_AND_DELIVERY_NO_ORDER = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_NO_ORDER
 PICKUP_AND_DELIVERY_LIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_LIFO
 PICKUP_AND_DELIVERY_FIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_FIFO
 kTransitEvaluatorSignUnknown = _pywrapcp.RoutingModel_kTransitEvaluatorSignUnknown
 kTransitEvaluatorSignPositiveOrZero = _pywrapcp.RoutingModel_kTransitEvaluatorSignPositiveOrZero
 kTransitEvaluatorSignNegativeOrZero = _pywrapcp.RoutingModel_kTransitEvaluatorSignNegativeOrZero
 PENALIZE_ONCE = _pywrapcp.RoutingModel_PENALIZE_ONCE
 PENALIZE_PER_INACTIVE = _pywrapcp.RoutingModel_PENALIZE_PER_INACTIVE
 TYPE_ADDED_TO_VEHICLE = _pywrapcp.RoutingModel_TYPE_ADDED_TO_VEHICLE
 ADDED_TYPE_REMOVED_FROM_VEHICLE = _pywrapcp.RoutingModel_ADDED_TYPE_REMOVED_FROM_VEHICLE
 TYPE_ON_VEHICLE_UP_TO_VISIT = _pywrapcp.RoutingModel_TYPE_ON_VEHICLE_UP_TO_VISIT
 TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = _pywrapcp.RoutingModel_TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED

Properties

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

Constructor & Destructor Documentation

◆ __init__()

ortools.constraint_solver.pywrapcp.RoutingModel.__init__ ( self,
* args )
Constructor taking an index manager. The version which does not take
RoutingModelParameters is equivalent to passing
DefaultRoutingModelParameters().

Definition at line 4926 of file pywrapcp.py.

Member Function Documentation

◆ ActiveVar()

ortools.constraint_solver.pywrapcp.RoutingModel.ActiveVar ( self,
index )
Returns the active variable of the node corresponding to index.

Definition at line 6028 of file pywrapcp.py.

◆ ActiveVehicleVar()

ortools.constraint_solver.pywrapcp.RoutingModel.ActiveVehicleVar ( self,
vehicle )
Returns the active variable of the vehicle. It will be equal to 1 iff the
route of the vehicle is not empty, 0 otherwise.

Definition at line 6032 of file pywrapcp.py.

◆ AddAtSolutionCallback()

ortools.constraint_solver.pywrapcp.RoutingModel.AddAtSolutionCallback ( self,
callback,
track_unchecked_neighbors = False )
Adds a callback called each time a solution is found during the search.
This is a shortcut to creating a monitor to call the callback on
AtSolution() and adding it with AddSearchMonitor.
If track_unchecked_neighbors is true, the callback will also be called on
AcceptUncheckedNeighbor() events, which is useful to grab solutions
obtained when solver_parameters.check_solution_period > 1 (aka fastLS).

Definition at line 5629 of file pywrapcp.py.

◆ AddConstantDimension()

ortools.constraint_solver.pywrapcp.RoutingModel.AddConstantDimension ( self,
value,
capacity,
fix_start_cumul_to_zero,
name )

Definition at line 5027 of file pywrapcp.py.

◆ AddConstantDimensionWithSlack()

ortools.constraint_solver.pywrapcp.RoutingModel.AddConstantDimensionWithSlack ( self,
value,
capacity,
slack_max,
fix_start_cumul_to_zero,
name )
Creates a dimension where the transit variable is constrained to be
equal to 'value'; 'capacity' is the upper bound of the cumul variables.
'name' is the name used to reference the dimension; this name is used to
get cumul and transit variables from the routing model.
Returns a pair consisting of an index to the registered unary transit
callback and a bool denoting whether the dimension has been created.
It is false if a dimension with the same name has already been created
(and doesn't create the new dimension but still register a new callback).

Definition at line 5014 of file pywrapcp.py.

◆ AddDimension()

ortools.constraint_solver.pywrapcp.RoutingModel.AddDimension ( self,
evaluator_index,
slack_max,
capacity,
fix_start_cumul_to_zero,
name )
Model creation
Methods to add dimensions to routes; 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), cumul(j) = cumul(i) + transit(i, j) + slack(i)
where slack is a positive slack variable (can represent waiting times for
a time dimension).
Setting the value of fix_start_cumul_to_zero to true will force the
"cumul" variable of the start node of all vehicles to be equal to 0.
Creates a dimension where the transit variable is constrained to be
equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the
slack variable and 'capacity' is the upper bound of the cumul variables.
'name' is the name used to reference the dimension; this name is used to
get cumul and transit variables from the routing model.
Returns false if a dimension with the same name has already been created
(and doesn't create the new dimension).
Takes ownership of the callback 'evaluator'.

Definition at line 4969 of file pywrapcp.py.

◆ AddDimensionWithCumulDependentVehicleTransitAndCapacity()

ortools.constraint_solver.pywrapcp.RoutingModel.AddDimensionWithCumulDependentVehicleTransitAndCapacity ( self,
fixed_evaluator_indices,
cumul_dependent_evaluator_indices,
slack_max,
vehicle_capacities,
fix_start_cumul_to_zero,
name )
Creates a dimension where the transit variable on arc i->j is the sum of:
- A "fixed" transit value, obtained from the fixed_evaluator_index for
  this vehicle, referencing evaluators in transit_evaluators_, and
- A FloatSlopePiecewiseLinearFunction of the cumul of node i, obtained
  from the cumul_dependent_evaluator_index of this vehicle, pointing to
  an evaluator in cumul_dependent_transit_evaluators_.

Definition at line 5003 of file pywrapcp.py.

◆ AddDimensionWithVehicleCapacity()

ortools.constraint_solver.pywrapcp.RoutingModel.AddDimensionWithVehicleCapacity ( self,
evaluator_index,
slack_max,
vehicle_capacities,
fix_start_cumul_to_zero,
name )

Definition at line 4997 of file pywrapcp.py.

◆ AddDimensionWithVehicleTransitAndCapacity()

ortools.constraint_solver.pywrapcp.RoutingModel.AddDimensionWithVehicleTransitAndCapacity ( self,
evaluator_indices,
slack_max,
vehicle_capacities,
fix_start_cumul_to_zero,
name )

Definition at line 5000 of file pywrapcp.py.

◆ AddDimensionWithVehicleTransits()

ortools.constraint_solver.pywrapcp.RoutingModel.AddDimensionWithVehicleTransits ( self,
evaluator_indices,
slack_max,
capacity,
fix_start_cumul_to_zero,
name )

Definition at line 4994 of file pywrapcp.py.

◆ AddDisjunction()

ortools.constraint_solver.pywrapcp.RoutingModel.AddDisjunction ( self,
* args )
Adds a disjunction constraint on the indices.
Exactly 'max_cardinality' of the indices are active.

If a penalty is given, at most 'max_cardinality' of the indices can be
active, and if less are active, 'penalty' is payed per inactive index if
the penalty cost is set to `PENALIZE_PER_INACTIVE`.
This is equivalent to adding the constraint:
    p + Sum(i)active[i] == max_cardinality
where p is an integer variable.
If the penalty cost is set to `PENALIZE_ONCE`, then 'penalty' is payed
once if there are less than `max_cardinality` of the indices active.
This is equivalent to adding the constraint:
    p == (Sum(i)active[i] != max_cardinality)
where p is a boolean variable.
The following cost is added to the cost function: p * penalty.
:type penalty: int, in, optional
:param penalty: must be positive to make the disjunction optional; a
    negative penalty will force 'max_cardinality' indices of the disjunction
    to be performed, and therefore p == 0.
    Note: passing a vector with a single index will model an optional index
    with a penalty cost if it is not visited.
Warning: Start and end indices of any vehicle cannot be part of a
disjunction.

Definition at line 5151 of file pywrapcp.py.

◆ AddEnterSearchCallback()

ortools.constraint_solver.pywrapcp.RoutingModel.AddEnterSearchCallback ( self,
callback )

Definition at line 5626 of file pywrapcp.py.

◆ AddHardTypeIncompatibility()

ortools.constraint_solver.pywrapcp.RoutingModel.AddHardTypeIncompatibility ( self,
type1,
type2 )
Incompatibilities:
Two nodes with "hard" incompatible types cannot share the same route at
all, while with a "temporal" incompatibility they can't be on the same
route at the same time.
NOTE: To avoid unnecessary memory reallocations, it is recommended to only
add incompatibilities once all the existing types have been set with
SetVisitType().

Definition at line 5379 of file pywrapcp.py.

◆ AddIntervalToAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.AddIntervalToAssignment ( self,
interval )

Definition at line 5939 of file pywrapcp.py.

◆ AddLocalSearchFilter()

ortools.constraint_solver.pywrapcp.RoutingModel.AddLocalSearchFilter ( self,
filter )
Adds a custom local search filter to the list of filters used to speed up
local search by pruning unfeasible variable assignments.
Calling this method after the routing model has been closed (CloseModel()
or Solve() has been called) has no effect.
The routing model does not take ownership of the filter.

Definition at line 5973 of file pywrapcp.py.

◆ AddLocalSearchOperator()

ortools.constraint_solver.pywrapcp.RoutingModel.AddLocalSearchOperator ( self,
ls_operator )
Adds a local search operator to the set of operators used to solve the
vehicle routing problem.

Definition at line 5615 of file pywrapcp.py.

◆ AddMatrixDimension()

ortools.constraint_solver.pywrapcp.RoutingModel.AddMatrixDimension ( self,
values,
capacity,
fix_start_cumul_to_zero,
name )
Creates a dimension where the transit variable is constrained to be
equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of
the cumul variables. 'name' is the name used to reference the dimension;
this name is used to get cumul and transit variables from the routing
model.
Returns a pair consisting of an index to the registered transit callback
and a bool denoting whether the dimension has been created.
It is false if a dimension with the same name has already been created
(and doesn't create the new dimension but still register a new callback).

Definition at line 5044 of file pywrapcp.py.

◆ AddPickupAndDelivery()

ortools.constraint_solver.pywrapcp.RoutingModel.AddPickupAndDelivery ( self,
pickup,
delivery )
Notifies that index1 and index2 form a pair of nodes which should belong
to the same route. This methods helps the search find better solutions,
especially in the local search phase.
It should be called each time you have an equality constraint linking
the vehicle variables of two node (including for instance pickup and
delivery problems):
    Solver* const solver = routing.solver();
    int64_t index1 = manager.NodeToIndex(node1);
    int64_t index2 = manager.NodeToIndex(node2);
    solver->AddConstraint(solver->MakeEquality(
        routing.VehicleVar(index1),
        routing.VehicleVar(index2)));
    routing.AddPickupAndDelivery(index1, index2);

Definition at line 5276 of file pywrapcp.py.

◆ AddPickupAndDeliverySets()

ortools.constraint_solver.pywrapcp.RoutingModel.AddPickupAndDeliverySets ( self,
pickup_disjunction,
delivery_disjunction )
Same as AddPickupAndDelivery but notifying that the performed node from
the disjunction of index 'pickup_disjunction' is on the same route as the
performed node from the disjunction of index 'delivery_disjunction'.

Definition at line 5294 of file pywrapcp.py.

◆ AddRequiredTypeAlternativesWhenAddingType()

ortools.constraint_solver.pywrapcp.RoutingModel.AddRequiredTypeAlternativesWhenAddingType ( self,
dependent_type,
required_type_alternatives )
If type_D depends on type_R when adding type_D, any node_D of type_D and
VisitTypePolicy TYPE_ADDED_TO_VEHICLE or
TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its
vehicle at the time node_D is visited.

Definition at line 5429 of file pywrapcp.py.

◆ AddRequiredTypeAlternativesWhenRemovingType()

ortools.constraint_solver.pywrapcp.RoutingModel.AddRequiredTypeAlternativesWhenRemovingType ( self,
dependent_type,
required_type_alternatives )
The following requirements apply when visiting dependent nodes that remove
their type from the route, i.e. type_R must be on the vehicle when type_D
of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE,
TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is
visited.

Definition at line 5438 of file pywrapcp.py.

◆ AddRestoreDimensionValuesResetCallback()

ortools.constraint_solver.pywrapcp.RoutingModel.AddRestoreDimensionValuesResetCallback ( self,
callback )

Definition at line 5640 of file pywrapcp.py.

◆ AddSameActivityGroup()

ortools.constraint_solver.pywrapcp.RoutingModel.AddSameActivityGroup ( self,
nodes )

Definition at line 6139 of file pywrapcp.py.

◆ AddSameVehicleRequiredTypeAlternatives()

ortools.constraint_solver.pywrapcp.RoutingModel.AddSameVehicleRequiredTypeAlternatives ( self,
dependent_type,
required_type_alternatives )
Requirements:
NOTE: As of 2019-04, cycles in the requirement graph are not supported,
and lead to the dependent nodes being skipped if possible (otherwise
the model is considered infeasible).
The following functions specify that "dependent_type" requires at least
one of the types in "required_type_alternatives".

For same-vehicle requirements, a node of dependent type type_D requires at
least one node of type type_R among the required alternatives on the same
route.
NOTE: To avoid unnecessary memory reallocations, it is recommended to only
add requirements once all the existing types have been set with
SetVisitType().

Definition at line 5411 of file pywrapcp.py.

◆ AddSearchMonitor()

ortools.constraint_solver.pywrapcp.RoutingModel.AddSearchMonitor ( self,
monitor )
Adds a search monitor to the search used to solve the routing model.

Definition at line 5622 of file pywrapcp.py.

◆ AddSoftSameVehicleConstraint()

ortools.constraint_solver.pywrapcp.RoutingModel.AddSoftSameVehicleConstraint ( self,
indices,
cost )
Adds a soft constraint to force a set of variable indices to be on the
same vehicle. If all nodes are not on the same vehicle, each extra vehicle
used adds 'cost' to the cost function.
TODO(user): Extend this to allow nodes/indices to be on the same given
set of vehicle.

Definition at line 5238 of file pywrapcp.py.

◆ AddTemporalTypeIncompatibility()

ortools.constraint_solver.pywrapcp.RoutingModel.AddTemporalTypeIncompatibility ( self,
type1,
type2 )

Definition at line 5391 of file pywrapcp.py.

◆ AddToAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.AddToAssignment ( self,
var )
Adds an extra variable to the vehicle routing assignment.

Definition at line 5935 of file pywrapcp.py.

◆ AddVariableMaximizedByFinalizer()

ortools.constraint_solver.pywrapcp.RoutingModel.AddVariableMaximizedByFinalizer ( self,
var )
Adds a variable to maximize in the solution finalizer (see above for
information on the solution finalizer).

Definition at line 5652 of file pywrapcp.py.

◆ AddVariableMinimizedByFinalizer()

ortools.constraint_solver.pywrapcp.RoutingModel.AddVariableMinimizedByFinalizer ( self,
var )
Adds a variable to minimize in the solution finalizer. The solution
finalizer is called each time a solution is found during the search and
allows to instantiate secondary variables (such as dimension cumul
variables).

Definition at line 5643 of file pywrapcp.py.

◆ AddVariableTargetToFinalizer()

ortools.constraint_solver.pywrapcp.RoutingModel.AddVariableTargetToFinalizer ( self,
var,
target )
Add a variable to set the closest possible to the target value in the
solution finalizer.

Definition at line 5673 of file pywrapcp.py.

◆ AddVectorDimension()

ortools.constraint_solver.pywrapcp.RoutingModel.AddVectorDimension ( self,
values,
capacity,
fix_start_cumul_to_zero,
name )
Creates a dimension where the transit variable is constrained to be
equal to 'values[i]' for node i; 'capacity' is the upper bound of
the cumul variables. 'name' is the name used to reference the dimension;
this name is used to get cumul and transit variables from the routing
model.
Returns a pair consisting of an index to the registered unary transit
callback and a bool denoting whether the dimension has been created.
It is false if a dimension with the same name has already been created
(and doesn't create the new dimension but still register a new callback).

Definition at line 5030 of file pywrapcp.py.

◆ AddWeightedVariableMaximizedByFinalizer()

ortools.constraint_solver.pywrapcp.RoutingModel.AddWeightedVariableMaximizedByFinalizer ( self,
var,
cost )
Adds a variable to maximize in the solution finalizer, with a weighted
priority: the higher the more priority it has.

Definition at line 5666 of file pywrapcp.py.

◆ AddWeightedVariableMinimizedByFinalizer()

ortools.constraint_solver.pywrapcp.RoutingModel.AddWeightedVariableMinimizedByFinalizer ( self,
var,
cost )
Adds a variable to minimize in the solution finalizer, with a weighted
priority: the higher the more priority it has.

Definition at line 5659 of file pywrapcp.py.

◆ AddWeightedVariableTargetToFinalizer()

ortools.constraint_solver.pywrapcp.RoutingModel.AddWeightedVariableTargetToFinalizer ( self,
var,
target,
cost )
Same as above with a weighted priority: the higher the cost, the more
priority it has to be set close to the target value.

Definition at line 5680 of file pywrapcp.py.

◆ ApplyLocks()

ortools.constraint_solver.pywrapcp.RoutingModel.ApplyLocks ( self,
locks )
Applies a lock chain to the next search. 'locks' represents an ordered
vector of nodes representing a partial route which will be fixed during
the next search; it will constrain next variables such that:
next[locks[i]] == locks[i+1].

Returns the next variable at the end of the locked chain; this variable is
not locked. An assignment containing the locks can be obtained by calling
PreAssignment().

Definition at line 5801 of file pywrapcp.py.

◆ ApplyLocksToAllVehicles()

ortools.constraint_solver.pywrapcp.RoutingModel.ApplyLocksToAllVehicles ( self,
locks,
close_routes )
Applies lock chains to all vehicles to the next search, such that locks[p]
is the lock chain for route p. Returns false if the locks do not contain
valid routes; expects that the routes do not contain the depots,
i.e. there are empty vectors in place of empty routes.
If close_routes is set to true, adds the end nodes to the route of each
vehicle and deactivates other nodes.
An assignment containing the locks can be obtained by calling
PreAssignment().

Definition at line 5814 of file pywrapcp.py.

◆ ArcIsMoreConstrainedThanArc()

ortools.constraint_solver.pywrapcp.RoutingModel.ArcIsMoreConstrainedThanArc ( self,
_from,
to1,
to2 )
Returns whether the arc from->to1 is more constrained than from->to2,
taking into account, in order:
- whether the destination node isn't an end node
- whether the destination node is mandatory
- whether the destination node is bound to the same vehicle as the source
- the "primary constrained" dimension (see SetPrimaryConstrainedDimension)
It then breaks ties using, in order:
- the arc cost (taking unperformed penalties into account)
- the size of the vehicle vars of "to1" and "to2" (lowest size wins)
- the value: the lowest value of the indices to1 and to2 wins.
See the .cc for details.
The more constrained arc is typically preferable when building a
first solution. This method is intended to be used as a callback for the
BestValueByComparisonSelector value selector.
Args:
  from: the variable index of the source node
  to1: the variable index of the first candidate destination node.
  to2: the variable index of the second candidate destination node.

Definition at line 6165 of file pywrapcp.py.

◆ AreRoutesInterdependent()

ortools.constraint_solver.pywrapcp.RoutingModel.AreRoutesInterdependent ( self,
parameters )
Returns true if routes are interdependent. This means that any
modification to a route might impact another.

Definition at line 6279 of file pywrapcp.py.

◆ AssignmentToRoutes()

ortools.constraint_solver.pywrapcp.RoutingModel.AssignmentToRoutes ( self,
assignment,
routes )
Converts the solution in the given assignment to routes for all vehicles.
Expects that assignment contains a valid solution (i.e. routes for all
vehicles end with an end index for that vehicle).

Definition at line 5893 of file pywrapcp.py.

◆ CancelSearch()

ortools.constraint_solver.pywrapcp.RoutingModel.CancelSearch ( self)
Cancels the current search.

Definition at line 6242 of file pywrapcp.py.

◆ CheckIfAssignmentIsFeasible()

ortools.constraint_solver.pywrapcp.RoutingModel.CheckIfAssignmentIsFeasible ( self,
assignment,
call_at_solution_monitors )
Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair
containing the minimum and maximum of the CumulVar of the jth node on
route i.
- cumul_bounds[i][j].first is the minimum.
- cumul_bounds[i][j].second is the maximum.
Checks if an assignment is feasible.

Definition at line 6197 of file pywrapcp.py.

◆ CheckLimit()

ortools.constraint_solver.pywrapcp.RoutingModel.CheckLimit ( self,
* args )
Returns true if the search limit has been crossed with the given time
offset.

Definition at line 6215 of file pywrapcp.py.

◆ CloseModel()

ortools.constraint_solver.pywrapcp.RoutingModel.CloseModel ( self)
Closes the current routing model; after this method is called, no
modification to the model can be done, but RoutesToAssignment becomes
available. Note that CloseModel() is automatically called by Solve() and
other methods that produce solution.
This is equivalent to calling
CloseModelWithParameters(DefaultRoutingSearchParameters()).

Definition at line 5687 of file pywrapcp.py.

◆ CloseModelWithParameters()

ortools.constraint_solver.pywrapcp.RoutingModel.CloseModelWithParameters ( self,
search_parameters )
Same as above taking search parameters (as of 10/2015 some the parameters
have to be set when closing the model).

Definition at line 5698 of file pywrapcp.py.

◆ CompactAndCheckAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.CompactAndCheckAssignment ( self,
assignment )
Same as CompactAssignment() but also checks the validity of the final
compact solution; if it is not valid, no attempts to repair it are made
(instead, the method returns nullptr).

Definition at line 5927 of file pywrapcp.py.

◆ CompactAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.CompactAssignment ( self,
assignment )
Converts the solution in the given assignment to routes for all vehicles.
If the returned vector is route_indices, route_indices[i][j] is the index
for jth location visited on route i. Note that contrary to
AssignmentToRoutes, the vectors do include start and end locations.
Returns a compacted version of the given assignment, in which all vehicles
with id lower or equal to some N have non-empty routes, and all vehicles
with id greater than N have empty routes. Does not take ownership of the
returned object.
If found, the cost of the compact assignment is the same as in the
original assignment and it preserves the values of 'active' variables.
Returns nullptr if a compact assignment was not found.
This method only works in homogenous mode, and it only swaps equivalent
vehicles (vehicles with the same start and end nodes). When creating the
compact assignment, the empty plan is replaced by the route assigned to
the compatible vehicle with the highest id. Note that with more complex
constraints on vehicle variables, this method might fail even if a compact
solution exists.
This method changes the vehicle and dimension variables as necessary.
While compacting the solution, only basic checks on vehicle variables are
performed; if one of these checks fails no attempts to repair it are made
(instead, the method returns nullptr).

Definition at line 5901 of file pywrapcp.py.

◆ ComputeLowerBound()

ortools.constraint_solver.pywrapcp.RoutingModel.ComputeLowerBound ( self)
Computes a lower bound to the routing problem solving a linear assignment
problem. The routing model must be closed before calling this method.
Note that problems with node disjunction constraints (including optional
nodes) and non-homogenous costs are not supported (the method returns 0 in
these cases).

Definition at line 5772 of file pywrapcp.py.

◆ CostsAreHomogeneousAcrossVehicles()

ortools.constraint_solver.pywrapcp.RoutingModel.CostsAreHomogeneousAcrossVehicles ( self)
Whether costs are homogeneous across all vehicles.

Definition at line 6073 of file pywrapcp.py.

◆ CostVar()

ortools.constraint_solver.pywrapcp.RoutingModel.CostVar ( self)
Returns the global cost variable which is being minimized.

Definition at line 6062 of file pywrapcp.py.

◆ CumulDependentTransitCallback()

ortools.constraint_solver.pywrapcp.RoutingModel.CumulDependentTransitCallback ( self,
callback_index )

Definition at line 4966 of file pywrapcp.py.

◆ DebugOutputAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.DebugOutputAssignment ( self,
solution_assignment,
dimension_to_print )
Print some debugging information about an assignment, including the
feasible intervals of the CumulVar for dimension "dimension_to_print"
at each step of the routes.
If "dimension_to_print" is omitted, all dimensions will be printed.

Definition at line 6188 of file pywrapcp.py.

◆ enable_deep_serialization()

ortools.constraint_solver.pywrapcp.RoutingModel.enable_deep_serialization ( self)
Returns the value of the internal enable_deep_serialization_ parameter.

Definition at line 5797 of file pywrapcp.py.

◆ End()

ortools.constraint_solver.pywrapcp.RoutingModel.End ( self,
vehicle )
Returns the variable index of the ending node of a vehicle route.

Definition at line 5990 of file pywrapcp.py.

◆ FastSolveFromAssignmentWithParameters()

ortools.constraint_solver.pywrapcp.RoutingModel.FastSolveFromAssignmentWithParameters ( self,
assignment,
search_parameters,
check_solution_in_cp,
touched = None )
Improves a given assignment using unchecked local search.
If check_solution_in_cp is true the final solution will be checked with
the CP solver.
As of 11/2023, only works with greedy descent.

Definition at line 5735 of file pywrapcp.py.

◆ GetAllDimensionNames()

ortools.constraint_solver.pywrapcp.RoutingModel.GetAllDimensionNames ( self)
Outputs the names of all dimensions added to the routing engine.

Definition at line 5058 of file pywrapcp.py.

◆ GetAmortizedLinearCostFactorOfVehicles()

ortools.constraint_solver.pywrapcp.RoutingModel.GetAmortizedLinearCostFactorOfVehicles ( self)

Definition at line 5579 of file pywrapcp.py.

◆ GetAmortizedQuadraticCostFactorOfVehicles()

ortools.constraint_solver.pywrapcp.RoutingModel.GetAmortizedQuadraticCostFactorOfVehicles ( self)

Definition at line 5582 of file pywrapcp.py.

◆ GetArcCostForClass()

ortools.constraint_solver.pywrapcp.RoutingModel.GetArcCostForClass ( self,
from_index,
to_index,
cost_class_index )
Returns the cost of the segment between two nodes for a given cost
class. Input are variable indices of nodes and the cost class.
Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the
returned cost won't necessarily be zero: only some of the components
of the cost that depend on the cost class will be omited. See the code
for details.

Definition at line 6091 of file pywrapcp.py.

◆ GetArcCostForFirstSolution()

ortools.constraint_solver.pywrapcp.RoutingModel.GetArcCostForFirstSolution ( self,
from_index,
to_index )
Returns the cost of the arc in the context of the first solution strategy.
This is typically a simplification of the actual cost; see the .cc.

Definition at line 6084 of file pywrapcp.py.

◆ GetArcCostForVehicle()

ortools.constraint_solver.pywrapcp.RoutingModel.GetArcCostForVehicle ( self,
from_index,
to_index,
vehicle )
Returns the cost of the transit arc between two nodes for a given vehicle.
Input are variable indices of node. This returns 0 if vehicle < 0.

Definition at line 6066 of file pywrapcp.py.

◆ GetAutomaticFirstSolutionStrategy()

ortools.constraint_solver.pywrapcp.RoutingModel.GetAutomaticFirstSolutionStrategy ( self)
Returns the automatic first solution strategy selected.

Definition at line 6271 of file pywrapcp.py.

◆ GetCostClassesCount()

ortools.constraint_solver.pywrapcp.RoutingModel.GetCostClassesCount ( self)
Returns the number of different cost classes in the model.

Definition at line 6113 of file pywrapcp.py.

◆ GetCostClassIndexOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingModel.GetCostClassIndexOfVehicle ( self,
vehicle )
Get the cost class index of the given vehicle.

Definition at line 6102 of file pywrapcp.py.

◆ GetDeliveryPosition()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDeliveryPosition ( self,
node_index )
Returns the pickup and delivery positions where the node is a delivery.

Definition at line 5306 of file pywrapcp.py.

◆ GetDepot()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDepot ( self)
Returns the variable index of the first starting or ending node of all
routes. If all routes start  and end at the same node (single depot), this
is the node returned.

Definition at line 5497 of file pywrapcp.py.

◆ GetDimensionOrDie()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDimensionOrDie ( self,
dimension_name )
Returns a dimension from its name. Dies if the dimension does not exist.

Definition at line 5108 of file pywrapcp.py.

◆ GetDimensionResourceGroupIndex()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDimensionResourceGroupIndex ( self,
dimension )
Returns the index of the resource group attached to the dimension.
DCHECKS that there's exactly one resource group for this dimension.

Definition at line 5142 of file pywrapcp.py.

◆ GetDimensionResourceGroupIndices()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDimensionResourceGroupIndices ( self,
dimension )
Returns the indices of resource groups for this dimension. This method can
only be called after the model has been closed.

Definition at line 5135 of file pywrapcp.py.

◆ GetDimensions()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDimensions ( self)
Returns all dimensions of the model.

Definition at line 5062 of file pywrapcp.py.

◆ GetDimensionsWithGlobalCumulOptimizers()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDimensionsWithGlobalCumulOptimizers ( self)
Returns the dimensions which have [global|local]_dimension_optimizers_.

Definition at line 5074 of file pywrapcp.py.

◆ GetDimensionsWithLocalCumulOptimizers()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDimensionsWithLocalCumulOptimizers ( self)

Definition at line 5078 of file pywrapcp.py.

◆ GetDimensionsWithSoftOrSpanCosts()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDimensionsWithSoftOrSpanCosts ( self)
Returns dimensions with soft or vehicle span costs.

Definition at line 5066 of file pywrapcp.py.

◆ GetDisjunctionIndices()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDisjunctionIndices ( self,
index )
Returns the indices of the disjunctions to which an index belongs.

Definition at line 5179 of file pywrapcp.py.

◆ GetDisjunctionMaxCardinality()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDisjunctionMaxCardinality ( self,
index )
Returns the maximum number of possible active nodes of the node
disjunction of index 'index'.

Definition at line 5187 of file pywrapcp.py.

◆ GetDisjunctionPenalty()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDisjunctionPenalty ( self,
index )
Returns the penalty of the node disjunction of index 'index'.

Definition at line 5183 of file pywrapcp.py.

◆ GetDisjunctionPenaltyCostBehavior()

ortools.constraint_solver.pywrapcp.RoutingModel.GetDisjunctionPenaltyCostBehavior ( self,
index )
Returns the 'PenaltyCostBehavior' used by the disjunction of index
'index'.

Definition at line 5194 of file pywrapcp.py.

◆ GetFirstMatchingPickupDeliverySibling()

ortools.constraint_solver.pywrapcp.RoutingModel.GetFirstMatchingPickupDeliverySibling ( self,
node,
is_match )

Definition at line 5337 of file pywrapcp.py.

◆ GetFirstSolutionHint()

ortools.constraint_solver.pywrapcp.RoutingModel.GetFirstSolutionHint ( self)
Returns the current hint assignment.

Definition at line 5611 of file pywrapcp.py.

◆ GetFixedCostOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingModel.GetFixedCostOfVehicle ( self,
vehicle )
Returns the route fixed cost taken into account if the route of the
vehicle is not empty, aka there's at least one node on the route other
than the first and last nodes.

Definition at line 5541 of file pywrapcp.py.

◆ GetHardTypeIncompatibilitiesOfType()

ortools.constraint_solver.pywrapcp.RoutingModel.GetHardTypeIncompatibilitiesOfType ( self,
type )
Returns visit types incompatible with a given type.

Definition at line 5394 of file pywrapcp.py.

◆ GetHomogeneousCost()

ortools.constraint_solver.pywrapcp.RoutingModel.GetHomogeneousCost ( self,
from_index,
to_index )
Returns the cost of the segment between two nodes supposing all vehicle
costs are the same (returns the cost for the first vehicle otherwise).

Definition at line 6077 of file pywrapcp.py.

◆ GetMaximumNumberOfActiveVehicles()

ortools.constraint_solver.pywrapcp.RoutingModel.GetMaximumNumberOfActiveVehicles ( self)
Returns the maximum number of active vehicles.

Definition at line 5514 of file pywrapcp.py.

◆ GetMutableCPInterrupt()

ortools.constraint_solver.pywrapcp.RoutingModel.GetMutableCPInterrupt ( self)
Returns the atomic<bool> to stop the CP solver.

Definition at line 6238 of file pywrapcp.py.

◆ GetMutableCPSatInterrupt()

ortools.constraint_solver.pywrapcp.RoutingModel.GetMutableCPSatInterrupt ( self)
Returns the atomic<bool> to stop the CP-SAT solver.

Definition at line 6234 of file pywrapcp.py.

◆ GetMutableDimension()

ortools.constraint_solver.pywrapcp.RoutingModel.GetMutableDimension ( self,
dimension_name )
Returns a dimension from its name. Returns nullptr if the dimension does
not exist.

Definition at line 5112 of file pywrapcp.py.

◆ GetMutableGlobalCumulLPOptimizer()

ortools.constraint_solver.pywrapcp.RoutingModel.GetMutableGlobalCumulLPOptimizer ( self,
dimension )
Returns the global/local dimension cumul optimizer for a given dimension,
or nullptr if there is none.

Definition at line 5088 of file pywrapcp.py.

◆ GetMutableGlobalCumulMPOptimizer()

ortools.constraint_solver.pywrapcp.RoutingModel.GetMutableGlobalCumulMPOptimizer ( self,
dimension )

Definition at line 5095 of file pywrapcp.py.

◆ GetMutableLocalCumulLPOptimizer()

ortools.constraint_solver.pywrapcp.RoutingModel.GetMutableLocalCumulLPOptimizer ( self,
dimension )

Definition at line 5098 of file pywrapcp.py.

◆ GetMutableLocalCumulMPOptimizer()

ortools.constraint_solver.pywrapcp.RoutingModel.GetMutableLocalCumulMPOptimizer ( self,
dimension )

Definition at line 5101 of file pywrapcp.py.

◆ GetNonZeroCostClassesCount()

ortools.constraint_solver.pywrapcp.RoutingModel.GetNonZeroCostClassesCount ( self)
Ditto, minus the 'always zero', built-in cost class.

Definition at line 6117 of file pywrapcp.py.

◆ GetNumberOfDecisionsInFirstSolution()

ortools.constraint_solver.pywrapcp.RoutingModel.GetNumberOfDecisionsInFirstSolution ( self,
search_parameters )
Returns statistics on first solution search, number of decisions sent to
filters, number of decisions rejected by filters.

Definition at line 6261 of file pywrapcp.py.

◆ GetNumberOfDisjunctions()

ortools.constraint_solver.pywrapcp.RoutingModel.GetNumberOfDisjunctions ( self)
Returns the number of node disjunctions in the model.

Definition at line 5201 of file pywrapcp.py.

◆ GetNumberOfRejectsInFirstSolution()

ortools.constraint_solver.pywrapcp.RoutingModel.GetNumberOfRejectsInFirstSolution ( self,
search_parameters )

Definition at line 6268 of file pywrapcp.py.

◆ GetNumberOfSoftSameVehicleConstraints()

ortools.constraint_solver.pywrapcp.RoutingModel.GetNumberOfSoftSameVehicleConstraints ( self)
Returns the number of soft same vehicle constraints in the model.

Definition at line 5248 of file pywrapcp.py.

◆ GetNumberOfVisitTypes()

ortools.constraint_solver.pywrapcp.RoutingModel.GetNumberOfVisitTypes ( self)

Definition at line 5376 of file pywrapcp.py.

◆ GetNumOfSingletonNodes()

ortools.constraint_solver.pywrapcp.RoutingModel.GetNumOfSingletonNodes ( self)
Returns the number of non-start/end nodes which do not appear in a
pickup/delivery pair.

Definition at line 5330 of file pywrapcp.py.

◆ GetOrCreateNodeNeighborsByCostClass()

ortools.constraint_solver.pywrapcp.RoutingModel.GetOrCreateNodeNeighborsByCostClass ( self,
* args )
*Overload 1:*
Returns neighbors of all nodes for every cost class. The result is cached
and is computed once. The number of neighbors considered is based on a
ratio of non-vehicle nodes, specified by neighbors_ratio, with a minimum
of min-neighbors node considered.

|

*Overload 2:*
Returns parameters.num_neighbors neighbors of all nodes for every cost
class. The result is cached and is computed once.

Definition at line 5957 of file pywrapcp.py.

◆ GetPairIndicesOfType()

ortools.constraint_solver.pywrapcp.RoutingModel.GetPairIndicesOfType ( self,
type )

Definition at line 5370 of file pywrapcp.py.

◆ GetPathsMetadata()

ortools.constraint_solver.pywrapcp.RoutingModel.GetPathsMetadata ( self)

Definition at line 6321 of file pywrapcp.py.

◆ GetPerfectBinaryDisjunctions()

ortools.constraint_solver.pywrapcp.RoutingModel.GetPerfectBinaryDisjunctions ( self)
Returns the list of all perfect binary disjunctions, as pairs of variable
indices: a disjunction is "perfect" when its variables do not appear in
any other disjunction. Each pair is sorted (lowest variable index first),
and the output vector is also sorted (lowest pairs first).

Definition at line 5219 of file pywrapcp.py.

◆ GetPickupAndDeliveryPolicyOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingModel.GetPickupAndDeliveryPolicyOfVehicle ( self,
vehicle )

Definition at line 5327 of file pywrapcp.py.

◆ GetPickupPosition()

ortools.constraint_solver.pywrapcp.RoutingModel.GetPickupPosition ( self,
node_index )
Returns the pickup and delivery positions where the node is a pickup.

Definition at line 5302 of file pywrapcp.py.

◆ GetPrimaryConstrainedDimension()

ortools.constraint_solver.pywrapcp.RoutingModel.GetPrimaryConstrainedDimension ( self)
Get the primary constrained dimension, or an empty string if it is unset.

Definition at line 5128 of file pywrapcp.py.

◆ GetRequiredTypeAlternativesWhenAddingType()

ortools.constraint_solver.pywrapcp.RoutingModel.GetRequiredTypeAlternativesWhenAddingType ( self,
type )
Returns the set of requirement alternatives when adding the given type.

Definition at line 5455 of file pywrapcp.py.

◆ GetRequiredTypeAlternativesWhenRemovingType()

ortools.constraint_solver.pywrapcp.RoutingModel.GetRequiredTypeAlternativesWhenRemovingType ( self,
type )
Returns the set of requirement alternatives when removing the given type.

Definition at line 5459 of file pywrapcp.py.

◆ GetResourceGroup()

ortools.constraint_solver.pywrapcp.RoutingModel.GetResourceGroup ( self,
rg_index )

Definition at line 5132 of file pywrapcp.py.

◆ GetRouteCost()

ortools.constraint_solver.pywrapcp.RoutingModel.GetRouteCost ( self,
route )

Definition at line 5585 of file pywrapcp.py.

◆ GetSameActivityGroupOfIndex()

ortools.constraint_solver.pywrapcp.RoutingModel.GetSameActivityGroupOfIndex ( self,
node )
Returns the same activity group of the node.

Definition at line 6146 of file pywrapcp.py.

◆ GetSameActivityGroups()

ortools.constraint_solver.pywrapcp.RoutingModel.GetSameActivityGroups ( self)
Returns same activity groups of all nodes.

Definition at line 6150 of file pywrapcp.py.

◆ GetSameActivityGroupsCount()

ortools.constraint_solver.pywrapcp.RoutingModel.GetSameActivityGroupsCount ( self)
Returns the number of same activity groups.

Definition at line 6154 of file pywrapcp.py.

◆ GetSameActivityIndicesOfGroup()

ortools.constraint_solver.pywrapcp.RoutingModel.GetSameActivityIndicesOfGroup ( self,
group )
Returns variable indices of nodes in the same activity group.

Definition at line 6158 of file pywrapcp.py.

◆ GetSameActivityIndicesOfIndex()

ortools.constraint_solver.pywrapcp.RoutingModel.GetSameActivityIndicesOfIndex ( self,
node )
Returns variable indices of nodes constrained to have the same activity.

Definition at line 6142 of file pywrapcp.py.

◆ GetSameVehicleClassArcs()

ortools.constraint_solver.pywrapcp.RoutingModel.GetSameVehicleClassArcs ( self,
from_index,
to_index )
Returns all arcs which are equivalent to the {from_index, to_index} arc
wrt vehicle classes. Arcs will be returned only if from_index is the
start of a vehicle or if to_index is the end of a vehicle. The returned
arcs will then be starting or ending at start or end nodes of vehicles in
the same vehicle class. The input arc is included in the returned vector.

Definition at line 6331 of file pywrapcp.py.

◆ GetSameVehicleIndicesOfIndex()

ortools.constraint_solver.pywrapcp.RoutingModel.GetSameVehicleIndicesOfIndex ( self,
node )
Returns variable indices of nodes constrained to be on the same route.

Definition at line 6135 of file pywrapcp.py.

◆ GetSameVehicleRequiredTypeAlternativesOfType()

ortools.constraint_solver.pywrapcp.RoutingModel.GetSameVehicleRequiredTypeAlternativesOfType ( self,
type )
Returns the set of same-vehicle requirement alternatives for the given
type.

Definition at line 5448 of file pywrapcp.py.

◆ GetSingleNodesOfType()

ortools.constraint_solver.pywrapcp.RoutingModel.GetSingleNodesOfType ( self,
type )

Definition at line 5367 of file pywrapcp.py.

◆ GetSoftSameVehicleCost()

ortools.constraint_solver.pywrapcp.RoutingModel.GetSoftSameVehicleCost ( self,
index )
Returns the cost of the soft same vehicle constraint of index 'index'.

Definition at line 5259 of file pywrapcp.py.

◆ GetSoftSameVehicleIndices()

ortools.constraint_solver.pywrapcp.RoutingModel.GetSoftSameVehicleIndices ( self,
index )
Returns the indices of the nodes in the soft same vehicle constraint of
index 'index'.

Definition at line 5252 of file pywrapcp.py.

◆ GetSubSolverStatistics()

ortools.constraint_solver.pywrapcp.RoutingModel.GetSubSolverStatistics ( self)
Returns detailed search statistics.

Definition at line 5768 of file pywrapcp.py.

◆ GetTemporalTypeIncompatibilitiesOfType()

ortools.constraint_solver.pywrapcp.RoutingModel.GetTemporalTypeIncompatibilitiesOfType ( self,
type )

Definition at line 5398 of file pywrapcp.py.

◆ GetUnaryDimensions()

ortools.constraint_solver.pywrapcp.RoutingModel.GetUnaryDimensions ( self)
Returns dimensions for which all transit evaluators are unary.

Definition at line 5070 of file pywrapcp.py.

◆ GetVehicleClassesCount()

ortools.constraint_solver.pywrapcp.RoutingModel.GetVehicleClassesCount ( self)
Returns the number of different vehicle classes in the model.

Definition at line 6131 of file pywrapcp.py.

◆ GetVehicleClassIndexOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingModel.GetVehicleClassIndexOfVehicle ( self,
vehicle )

Definition at line 6121 of file pywrapcp.py.

◆ GetVehicleOfClass()

ortools.constraint_solver.pywrapcp.RoutingModel.GetVehicleOfClass ( self,
vehicle_class )
Returns a vehicle of the given vehicle class, and -1 if there are no
vehicles for this class.

Definition at line 6124 of file pywrapcp.py.

◆ GetVehiclesOfSameClass()

ortools.constraint_solver.pywrapcp.RoutingModel.GetVehiclesOfSameClass ( self,
start_end_index )
Returns indices of the vehicles which are in the same vehicle class as the
vehicle starting or ending at start_end_index.

Definition at line 6324 of file pywrapcp.py.

◆ GetVehicleTypeContainer()

ortools.constraint_solver.pywrapcp.RoutingModel.GetVehicleTypeContainer ( self)

Definition at line 6162 of file pywrapcp.py.

◆ GetVisitType()

ortools.constraint_solver.pywrapcp.RoutingModel.GetVisitType ( self,
index )

Definition at line 5364 of file pywrapcp.py.

◆ GetVisitTypePolicy()

ortools.constraint_solver.pywrapcp.RoutingModel.GetVisitTypePolicy ( self,
index )

Definition at line 5373 of file pywrapcp.py.

◆ HasDimension()

ortools.constraint_solver.pywrapcp.RoutingModel.HasDimension ( self,
dimension_name )
Returns true if a dimension exists for a given dimension name.

Definition at line 5104 of file pywrapcp.py.

◆ HasGlobalCumulOptimizer()

ortools.constraint_solver.pywrapcp.RoutingModel.HasGlobalCumulOptimizer ( self,
dimension )
Returns whether the given dimension has global/local cumul optimizers.

Definition at line 5081 of file pywrapcp.py.

◆ HasHardTypeIncompatibilities()

ortools.constraint_solver.pywrapcp.RoutingModel.HasHardTypeIncompatibilities ( self)
Returns true iff any hard (resp. temporal) type incompatibilities have
been added to the model.

Definition at line 5401 of file pywrapcp.py.

◆ HasLocalCumulOptimizer()

ortools.constraint_solver.pywrapcp.RoutingModel.HasLocalCumulOptimizer ( self,
dimension )

Definition at line 5085 of file pywrapcp.py.

◆ HasMandatoryDisjunctions()

ortools.constraint_solver.pywrapcp.RoutingModel.HasMandatoryDisjunctions ( self)
Returns true if the model contains mandatory disjunctions (ones with
kNoPenalty as penalty).

Definition at line 5205 of file pywrapcp.py.

◆ HasMaxCardinalityConstrainedDisjunctions()

ortools.constraint_solver.pywrapcp.RoutingModel.HasMaxCardinalityConstrainedDisjunctions ( self)
Returns true if the model contains at least one disjunction which is
constrained by its max_cardinality.

Definition at line 5212 of file pywrapcp.py.

◆ HasSameVehicleTypeRequirements()

ortools.constraint_solver.pywrapcp.RoutingModel.HasSameVehicleTypeRequirements ( self)
Returns true iff any same-route (resp. temporal) type requirements have
been added to the model.

Definition at line 5463 of file pywrapcp.py.

◆ HasTemporalTypeIncompatibilities()

ortools.constraint_solver.pywrapcp.RoutingModel.HasTemporalTypeIncompatibilities ( self)

Definition at line 5408 of file pywrapcp.py.

◆ HasTemporalTypeRequirements()

ortools.constraint_solver.pywrapcp.RoutingModel.HasTemporalTypeRequirements ( self)

Definition at line 5470 of file pywrapcp.py.

◆ HasTypeRegulations()

ortools.constraint_solver.pywrapcp.RoutingModel.HasTypeRegulations ( self)
Returns true iff the model has any incompatibilities or requirements set
on node types.

Definition at line 5473 of file pywrapcp.py.

◆ HasVehicleWithCostClassIndex()

ortools.constraint_solver.pywrapcp.RoutingModel.HasVehicleWithCostClassIndex ( self,
cost_class_index )
Returns true iff the model contains a vehicle with the given
cost_class_index.

Definition at line 6106 of file pywrapcp.py.

◆ IgnoreDisjunctionsAlreadyForcedToZero()

ortools.constraint_solver.pywrapcp.RoutingModel.IgnoreDisjunctionsAlreadyForcedToZero ( self)
SPECIAL: Makes the solver ignore all the disjunctions whose active
variables are all trivially zero (i.e. Max() == 0), by setting their
max_cardinality to 0.
This can be useful when using the BaseBinaryDisjunctionNeighborhood
operators, in the context of arc-based routing.

Definition at line 5228 of file pywrapcp.py.

◆ IsDelivery()

ortools.constraint_solver.pywrapcp.RoutingModel.IsDelivery ( self,
node_index )

Definition at line 5314 of file pywrapcp.py.

◆ IsEnd()

ortools.constraint_solver.pywrapcp.RoutingModel.IsEnd ( self,
index )
Returns true if 'index' represents the last node of a route.

Definition at line 5998 of file pywrapcp.py.

◆ IsMatchingModel()

ortools.constraint_solver.pywrapcp.RoutingModel.IsMatchingModel ( self)
Returns true if a vehicle/node matching problem is detected.

Definition at line 6275 of file pywrapcp.py.

◆ IsPickup()

ortools.constraint_solver.pywrapcp.RoutingModel.IsPickup ( self,
node_index )
Returns whether the node is a pickup (resp. delivery).

Definition at line 5310 of file pywrapcp.py.

◆ IsStart()

ortools.constraint_solver.pywrapcp.RoutingModel.IsStart ( self,
index )
Returns true if 'index' represents the first node of a route.

Definition at line 5994 of file pywrapcp.py.

◆ IsVehicleAllowedForIndex()

ortools.constraint_solver.pywrapcp.RoutingModel.IsVehicleAllowedForIndex ( self,
vehicle,
index )
Returns true if a vehicle is allowed to visit a given node.

Definition at line 5272 of file pywrapcp.py.

◆ IsVehicleUsed()

ortools.constraint_solver.pywrapcp.RoutingModel.IsVehicleUsed ( self,
assignment,
vehicle )
Returns true if the route of 'vehicle' is non empty in 'assignment'.

Definition at line 6017 of file pywrapcp.py.

◆ IsVehicleUsedWhenEmpty()

ortools.constraint_solver.pywrapcp.RoutingModel.IsVehicleUsedWhenEmpty ( self,
vehicle )

Definition at line 5591 of file pywrapcp.py.

◆ MakeGuidedSlackFinalizer()

ortools.constraint_solver.pywrapcp.RoutingModel.MakeGuidedSlackFinalizer ( self,
dimension,
initializer )
The next few members are in the public section only for testing purposes.

MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a
dimension using a callback to choose which values to start with.
The finalizer works only when all next variables in the model have
been fixed. It has the following two characteristics:
1. It follows the routes defined by the nexts variables when choosing a
   variable to make a decision on.
2. When it comes to choose a value for the slack of node i, the decision
   builder first calls the callback with argument i, and supposingly the
   returned value is x it creates decisions slack[i] = x, slack[i] = x +
   1, slack[i] = x - 1, slack[i] = x + 2, etc.

Definition at line 6286 of file pywrapcp.py.

◆ MakeSelfDependentDimensionFinalizer()

ortools.constraint_solver.pywrapcp.RoutingModel.MakeSelfDependentDimensionFinalizer ( self,
dimension )
MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a
self-dependent dimension. It makes an extensive use of the caches of the
state dependent transits.
In detail, MakeSelfDependentDimensionFinalizer returns a composition of a
local search decision builder with a greedy descent operator for the cumul
of the start of each route and a guided slack finalizer. Provided there
are no time windows and the maximum slacks are large enough, once the
cumul of the start of route is fixed, the guided finalizer can find
optimal values of the slacks for the rest of the route in time
proportional to the length of the route. Therefore the composed finalizer
generally works in time O(log(t)*n*m), where t is the latest possible
departute time, n is the number of nodes in the network and m is the
number of vehicles.

Definition at line 6303 of file pywrapcp.py.

◆ MutablePreAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.MutablePreAssignment ( self)

Definition at line 5836 of file pywrapcp.py.

◆ Next()

ortools.constraint_solver.pywrapcp.RoutingModel.Next ( self,
assignment,
index )
Assignment inspection
Returns the variable index of the node directly after the node
corresponding to 'index' in 'assignment'.

Definition at line 6009 of file pywrapcp.py.

◆ NextVar()

ortools.constraint_solver.pywrapcp.RoutingModel.NextVar ( self,
index )
Returns the next variable of the node corresponding to index. Note that
NextVar(index) == index is equivalent to ActiveVar(index) == 0.

Definition at line 6021 of file pywrapcp.py.

◆ nodes()

ortools.constraint_solver.pywrapcp.RoutingModel.nodes ( self)
Sizes and indices
Returns the number of nodes in the model.

Definition at line 6246 of file pywrapcp.py.

◆ objective_lower_bound()

ortools.constraint_solver.pywrapcp.RoutingModel.objective_lower_bound ( self)
Returns the current lower bound found by internal solvers during the
search.

Definition at line 5782 of file pywrapcp.py.

◆ PackCumulsOfOptimizerDimensionsFromAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.PackCumulsOfOptimizerDimensionsFromAssignment ( self,
original_assignment,
duration_limit,
time_limit_was_reached = None )
For every dimension in the model with an optimizer in
local/global_dimension_optimizers_, this method tries to pack the cumul
values of the dimension, such that:
- The cumul costs (span costs, soft lower and upper bound costs, etc) are
  minimized.
- The cumuls of the ends of the routes are minimized for this given
  minimal cumul cost.
- Given these minimal end cumuls, the route start cumuls are maximized.
Returns the assignment resulting from allocating these packed cumuls with
the solver, and nullptr if these cumuls could not be set by the solver.

Definition at line 5942 of file pywrapcp.py.

◆ PreAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.PreAssignment ( self)
Returns an assignment used to fix some of the variables of the problem.
In practice, this assignment locks partial routes of the problem. This
can be used in the context of locking the parts of the routes which have
already been driven in online routing problems.

Definition at line 5827 of file pywrapcp.py.

◆ ReadAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.ReadAssignment ( self,
file_name )
Reads an assignment from a file and returns the current solution.
Returns nullptr if the file cannot be opened or if the assignment is not
valid.

Definition at line 5847 of file pywrapcp.py.

◆ ReadAssignmentFromRoutes()

ortools.constraint_solver.pywrapcp.RoutingModel.ReadAssignmentFromRoutes ( self,
routes,
ignore_inactive_indices )
Restores the routes as the current solution. Returns nullptr if the
solution cannot be restored (routes do not contain a valid solution). Note
that calling this method will run the solver to assign values to the
dimension variables; this may take considerable amount of time, especially
when using dimensions with slack.

Definition at line 5862 of file pywrapcp.py.

◆ RegisterCumulDependentTransitCallback()

ortools.constraint_solver.pywrapcp.RoutingModel.RegisterCumulDependentTransitCallback ( self,
callback )

Definition at line 4957 of file pywrapcp.py.

◆ RegisterTransitCallback()

ortools.constraint_solver.pywrapcp.RoutingModel.RegisterTransitCallback ( self,
* args )

Definition at line 4954 of file pywrapcp.py.

◆ RegisterTransitMatrix()

ortools.constraint_solver.pywrapcp.RoutingModel.RegisterTransitMatrix ( self,
values )

Definition at line 4951 of file pywrapcp.py.

◆ RegisterUnaryTransitCallback()

ortools.constraint_solver.pywrapcp.RoutingModel.RegisterUnaryTransitCallback ( self,
* args )

Definition at line 4948 of file pywrapcp.py.

◆ RegisterUnaryTransitVector()

ortools.constraint_solver.pywrapcp.RoutingModel.RegisterUnaryTransitVector ( self,
values )
Registers 'callback' and returns its index.
The sign parameter allows to notify the solver that the callback only
return values of the given sign. This can help the solver, but passing
an incorrect sign may crash in non-opt compilation mode, and yield
incorrect results in opt.

Definition at line 4938 of file pywrapcp.py.

◆ RemainingTime()

ortools.constraint_solver.pywrapcp.RoutingModel.RemainingTime ( self)
Returns the time left in the search limit.

Definition at line 6222 of file pywrapcp.py.

◆ ResourceVar()

ortools.constraint_solver.pywrapcp.RoutingModel.ResourceVar ( self,
vehicle,
resource_group )
Returns the resource variable for the given vehicle index in the given
resource group. If a vehicle doesn't require a resource from the
corresponding resource group, then ResourceVar(v, r_g) == -1.

Definition at line 6054 of file pywrapcp.py.

◆ RestoreAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.RestoreAssignment ( self,
solution )
Restores an assignment as a solution in the routing model and returns the
new solution. Returns nullptr if the assignment is not valid.

Definition at line 5855 of file pywrapcp.py.

◆ RoutesToAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.RoutesToAssignment ( self,
routes,
ignore_inactive_indices,
close_routes,
assignment )
Fills an assignment from a specification of the routes of the
vehicles. The routes are specified as lists of variable indices that
appear on the routes of the vehicles. The indices of the outer vector in
'routes' correspond to vehicles IDs, the inner vector contains the
variable indices on the routes for the given vehicle. The inner vectors
must not contain the start and end indices, as these are determined by the
routing model.  Sets the value of NextVars in the assignment, adding the
variables to the assignment if necessary. The method does not touch other
variables in the assignment. The method can only be called after the model
is closed.  With ignore_inactive_indices set to false, this method will
fail (return nullptr) in case some of the route contain indices that are
deactivated in the model; when set to true, these indices will be
skipped.  Returns true if routes were successfully
loaded. However, such assignment still might not be a valid
solution to the routing problem due to more complex constraints;
it is advisible to call solver()->CheckSolution() afterwards.

Definition at line 5872 of file pywrapcp.py.

◆ search_stats()

ortools.constraint_solver.pywrapcp.RoutingModel.search_stats ( self)
Returns search statistics.

Definition at line 5793 of file pywrapcp.py.

◆ SetAllowedVehiclesForIndex()

ortools.constraint_solver.pywrapcp.RoutingModel.SetAllowedVehiclesForIndex ( self,
vehicles,
index )
Sets the vehicles which can visit a given node. If the node is in a
disjunction, this will not prevent it from being unperformed.
Specifying an empty vector of vehicles has no effect (all vehicles
will be allowed to visit the node).

Definition at line 5263 of file pywrapcp.py.

◆ SetAmortizedCostFactorsOfAllVehicles()

ortools.constraint_solver.pywrapcp.RoutingModel.SetAmortizedCostFactorsOfAllVehicles ( self,
linear_cost_factor,
quadratic_cost_factor )
The following methods set the linear and quadratic cost factors of
vehicles (must be positive values). The default value of these parameters
is zero for all vehicles.

When set, the cost_ of the model will contain terms aiming at reducing the
number of vehicles used in the model, by adding the following to the
objective for every vehicle v:
INDICATOR(v used in the model) *
  [linear_cost_factor_of_vehicle_[v]
   - quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)]
i.e. for every used vehicle, we add the linear factor as fixed cost, and
subtract the square of the route length multiplied by the quadratic
factor. This second term aims at making the routes as dense as possible.

Sets the linear and quadratic cost factor of all vehicles.

Definition at line 5555 of file pywrapcp.py.

◆ SetAmortizedCostFactorsOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingModel.SetAmortizedCostFactorsOfVehicle ( self,
linear_cost_factor,
quadratic_cost_factor,
vehicle )
Sets the linear and quadratic cost factor of the given vehicle.

Definition at line 5575 of file pywrapcp.py.

◆ SetArcCostEvaluatorOfAllVehicles()

ortools.constraint_solver.pywrapcp.RoutingModel.SetArcCostEvaluatorOfAllVehicles ( self,
evaluator_index )
Sets the cost function of the model such that the cost of a segment of a
route between node 'from' and 'to' is evaluator(from, to), whatever the
route or vehicle performing the route.

Definition at line 5518 of file pywrapcp.py.

◆ SetArcCostEvaluatorOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingModel.SetArcCostEvaluatorOfVehicle ( self,
evaluator_index,
vehicle )
Sets the cost function for a given vehicle route.

Definition at line 5526 of file pywrapcp.py.

◆ SetAssignmentFromOtherModelAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.SetAssignmentFromOtherModelAssignment ( self,
target_assignment,
source_model,
source_assignment )
Given a "source_model" and its "source_assignment", resets
"target_assignment" with the IntVar variables (nexts_, and vehicle_vars_
if costs aren't homogeneous across vehicles) of "this" model, with the
values set according to those in "other_assignment".
The objective_element of target_assignment is set to this->cost_.

Definition at line 5758 of file pywrapcp.py.

◆ SetFirstSolutionEvaluator()

ortools.constraint_solver.pywrapcp.RoutingModel.SetFirstSolutionEvaluator ( self,
evaluator )
Gets/sets the evaluator used during the search. Only relevant when
RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY.
Takes ownership of evaluator.

Definition at line 5594 of file pywrapcp.py.

◆ SetFirstSolutionHint()

ortools.constraint_solver.pywrapcp.RoutingModel.SetFirstSolutionHint ( self,
hint )
Adds a hint to be used by first solution strategies. The hint assignment
must outlive the search.
As of 2024-12, only used by LOCAL_CHEAPEST_INSERTION and
LOCAL_CHEAPEST_COST_INSERTION.

Definition at line 5602 of file pywrapcp.py.

◆ SetFixedCostOfAllVehicles()

ortools.constraint_solver.pywrapcp.RoutingModel.SetFixedCostOfAllVehicles ( self,
cost )
Sets the fixed cost of all vehicle routes. It is equivalent to calling
SetFixedCostOfVehicle on all vehicle routes.

Definition at line 5530 of file pywrapcp.py.

◆ SetFixedCostOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingModel.SetFixedCostOfVehicle ( self,
cost,
vehicle )
Sets the fixed cost of one vehicle route.

Definition at line 5537 of file pywrapcp.py.

◆ SetMaximumNumberOfActiveVehicles()

ortools.constraint_solver.pywrapcp.RoutingModel.SetMaximumNumberOfActiveVehicles ( self,
max_active_vehicles )
Constrains the maximum number of active vehicles, aka the number of
vehicles which do not have an empty route. For instance, this can be used
to limit the number of routes in the case where there are fewer drivers
than vehicles and that the fleet of vehicle is heterogeneous.

Definition at line 5505 of file pywrapcp.py.

◆ SetPathEnergyCostOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingModel.SetPathEnergyCostOfVehicle ( self,
force,
distance,
cost_per_unit,
vehicle )

Definition at line 5549 of file pywrapcp.py.

◆ SetPathEnergyCostsOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingModel.SetPathEnergyCostsOfVehicle ( self,
force,
distance,
threshold,
cost_per_unit_below_threshold,
cost_per_unit_above_threshold,
vehicle )

Definition at line 5552 of file pywrapcp.py.

◆ SetPickupAndDeliveryPolicyOfAllVehicles()

ortools.constraint_solver.pywrapcp.RoutingModel.SetPickupAndDeliveryPolicyOfAllVehicles ( self,
policy )
Sets the Pickup and delivery policy of all vehicles. It is equivalent to
calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.

Definition at line 5317 of file pywrapcp.py.

◆ SetPickupAndDeliveryPolicyOfVehicle()

ortools.constraint_solver.pywrapcp.RoutingModel.SetPickupAndDeliveryPolicyOfVehicle ( self,
policy,
vehicle )

Definition at line 5324 of file pywrapcp.py.

◆ SetPrimaryConstrainedDimension()

ortools.constraint_solver.pywrapcp.RoutingModel.SetPrimaryConstrainedDimension ( self,
dimension_name )
Set the given dimension as "primary constrained". As of August 2013, this
is only used by ArcIsMoreConstrainedThanArc().
"dimension" must be the name of an existing dimension, or be empty, in
which case there will not be a primary dimension after this call.

Definition at line 5119 of file pywrapcp.py.

◆ SetVehicleUsedWhenEmpty()

ortools.constraint_solver.pywrapcp.RoutingModel.SetVehicleUsedWhenEmpty ( self,
is_used,
vehicle )

Definition at line 5588 of file pywrapcp.py.

◆ SetVisitType()

ortools.constraint_solver.pywrapcp.RoutingModel.SetVisitType ( self,
index,
type,
type_policy )

Definition at line 5361 of file pywrapcp.py.

◆ Size()

ortools.constraint_solver.pywrapcp.RoutingModel.Size ( self)
Returns the number of next variables in the model.

Definition at line 6257 of file pywrapcp.py.

◆ Solve()

ortools.constraint_solver.pywrapcp.RoutingModel.Solve ( self,
assignment = None )
Solves the current routing model; closes the current model.
This is equivalent to calling
SolveWithParameters(DefaultRoutingSearchParameters())
or
SolveFromAssignmentWithParameters(assignment,
                                  DefaultRoutingSearchParameters()).

Definition at line 5705 of file pywrapcp.py.

◆ SolveFromAssignmentsWithParameters()

ortools.constraint_solver.pywrapcp.RoutingModel.SolveFromAssignmentsWithParameters ( self,
assignments,
search_parameters,
solutions = None )
Same as above but will try all assignments in order as first solutions
until one succeeds.

Definition at line 5744 of file pywrapcp.py.

◆ SolveFromAssignmentWithParameters()

ortools.constraint_solver.pywrapcp.RoutingModel.SolveFromAssignmentWithParameters ( self,
assignment,
search_parameters,
solutions = None )
Same as above, except that if assignment is not null, it will be used as
the initial solution.

Definition at line 5728 of file pywrapcp.py.

◆ solver()

ortools.constraint_solver.pywrapcp.RoutingModel.solver ( self)
Returns the underlying constraint solver. Can be used to add extra
constraints and/or modify search algorithms.

Definition at line 6208 of file pywrapcp.py.

◆ SolveWithIteratedLocalSearch()

ortools.constraint_solver.pywrapcp.RoutingModel.SolveWithIteratedLocalSearch ( self,
search_parameters )
Solves the current routing model by using an Iterated Local Search
approach.

Definition at line 5751 of file pywrapcp.py.

◆ SolveWithParameters()

ortools.constraint_solver.pywrapcp.RoutingModel.SolveWithParameters ( self,
search_parameters,
solutions = None )
Solves the current routing model with the given parameters. If 'solutions'
is specified, it will contain the k best solutions found during the search
(from worst to best, including the one returned by this method), where k
corresponds to the 'number_of_solutions_to_collect' in
'search_parameters'. Note that the Assignment returned by the method and
the ones in solutions are owned by the underlying solver and should not be
deleted.

Definition at line 5716 of file pywrapcp.py.

◆ Start()

ortools.constraint_solver.pywrapcp.RoutingModel.Start ( self,
vehicle )
Model inspection.
Returns the variable index of the starting node of a vehicle route.

Definition at line 5983 of file pywrapcp.py.

◆ status()

ortools.constraint_solver.pywrapcp.RoutingModel.status ( self)
Returns the current status of the routing model.

Definition at line 5789 of file pywrapcp.py.

◆ TimeBuffer()

ortools.constraint_solver.pywrapcp.RoutingModel.TimeBuffer ( self)
Returns the time buffer to safely return a solution.

Definition at line 6230 of file pywrapcp.py.

◆ TransitCallback()

ortools.constraint_solver.pywrapcp.RoutingModel.TransitCallback ( self,
callback_index )

Definition at line 4960 of file pywrapcp.py.

◆ UnaryTransitCallbackOrNull()

ortools.constraint_solver.pywrapcp.RoutingModel.UnaryTransitCallbackOrNull ( self,
callback_index )

Definition at line 4963 of file pywrapcp.py.

◆ UnperformedPenalty()

ortools.constraint_solver.pywrapcp.RoutingModel.UnperformedPenalty ( self,
var_index )
Get the "unperformed" penalty of a node. This is only well defined if the
node is only part of a single Disjunction, and that disjunction has a
penalty. For forced active nodes returns max int64_t. In all other cases,
this returns 0.

Definition at line 5480 of file pywrapcp.py.

◆ UnperformedPenaltyOrValue()

ortools.constraint_solver.pywrapcp.RoutingModel.UnperformedPenaltyOrValue ( self,
default_value,
var_index )
Same as above except that it returns default_value instead of 0 when
penalty is not well defined (default value is passed as first argument to
simplify the usage of the method in a callback).

Definition at line 5489 of file pywrapcp.py.

◆ UpdateTimeLimit()

ortools.constraint_solver.pywrapcp.RoutingModel.UpdateTimeLimit ( self,
time_limit )
Updates the time limit of the search limit.

Definition at line 6226 of file pywrapcp.py.

◆ VehicleIndex()

ortools.constraint_solver.pywrapcp.RoutingModel.VehicleIndex ( self,
index )
Returns the vehicle of the given start/end index, and -1 if the given
index is not a vehicle start/end.

Definition at line 6002 of file pywrapcp.py.

◆ VehicleRouteConsideredVar()

ortools.constraint_solver.pywrapcp.RoutingModel.VehicleRouteConsideredVar ( self,
vehicle )
Returns the variable specifying whether or not the given vehicle route is
considered for costs and constraints. It will be equal to 1 iff the route
of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.

Definition at line 6039 of file pywrapcp.py.

◆ vehicles()

ortools.constraint_solver.pywrapcp.RoutingModel.vehicles ( self)
Returns the number of vehicle routes in the model.

Definition at line 6253 of file pywrapcp.py.

◆ VehicleVar()

ortools.constraint_solver.pywrapcp.RoutingModel.VehicleVar ( self,
index )
Returns the vehicle variable of the node corresponding to index. Note that
VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.

Definition at line 6047 of file pywrapcp.py.

◆ WriteAssignment()

ortools.constraint_solver.pywrapcp.RoutingModel.WriteAssignment ( self,
file_name )
Writes the current solution to a file containing an AssignmentProto.
Returns false if the file cannot be opened or if there is no current
solution.

Definition at line 5839 of file pywrapcp.py.

Member Data Documentation

◆ ADDED_TYPE_REMOVED_FROM_VEHICLE

ortools.constraint_solver.pywrapcp.RoutingModel.ADDED_TYPE_REMOVED_FROM_VEHICLE = _pywrapcp.RoutingModel_ADDED_TYPE_REMOVED_FROM_VEHICLE
static

Definition at line 5341 of file pywrapcp.py.

◆ kTransitEvaluatorSignNegativeOrZero

ortools.constraint_solver.pywrapcp.RoutingModel.kTransitEvaluatorSignNegativeOrZero = _pywrapcp.RoutingModel_kTransitEvaluatorSignNegativeOrZero
static

Definition at line 4936 of file pywrapcp.py.

◆ kTransitEvaluatorSignPositiveOrZero

ortools.constraint_solver.pywrapcp.RoutingModel.kTransitEvaluatorSignPositiveOrZero = _pywrapcp.RoutingModel_kTransitEvaluatorSignPositiveOrZero
static

Definition at line 4935 of file pywrapcp.py.

◆ kTransitEvaluatorSignUnknown

ortools.constraint_solver.pywrapcp.RoutingModel.kTransitEvaluatorSignUnknown = _pywrapcp.RoutingModel_kTransitEvaluatorSignUnknown
static

Definition at line 4934 of file pywrapcp.py.

◆ PENALIZE_ONCE

ortools.constraint_solver.pywrapcp.RoutingModel.PENALIZE_ONCE = _pywrapcp.RoutingModel_PENALIZE_ONCE
static

Definition at line 5148 of file pywrapcp.py.

◆ PENALIZE_PER_INACTIVE

ortools.constraint_solver.pywrapcp.RoutingModel.PENALIZE_PER_INACTIVE = _pywrapcp.RoutingModel_PENALIZE_PER_INACTIVE
static

Definition at line 5149 of file pywrapcp.py.

◆ PICKUP_AND_DELIVERY_FIFO

ortools.constraint_solver.pywrapcp.RoutingModel.PICKUP_AND_DELIVERY_FIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_FIFO
static

Definition at line 4923 of file pywrapcp.py.

◆ PICKUP_AND_DELIVERY_LIFO

ortools.constraint_solver.pywrapcp.RoutingModel.PICKUP_AND_DELIVERY_LIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_LIFO
static

Definition at line 4921 of file pywrapcp.py.

◆ PICKUP_AND_DELIVERY_NO_ORDER

ortools.constraint_solver.pywrapcp.RoutingModel.PICKUP_AND_DELIVERY_NO_ORDER = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_NO_ORDER
static

Definition at line 4919 of file pywrapcp.py.

◆ TYPE_ADDED_TO_VEHICLE

ortools.constraint_solver.pywrapcp.RoutingModel.TYPE_ADDED_TO_VEHICLE = _pywrapcp.RoutingModel_TYPE_ADDED_TO_VEHICLE
static

Definition at line 5339 of file pywrapcp.py.

◆ TYPE_ON_VEHICLE_UP_TO_VISIT

ortools.constraint_solver.pywrapcp.RoutingModel.TYPE_ON_VEHICLE_UP_TO_VISIT = _pywrapcp.RoutingModel_TYPE_ON_VEHICLE_UP_TO_VISIT
static

Definition at line 5348 of file pywrapcp.py.

◆ TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED

ortools.constraint_solver.pywrapcp.RoutingModel.TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = _pywrapcp.RoutingModel_TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
static

Definition at line 5353 of file pywrapcp.py.

Property Documentation

◆ thisown

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

Definition at line 4917 of file pywrapcp.py.


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