Java Reference

Java Reference

RoutingModel.java
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * This file was automatically generated by SWIG (http://www.swig.org).
3  * Version 4.0.1
4  *
5  * Do not make changes to this file unless you know what you are doing--modify
6  * the SWIG interface file instead.
7  * ----------------------------------------------------------------------------- */
8 
9 package com.google.ortools.constraintsolver;
10 
11 // Used to wrap RoutingTransitCallback2
12 // see https://docs.oracle.com/javase/8/docs/api/java/util/function/LongBinaryOperator.html
13 import java.util.function.LongBinaryOperator;
14 // Used to wrap RoutingTransitCallback1
15 // see https://docs.oracle.com/javase/8/docs/api/java/util/function/LongUnaryOperator.html
16 import java.util.function.LongUnaryOperator;
17 
18 public class RoutingModel {
19  private transient long swigCPtr;
20  protected transient boolean swigCMemOwn;
21 
22  protected RoutingModel(long cPtr, boolean cMemoryOwn) {
23  swigCMemOwn = cMemoryOwn;
24  swigCPtr = cPtr;
25  }
26 
27  protected static long getCPtr(RoutingModel obj) {
28  return (obj == null) ? 0 : obj.swigCPtr;
29  }
30 
31  @SuppressWarnings("deprecation")
32  protected void finalize() {
33  delete();
34  }
35 
36  public synchronized void delete() {
37  if (swigCPtr != 0) {
38  if (swigCMemOwn) {
39  swigCMemOwn = false;
40  mainJNI.delete_RoutingModel(swigCPtr);
41  }
42  swigCPtr = 0;
43  }
44  }
45 
49  static public class VehicleTypeContainer {
50  private transient long swigCPtr;
51  protected transient boolean swigCMemOwn;
52 
53  protected VehicleTypeContainer(long cPtr, boolean cMemoryOwn) {
54  swigCMemOwn = cMemoryOwn;
55  swigCPtr = cPtr;
56  }
57 
58  protected static long getCPtr(VehicleTypeContainer obj) {
59  return (obj == null) ? 0 : obj.swigCPtr;
60  }
61 
62  @SuppressWarnings("deprecation")
63  protected void finalize() {
64  delete();
65  }
66 
67  public synchronized void delete() {
68  if (swigCPtr != 0) {
69  if (swigCMemOwn) {
70  swigCMemOwn = false;
71  mainJNI.delete_RoutingModel_VehicleTypeContainer(swigCPtr);
72  }
73  swigCPtr = 0;
74  }
75  }
76 
77  static public class VehicleClassEntry {
78  private transient long swigCPtr;
79  protected transient boolean swigCMemOwn;
80 
81  protected VehicleClassEntry(long cPtr, boolean cMemoryOwn) {
82  swigCMemOwn = cMemoryOwn;
83  swigCPtr = cPtr;
84  }
85 
86  protected static long getCPtr(VehicleClassEntry obj) {
87  return (obj == null) ? 0 : obj.swigCPtr;
88  }
89 
90  @SuppressWarnings("deprecation")
91  protected void finalize() {
92  delete();
93  }
94 
95  public synchronized void delete() {
96  if (swigCPtr != 0) {
97  if (swigCMemOwn) {
98  swigCMemOwn = false;
99  mainJNI.delete_RoutingModel_VehicleTypeContainer_VehicleClassEntry(swigCPtr);
100  }
101  swigCPtr = 0;
102  }
103  }
104 
105  public void setVehicle_class(int value) {
106  mainJNI.RoutingModel_VehicleTypeContainer_VehicleClassEntry_vehicle_class_set(swigCPtr, this, value);
107  }
108 
109  public int getVehicle_class() {
110  return mainJNI.RoutingModel_VehicleTypeContainer_VehicleClassEntry_vehicle_class_get(swigCPtr, this);
111  }
112 
113  public void setFixed_cost(long value) {
114  mainJNI.RoutingModel_VehicleTypeContainer_VehicleClassEntry_fixed_cost_set(swigCPtr, this, value);
115  }
116 
117  public long getFixed_cost() {
118  return mainJNI.RoutingModel_VehicleTypeContainer_VehicleClassEntry_fixed_cost_get(swigCPtr, this);
119  }
120 
121  public VehicleClassEntry() {
122  this(mainJNI.new_RoutingModel_VehicleTypeContainer_VehicleClassEntry(), true);
123  }
124 
125  }
126 
127  public int NumTypes() {
128  return mainJNI.RoutingModel_VehicleTypeContainer_NumTypes(swigCPtr, this);
129  }
130 
131  public int Type(int vehicle) {
132  return mainJNI.RoutingModel_VehicleTypeContainer_Type(swigCPtr, this, vehicle);
133  }
134 
135  public void setType_index_of_vehicle(int[] value) {
136  mainJNI.RoutingModel_VehicleTypeContainer_type_index_of_vehicle_set(swigCPtr, this, value);
137  }
138 
139  public int[] getType_index_of_vehicle() {
140  return mainJNI.RoutingModel_VehicleTypeContainer_type_index_of_vehicle_get(swigCPtr, this);
141  }
142 
143  public void setSorted_vehicle_classes_per_type(SWIGTYPE_p_std__vectorT_std__setT_operations_research__RoutingModel__VehicleTypeContainer__VehicleClassEntry_t_t value) {
144  mainJNI.RoutingModel_VehicleTypeContainer_sorted_vehicle_classes_per_type_set(swigCPtr, this, SWIGTYPE_p_std__vectorT_std__setT_operations_research__RoutingModel__VehicleTypeContainer__VehicleClassEntry_t_t.getCPtr(value));
145  }
146 
147  public SWIGTYPE_p_std__vectorT_std__setT_operations_research__RoutingModel__VehicleTypeContainer__VehicleClassEntry_t_t getSorted_vehicle_classes_per_type() {
148  long cPtr = mainJNI.RoutingModel_VehicleTypeContainer_sorted_vehicle_classes_per_type_get(swigCPtr, this);
149  return (cPtr == 0) ? null : new SWIGTYPE_p_std__vectorT_std__setT_operations_research__RoutingModel__VehicleTypeContainer__VehicleClassEntry_t_t(cPtr, false);
150  }
151 
152  public void setVehicles_per_vehicle_class(SWIGTYPE_p_std__vectorT_std__dequeT_int_t_t value) {
153  mainJNI.RoutingModel_VehicleTypeContainer_vehicles_per_vehicle_class_set(swigCPtr, this, SWIGTYPE_p_std__vectorT_std__dequeT_int_t_t.getCPtr(value));
154  }
155 
156  public SWIGTYPE_p_std__vectorT_std__dequeT_int_t_t getVehicles_per_vehicle_class() {
157  return new SWIGTYPE_p_std__vectorT_std__dequeT_int_t_t(mainJNI.RoutingModel_VehicleTypeContainer_vehicles_per_vehicle_class_get(swigCPtr, this), true);
158  }
159 
161  this(mainJNI.new_RoutingModel_VehicleTypeContainer(), true);
162  }
163 
164  }
165 
169  public static long getKNoPenalty() {
170  return mainJNI.RoutingModel_kNoPenalty_get();
171  }
172 
176  public static int getKNoDisjunction() {
177  return mainJNI.RoutingModel_kNoDisjunction_get();
178 }
179 
183  public static int getKNoDimension() {
184  return mainJNI.RoutingModel_kNoDimension_get();
185 }
186 
190  public RoutingModel(RoutingIndexManager index_manager) {
191  this(mainJNI.new_RoutingModel__SWIG_0(RoutingIndexManager.getCPtr(index_manager), index_manager), true);
192  }
193 
195  this(mainJNI.new_RoutingModel__SWIG_1(RoutingIndexManager.getCPtr(index_manager), index_manager, parameters.toByteArray()), true);
196  }
197 
201  public int registerUnaryTransitVector(long[] values) {
202  return mainJNI.RoutingModel_registerUnaryTransitVector(swigCPtr, this, values);
203  }
204 
205  public int registerUnaryTransitCallback(LongUnaryOperator callback) {
206  return mainJNI.RoutingModel_registerUnaryTransitCallback(swigCPtr, this, callback);
207  }
208 
209  public int registerPositiveUnaryTransitCallback(LongUnaryOperator callback) {
210  return mainJNI.RoutingModel_registerPositiveUnaryTransitCallback(swigCPtr, this, callback);
211  }
212 
213  public int registerTransitMatrix(long[][] values) {
214  return mainJNI.RoutingModel_registerTransitMatrix(swigCPtr, this, values);
215  }
216 
217  public int registerTransitCallback(LongBinaryOperator callback) {
218  return mainJNI.RoutingModel_registerTransitCallback(swigCPtr, this, callback);
219  }
220 
221  public int registerPositiveTransitCallback(LongBinaryOperator callback) {
222  return mainJNI.RoutingModel_registerPositiveTransitCallback(swigCPtr, this, callback);
223  }
224 
228  public boolean addDimension(int evaluator_index, long slack_max, long capacity, boolean fix_start_cumul_to_zero, String name) {
229  return mainJNI.RoutingModel_addDimension(swigCPtr, this, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name);
230  }
231 
232  public boolean addDimensionWithVehicleTransits(int[] evaluator_indices, long slack_max, long capacity, boolean fix_start_cumul_to_zero, String name) {
233  return mainJNI.RoutingModel_addDimensionWithVehicleTransits(swigCPtr, this, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name);
234  }
235 
236  public boolean addDimensionWithVehicleCapacity(int evaluator_index, long slack_max, long[] vehicle_capacities, boolean fix_start_cumul_to_zero, String name) {
237  return mainJNI.RoutingModel_addDimensionWithVehicleCapacity(swigCPtr, this, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name);
238  }
239 
240  public boolean addDimensionWithVehicleTransitAndCapacity(int[] evaluator_indices, long slack_max, long[] vehicle_capacities, boolean fix_start_cumul_to_zero, String name) {
241  return mainJNI.RoutingModel_addDimensionWithVehicleTransitAndCapacity(swigCPtr, this, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name);
242  }
243 
247  public IntBoolPair addConstantDimensionWithSlack(long value, long capacity, long slack_max, boolean fix_start_cumul_to_zero, String name) {
248  return new IntBoolPair(mainJNI.RoutingModel_addConstantDimensionWithSlack(swigCPtr, this, value, capacity, slack_max, fix_start_cumul_to_zero, name), true);
249  }
250 
251  public IntBoolPair addConstantDimension(long value, long capacity, boolean fix_start_cumul_to_zero, String name) {
252  return new IntBoolPair(mainJNI.RoutingModel_addConstantDimension(swigCPtr, this, value, capacity, fix_start_cumul_to_zero, name), true);
253  }
254 
258  public IntBoolPair addVectorDimension(long[] values, long capacity, boolean fix_start_cumul_to_zero, String name) {
259  return new IntBoolPair(mainJNI.RoutingModel_addVectorDimension(swigCPtr, this, values, capacity, fix_start_cumul_to_zero, name), true);
260  }
261 
265  public IntBoolPair addMatrixDimension(long[][] values, long capacity, boolean fix_start_cumul_to_zero, String name) {
266  return new IntBoolPair(mainJNI.RoutingModel_addMatrixDimension(swigCPtr, this, values, capacity, fix_start_cumul_to_zero, name), true);
267  }
268 
272  public Constraint MakePathSpansAndTotalSlacks(RoutingDimension dimension, IntVar[] spans, IntVar[] total_slacks) {
273  long cPtr = mainJNI.RoutingModel_MakePathSpansAndTotalSlacks(swigCPtr, this, RoutingDimension.getCPtr(dimension), dimension, spans, total_slacks);
274  return (cPtr == 0) ? null : new Constraint(cPtr, false);
275  }
276 
277  public SWIGTYPE_p_std__vectorT_std__unique_ptrT_operations_research__GlobalDimensionCumulOptimizer_t_t GetGlobalDimensionCumulMPOptimizers() {
278  return new SWIGTYPE_p_std__vectorT_std__unique_ptrT_operations_research__GlobalDimensionCumulOptimizer_t_t(mainJNI.RoutingModel_GetGlobalDimensionCumulMPOptimizers(swigCPtr, this), false);
279  }
280 
281  public SWIGTYPE_p_operations_research__GlobalDimensionCumulOptimizer GetMutableGlobalCumulMPOptimizer(RoutingDimension dimension) {
282  long cPtr = mainJNI.RoutingModel_GetMutableGlobalCumulMPOptimizer(swigCPtr, this, RoutingDimension.getCPtr(dimension), dimension);
283  return (cPtr == 0) ? null : new SWIGTYPE_p_operations_research__GlobalDimensionCumulOptimizer(cPtr, false);
284  }
285 
289  public boolean hasDimension(String dimension_name) {
290  return mainJNI.RoutingModel_hasDimension(swigCPtr, this, dimension_name);
291  }
292 
296  public RoutingDimension getDimensionOrDie(String dimension_name) {
297  return new RoutingDimension(mainJNI.RoutingModel_getDimensionOrDie(swigCPtr, this, dimension_name), false);
298  }
299 
303  public RoutingDimension getMutableDimension(String dimension_name) {
304  long cPtr = mainJNI.RoutingModel_getMutableDimension(swigCPtr, this, dimension_name);
305  return (cPtr == 0) ? null : new RoutingDimension(cPtr, false);
306  }
307 
311  public void setPrimaryConstrainedDimension(String dimension_name) {
312  mainJNI.RoutingModel_setPrimaryConstrainedDimension(swigCPtr, this, dimension_name);
313  }
314 
319  return mainJNI.RoutingModel_getPrimaryConstrainedDimension(swigCPtr, this);
320  }
321 
326  return mainJNI.RoutingModel_GetDimensionResourceGroupIndices(swigCPtr, this, RoutingDimension.getCPtr(dimension), dimension);
327 }
328 
332  public int addDisjunction(long[] indices, long penalty, long max_cardinality) {
333  return mainJNI.RoutingModel_addDisjunction__SWIG_0(swigCPtr, this, indices, penalty, max_cardinality);
334 }
335 
339  public int addDisjunction(long[] indices, long penalty) {
340  return mainJNI.RoutingModel_addDisjunction__SWIG_1(swigCPtr, this, indices, penalty);
341 }
342 
346  public int addDisjunction(long[] indices) {
347  return mainJNI.RoutingModel_addDisjunction__SWIG_2(swigCPtr, this, indices);
348 }
349 
353  public int[] getDisjunctionIndices(long index) {
354  return mainJNI.RoutingModel_getDisjunctionIndices(swigCPtr, this, index);
355 }
356 
360  public long[] GetDisjunctionNodeIndices(int index) {
361  return mainJNI.RoutingModel_GetDisjunctionNodeIndices(swigCPtr, this, index);
362 }
363 
367  public long getDisjunctionPenalty(int index) {
368  return mainJNI.RoutingModel_getDisjunctionPenalty(swigCPtr, this, index);
369  }
370 
374  public long getDisjunctionMaxCardinality(int index) {
375  return mainJNI.RoutingModel_getDisjunctionMaxCardinality(swigCPtr, this, index);
376  }
377 
381  public int getNumberOfDisjunctions() {
382  return mainJNI.RoutingModel_getNumberOfDisjunctions(swigCPtr, this);
383  }
384 
389  mainJNI.RoutingModel_ignoreDisjunctionsAlreadyForcedToZero(swigCPtr, this);
390  }
391 
395  public void addSoftSameVehicleConstraint(long[] indices, long cost) {
396  mainJNI.RoutingModel_addSoftSameVehicleConstraint(swigCPtr, this, indices, cost);
397  }
398 
402  public void setAllowedVehiclesForIndex(int[] vehicles, long index) {
403  mainJNI.RoutingModel_setAllowedVehiclesForIndex(swigCPtr, this, vehicles, index);
404  }
405 
409  public boolean isVehicleAllowedForIndex(int vehicle, long index) {
410  return mainJNI.RoutingModel_isVehicleAllowedForIndex(swigCPtr, this, vehicle, index);
411  }
412 
416  public void addPickupAndDelivery(long pickup, long delivery) {
417  mainJNI.RoutingModel_addPickupAndDelivery(swigCPtr, this, pickup, delivery);
418  }
419 
423  public void addPickupAndDeliverySets(int pickup_disjunction, int delivery_disjunction) {
424  mainJNI.RoutingModel_addPickupAndDeliverySets(swigCPtr, this, pickup_disjunction, delivery_disjunction);
425  }
426 
430  public void setPickupAndDeliveryPolicyOfAllVehicles(int policy) {
431  mainJNI.RoutingModel_setPickupAndDeliveryPolicyOfAllVehicles(swigCPtr, this, policy);
432  }
433 
434  public void setPickupAndDeliveryPolicyOfVehicle(int policy, int vehicle) {
435  mainJNI.RoutingModel_setPickupAndDeliveryPolicyOfVehicle(swigCPtr, this, policy, vehicle);
436  }
437 
438  public int getPickupAndDeliveryPolicyOfVehicle(int vehicle) {
439  return mainJNI.RoutingModel_getPickupAndDeliveryPolicyOfVehicle(swigCPtr, this, vehicle);
440  }
441 
445  public int getNumOfSingletonNodes() {
446  return mainJNI.RoutingModel_getNumOfSingletonNodes(swigCPtr, this);
447  }
448 
449  public void setVisitType(long index, int type, int type_policy) {
450  mainJNI.RoutingModel_setVisitType(swigCPtr, this, index, type, type_policy);
451  }
452 
453  public int getVisitType(long index) {
454  return mainJNI.RoutingModel_getVisitType(swigCPtr, this, index);
455  }
456 
457  public int[] GetSingleNodesOfType(int type) {
458  return mainJNI.RoutingModel_GetSingleNodesOfType(swigCPtr, this, type);
459 }
460 
461  public int[] GetPairIndicesOfType(int type) {
462  return mainJNI.RoutingModel_GetPairIndicesOfType(swigCPtr, this, type);
463 }
464 
465  public int GetVisitTypePolicy(long index) {
466  return mainJNI.RoutingModel_GetVisitTypePolicy(swigCPtr, this, index);
467  }
468 
472  public void closeVisitTypes() {
473  mainJNI.RoutingModel_closeVisitTypes(swigCPtr, this);
474  }
475 
476  public int getNumberOfVisitTypes() {
477  return mainJNI.RoutingModel_getNumberOfVisitTypes(swigCPtr, this);
478  }
479 
483  public void addHardTypeIncompatibility(int type1, int type2) {
484  mainJNI.RoutingModel_addHardTypeIncompatibility(swigCPtr, this, type1, type2);
485  }
486 
487  public void addTemporalTypeIncompatibility(int type1, int type2) {
488  mainJNI.RoutingModel_addTemporalTypeIncompatibility(swigCPtr, this, type1, type2);
489  }
490 
491  public SWIGTYPE_p_absl__flat_hash_setT_int_t getTemporalTypeIncompatibilitiesOfType(int type) {
492  return new SWIGTYPE_p_absl__flat_hash_setT_int_t(mainJNI.RoutingModel_getTemporalTypeIncompatibilitiesOfType(swigCPtr, this, type), false);
493  }
494 
498  public boolean hasHardTypeIncompatibilities() {
499  return mainJNI.RoutingModel_hasHardTypeIncompatibilities(swigCPtr, this);
500  }
501 
503  return mainJNI.RoutingModel_hasTemporalTypeIncompatibilities(swigCPtr, this);
504  }
505 
509  public void addRequiredTypeAlternativesWhenAddingType(int dependent_type, SWIGTYPE_p_absl__flat_hash_setT_int_t required_type_alternatives) {
510  mainJNI.RoutingModel_addRequiredTypeAlternativesWhenAddingType(swigCPtr, this, dependent_type, SWIGTYPE_p_absl__flat_hash_setT_int_t.getCPtr(required_type_alternatives));
511  }
512 
516  public void addRequiredTypeAlternativesWhenRemovingType(int dependent_type, SWIGTYPE_p_absl__flat_hash_setT_int_t required_type_alternatives) {
517  mainJNI.RoutingModel_addRequiredTypeAlternativesWhenRemovingType(swigCPtr, this, dependent_type, SWIGTYPE_p_absl__flat_hash_setT_int_t.getCPtr(required_type_alternatives));
518  }
519 
523  public SWIGTYPE_p_std__vectorT_absl__flat_hash_setT_int_t_t GetRequiredTypeAlternativesWhenAddingType(int type) {
524  return new SWIGTYPE_p_std__vectorT_absl__flat_hash_setT_int_t_t(mainJNI.RoutingModel_GetRequiredTypeAlternativesWhenAddingType(swigCPtr, this, type), false);
525  }
526 
530  public SWIGTYPE_p_std__vectorT_absl__flat_hash_setT_int_t_t GetRequiredTypeAlternativesWhenRemovingType(int type) {
531  return new SWIGTYPE_p_std__vectorT_absl__flat_hash_setT_int_t_t(mainJNI.RoutingModel_GetRequiredTypeAlternativesWhenRemovingType(swigCPtr, this, type), false);
532  }
533 
538  return mainJNI.RoutingModel_hasSameVehicleTypeRequirements(swigCPtr, this);
539  }
540 
541  public boolean hasTemporalTypeRequirements() {
542  return mainJNI.RoutingModel_hasTemporalTypeRequirements(swigCPtr, this);
543  }
544 
548  public long unperformedPenalty(long var_index) {
549  return mainJNI.RoutingModel_unperformedPenalty(swigCPtr, this, var_index);
550  }
551 
555  public long unperformedPenaltyOrValue(long default_value, long var_index) {
556  return mainJNI.RoutingModel_unperformedPenaltyOrValue(swigCPtr, this, default_value, var_index);
557  }
558 
562  public long getDepot() {
563  return mainJNI.RoutingModel_getDepot(swigCPtr, this);
564  }
565 
569  public void SetMaximumNumberOfActiveVehicles(int max_active_vehicles) {
570  mainJNI.RoutingModel_SetMaximumNumberOfActiveVehicles(swigCPtr, this, max_active_vehicles);
571  }
572 
577  return mainJNI.RoutingModel_GetMaximumNumberOfActiveVehicles(swigCPtr, this);
578  }
579 
583  public void setArcCostEvaluatorOfAllVehicles(int evaluator_index) {
584  mainJNI.RoutingModel_setArcCostEvaluatorOfAllVehicles(swigCPtr, this, evaluator_index);
585  }
586 
590  public void setArcCostEvaluatorOfVehicle(int evaluator_index, int vehicle) {
591  mainJNI.RoutingModel_setArcCostEvaluatorOfVehicle(swigCPtr, this, evaluator_index, vehicle);
592  }
593 
597  public void setFixedCostOfAllVehicles(long cost) {
598  mainJNI.RoutingModel_setFixedCostOfAllVehicles(swigCPtr, this, cost);
599  }
600 
604  public void setFixedCostOfVehicle(long cost, int vehicle) {
605  mainJNI.RoutingModel_setFixedCostOfVehicle(swigCPtr, this, cost, vehicle);
606  }
607 
611  public long getFixedCostOfVehicle(int vehicle) {
612  return mainJNI.RoutingModel_getFixedCostOfVehicle(swigCPtr, this, vehicle);
613  }
614 
618  public void setAmortizedCostFactorsOfAllVehicles(long linear_cost_factor, long quadratic_cost_factor) {
619  mainJNI.RoutingModel_setAmortizedCostFactorsOfAllVehicles(swigCPtr, this, linear_cost_factor, quadratic_cost_factor);
620  }
621 
625  public void setAmortizedCostFactorsOfVehicle(long linear_cost_factor, long quadratic_cost_factor, int vehicle) {
626  mainJNI.RoutingModel_setAmortizedCostFactorsOfVehicle(swigCPtr, this, linear_cost_factor, quadratic_cost_factor, vehicle);
627  }
628 
630  return mainJNI.RoutingModel_getAmortizedLinearCostFactorOfVehicles(swigCPtr, this);
631 }
632 
634  return mainJNI.RoutingModel_getAmortizedQuadraticCostFactorOfVehicles(swigCPtr, this);
635 }
636 
637  public void ConsiderEmptyRouteCostsForVehicle(boolean consider_costs, int vehicle) {
638  mainJNI.RoutingModel_ConsiderEmptyRouteCostsForVehicle(swigCPtr, this, consider_costs, vehicle);
639  }
640 
641  public boolean AreEmptyRouteCostsConsideredForVehicle(int vehicle) {
642  return mainJNI.RoutingModel_AreEmptyRouteCostsConsideredForVehicle(swigCPtr, this, vehicle);
643  }
644 
648  public void setFirstSolutionEvaluator(LongBinaryOperator evaluator) {
649  mainJNI.RoutingModel_setFirstSolutionEvaluator(swigCPtr, this, evaluator);
650  }
651 
655  public void addLocalSearchOperator(LocalSearchOperator ls_operator) {
656  mainJNI.RoutingModel_addLocalSearchOperator(swigCPtr, this, LocalSearchOperator.getCPtr(ls_operator), ls_operator);
657  }
658 
662  public void addSearchMonitor(SearchMonitor monitor) {
663  mainJNI.RoutingModel_addSearchMonitor(swigCPtr, this, SearchMonitor.getCPtr(monitor), monitor);
664  }
665 
669  public void addAtSolutionCallback(Runnable callback) {
670  mainJNI.RoutingModel_addAtSolutionCallback(swigCPtr, this, callback);
671  }
672 
677  mainJNI.RoutingModel_addVariableMinimizedByFinalizer(swigCPtr, this, IntVar.getCPtr(var), var);
678  }
679 
684  mainJNI.RoutingModel_addVariableMaximizedByFinalizer(swigCPtr, this, IntVar.getCPtr(var), var);
685  }
686 
690  public void AddWeightedVariableMinimizedByFinalizer(IntVar var, long cost) {
691  mainJNI.RoutingModel_AddWeightedVariableMinimizedByFinalizer(swigCPtr, this, IntVar.getCPtr(var), var, cost);
692  }
693 
697  public void addVariableTargetToFinalizer(IntVar var, long target) {
698  mainJNI.RoutingModel_addVariableTargetToFinalizer(swigCPtr, this, IntVar.getCPtr(var), var, target);
699  }
700 
704  public void closeModel() {
705  mainJNI.RoutingModel_closeModel(swigCPtr, this);
706  }
707 
712  mainJNI.RoutingModel_closeModelWithParameters(swigCPtr, this, search_parameters.toByteArray());
713  }
714 
718  public Assignment solve(Assignment assignment) {
719  long cPtr = mainJNI.RoutingModel_solve__SWIG_0(swigCPtr, this, Assignment.getCPtr(assignment), assignment);
720  return (cPtr == 0) ? null : new Assignment(cPtr, false);
721  }
722 
726  public Assignment solve() {
727  long cPtr = mainJNI.RoutingModel_solve__SWIG_1(swigCPtr, this);
728  return (cPtr == 0) ? null : new Assignment(cPtr, false);
729  }
730 
735  long cPtr = mainJNI.RoutingModel_solveWithParameters(swigCPtr, this, search_parameters.toByteArray());
736  return (cPtr == 0) ? null : new Assignment(cPtr, false);
737  }
738 
743  long cPtr = mainJNI.RoutingModel_solveFromAssignmentWithParameters(swigCPtr, this, Assignment.getCPtr(assignment), assignment, search_parameters.toByteArray());
744  return (cPtr == 0) ? null : new Assignment(cPtr, false);
745  }
746 
750  public Assignment SolveFromAssignmentsWithParameters(SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t assignments, com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters, SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t solutions) {
751  long cPtr = mainJNI.RoutingModel_SolveFromAssignmentsWithParameters__SWIG_0(swigCPtr, this, SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t.getCPtr(assignments), search_parameters.toByteArray(), SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t.getCPtr(solutions));
752  return (cPtr == 0) ? null : new Assignment(cPtr, false);
753  }
754 
758  public Assignment SolveFromAssignmentsWithParameters(SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t assignments, com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters) {
759  long cPtr = mainJNI.RoutingModel_SolveFromAssignmentsWithParameters__SWIG_1(swigCPtr, this, SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t.getCPtr(assignments), search_parameters.toByteArray());
760  return (cPtr == 0) ? null : new Assignment(cPtr, false);
761  }
762 
766  public void setAssignmentFromOtherModelAssignment(Assignment target_assignment, RoutingModel source_model, Assignment source_assignment) {
767  mainJNI.RoutingModel_setAssignmentFromOtherModelAssignment(swigCPtr, this, Assignment.getCPtr(target_assignment), target_assignment, RoutingModel.getCPtr(source_model), source_model, Assignment.getCPtr(source_assignment), source_assignment);
768  }
769 
773  public long computeLowerBound() {
774  return mainJNI.RoutingModel_computeLowerBound(swigCPtr, this);
775  }
776 
780  public int status() {
781  return mainJNI.RoutingModel_status(swigCPtr, this);
782  }
783 
787  public IntVar applyLocks(long[] locks) {
788  long cPtr = mainJNI.RoutingModel_applyLocks(swigCPtr, this, locks);
789  return (cPtr == 0) ? null : new IntVar(cPtr, false);
790  }
791 
795  public boolean applyLocksToAllVehicles(long[][] locks, boolean close_routes) {
796  return mainJNI.RoutingModel_applyLocksToAllVehicles(swigCPtr, this, locks, close_routes);
797  }
798 
803  long cPtr = mainJNI.RoutingModel_preAssignment(swigCPtr, this);
804  return (cPtr == 0) ? null : new Assignment(cPtr, false);
805  }
806 
808  long cPtr = mainJNI.RoutingModel_mutablePreAssignment(swigCPtr, this);
809  return (cPtr == 0) ? null : new Assignment(cPtr, false);
810  }
811 
815  public boolean writeAssignment(String file_name) {
816  return mainJNI.RoutingModel_writeAssignment(swigCPtr, this, file_name);
817  }
818 
822  public Assignment readAssignment(String file_name) {
823  long cPtr = mainJNI.RoutingModel_readAssignment(swigCPtr, this, file_name);
824  return (cPtr == 0) ? null : new Assignment(cPtr, false);
825  }
826 
831  long cPtr = mainJNI.RoutingModel_restoreAssignment(swigCPtr, this, Assignment.getCPtr(solution), solution);
832  return (cPtr == 0) ? null : new Assignment(cPtr, false);
833  }
834 
838  public Assignment readAssignmentFromRoutes(long[][] routes, boolean ignore_inactive_indices) {
839  long cPtr = mainJNI.RoutingModel_readAssignmentFromRoutes(swigCPtr, this, routes, ignore_inactive_indices);
840  return (cPtr == 0) ? null : new Assignment(cPtr, false);
841  }
842 
846  public boolean routesToAssignment(long[][] routes, boolean ignore_inactive_indices, boolean close_routes, Assignment assignment) {
847  return mainJNI.RoutingModel_routesToAssignment(swigCPtr, this, routes, ignore_inactive_indices, close_routes, Assignment.getCPtr(assignment), assignment);
848  }
849 
853  public void assignmentToRoutes(Assignment assignment, long[][] routes) {
854  mainJNI.RoutingModel_assignmentToRoutes(swigCPtr, this, Assignment.getCPtr(assignment), assignment, routes);
855  }
856 
861  long cPtr = mainJNI.RoutingModel_compactAssignment(swigCPtr, this, Assignment.getCPtr(assignment), assignment);
862  return (cPtr == 0) ? null : new Assignment(cPtr, false);
863  }
864 
869  long cPtr = mainJNI.RoutingModel_compactAndCheckAssignment(swigCPtr, this, Assignment.getCPtr(assignment), assignment);
870  return (cPtr == 0) ? null : new Assignment(cPtr, false);
871  }
872 
876  public void addToAssignment(IntVar var) {
877  mainJNI.RoutingModel_addToAssignment(swigCPtr, this, IntVar.getCPtr(var), var);
878  }
879 
880  public void addIntervalToAssignment(IntervalVar interval) {
881  mainJNI.RoutingModel_addIntervalToAssignment(swigCPtr, this, IntervalVar.getCPtr(interval), interval);
882  }
883 
888  mainJNI.RoutingModel_addLocalSearchFilter(swigCPtr, this, LocalSearchFilter.getCPtr(filter), filter);
889  }
890 
894  public long start(int vehicle) {
895  return mainJNI.RoutingModel_start(swigCPtr, this, vehicle);
896  }
897 
901  public long end(int vehicle) {
902  return mainJNI.RoutingModel_end(swigCPtr, this, vehicle);
903  }
904 
908  public boolean isStart(long index) {
909  return mainJNI.RoutingModel_isStart(swigCPtr, this, index);
910  }
911 
915  public boolean isEnd(long index) {
916  return mainJNI.RoutingModel_isEnd(swigCPtr, this, index);
917  }
918 
922  public int VehicleIndex(long index) {
923  return mainJNI.RoutingModel_VehicleIndex(swigCPtr, this, index);
924  }
925 
929  public long next(Assignment assignment, long index) {
930  return mainJNI.RoutingModel_next(swigCPtr, this, Assignment.getCPtr(assignment), assignment, index);
931  }
932 
936  public boolean isVehicleUsed(Assignment assignment, int vehicle) {
937  return mainJNI.RoutingModel_isVehicleUsed(swigCPtr, this, Assignment.getCPtr(assignment), assignment, vehicle);
938  }
939 
943  public IntVar[] nexts() {
944  return mainJNI.RoutingModel_nexts(swigCPtr, this);
945 }
946 
950  public IntVar[] vehicleVars() {
951  return mainJNI.RoutingModel_vehicleVars(swigCPtr, this);
952 }
953 
957  public IntVar nextVar(long index) {
958  long cPtr = mainJNI.RoutingModel_nextVar(swigCPtr, this, index);
959  return (cPtr == 0) ? null : new IntVar(cPtr, false);
960  }
961 
965  public IntVar activeVar(long index) {
966  long cPtr = mainJNI.RoutingModel_activeVar(swigCPtr, this, index);
967  return (cPtr == 0) ? null : new IntVar(cPtr, false);
968  }
969 
973  public IntVar activeVehicleVar(int vehicle) {
974  long cPtr = mainJNI.RoutingModel_activeVehicleVar(swigCPtr, this, vehicle);
975  return (cPtr == 0) ? null : new IntVar(cPtr, false);
976  }
977 
981  public IntVar VehicleCostsConsideredVar(int vehicle) {
982  long cPtr = mainJNI.RoutingModel_VehicleCostsConsideredVar(swigCPtr, this, vehicle);
983  return (cPtr == 0) ? null : new IntVar(cPtr, false);
984  }
985 
989  public IntVar vehicleVar(long index) {
990  long cPtr = mainJNI.RoutingModel_vehicleVar(swigCPtr, this, index);
991  return (cPtr == 0) ? null : new IntVar(cPtr, false);
992  }
993 
997  public IntVar costVar() {
998  long cPtr = mainJNI.RoutingModel_costVar(swigCPtr, this);
999  return (cPtr == 0) ? null : new IntVar(cPtr, false);
1000  }
1001 
1005  public long getArcCostForVehicle(long from_index, long to_index, long vehicle) {
1006  return mainJNI.RoutingModel_getArcCostForVehicle(swigCPtr, this, from_index, to_index, vehicle);
1007  }
1008 
1013  return mainJNI.RoutingModel_costsAreHomogeneousAcrossVehicles(swigCPtr, this);
1014  }
1015 
1019  public long getHomogeneousCost(long from_index, long to_index) {
1020  return mainJNI.RoutingModel_getHomogeneousCost(swigCPtr, this, from_index, to_index);
1021  }
1022 
1026  public long getArcCostForFirstSolution(long from_index, long to_index) {
1027  return mainJNI.RoutingModel_getArcCostForFirstSolution(swigCPtr, this, from_index, to_index);
1028  }
1029 
1033  public long getArcCostForClass(long from_index, long to_index, long cost_class_index) {
1034  return mainJNI.RoutingModel_getArcCostForClass(swigCPtr, this, from_index, to_index, cost_class_index);
1035  }
1036 
1040  public int getCostClassIndexOfVehicle(long vehicle) {
1041  return mainJNI.RoutingModel_getCostClassIndexOfVehicle(swigCPtr, this, vehicle);
1042 }
1043 
1047  public boolean hasVehicleWithCostClassIndex(int cost_class_index) {
1048  return mainJNI.RoutingModel_hasVehicleWithCostClassIndex(swigCPtr, this, cost_class_index);
1049  }
1050 
1054  public int getCostClassesCount() {
1055  return mainJNI.RoutingModel_getCostClassesCount(swigCPtr, this);
1056  }
1057 
1062  return mainJNI.RoutingModel_getNonZeroCostClassesCount(swigCPtr, this);
1063  }
1064 
1065  public int getVehicleClassIndexOfVehicle(long vehicle) {
1066  return mainJNI.RoutingModel_getVehicleClassIndexOfVehicle(swigCPtr, this, vehicle);
1067 }
1068 
1072  public int GetVehicleOfClass(int vehicle_class) {
1073  return mainJNI.RoutingModel_GetVehicleOfClass(swigCPtr, this, vehicle_class);
1074  }
1075 
1079  public int getVehicleClassesCount() {
1080  return mainJNI.RoutingModel_getVehicleClassesCount(swigCPtr, this);
1081  }
1082 
1086  public int[] getSameVehicleIndicesOfIndex(int node) {
1087  return mainJNI.RoutingModel_getSameVehicleIndicesOfIndex(swigCPtr, this, node);
1088 }
1089 
1091  return new RoutingModel.VehicleTypeContainer(mainJNI.RoutingModel_GetVehicleTypeContainer(swigCPtr, this), false);
1092  }
1093 
1097  public boolean arcIsMoreConstrainedThanArc(long from, long to1, long to2) {
1098  return mainJNI.RoutingModel_arcIsMoreConstrainedThanArc(swigCPtr, this, from, to1, to2);
1099  }
1100 
1104  public String debugOutputAssignment(Assignment solution_assignment, String dimension_to_print) {
1105  return mainJNI.RoutingModel_debugOutputAssignment(swigCPtr, this, Assignment.getCPtr(solution_assignment), solution_assignment, dimension_to_print);
1106  }
1107 
1111  public Solver solver() {
1112  long cPtr = mainJNI.RoutingModel_solver(swigCPtr, this);
1113  return (cPtr == 0) ? null : new Solver(cPtr, false);
1114  }
1115 
1119  public boolean checkLimit() {
1120  return mainJNI.RoutingModel_checkLimit(swigCPtr, this);
1121  }
1122 
1126  public int nodes() {
1127  return mainJNI.RoutingModel_nodes(swigCPtr, this);
1128  }
1129 
1133  public int vehicles() {
1134  return mainJNI.RoutingModel_vehicles(swigCPtr, this);
1135  }
1136 
1140  public long size() {
1141  return mainJNI.RoutingModel_size(swigCPtr, this);
1142  }
1143 
1148  return mainJNI.RoutingModel_getNumberOfDecisionsInFirstSolution(swigCPtr, this, search_parameters.toByteArray());
1149  }
1150 
1152  return mainJNI.RoutingModel_getNumberOfRejectsInFirstSolution(swigCPtr, this, search_parameters.toByteArray());
1153  }
1154 
1158  public boolean isMatchingModel() {
1159  return mainJNI.RoutingModel_isMatchingModel(swigCPtr, this);
1160  }
1161 
1165  public DecisionBuilder makeGuidedSlackFinalizer(RoutingDimension dimension, LongUnaryOperator initializer) {
1166  long cPtr = mainJNI.RoutingModel_makeGuidedSlackFinalizer(swigCPtr, this, RoutingDimension.getCPtr(dimension), dimension, initializer);
1167  return (cPtr == 0) ? null : new DecisionBuilder(cPtr, false);
1168  }
1169 
1174  long cPtr = mainJNI.RoutingModel_makeSelfDependentDimensionFinalizer(swigCPtr, this, RoutingDimension.getCPtr(dimension), dimension);
1175  return (cPtr == 0) ? null : new DecisionBuilder(cPtr, false);
1176  }
1177 
1178  // Status
1186  public final static int ROUTING_NOT_SOLVED = mainJNI.RoutingModel_ROUTING_NOT_SOLVED_get();
1190  public final static int ROUTING_SUCCESS = mainJNI.RoutingModel_ROUTING_SUCCESS_get();
1194  public final static int ROUTING_FAIL = mainJNI.RoutingModel_ROUTING_FAIL_get();
1198  public final static int ROUTING_FAIL_TIMEOUT = mainJNI.RoutingModel_ROUTING_FAIL_TIMEOUT_get();
1202  public final static int ROUTING_INVALID = mainJNI.RoutingModel_ROUTING_INVALID_get();
1203 
1204  // PickupAndDeliveryPolicy
1212  public final static int PICKUP_AND_DELIVERY_NO_ORDER = mainJNI.RoutingModel_PICKUP_AND_DELIVERY_NO_ORDER_get();
1216  public final static int PICKUP_AND_DELIVERY_LIFO = mainJNI.RoutingModel_PICKUP_AND_DELIVERY_LIFO_get();
1220  public final static int PICKUP_AND_DELIVERY_FIFO = mainJNI.RoutingModel_PICKUP_AND_DELIVERY_FIFO_get();
1221 
1222  // VisitTypePolicy
1230  public final static int TYPE_ADDED_TO_VEHICLE = mainJNI.RoutingModel_TYPE_ADDED_TO_VEHICLE_get();
1234  public final static int ADDED_TYPE_REMOVED_FROM_VEHICLE = mainJNI.RoutingModel_ADDED_TYPE_REMOVED_FROM_VEHICLE_get();
1238  public final static int TYPE_ON_VEHICLE_UP_TO_VISIT = mainJNI.RoutingModel_TYPE_ON_VEHICLE_UP_TO_VISIT_get();
1242  public final static int TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = mainJNI.RoutingModel_TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED_get();
1243 
1244 }
int vehicles()
Returns the number of vehicle routes in the model.
Assignment compactAndCheckAssignment(Assignment assignment)
Same as CompactAssignment() but also checks the validity of the final compact solution; if it is not ...
SWIGTYPE_p_operations_research__GlobalDimensionCumulOptimizer GetMutableGlobalCumulMPOptimizer(RoutingDimension dimension)
long getFixedCostOfVehicle(int vehicle)
Returns the route fixed cost taken into account if the route of the vehicle is not empty,...
int status()
Returns the current status of the routing model.
void setAmortizedCostFactorsOfVehicle(long linear_cost_factor, long quadratic_cost_factor, int vehicle)
Sets the linear and quadratic cost factor of the given vehicle.
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.
Dimensions represent quantities accumulated at nodes along the routes.
RoutingDimension getMutableDimension(String dimension_name)
Returns a dimension from its name.
IntVar [] nexts()
Returns all next variables of the model, such that Nexts(i) is the next variable of the node correspo...
void addVariableMinimizedByFinalizer(IntVar var)
Adds a variable to minimize in the solution finalizer.
long [] GetDisjunctionNodeIndices(int index)
Returns the variable indices of the nodes in the disjunction of index 'index'.
static int getKNoDimension()
Constant used to express the "no dimension" index, returned when a dimension name does not correspond...
Solver Class A solver represents the main computation engine.
Definition: Solver.java:57
static final int ADDED_TYPE_REMOVED_FROM_VEHICLE
When visited, one instance of type 'T' previously added to the route (TYPE_ADDED_TO_VEHICLE),...
int registerPositiveUnaryTransitCallback(LongUnaryOperator callback)
Assignment readAssignment(String file_name)
Reads an assignment from a file and returns the current solution.
int getVehicleClassesCount()
Returns the number of different vehicle classes in the model.
RoutingModel.VehicleTypeContainer GetVehicleTypeContainer()
IntVar vehicleVar(long index)
Returns the vehicle variable of the node corresponding to index.
void setVehicles_per_vehicle_class(SWIGTYPE_p_std__vectorT_std__dequeT_int_t_t value)
int registerPositiveTransitCallback(LongBinaryOperator callback)
SWIGTYPE_p_absl__flat_hash_setT_int_t getTemporalTypeIncompatibilitiesOfType(int type)
void closeVisitTypes()
This function should be called once all node visit types have been set and prior to adding any incomp...
IntVar applyLocks(long[] locks)
Applies a lock chain to the next search.
void addTemporalTypeIncompatibility(int type1, int type2)
void setAllowedVehiclesForIndex(int[] vehicles, long index)
Sets the vehicles which can visit a given node.
void closeModel()
Closes the current routing model; after this method is called, no modification to the model can be do...
static final int TYPE_ADDED_TO_VEHICLE
Set the node visit types and incompatibilities/requirements between the types (see below).
Assignment preAssignment()
Returns an assignment used to fix some of the variables of the problem.
Manager for any NodeIndex <-> variable index conversion.
static final int ROUTING_INVALID
Model, model parameters or flags are not valid.
boolean isVehicleUsed(Assignment assignment, int vehicle)
Returns true if the route of 'vehicle' is non empty in 'assignment'.
void setPrimaryConstrainedDimension(String dimension_name)
Set the given dimension as "primary constrained".
SWIGTYPE_p_std__vectorT_std__unique_ptrT_operations_research__GlobalDimensionCumulOptimizer_t_t GetGlobalDimensionCumulMPOptimizers()
Assignment solve(Assignment assignment)
Solves the current routing model; closes the current model.
static long getKNoPenalty()
Constant used to express a hard constraint instead of a soft penalty.
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_T...
boolean writeAssignment(String file_name)
Writes the current solution to a file containing an AssignmentProto.
boolean hasHardTypeIncompatibilities()
Returns true iff any hard (resp.
int [] getDisjunctionIndices(long index)
Returns the indices of the disjunctions to which an index belongs.
int getCostClassesCount()
Returns the number of different cost classes in the model.
boolean isMatchingModel()
Returns true if a vehicle/node matching problem is detected.
int getNumOfSingletonNodes()
Returns the number of non-start/end nodes which do not appear in a pickup/delivery pair.
static final int ROUTING_FAIL_TIMEOUT
Time limit reached before finding a solution with RoutingModel::Solve().
boolean addDimensionWithVehicleTransitAndCapacity(int[] evaluator_indices, long slack_max, long[] vehicle_capacities, boolean fix_start_cumul_to_zero, String name)
boolean addDimensionWithVehicleCapacity(int evaluator_index, long slack_max, long[] vehicle_capacities, boolean fix_start_cumul_to_zero, String name)
long unperformedPenalty(long var_index)
Get the "unperformed" penalty of a node.
long getDisjunctionMaxCardinality(int index)
Returns the maximum number of possible active nodes of the node disjunction of index 'index'.
Assignment SolveFromAssignmentsWithParameters(SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t assignments, com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters)
Same as above but will try all assignments in order as first solutions until one succeeds.
void addSearchMonitor(SearchMonitor monitor)
Adds a search monitor to the search used to solve the routing model.
static final 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...
int VehicleIndex(long index)
Returns the vehicle of the given start/end index, and -1 if the given index is not a vehicle start/en...
long getDepot()
Returns the variable index of the first starting or ending node of all routes.
long computeLowerBound()
Computes a lower bound to the routing problem solving a linear assignment problem.
static final int PICKUP_AND_DELIVERY_LIFO
Deliveries must be performed in reverse order of pickups.
boolean addDimension(int evaluator_index, long slack_max, long capacity, boolean fix_start_cumul_to_zero, String name)
Model creation Methods to add dimensions to routes; dimensions represent quantities accumulated at no...
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 t...
Assignment solveFromAssignmentWithParameters(Assignment assignment, com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters)
Same as above, except that if assignment is not null, it will be used as the initial solution.
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 variab...
boolean isStart(long index)
Returns true if 'index' represents the first node of a route.
void addLocalSearchOperator(LocalSearchOperator ls_operator)
Adds a local search operator to the set of operators used to solve the vehicle routing problem.
static final int ROUTING_NOT_SOLVED
Status of the search.
void addSoftSameVehicleConstraint(long[] indices, long cost)
Adds a soft constraint to force a set of variable indices to be on the same vehicle.
long getDisjunctionPenalty(int index)
Returns the penalty of the node disjunction of index 'index'.
boolean arcIsMoreConstrainedThanArc(long from, long to1, long to2)
Returns whether the arc from->to1 is more constrained than from->to2, taking into account,...
void AddWeightedVariableMinimizedByFinalizer(IntVar var, long cost)
Adds a variable to minimize in the solution finalizer, with a weighted priority: the higher the more ...
int addDisjunction(long[] indices, long penalty, long max_cardinality)
Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active.
Struct used to sort and store vehicles by their type.
IntVar activeVar(long index)
Returns the active variable of the node corresponding to index.
Assignment solve()
Solves the current routing model; closes the current model.
int [] getSameVehicleIndicesOfIndex(int node)
Returns variable indices of nodes constrained to be on the same route.
long size()
Returns the number of next variables in the model.
long next(Assignment assignment, long index)
Assignment inspection Returns the variable index of the node directly after the node corresponding to...
void addIntervalToAssignment(IntervalVar interval)
boolean checkLimit()
Returns true if the search limit has been crossed.
IntVar [] vehicleVars()
Returns all vehicle variables of the model, such that VehicleVars(i) is the vehicle variable of the n...
RoutingModel(long cPtr, boolean cMemoryOwn)
Assignment solveWithParameters(com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters)
Solves the current routing model with the given parameters.
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,...
SWIGTYPE_p_std__vectorT_std__setT_operations_research__RoutingModel__VehicleTypeContainer__VehicleClassEntry_t_t getSorted_vehicle_classes_per_type()
Constraint MakePathSpansAndTotalSlacks(RoutingDimension dimension, IntVar[] spans, IntVar[] total_slacks)
For every vehicle of the routing model: - if total_slacks[vehicle] is not nullptr,...
void addPickupAndDeliverySets(int pickup_disjunction, int delivery_disjunction)
Same as AddPickupAndDelivery but notifying that the performed node from the disjunction of index 'pic...
A search monitor is a simple set of callbacks to monitor all search events.
long start(int vehicle)
Model inspection.
long getArcCostForVehicle(long from_index, long to_index, long vehicle)
Returns the cost of the transit arc between two nodes for a given vehicle.
IntVar nextVar(long index)
Returns the next variable of the node corresponding to index.
A DecisionBuilder is responsible for creating the search tree.
boolean hasSameVehicleTypeRequirements()
Returns true iff any same-route (resp.
boolean isEnd(long index)
Returns true if 'index' represents the last node of a route.
void addHardTypeIncompatibility(int type1, int type2)
Incompatibilities: Two nodes with "hard" incompatible types cannot share the same route at all,...
void addVariableTargetToFinalizer(IntVar var, long target)
Add a variable to set the closest possible to the target value in the solution finalizer.
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 rout...
int addDisjunction(long[] indices, long penalty)
Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active.
boolean addDimensionWithVehicleTransits(int[] evaluator_indices, long slack_max, long capacity, boolean fix_start_cumul_to_zero, String name)
IntBoolPair addVectorDimension(long[] values, long capacity, boolean fix_start_cumul_to_zero, String name)
Creates a dimension where the transit variable is constrained to be equal to 'values[i]' for node i; ...
SWIGTYPE_p_std__vectorT_std__dequeT_int_t_t getVehicles_per_vehicle_class()
IntBoolPair addMatrixDimension(long[][] values, long capacity, boolean fix_start_cumul_to_zero, String name)
Creates a dimension where the transit variable is constrained to be equal to 'values[i][next(i)]' for...
int getNonZeroCostClassesCount()
Ditto, minus the 'always zero', built-in cost class.
void SetMaximumNumberOfActiveVehicles(int max_active_vehicles)
Constrains the maximum number of active vehicles, aka the number of vehicles which do not have an emp...
void addPickupAndDelivery(long pickup, long delivery)
Notifies that index1 and index2 form a pair of nodes which should belong to the same route.
void closeModelWithParameters(com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters)
Same as above taking search parameters (as of 10/2015 some the parameters have to be set when closing...
void addToAssignment(IntVar var)
Adds an extra variable to the vehicle routing assignment.
int GetVehicleOfClass(int vehicle_class)
Returns a vehicle of the given vehicle class, and -1 if there are no vehicles for this class.
This class represent a reversible FIFO structure.
long end(int vehicle)
Returns the variable index of the ending node of a vehicle route.
RoutingModel(RoutingIndexManager index_manager, com.google.ortools.constraintsolver.RoutingModelParameters parameters)
void ignoreDisjunctionsAlreadyForcedToZero()
SPECIAL: Makes the solver ignore all the disjunctions whose active variables are all trivially zero (...
void addVariableMaximizedByFinalizer(IntVar var)
Adds a variable to maximize in the solution finalizer (see above for information on the solution fina...
Assignment restoreAssignment(Assignment solution)
Restores an assignment as a solution in the routing model and returns the new solution.
Classes to which this template function can be applied to as of 04/2014.
int addDisjunction(long[] indices)
Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active.
void setVisitType(long index, int type, int type_policy)
void setPickupAndDeliveryPolicyOfAllVehicles(int policy)
Sets the Pickup and delivery policy of all vehicles.
boolean isVehicleAllowedForIndex(int vehicle, long index)
Returns true if a vehicle is allowed to visit a given node.
static final int PICKUP_AND_DELIVERY_NO_ORDER
Types of precedence policy applied to pickup and delivery pairs.
DecisionBuilder makeGuidedSlackFinalizer(RoutingDimension dimension, LongUnaryOperator initializer)
The next few members are in the public section only for testing purposes.
Assignment compactAssignment(Assignment assignment)
Converts the solution in the given assignment to routes for all vehicles.
IntVar costVar()
Returns the global cost variable which is being minimized.
An Assignment is a variable -> domains mapping, used to report solutions to the user.
Definition: Assignment.java:14
String getPrimaryConstrainedDimension()
Get the primary constrained dimension, or an empty string if it is unset.
Assignment readAssignmentFromRoutes(long[][] routes, boolean ignore_inactive_indices)
Restores the routes as the current solution.
int registerTransitCallback(LongBinaryOperator callback)
IntVar VehicleCostsConsideredVar(int vehicle)
Returns the variable specifying whether or not costs are considered for vehicle.
int registerUnaryTransitCallback(LongUnaryOperator callback)
void setFixedCostOfVehicle(long cost, int vehicle)
Sets the fixed cost of one vehicle route.
RoutingModel(RoutingIndexManager index_manager)
Constructor taking an index manager.
Solver solver()
Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair containing the minimum and maxi...
long getArcCostForFirstSolution(long from_index, long to_index)
Returns the cost of the arc in the context of the first solution strategy.
int getCostClassIndexOfVehicle(long vehicle)
Get the cost class index of the given vehicle.
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.
IntBoolPair addConstantDimension(long value, long capacity, boolean fix_start_cumul_to_zero, String name)
void addLocalSearchFilter(LocalSearchFilter filter)
Adds a custom local search filter to the list of filters used to speed up local search by pruning unf...
String debugOutputAssignment(Assignment solution_assignment, String dimension_to_print)
Print some debugging information about an assignment, including the feasible intervals of the CumulVa...
void ConsiderEmptyRouteCostsForVehicle(boolean consider_costs, int vehicle)
void setFixedCostOfAllVehicles(long cost)
Sets the fixed cost of all vehicle routes.
int registerUnaryTransitVector(long[] values)
Registers 'callback' and returns its index.
Assignment SolveFromAssignmentsWithParameters(SWIGTYPE_p_std__vectorT_operations_research__Assignment_const_p_t assignments, com.google.ortools.constraintsolver.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.
void setSorted_vehicle_classes_per_type(SWIGTYPE_p_std__vectorT_std__setT_operations_research__RoutingModel__VehicleTypeContainer__VehicleClassEntry_t_t value)
void setArcCostEvaluatorOfVehicle(int evaluator_index, int vehicle)
Sets the cost function for a given vehicle route.
static final int ROUTING_FAIL
No solution found to the problem after calling RoutingModel::Solve().
IntBoolPair addConstantDimensionWithSlack(long value, long capacity, long slack_max, boolean fix_start_cumul_to_zero, String name)
Creates a dimension where the transit variable is constrained to be equal to 'value'; 'capacity' is t...
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 (def...
void assignmentToRoutes(Assignment assignment, long[][] routes)
Converts the solution in the given assignment to routes for all vehicles.
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.
RoutingDimension getDimensionOrDie(String dimension_name)
Returns a dimension from its name.
int GetMaximumNumberOfActiveVehicles()
Returns the maximum number of active vehicles.
boolean hasDimension(String dimension_name)
Returns true if a dimension exists for a given dimension name.
IntVar activeVehicleVar(int vehicle)
Returns the active variable of the vehicle.
long getNumberOfRejectsInFirstSolution(com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters)
static final int PICKUP_AND_DELIVERY_FIFO
Deliveries must be performed in the same order as pickups.
long getNumberOfDecisionsInFirstSolution(com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters)
Returns statistics on first solution search, number of decisions sent to filters, number of decisions...
static final 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 a...
boolean costsAreHomogeneousAcrossVehicles()
Whether costs are homogeneous across all vehicles.
boolean hasVehicleWithCostClassIndex(int cost_class_index)
Returns true iff the model contains a vehicle with the given cost_class_index.
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' an...
int nodes()
Sizes and indices Returns the number of nodes in the model.
int [] GetDimensionResourceGroupIndices(RoutingDimension dimension)
Returns the indices of resource groups for this dimension.
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 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 setPickupAndDeliveryPolicyOfVehicle(int policy, int vehicle)
void setFirstSolutionEvaluator(LongBinaryOperator evaluator)
Gets/sets the evaluator used during the search.
DecisionBuilder makeSelfDependentDimensionFinalizer(RoutingDimension dimension)
MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a self-dependent dimension.
static int getKNoDisjunction()
Constant used to express the "no disjunction" index, returned when a node does not appear in any disj...
int getNumberOfDisjunctions()
Returns the number of node disjunctions in the model.
static final int ROUTING_SUCCESS
Problem solved successfully after calling RoutingModel::Solve().
void addAtSolutionCallback(Runnable callback)
Adds a callback called each time a solution is found during the search.