public class RoutingModel
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
RoutingModel.NodeNeighborsByCostClass |
static class |
RoutingModel.PickupDeliveryPosition
The position of a node in the set of pickup and delivery pairs.
|
static class |
RoutingModel.ResourceGroup
A ResourceGroup defines a set of available Resources with attributes on
one or multiple dimensions. For every ResourceGroup in the model, each (used) vehicle in the solution which requires a resource (see NotifyVehicleRequiresResource()) from this group must be assigned to exactly 1 resource, and each resource can in turn be assigned to at most 1 vehicle requiring it. |
static class |
RoutingModel.RouteDimensionTravelInfo
Contains the information needed by the solver to optimize a dimension's
cumuls with travel-start dependent transit values. |
static class |
RoutingModel.SecondaryOptimizer
Class used to solve a secondary model within a first solution strategy.
|
static class |
RoutingModel.VariableValuePair
Struct used to store a variable value.
|
static class |
RoutingModel.VehicleTypeContainer
Struct used to sort and store vehicles by their type.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
ADDED_TYPE_REMOVED_FROM_VEHICLE
When visited, one instance of type 'T' previously added to the route
(TYPE_ADDED_TO_VEHICLE), if any, is removed from the vehicle. If the type was not previously added to the route or all added instances have already been removed, this visit has no effect on the types. |
static int |
kTransitEvaluatorSignNegativeOrZero |
static int |
kTransitEvaluatorSignPositiveOrZero |
static int |
kTransitEvaluatorSignUnknown
Represents the sign of values returned by a transit evaluator.
|
static int |
PICKUP_AND_DELIVERY_FIFO
Deliveries must be performed in the same order as pickups.
|
static int |
PICKUP_AND_DELIVERY_LIFO
Deliveries must be performed in reverse order of pickups.
|
static int |
PICKUP_AND_DELIVERY_NO_ORDER
Any precedence is accepted.
|
static int |
ROUTING_FAIL
No solution found to the problem after calling RoutingModel::Solve().
|
static int |
ROUTING_FAIL_TIMEOUT
Time limit reached before finding a solution with RoutingModel::Solve().
|
static int |
ROUTING_INFEASIBLE
Problem proven to be infeasible.
|
static int |
ROUTING_INVALID
Model, model parameters or flags are not valid.
|
static int |
ROUTING_NOT_SOLVED
Problem not solved yet (before calling RoutingModel::Solve()).
|
static int |
ROUTING_OPTIMAL
Problem has been solved to optimality.
|
static int |
ROUTING_PARTIAL_SUCCESS_LOCAL_OPTIMUM_NOT_REACHED
Problem solved successfully after calling RoutingModel::Solve(), except
that a local optimum has not been reached. |
static int |
ROUTING_SUCCESS
Problem solved successfully after calling RoutingModel::Solve().
|
protected boolean |
swigCMemOwn |
static int |
TYPE_ADDED_TO_VEHICLE
When visited, the number of types 'T' on the vehicle increases by one.
|
static int |
TYPE_ON_VEHICLE_UP_TO_VISIT
With the following policy, the visit enforces that type 'T' is
considered on the route from its start until this node is visited. |
static int |
TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
The visit doesn't have an impact on the number of types 'T' on the
route, as it's (virtually) added and removed directly. This policy can be used for visits which are part of an incompatibility or requirement set without affecting the type count on the route. |
| Constructor and Description |
|---|
RoutingModel(long cPtr,
boolean cMemoryOwn) |
RoutingModel(RoutingIndexManager index_manager)
Constructor taking an index manager.
|
RoutingModel(RoutingIndexManager index_manager,
RoutingModelParameters parameters) |
| Modifier and Type | Method and Description |
|---|---|
IntVar |
activeVar(long index)
Returns the active variable of the node corresponding to index.
|
IntVar |
activeVehicleVar(int vehicle)
Returns the active variable of the vehicle.
|
void |
addAtSolutionCallback(java.lang.Runnable callback)
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). |
void |
addAtSolutionCallback(java.lang.Runnable callback,
boolean track_unchecked_neighbors)
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). |
IntBoolPair |
addConstantDimension(long value,
long capacity,
boolean fix_start_cumul_to_zero,
java.lang.String name) |
IntBoolPair |
addConstantDimensionWithSlack(long value,
long capacity,
long slack_max,
boolean fix_start_cumul_to_zero,
java.lang.String 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). |
boolean |
addDimension(int evaluator_index,
long slack_max,
long capacity,
boolean fix_start_cumul_to_zero,
java.lang.String name)
Model creation
Methods to add dimensions to routes; dimensions represent quantities accumulated at nodes along the routes. |
boolean |
addDimensionWithVehicleCapacity(int evaluator_index,
long slack_max,
long[] vehicle_capacities,
boolean fix_start_cumul_to_zero,
java.lang.String name) |
boolean |
addDimensionWithVehicleTransitAndCapacity(int[] evaluator_indices,
long slack_max,
long[] vehicle_capacities,
boolean fix_start_cumul_to_zero,
java.lang.String name) |
boolean |
addDimensionWithVehicleTransits(int[] evaluator_indices,
long slack_max,
long capacity,
boolean fix_start_cumul_to_zero,
java.lang.String name) |
int |
addDisjunction(long[] indices)
Adds a disjunction constraint on the indices: exactly 'max_cardinality' of
the indices are active. |
int |
addDisjunction(long[] indices,
long penalty)
Adds a disjunction constraint on the indices: exactly 'max_cardinality' of
the indices are active. |
int |
addDisjunction(long[] indices,
long penalty,
long max_cardinality)
Adds a disjunction constraint on the indices: exactly 'max_cardinality' of
the indices are active. |
void |
addHardTypeIncompatibility(int type1,
int 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. |
void |
addIntervalToAssignment(IntervalVar interval) |
void |
addLocalSearchFilter(LocalSearchFilter 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. |
void |
addLocalSearchOperator(LocalSearchOperator ls_operator)
Adds a local search operator to the set of operators used to solve the
vehicle routing problem. |
IntBoolPair |
addMatrixDimension(long[][] values,
long capacity,
boolean fix_start_cumul_to_zero,
java.lang.String 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. |
void |
addPickupAndDelivery(long pickup,
long delivery)
Notifies that index1 and index2 form a pair of nodes which should belong
to the same route. |
void |
addPickupAndDeliverySets(int pickup_disjunction,
int 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'. |
void |
addRequiredTypeAlternativesWhenAddingType(int dependent_type,
SWIGTYPE_p_absl__flat_hash_setT_int_t 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. |
void |
addRequiredTypeAlternativesWhenRemovingType(int dependent_type,
SWIGTYPE_p_absl__flat_hash_setT_int_t required_type_alternatives)
The following requirements apply when visiting dependent nodes that remove
their type from the route, i.e. |
RoutingModel.ResourceGroup |
AddResourceGroup()
Adds a resource group to the routing model and returns a pointer to it.
|
void |
addSearchMonitor(SearchMonitor monitor)
Adds a search monitor to the search used to solve the routing model.
|
void |
addSoftSameVehicleConstraint(long[] indices,
long cost)
Adds a soft constraint to force a set of variable indices to be on the
same vehicle. |
void |
addTemporalTypeIncompatibility(int type1,
int type2) |
void |
addToAssignment(IntVar var)
Adds an extra variable to the vehicle routing assignment.
|
void |
addVariableMaximizedByFinalizer(IntVar var)
Adds a variable to maximize in the solution finalizer (see above for
information on the solution finalizer). |
void |
addVariableMinimizedByFinalizer(IntVar var)
Adds a variable to minimize in the solution finalizer.
|
void |
addVariableTargetToFinalizer(IntVar var,
long target)
Add a variable to set the closest possible to the target value in the
solution finalizer. |
IntBoolPair |
addVectorDimension(long[] values,
long capacity,
boolean fix_start_cumul_to_zero,
java.lang.String 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. |
void |
AddWeightedVariableMaximizedByFinalizer(IntVar var,
long cost)
Adds a variable to maximize in the solution finalizer, with a weighted
priority: the higher the more priority it has. |
void |
AddWeightedVariableMinimizedByFinalizer(IntVar var,
long cost)
Adds a variable to minimize in the solution finalizer, with a weighted
priority: the higher the more priority it has. |
void |
AddWeightedVariableTargetToFinalizer(IntVar var,
long target,
long 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. |
IntVar |
applyLocks(long[] locks)
Applies a lock chain to the next search.
|
boolean |
applyLocksToAllVehicles(long[][] locks,
boolean close_routes)
Applies lock chains to all vehicles to the next search, such that locks[p]
is the lock chain for route p. |
boolean |
arcIsMoreConstrainedThanArc(long from,
long to1,
long 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. |
boolean |
AreRoutesInterdependent(SWIGTYPE_p_operations_research__RoutingSearchParameters parameters)
Returns true if routes are interdependent.
|
void |
assignmentToRoutes(Assignment assignment,
long[][] routes)
Converts the solution in the given assignment to routes for all vehicles.
Expects that assignment contains a valid solution (i.e. |
void |
CancelSearch()
Cancels the current search.
|
boolean |
CheckIfAssignmentIsFeasible(Assignment assignment,
boolean 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. |
boolean |
checkLimit()
Returns true if the search limit has been crossed with the given time
offset. |
boolean |
checkLimit(SWIGTYPE_p_absl__Duration offset)
Returns true if the search limit has been crossed with the given time
offset. |
void |
closeModel()
Closes the current routing model; after this method is called, no
modification to the model can be done, but RoutesToAssignment becomes available. |
void |
closeModelWithParameters(RoutingSearchParameters search_parameters)
Same as above taking search parameters (as of 10/2015 some the parameters
have to be set when closing the model). |
void |
closeVisitTypes()
This function should be called once all node visit types have been set and
prior to adding any incompatibilities/requirements. "close" types. |
Assignment |
compactAndCheckAssignment(Assignment 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). |
Assignment |
compactAssignment(Assignment 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. |
long |
computeLowerBound()
Computes a lower bound to the routing problem solving a linear assignment
problem. |
boolean |
costsAreHomogeneousAcrossVehicles()
Whether costs are homogeneous across all vehicles.
|
IntVar |
costVar()
Returns the global cost variable which is being minimized.
|
java.lang.String |
debugOutputAssignment(Assignment solution_assignment,
java.lang.String 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. |
void |
delete() |
boolean |
enable_deep_serialization()
Returns the value of the internal enable_deep_serialization_ parameter.
|
long |
end(int vehicle)
Returns the variable index of the ending node of a vehicle route.
|
Assignment |
FastSolveFromAssignmentWithParameters(Assignment assignment,
RoutingSearchParameters search_parameters,
boolean check_solution_in_cp)
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. |
Assignment |
FastSolveFromAssignmentWithParameters(Assignment assignment,
RoutingSearchParameters search_parameters,
boolean check_solution_in_cp,
SWIGTYPE_p_absl__flat_hash_setT_operations_research__IntVar_p_t touched)
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. |
protected void |
finalize() |
long[] |
getAmortizedLinearCostFactorOfVehicles() |
long[] |
getAmortizedQuadraticCostFactorOfVehicles() |
long |
getArcCostForClass(long from_index,
long to_index,
long cost_class_index)
Returns the cost of the segment between two nodes for a given cost
class. |
long |
getArcCostForFirstSolution(long from_index,
long 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. |
long |
getArcCostForVehicle(long from_index,
long to_index,
long vehicle)
Returns the cost of the transit arc between two nodes for a given vehicle.
Input are variable indices of node. |
int |
getCostClassesCount()
Returns the number of different cost classes in the model.
|
int |
getCostClassIndexOfVehicle(long vehicle)
Get the cost class index of the given vehicle.
|
static long |
getCPtr(RoutingModel obj) |
SWIGTYPE_p_std__vectorT_operations_research__RoutingModel__PickupDeliveryPosition_t |
GetDeliveryPositions(long node_index)
Returns the pickup and delivery positions where the node is a delivery.
|
long |
getDepot()
Returns the variable index of the first starting or ending node of all
routes. |
RoutingDimension |
getDimensionOrDie(java.lang.String dimension_name)
Returns a dimension from its name.
|
int |
GetDimensionResourceGroupIndex(RoutingDimension dimension)
Returns the index of the resource group attached to the dimension.
DCHECKS that there's exactly one resource group for this dimension. |
int[] |
GetDimensionResourceGroupIndices(RoutingDimension dimension)
Returns the indices of resource groups for this dimension.
|
SWIGTYPE_p_std__vectorT_operations_research__RoutingDimension_const_p_t |
GetDimensionsWithGlobalCumulOptimizers()
Returns the dimensions which have [global|local]_dimension_optimizers_.
|
SWIGTYPE_p_std__vectorT_operations_research__RoutingDimension_const_p_t |
GetDimensionsWithLocalCumulOptimizers() |
int[] |
getDisjunctionIndices(long index)
Returns the indices of the disjunctions to which an index belongs.
|
long |
getDisjunctionMaxCardinality(int index)
Returns the maximum number of possible active nodes of the node
disjunction of index 'index'. |
long[] |
GetDisjunctionNodeIndices(int index)
Returns the variable indices of the nodes in the disjunction of index
'index'. |
long |
getDisjunctionPenalty(int index)
Returns the penalty of the node disjunction of index 'index'.
|
long |
getFixedCostOfVehicle(int 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. |
long |
getHomogeneousCost(long from_index,
long 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). |
static int |
getKNoDimension()
Constant used to express the "no dimension" index, returned when a
dimension name does not correspond to an actual dimension. |
static int |
getKNoDisjunction()
Constant used to express the "no disjunction" index, returned when a node
does not appear in any disjunction. |
static long |
getKNoPenalty()
Constant used to express a hard constraint instead of a soft penalty.
|
int |
GetMaximumNumberOfActiveVehicles()
Returns the maximum number of active vehicles.
|
SWIGTYPE_p_std__atomicT_bool_t |
GetMutableCPInterrupt()
Returns the atomic<bool> to stop the CP solver.
|
SWIGTYPE_p_std__atomicT_bool_t |
GetMutableCPSatInterrupt()
Returns the atomic<bool> to stop the CP-SAT solver.
|
RoutingDimension |
getMutableDimension(java.lang.String dimension_name)
Returns a dimension from its name.
|
SWIGTYPE_p_operations_research__GlobalDimensionCumulOptimizer |
GetMutableGlobalCumulLPOptimizer(RoutingDimension dimension)
Returns the global/local dimension cumul optimizer for a given dimension,
or nullptr if there is none. |
SWIGTYPE_p_operations_research__GlobalDimensionCumulOptimizer |
GetMutableGlobalCumulMPOptimizer(RoutingDimension dimension) |
SWIGTYPE_p_operations_research__LocalDimensionCumulOptimizer |
GetMutableLocalCumulLPOptimizer(RoutingDimension dimension) |
int |
getNonZeroCostClassesCount()
Ditto, minus the 'always zero', built-in cost class.
|
long |
getNumberOfDecisionsInFirstSolution(RoutingSearchParameters search_parameters)
Returns statistics on first solution search, number of decisions sent to
filters, number of decisions rejected by filters. |
int |
getNumberOfDisjunctions()
Returns the number of node disjunctions in the model.
|
long |
getNumberOfRejectsInFirstSolution(RoutingSearchParameters search_parameters) |
int |
getNumberOfVisitTypes() |
int |
getNumOfSingletonNodes()
Returns the number of non-start/end nodes which do not appear in a
pickup/delivery pair. |
RoutingModel.NodeNeighborsByCostClass |
GetOrCreateNodeNeighborsByCostClass(double neighbors_ratio,
long min_neighbors,
SWIGTYPE_p_double neighbors_ratio_used)
Returns neighbors of all nodes for every cost class.
|
RoutingModel.NodeNeighborsByCostClass |
GetOrCreateNodeNeighborsByCostClass(double neighbors_ratio,
long min_neighbors,
SWIGTYPE_p_double neighbors_ratio_used,
boolean add_vehicle_starts_to_neighbors)
Returns neighbors of all nodes for every cost class.
|
RoutingModel.NodeNeighborsByCostClass |
GetOrCreateNodeNeighborsByCostClass(int num_neighbors)
Returns parameters.num_neighbors neighbors of all nodes for every cost
class. |
RoutingModel.NodeNeighborsByCostClass |
GetOrCreateNodeNeighborsByCostClass(int num_neighbors,
boolean add_vehicle_starts_to_neighbors)
Returns parameters.num_neighbors neighbors of all nodes for every cost
class. |
int[] |
GetPairIndicesOfType(int type) |
PathsMetadata |
GetPathsMetadata() |
int |
getPickupAndDeliveryPolicyOfVehicle(int vehicle) |
SWIGTYPE_p_std__vectorT_operations_research__RoutingModel__PickupDeliveryPosition_t |
GetPickupPositions(long node_index)
Returns the pickup and delivery positions where the node is a pickup.
|
java.lang.String |
getPrimaryConstrainedDimension()
Get the primary constrained dimension, or an empty string if it is unset.
|
SWIGTYPE_p_std__vectorT_absl__flat_hash_setT_int_t_t |
GetRequiredTypeAlternativesWhenAddingType(int type)
Returns the set of requirement alternatives when adding the given type.
|
SWIGTYPE_p_std__vectorT_absl__flat_hash_setT_int_t_t |
GetRequiredTypeAlternativesWhenRemovingType(int type)
Returns the set of requirement alternatives when removing the given type.
|
RoutingModel.ResourceGroup |
GetResourceGroup(int rg_index) |
SWIGTYPE_p_std__vectorT_std__unique_ptrT_operations_research__RoutingModel__ResourceGroup_t_t |
GetResourceGroups() |
int[] |
getSameVehicleIndicesOfIndex(int node)
Returns variable indices of nodes constrained to be on the same route.
|
int[] |
GetSingleNodesOfType(int type) |
SWIGTYPE_p_absl__flat_hash_setT_int_t |
getTemporalTypeIncompatibilitiesOfType(int type) |
SWIGTYPE_p_std__vectorT_operations_research__RoutingDimension_p_t |
GetUnaryDimensions()
Returns dimensions for which all transit evaluators are unary.
|
int |
getVehicleClassesCount()
Returns the number of different vehicle classes in the model.
|
int |
getVehicleClassIndexOfVehicle(long vehicle) |
int |
GetVehicleOfClass(int vehicle_class)
Returns a vehicle of the given vehicle class, and -1 if there are no
vehicles for this class. |
RoutingModel.VehicleTypeContainer |
GetVehicleTypeContainer() |
int |
getVisitType(long index) |
int |
GetVisitTypePolicy(long index) |
boolean |
hasDimension(java.lang.String dimension_name)
Returns true if a dimension exists for a given dimension name.
|
boolean |
HasGlobalCumulOptimizer(RoutingDimension dimension)
Returns whether the given dimension has global/local cumul optimizers.
|
boolean |
hasHardTypeIncompatibilities()
Returns true iff any hard (resp.
|
boolean |
HasLocalCumulOptimizer(RoutingDimension dimension) |
boolean |
HasMandatoryDisjunctions()
Returns true if the model contains mandatory disjunctions (ones with
kNoPenalty as penalty). |
boolean |
HasMaxCardinalityConstrainedDisjunctions()
Returns true if the model contains at least one disjunction which is
constrained by its max_cardinality. |
boolean |
hasSameVehicleTypeRequirements()
Returns true iff any same-route (resp.
|
boolean |
hasTemporalTypeIncompatibilities() |
boolean |
hasTemporalTypeRequirements() |
boolean |
hasVehicleWithCostClassIndex(int cost_class_index)
Returns true iff the model contains a vehicle with the given
cost_class_index. |
void |
ignoreDisjunctionsAlreadyForcedToZero()
SPECIAL: Makes the solver ignore all the disjunctions whose active
variables are all trivially zero (i.e. |
boolean |
IsDelivery(long node_index) |
boolean |
isEnd(long index)
Returns true if 'index' represents the last node of a route.
|
boolean |
isMatchingModel()
Returns true if a vehicle/node matching problem is detected.
|
boolean |
IsPickup(long node_index)
Returns whether the node is a pickup (resp.
|
boolean |
isStart(long index)
Returns true if 'index' represents the first node of a route.
|
boolean |
isVehicleAllowedForIndex(int vehicle,
long index)
Returns true if a vehicle is allowed to visit a given node.
|
boolean |
isVehicleUsed(Assignment assignment,
int vehicle)
Returns true if the route of 'vehicle' is non empty in 'assignment'.
|
boolean |
IsVehicleUsedWhenEmpty(int vehicle) |
DecisionBuilder |
makeGuidedSlackFinalizer(RoutingDimension dimension,
java.util.function.LongUnaryOperator 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. |
DecisionBuilder |
makeSelfDependentDimensionFinalizer(RoutingDimension dimension)
MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a
self-dependent dimension. |
Assignment |
mutablePreAssignment() |
long |
next(Assignment assignment,
long index)
Assignment inspection
Returns the variable index of the node directly after the node corresponding to 'index' in 'assignment'. |
IntVar[] |
nexts()
Returns all next variables of the model, such that Nexts(i) is the next
variable of the node corresponding to i. |
IntVar |
nextVar(long index)
Returns the next variable of the node corresponding to index.
|
int |
nodes()
Sizes and indices
Returns the number of nodes in the model. |
long |
objective_lower_bound()
Returns the current lower bound found by internal solvers during the
search. |
Assignment |
preAssignment()
Returns an assignment used to fix some of the variables of the problem.
In practice, this assignment locks partial routes of the problem. |
Assignment |
readAssignment(java.lang.String 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. |
Assignment |
readAssignmentFromRoutes(long[][] routes,
boolean ignore_inactive_indices)
Restores the routes as the current solution.
|
int |
registerTransitCallback(java.util.function.LongBinaryOperator callback) |
int |
registerTransitCallback(java.util.function.LongBinaryOperator callback,
int sign) |
int |
registerTransitMatrix(long[][] values) |
int |
registerUnaryTransitCallback(java.util.function.LongUnaryOperator callback) |
int |
registerUnaryTransitCallback(java.util.function.LongUnaryOperator callback,
int sign) |
int |
registerUnaryTransitVector(long[] 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. |
IntVar |
ResourceVar(int vehicle,
int resource_group)
Returns the resource variable for the given vehicle index in the given
resource group. |
IntVar[] |
ResourceVars(int resource_group)
Returns vehicle resource variables for a given resource group, such that
ResourceVars(r_g)[v] is the resource variable for vehicle 'v' in resource group 'r_g'. |
Assignment |
restoreAssignment(Assignment solution)
Restores an assignment as a solution in the routing model and returns the
new solution. |
boolean |
routesToAssignment(long[][] routes,
boolean ignore_inactive_indices,
boolean close_routes,
Assignment assignment)
Fills an assignment from a specification of the routes of the
vehicles. |
void |
setAllowedVehiclesForIndex(int[] vehicles,
long index)
Sets the vehicles which can visit a given node.
|
void |
setAmortizedCostFactorsOfAllVehicles(long linear_cost_factor,
long quadratic_cost_factor)
The following methods set the linear and quadratic cost factors of
vehicles (must be positive values). |
void |
setAmortizedCostFactorsOfVehicle(long linear_cost_factor,
long quadratic_cost_factor,
int vehicle)
Sets the linear and quadratic cost factor of the given vehicle.
|
void |
setArcCostEvaluatorOfAllVehicles(int 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. |
void |
setArcCostEvaluatorOfVehicle(int evaluator_index,
int vehicle)
Sets the cost function for a given vehicle route.
|
void |
setAssignmentFromOtherModelAssignment(Assignment target_assignment,
RoutingModel source_model,
Assignment 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_. |
void |
setFirstSolutionEvaluator(java.util.function.LongBinaryOperator evaluator)
Gets/sets the evaluator used during the search.
|
void |
setFixedCostOfAllVehicles(long cost)
Sets the fixed cost of all vehicle routes.
|
void |
setFixedCostOfVehicle(long cost,
int vehicle)
Sets the fixed cost of one vehicle route.
|
void |
SetMaximumNumberOfActiveVehicles(int max_active_vehicles)
Constrains the maximum number of active vehicles, aka the number of
vehicles which do not have an empty route. |
void |
SetPathEnergyCostOfVehicle(java.lang.String force,
java.lang.String distance,
long unit_cost,
int vehicle) |
void |
setPickupAndDeliveryPolicyOfAllVehicles(int policy)
Sets the Pickup and delivery policy of all vehicles.
|
void |
setPickupAndDeliveryPolicyOfVehicle(int policy,
int vehicle) |
void |
setPrimaryConstrainedDimension(java.lang.String dimension_name)
Set the given dimension as "primary constrained".
|
void |
SetVehicleUsedWhenEmpty(boolean is_used,
int vehicle) |
void |
setVisitType(long index,
int type,
int type_policy) |
long |
size()
Returns the number of next variables in the model.
|
Assignment |
solve()
Solves the current routing model; closes the current model.
This is equivalent to calling SolveWithParameters(DefaultRoutingSearchParameters()) or SolveFromAssignmentWithParameters(assignment, DefaultRoutingSearchParameters()). |
Assignment |
solve(Assignment assignment)
Solves the current routing model; closes the current model.
This is equivalent to calling SolveWithParameters(DefaultRoutingSearchParameters()) or SolveFromAssignmentWithParameters(assignment, DefaultRoutingSearchParameters()). |
Assignment |
SolveFromAssignmentsWithParameters(SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t assignments,
RoutingSearchParameters search_parameters)
Same as above but will try all assignments in order as first solutions
until one succeeds. |
Assignment |
SolveFromAssignmentsWithParameters(SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t assignments,
RoutingSearchParameters search_parameters,
SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t solutions)
Same as above but will try all assignments in order as first solutions
until one succeeds. |
Assignment |
solveFromAssignmentWithParameters(Assignment assignment,
RoutingSearchParameters search_parameters)
Same as above, except that if assignment is not null, it will be used as
the initial solution. |
Solver |
solver()
Returns the underlying constraint solver.
|
Assignment |
SolveWithIteratedLocalSearch(RoutingSearchParameters search_parameters)
Solves the current routing model by using an Iterated Local Search
approach. |
Assignment |
solveWithParameters(RoutingSearchParameters search_parameters)
Solves the current routing model with the given parameters.
|
long |
start(int vehicle)
Model inspection.
Returns the variable index of the starting node of a vehicle route. |
int |
status()
Returns the current status of the routing model.
|
static long |
swigRelease(RoutingModel obj) |
SWIGTYPE_p_absl__Duration |
TimeBuffer()
Returns the time buffer to safely return a solution.
|
long |
unperformedPenalty(long var_index)
Get the "unperformed" penalty of a node.
|
long |
unperformedPenaltyOrValue(long default_value,
long 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). |
void |
UpdateTimeLimit(SWIGTYPE_p_absl__Duration time_limit)
Updates the time limit of the search limit.
|
int |
VehicleIndex(long index)
Returns the vehicle of the given start/end index, and -1 if the given
index is not a vehicle start/end. |
IntVar |
VehicleRouteConsideredVar(int vehicle)
Returns the variable specifying whether or not the given vehicle route is
considered for costs and constraints. |
int |
vehicles()
Returns the number of vehicle routes in the model.
|
IntVar |
vehicleVar(long index)
Returns the vehicle variable of the node corresponding to index.
|
IntVar[] |
vehicleVars()
Returns all vehicle variables of the model, such that VehicleVars(i) is
the vehicle variable of the node corresponding to i. |
boolean |
writeAssignment(java.lang.String 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. |
protected transient boolean swigCMemOwn
public static final int ROUTING_NOT_SOLVED
public static final int ROUTING_SUCCESS
public static final int ROUTING_PARTIAL_SUCCESS_LOCAL_OPTIMUM_NOT_REACHED
public static final int ROUTING_FAIL
public static final int ROUTING_FAIL_TIMEOUT
public static final int ROUTING_INVALID
public static final int ROUTING_INFEASIBLE
public static final int ROUTING_OPTIMAL
public static final int PICKUP_AND_DELIVERY_NO_ORDER
public static final int PICKUP_AND_DELIVERY_LIFO
public static final int PICKUP_AND_DELIVERY_FIFO
public static final int kTransitEvaluatorSignUnknown
public static final int kTransitEvaluatorSignPositiveOrZero
public static final int kTransitEvaluatorSignNegativeOrZero
public static final int TYPE_ADDED_TO_VEHICLE
public static final int ADDED_TYPE_REMOVED_FROM_VEHICLE
public static final int TYPE_ON_VEHICLE_UP_TO_VISIT
public static final int TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
public RoutingModel(long cPtr,
boolean cMemoryOwn)
public RoutingModel(RoutingIndexManager index_manager)
public RoutingModel(RoutingIndexManager index_manager, RoutingModelParameters parameters)
public static long getCPtr(RoutingModel obj)
public static long swigRelease(RoutingModel obj)
protected void finalize()
finalize in class java.lang.Objectpublic void delete()
public static long getKNoPenalty()
public static int getKNoDisjunction()
public static int getKNoDimension()
public int registerUnaryTransitVector(long[] values)
public int registerUnaryTransitCallback(java.util.function.LongUnaryOperator callback,
int sign)
public int registerUnaryTransitCallback(java.util.function.LongUnaryOperator callback)
public int registerTransitMatrix(long[][] values)
public int registerTransitCallback(java.util.function.LongBinaryOperator callback,
int sign)
public int registerTransitCallback(java.util.function.LongBinaryOperator callback)
public boolean addDimension(int evaluator_index,
long slack_max,
long capacity,
boolean fix_start_cumul_to_zero,
java.lang.String name)
public boolean addDimensionWithVehicleTransits(int[] evaluator_indices,
long slack_max,
long capacity,
boolean fix_start_cumul_to_zero,
java.lang.String name)
public boolean addDimensionWithVehicleCapacity(int evaluator_index,
long slack_max,
long[] vehicle_capacities,
boolean fix_start_cumul_to_zero,
java.lang.String name)
public boolean addDimensionWithVehicleTransitAndCapacity(int[] evaluator_indices,
long slack_max,
long[] vehicle_capacities,
boolean fix_start_cumul_to_zero,
java.lang.String name)
public IntBoolPair addConstantDimensionWithSlack(long value, long capacity, long slack_max, boolean fix_start_cumul_to_zero, java.lang.String name)
public IntBoolPair addConstantDimension(long value, long capacity, boolean fix_start_cumul_to_zero, java.lang.String name)
public IntBoolPair addVectorDimension(long[] values, long capacity, boolean fix_start_cumul_to_zero, java.lang.String name)
public IntBoolPair addMatrixDimension(long[][] values, long capacity, boolean fix_start_cumul_to_zero, java.lang.String name)
public SWIGTYPE_p_std__vectorT_operations_research__RoutingDimension_p_t GetUnaryDimensions()
public SWIGTYPE_p_std__vectorT_operations_research__RoutingDimension_const_p_t GetDimensionsWithGlobalCumulOptimizers()
public SWIGTYPE_p_std__vectorT_operations_research__RoutingDimension_const_p_t GetDimensionsWithLocalCumulOptimizers()
public boolean HasGlobalCumulOptimizer(RoutingDimension dimension)
public boolean HasLocalCumulOptimizer(RoutingDimension dimension)
public SWIGTYPE_p_operations_research__GlobalDimensionCumulOptimizer GetMutableGlobalCumulLPOptimizer(RoutingDimension dimension)
public SWIGTYPE_p_operations_research__GlobalDimensionCumulOptimizer GetMutableGlobalCumulMPOptimizer(RoutingDimension dimension)
public SWIGTYPE_p_operations_research__LocalDimensionCumulOptimizer GetMutableLocalCumulLPOptimizer(RoutingDimension dimension)
public boolean hasDimension(java.lang.String dimension_name)
public RoutingDimension getDimensionOrDie(java.lang.String dimension_name)
public RoutingDimension getMutableDimension(java.lang.String dimension_name)
public void setPrimaryConstrainedDimension(java.lang.String dimension_name)
public java.lang.String getPrimaryConstrainedDimension()
public RoutingModel.ResourceGroup AddResourceGroup()
public SWIGTYPE_p_std__vectorT_std__unique_ptrT_operations_research__RoutingModel__ResourceGroup_t_t GetResourceGroups()
public RoutingModel.ResourceGroup GetResourceGroup(int rg_index)
public int[] GetDimensionResourceGroupIndices(RoutingDimension dimension)
public int GetDimensionResourceGroupIndex(RoutingDimension dimension)
public int addDisjunction(long[] indices,
long penalty,
long max_cardinality)
public int addDisjunction(long[] indices,
long penalty)
public int addDisjunction(long[] indices)
public int[] getDisjunctionIndices(long index)
public long[] GetDisjunctionNodeIndices(int index)
public long getDisjunctionPenalty(int index)
public long getDisjunctionMaxCardinality(int index)
public int getNumberOfDisjunctions()
public boolean HasMandatoryDisjunctions()
public boolean HasMaxCardinalityConstrainedDisjunctions()
public void ignoreDisjunctionsAlreadyForcedToZero()
public void addSoftSameVehicleConstraint(long[] indices,
long cost)
public void setAllowedVehiclesForIndex(int[] vehicles,
long index)
public boolean isVehicleAllowedForIndex(int vehicle,
long index)
public void addPickupAndDelivery(long pickup,
long delivery)
public void addPickupAndDeliverySets(int pickup_disjunction,
int delivery_disjunction)
public SWIGTYPE_p_std__vectorT_operations_research__RoutingModel__PickupDeliveryPosition_t GetPickupPositions(long node_index)
public SWIGTYPE_p_std__vectorT_operations_research__RoutingModel__PickupDeliveryPosition_t GetDeliveryPositions(long node_index)
public boolean IsPickup(long node_index)
public boolean IsDelivery(long node_index)
public void setPickupAndDeliveryPolicyOfAllVehicles(int policy)
public void setPickupAndDeliveryPolicyOfVehicle(int policy,
int vehicle)
public int getPickupAndDeliveryPolicyOfVehicle(int vehicle)
public int getNumOfSingletonNodes()
public void setVisitType(long index,
int type,
int type_policy)
public int getVisitType(long index)
public int[] GetSingleNodesOfType(int type)
public int[] GetPairIndicesOfType(int type)
public int GetVisitTypePolicy(long index)
public void closeVisitTypes()
public int getNumberOfVisitTypes()
public void addHardTypeIncompatibility(int type1,
int type2)
public void addTemporalTypeIncompatibility(int type1,
int type2)
public SWIGTYPE_p_absl__flat_hash_setT_int_t getTemporalTypeIncompatibilitiesOfType(int type)
public boolean hasHardTypeIncompatibilities()
public boolean hasTemporalTypeIncompatibilities()
public void addRequiredTypeAlternativesWhenAddingType(int dependent_type,
SWIGTYPE_p_absl__flat_hash_setT_int_t required_type_alternatives)
public void addRequiredTypeAlternativesWhenRemovingType(int dependent_type,
SWIGTYPE_p_absl__flat_hash_setT_int_t required_type_alternatives)
public SWIGTYPE_p_std__vectorT_absl__flat_hash_setT_int_t_t GetRequiredTypeAlternativesWhenAddingType(int type)
public SWIGTYPE_p_std__vectorT_absl__flat_hash_setT_int_t_t GetRequiredTypeAlternativesWhenRemovingType(int type)
public boolean hasSameVehicleTypeRequirements()
public boolean hasTemporalTypeRequirements()
public long unperformedPenalty(long var_index)
public long unperformedPenaltyOrValue(long default_value,
long var_index)
public long getDepot()
public void SetMaximumNumberOfActiveVehicles(int max_active_vehicles)
public int GetMaximumNumberOfActiveVehicles()
public void setArcCostEvaluatorOfAllVehicles(int evaluator_index)
public void setArcCostEvaluatorOfVehicle(int evaluator_index,
int vehicle)
public void setFixedCostOfAllVehicles(long cost)
public void setFixedCostOfVehicle(long cost,
int vehicle)
public long getFixedCostOfVehicle(int vehicle)
public void SetPathEnergyCostOfVehicle(java.lang.String force,
java.lang.String distance,
long unit_cost,
int vehicle)
public void setAmortizedCostFactorsOfAllVehicles(long linear_cost_factor,
long quadratic_cost_factor)
public void setAmortizedCostFactorsOfVehicle(long linear_cost_factor,
long quadratic_cost_factor,
int vehicle)
public long[] getAmortizedLinearCostFactorOfVehicles()
public long[] getAmortizedQuadraticCostFactorOfVehicles()
public void SetVehicleUsedWhenEmpty(boolean is_used,
int vehicle)
public boolean IsVehicleUsedWhenEmpty(int vehicle)
public void setFirstSolutionEvaluator(java.util.function.LongBinaryOperator evaluator)
public void addLocalSearchOperator(LocalSearchOperator ls_operator)
public void addSearchMonitor(SearchMonitor monitor)
public void addAtSolutionCallback(java.lang.Runnable callback,
boolean track_unchecked_neighbors)
public void addAtSolutionCallback(java.lang.Runnable callback)
public void addVariableMinimizedByFinalizer(IntVar var)
public void addVariableMaximizedByFinalizer(IntVar var)
public void AddWeightedVariableMinimizedByFinalizer(IntVar var, long cost)
public void AddWeightedVariableMaximizedByFinalizer(IntVar var, long cost)
public void addVariableTargetToFinalizer(IntVar var, long target)
public void AddWeightedVariableTargetToFinalizer(IntVar var, long target, long cost)
public void closeModel()
public void closeModelWithParameters(RoutingSearchParameters search_parameters)
public Assignment solve(Assignment assignment)
public Assignment solve()
public Assignment solveWithParameters(RoutingSearchParameters search_parameters)
public Assignment solveFromAssignmentWithParameters(Assignment assignment, RoutingSearchParameters search_parameters)
public Assignment FastSolveFromAssignmentWithParameters(Assignment assignment, RoutingSearchParameters search_parameters, boolean check_solution_in_cp, SWIGTYPE_p_absl__flat_hash_setT_operations_research__IntVar_p_t touched)
public Assignment FastSolveFromAssignmentWithParameters(Assignment assignment, RoutingSearchParameters search_parameters, boolean check_solution_in_cp)
public Assignment SolveFromAssignmentsWithParameters(SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t assignments, RoutingSearchParameters search_parameters, SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t solutions)
public Assignment SolveFromAssignmentsWithParameters(SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t assignments, RoutingSearchParameters search_parameters)
public Assignment SolveWithIteratedLocalSearch(RoutingSearchParameters search_parameters)
public void setAssignmentFromOtherModelAssignment(Assignment target_assignment, RoutingModel source_model, Assignment source_assignment)
public long computeLowerBound()
public long objective_lower_bound()
public int status()
public boolean enable_deep_serialization()
public IntVar applyLocks(long[] locks)
public boolean applyLocksToAllVehicles(long[][] locks,
boolean close_routes)
public Assignment preAssignment()
public Assignment mutablePreAssignment()
public boolean writeAssignment(java.lang.String file_name)
public Assignment readAssignment(java.lang.String file_name)
public Assignment restoreAssignment(Assignment solution)
public Assignment readAssignmentFromRoutes(long[][] routes, boolean ignore_inactive_indices)
public boolean routesToAssignment(long[][] routes,
boolean ignore_inactive_indices,
boolean close_routes,
Assignment assignment)
public void assignmentToRoutes(Assignment assignment, long[][] routes)
public Assignment compactAssignment(Assignment assignment)
public Assignment compactAndCheckAssignment(Assignment assignment)
public void addToAssignment(IntVar var)
public void addIntervalToAssignment(IntervalVar interval)
public RoutingModel.NodeNeighborsByCostClass GetOrCreateNodeNeighborsByCostClass(double neighbors_ratio, long min_neighbors, SWIGTYPE_p_double neighbors_ratio_used, boolean add_vehicle_starts_to_neighbors)
public RoutingModel.NodeNeighborsByCostClass GetOrCreateNodeNeighborsByCostClass(double neighbors_ratio, long min_neighbors, SWIGTYPE_p_double neighbors_ratio_used)
public RoutingModel.NodeNeighborsByCostClass GetOrCreateNodeNeighborsByCostClass(int num_neighbors, boolean add_vehicle_starts_to_neighbors)
public RoutingModel.NodeNeighborsByCostClass GetOrCreateNodeNeighborsByCostClass(int num_neighbors)
public void addLocalSearchFilter(LocalSearchFilter filter)
public long start(int vehicle)
public long end(int vehicle)
public boolean isStart(long index)
public boolean isEnd(long index)
public int VehicleIndex(long index)
public long next(Assignment assignment, long index)
public boolean isVehicleUsed(Assignment assignment, int vehicle)
public IntVar[] nexts()
public IntVar[] vehicleVars()
public IntVar[] ResourceVars(int resource_group)
public IntVar nextVar(long index)
public IntVar activeVar(long index)
public IntVar activeVehicleVar(int vehicle)
public IntVar VehicleRouteConsideredVar(int vehicle)
public IntVar vehicleVar(long index)
public IntVar ResourceVar(int vehicle, int resource_group)
public IntVar costVar()
public long getArcCostForVehicle(long from_index,
long to_index,
long vehicle)
public boolean costsAreHomogeneousAcrossVehicles()
public long getHomogeneousCost(long from_index,
long to_index)
public long getArcCostForFirstSolution(long from_index,
long to_index)
public long getArcCostForClass(long from_index,
long to_index,
long cost_class_index)
public int getCostClassIndexOfVehicle(long vehicle)
public boolean hasVehicleWithCostClassIndex(int cost_class_index)
public int getCostClassesCount()
public int getNonZeroCostClassesCount()
public int getVehicleClassIndexOfVehicle(long vehicle)
public int GetVehicleOfClass(int vehicle_class)
public int getVehicleClassesCount()
public int[] getSameVehicleIndicesOfIndex(int node)
public RoutingModel.VehicleTypeContainer GetVehicleTypeContainer()
public boolean arcIsMoreConstrainedThanArc(long from,
long to1,
long to2)
public java.lang.String debugOutputAssignment(Assignment solution_assignment, java.lang.String dimension_to_print)
public boolean CheckIfAssignmentIsFeasible(Assignment assignment, boolean call_at_solution_monitors)
public Solver solver()
public boolean checkLimit(SWIGTYPE_p_absl__Duration offset)
public boolean checkLimit()
public void UpdateTimeLimit(SWIGTYPE_p_absl__Duration time_limit)
public SWIGTYPE_p_absl__Duration TimeBuffer()
public SWIGTYPE_p_std__atomicT_bool_t GetMutableCPSatInterrupt()
public SWIGTYPE_p_std__atomicT_bool_t GetMutableCPInterrupt()
public void CancelSearch()
public int nodes()
public int vehicles()
public long size()
public long getNumberOfDecisionsInFirstSolution(RoutingSearchParameters search_parameters)
public long getNumberOfRejectsInFirstSolution(RoutingSearchParameters search_parameters)
public boolean isMatchingModel()
public boolean AreRoutesInterdependent(SWIGTYPE_p_operations_research__RoutingSearchParameters parameters)
public DecisionBuilder makeGuidedSlackFinalizer(RoutingDimension dimension, java.util.function.LongUnaryOperator initializer)
public DecisionBuilder makeSelfDependentDimensionFinalizer(RoutingDimension dimension)
public PathsMetadata GetPathsMetadata()
Copyright © 2024. All rights reserved.