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.0
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  public static long getKNoPenalty() {
50  return mainJNI.RoutingModel_kNoPenalty_get();
51  }
52 
56  public static int getKNoDisjunction() {
57  return mainJNI.RoutingModel_kNoDisjunction_get();
58 }
59 
63  public static int getKNoDimension() {
64  return mainJNI.RoutingModel_kNoDimension_get();
65 }
66 
70  public RoutingModel(RoutingIndexManager index_manager) {
71  this(mainJNI.new_RoutingModel__SWIG_0(RoutingIndexManager.getCPtr(index_manager), index_manager), true);
72  }
73 
75  this(mainJNI.new_RoutingModel__SWIG_1(RoutingIndexManager.getCPtr(index_manager), index_manager, parameters.toByteArray()), true);
76  }
77 
81  public int registerUnaryTransitCallback(LongUnaryOperator callback) {
82  return mainJNI.RoutingModel_registerUnaryTransitCallback(swigCPtr, this, callback);
83  }
84 
85  public int RegisterPositiveUnaryTransitCallback(LongUnaryOperator callback) {
86  return mainJNI.RoutingModel_RegisterPositiveUnaryTransitCallback(swigCPtr, this, callback);
87  }
88 
89  public int registerTransitCallback(LongBinaryOperator callback) {
90  return mainJNI.RoutingModel_registerTransitCallback(swigCPtr, this, callback);
91  }
92 
93  public int registerPositiveTransitCallback(LongBinaryOperator callback) {
94  return mainJNI.RoutingModel_registerPositiveTransitCallback(swigCPtr, this, callback);
95  }
96 
100  public boolean addDimension(int evaluator_index, long slack_max, long capacity, boolean fix_start_cumul_to_zero, String name) {
101  return mainJNI.RoutingModel_addDimension(swigCPtr, this, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name);
102  }
103 
104  public boolean addDimensionWithVehicleTransits(int[] evaluator_indices, long slack_max, long capacity, boolean fix_start_cumul_to_zero, String name) {
105  return mainJNI.RoutingModel_addDimensionWithVehicleTransits(swigCPtr, this, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name);
106  }
107 
108  public boolean addDimensionWithVehicleCapacity(int evaluator_index, long slack_max, long[] vehicle_capacities, boolean fix_start_cumul_to_zero, String name) {
109  return mainJNI.RoutingModel_addDimensionWithVehicleCapacity(swigCPtr, this, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name);
110  }
111 
112  public boolean addDimensionWithVehicleTransitAndCapacity(int[] evaluator_indices, long slack_max, long[] vehicle_capacities, boolean fix_start_cumul_to_zero, String name) {
113  return mainJNI.RoutingModel_addDimensionWithVehicleTransitAndCapacity(swigCPtr, this, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name);
114  }
115 
119  public boolean addConstantDimensionWithSlack(long value, long capacity, long slack_max, boolean fix_start_cumul_to_zero, String name) {
120  return mainJNI.RoutingModel_addConstantDimensionWithSlack(swigCPtr, this, value, capacity, slack_max, fix_start_cumul_to_zero, name);
121  }
122 
123  public boolean addConstantDimension(long value, long capacity, boolean fix_start_cumul_to_zero, String name) {
124  return mainJNI.RoutingModel_addConstantDimension(swigCPtr, this, value, capacity, fix_start_cumul_to_zero, name);
125  }
126 
130  public boolean addVectorDimension(long[] values, long capacity, boolean fix_start_cumul_to_zero, String name) {
131  return mainJNI.RoutingModel_addVectorDimension(swigCPtr, this, values, capacity, fix_start_cumul_to_zero, name);
132  }
133 
137  public Constraint MakePathSpansAndTotalSlacks(RoutingDimension dimension, IntVar[] spans, IntVar[] total_slacks) {
138  long cPtr = mainJNI.RoutingModel_MakePathSpansAndTotalSlacks(swigCPtr, this, RoutingDimension.getCPtr(dimension), dimension, spans, total_slacks);
139  return (cPtr == 0) ? null : new Constraint(cPtr, false);
140  }
141 
145  public SWIGTYPE_p_std__vectorT_std__unique_ptrT_operations_research__GlobalDimensionCumulOptimizer_t_t GetGlobalDimensionCumulOptimizers() {
146  return new SWIGTYPE_p_std__vectorT_std__unique_ptrT_operations_research__GlobalDimensionCumulOptimizer_t_t(mainJNI.RoutingModel_GetGlobalDimensionCumulOptimizers(swigCPtr, this), false);
147  }
148 
149  public SWIGTYPE_p_std__vectorT_std__unique_ptrT_operations_research__LocalDimensionCumulOptimizer_t_t GetLocalDimensionCumulOptimizers() {
150  return new SWIGTYPE_p_std__vectorT_std__unique_ptrT_operations_research__LocalDimensionCumulOptimizer_t_t(mainJNI.RoutingModel_GetLocalDimensionCumulOptimizers(swigCPtr, this), false);
151  }
152 
156  public SWIGTYPE_p_operations_research__GlobalDimensionCumulOptimizer GetMutableGlobalCumulOptimizer(RoutingDimension dimension) {
157  long cPtr = mainJNI.RoutingModel_GetMutableGlobalCumulOptimizer(swigCPtr, this, RoutingDimension.getCPtr(dimension), dimension);
158  return (cPtr == 0) ? null : new SWIGTYPE_p_operations_research__GlobalDimensionCumulOptimizer(cPtr, false);
159  }
160 
161  public SWIGTYPE_p_operations_research__LocalDimensionCumulOptimizer GetMutableLocalCumulOptimizer(RoutingDimension dimension) {
162  long cPtr = mainJNI.RoutingModel_GetMutableLocalCumulOptimizer(swigCPtr, this, RoutingDimension.getCPtr(dimension), dimension);
163  return (cPtr == 0) ? null : new SWIGTYPE_p_operations_research__LocalDimensionCumulOptimizer(cPtr, false);
164  }
165 
169  public boolean hasDimension(String dimension_name) {
170  return mainJNI.RoutingModel_hasDimension(swigCPtr, this, dimension_name);
171  }
172 
176  public RoutingDimension getDimensionOrDie(String dimension_name) {
177  return new RoutingDimension(mainJNI.RoutingModel_getDimensionOrDie(swigCPtr, this, dimension_name), false);
178  }
179 
183  public RoutingDimension getMutableDimension(String dimension_name) {
184  long cPtr = mainJNI.RoutingModel_getMutableDimension(swigCPtr, this, dimension_name);
185  return (cPtr == 0) ? null : new RoutingDimension(cPtr, false);
186  }
187 
191  public void setPrimaryConstrainedDimension(String dimension_name) {
192  mainJNI.RoutingModel_setPrimaryConstrainedDimension(swigCPtr, this, dimension_name);
193  }
194 
199  return mainJNI.RoutingModel_getPrimaryConstrainedDimension(swigCPtr, this);
200  }
201 
205  public int addDisjunction(long[] indices, long penalty, long max_cardinality) {
206  return mainJNI.RoutingModel_addDisjunction__SWIG_0(swigCPtr, this, indices, penalty, max_cardinality);
207 }
208 
212  public int addDisjunction(long[] indices, long penalty) {
213  return mainJNI.RoutingModel_addDisjunction__SWIG_1(swigCPtr, this, indices, penalty);
214 }
215 
219  public int addDisjunction(long[] indices) {
220  return mainJNI.RoutingModel_addDisjunction__SWIG_2(swigCPtr, this, indices);
221 }
222 
226  public int[] getDisjunctionIndices(long index) {
227  return mainJNI.RoutingModel_getDisjunctionIndices__SWIG_0(swigCPtr, this, index);
228 }
229 
233  public long[] getDisjunctionIndices(int index) {
234  return mainJNI.RoutingModel_getDisjunctionIndices__SWIG_1(swigCPtr, this, index);
235 }
236 
240  public long getDisjunctionPenalty(int index) {
241  return mainJNI.RoutingModel_getDisjunctionPenalty(swigCPtr, this, index);
242  }
243 
247  public long getDisjunctionMaxCardinality(int index) {
248  return mainJNI.RoutingModel_getDisjunctionMaxCardinality(swigCPtr, this, index);
249  }
250 
254  public int getNumberOfDisjunctions() {
255  return mainJNI.RoutingModel_getNumberOfDisjunctions(swigCPtr, this);
256  }
257 
262  mainJNI.RoutingModel_ignoreDisjunctionsAlreadyForcedToZero(swigCPtr, this);
263  }
264 
268  public void addSoftSameVehicleConstraint(long[] indices, long cost) {
269  mainJNI.RoutingModel_addSoftSameVehicleConstraint(swigCPtr, this, indices, cost);
270  }
271 
275  public void setAllowedVehiclesForIndex(int[] vehicles, long index) {
276  mainJNI.RoutingModel_setAllowedVehiclesForIndex(swigCPtr, this, vehicles, index);
277  }
278 
282  public boolean isVehicleAllowedForIndex(int vehicle, long index) {
283  return mainJNI.RoutingModel_isVehicleAllowedForIndex(swigCPtr, this, vehicle, index);
284  }
285 
289  public void addPickupAndDelivery(long pickup, long delivery) {
290  mainJNI.RoutingModel_addPickupAndDelivery(swigCPtr, this, pickup, delivery);
291  }
292 
296  public void addPickupAndDeliverySets(int pickup_disjunction, int delivery_disjunction) {
297  mainJNI.RoutingModel_addPickupAndDeliverySets(swigCPtr, this, pickup_disjunction, delivery_disjunction);
298  }
299 
303  public void setPickupAndDeliveryPolicyOfAllVehicles(int policy) {
304  mainJNI.RoutingModel_setPickupAndDeliveryPolicyOfAllVehicles(swigCPtr, this, policy);
305  }
306 
307  public void setPickupAndDeliveryPolicyOfVehicle(int policy, int vehicle) {
308  mainJNI.RoutingModel_setPickupAndDeliveryPolicyOfVehicle(swigCPtr, this, policy, vehicle);
309  }
310 
311  public int getPickupAndDeliveryPolicyOfVehicle(int vehicle) {
312  return mainJNI.RoutingModel_getPickupAndDeliveryPolicyOfVehicle(swigCPtr, this, vehicle);
313  }
314 
318  public int getNumOfSingletonNodes() {
319  return mainJNI.RoutingModel_getNumOfSingletonNodes(swigCPtr, this);
320  }
321 
325  public void setVisitType(long index, int type) {
326  mainJNI.RoutingModel_setVisitType(swigCPtr, this, index, type);
327  }
328 
329  public int getVisitType(long index) {
330  return mainJNI.RoutingModel_getVisitType(swigCPtr, this, index);
331  }
332 
333  public int getNumberOfVisitTypes() {
334  return mainJNI.RoutingModel_getNumberOfVisitTypes(swigCPtr, this);
335  }
336 
340  public long unperformedPenalty(long var_index) {
341  return mainJNI.RoutingModel_unperformedPenalty(swigCPtr, this, var_index);
342  }
343 
347  public long unperformedPenaltyOrValue(long default_value, long var_index) {
348  return mainJNI.RoutingModel_unperformedPenaltyOrValue(swigCPtr, this, default_value, var_index);
349  }
350 
354  public long getDepot() {
355  return mainJNI.RoutingModel_getDepot(swigCPtr, this);
356  }
357 
361  public void setArcCostEvaluatorOfAllVehicles(int evaluator_index) {
362  mainJNI.RoutingModel_setArcCostEvaluatorOfAllVehicles(swigCPtr, this, evaluator_index);
363  }
364 
368  public void setArcCostEvaluatorOfVehicle(int evaluator_index, int vehicle) {
369  mainJNI.RoutingModel_setArcCostEvaluatorOfVehicle(swigCPtr, this, evaluator_index, vehicle);
370  }
371 
375  public void setFixedCostOfAllVehicles(long cost) {
376  mainJNI.RoutingModel_setFixedCostOfAllVehicles(swigCPtr, this, cost);
377  }
378 
382  public void setFixedCostOfVehicle(long cost, int vehicle) {
383  mainJNI.RoutingModel_setFixedCostOfVehicle(swigCPtr, this, cost, vehicle);
384  }
385 
389  public long getFixedCostOfVehicle(int vehicle) {
390  return mainJNI.RoutingModel_getFixedCostOfVehicle(swigCPtr, this, vehicle);
391  }
392 
396  public void setAmortizedCostFactorsOfAllVehicles(long linear_cost_factor, long quadratic_cost_factor) {
397  mainJNI.RoutingModel_setAmortizedCostFactorsOfAllVehicles(swigCPtr, this, linear_cost_factor, quadratic_cost_factor);
398  }
399 
403  public void setAmortizedCostFactorsOfVehicle(long linear_cost_factor, long quadratic_cost_factor, int vehicle) {
404  mainJNI.RoutingModel_setAmortizedCostFactorsOfVehicle(swigCPtr, this, linear_cost_factor, quadratic_cost_factor, vehicle);
405  }
406 
408  return mainJNI.RoutingModel_getAmortizedLinearCostFactorOfVehicles(swigCPtr, this);
409 }
410 
412  return mainJNI.RoutingModel_getAmortizedQuadraticCostFactorOfVehicles(swigCPtr, this);
413 }
414 
415  public void ConsiderEmptyRouteCostsForVehicle(boolean consider_costs, int vehicle) {
416  mainJNI.RoutingModel_ConsiderEmptyRouteCostsForVehicle(swigCPtr, this, consider_costs, vehicle);
417  }
418 
419  public boolean AreEmptyRouteCostsConsideredForVehicle(int vehicle) {
420  return mainJNI.RoutingModel_AreEmptyRouteCostsConsideredForVehicle(swigCPtr, this, vehicle);
421  }
422 
426  public void setFirstSolutionEvaluator(LongBinaryOperator evaluator) {
427  mainJNI.RoutingModel_setFirstSolutionEvaluator(swigCPtr, this, evaluator);
428  }
429 
433  public void addLocalSearchOperator(LocalSearchOperator ls_operator) {
434  mainJNI.RoutingModel_addLocalSearchOperator(swigCPtr, this, LocalSearchOperator.getCPtr(ls_operator), ls_operator);
435  }
436 
440  public void addSearchMonitor(SearchMonitor monitor) {
441  mainJNI.RoutingModel_addSearchMonitor(swigCPtr, this, SearchMonitor.getCPtr(monitor), monitor);
442  }
443 
447  public void addAtSolutionCallback(Runnable callback) {
448  mainJNI.RoutingModel_addAtSolutionCallback(swigCPtr, this, callback);
449  }
450 
455  mainJNI.RoutingModel_addVariableMinimizedByFinalizer(swigCPtr, this, IntVar.getCPtr(var), var);
456  }
457 
462  mainJNI.RoutingModel_addVariableMaximizedByFinalizer(swigCPtr, this, IntVar.getCPtr(var), var);
463  }
464 
468  public void AddWeightedVariableMinimizedByFinalizer(IntVar var, long cost) {
469  mainJNI.RoutingModel_AddWeightedVariableMinimizedByFinalizer(swigCPtr, this, IntVar.getCPtr(var), var, cost);
470  }
471 
475  public void AddVariableTargetToFinalizer(IntVar var, long target) {
476  mainJNI.RoutingModel_AddVariableTargetToFinalizer(swigCPtr, this, IntVar.getCPtr(var), var, target);
477  }
478 
482  public void closeModel() {
483  mainJNI.RoutingModel_closeModel(swigCPtr, this);
484  }
485 
490  mainJNI.RoutingModel_closeModelWithParameters(swigCPtr, this, search_parameters.toByteArray());
491  }
492 
496  public Assignment solve(Assignment assignment) {
497  long cPtr = mainJNI.RoutingModel_solve__SWIG_0(swigCPtr, this, Assignment.getCPtr(assignment), assignment);
498  return (cPtr == 0) ? null : new Assignment(cPtr, false);
499  }
500 
504  public Assignment solve() {
505  long cPtr = mainJNI.RoutingModel_solve__SWIG_1(swigCPtr, this);
506  return (cPtr == 0) ? null : new Assignment(cPtr, false);
507  }
508 
513  long cPtr = mainJNI.RoutingModel_solveWithParameters(swigCPtr, this, search_parameters.toByteArray());
514  return (cPtr == 0) ? null : new Assignment(cPtr, false);
515  }
516 
518  long cPtr = mainJNI.RoutingModel_solveFromAssignmentWithParameters(swigCPtr, this, Assignment.getCPtr(assignment), assignment, search_parameters.toByteArray());
519  return (cPtr == 0) ? null : new Assignment(cPtr, false);
520  }
521 
525  public void setAssignmentFromOtherModelAssignment(Assignment target_assignment, RoutingModel source_model, Assignment source_assignment) {
526  mainJNI.RoutingModel_setAssignmentFromOtherModelAssignment(swigCPtr, this, Assignment.getCPtr(target_assignment), target_assignment, RoutingModel.getCPtr(source_model), source_model, Assignment.getCPtr(source_assignment), source_assignment);
527  }
528 
532  public long computeLowerBound() {
533  return mainJNI.RoutingModel_computeLowerBound(swigCPtr, this);
534  }
535 
539  public int status() {
540  return mainJNI.RoutingModel_status(swigCPtr, this);
541  }
542 
546  public IntVar applyLocks(long[] locks) {
547  long cPtr = mainJNI.RoutingModel_applyLocks(swigCPtr, this, locks);
548  return (cPtr == 0) ? null : new IntVar(cPtr, false);
549  }
550 
554  public boolean applyLocksToAllVehicles(long[][] locks, boolean close_routes) {
555  return mainJNI.RoutingModel_applyLocksToAllVehicles(swigCPtr, this, locks, close_routes);
556  }
557 
562  long cPtr = mainJNI.RoutingModel_preAssignment(swigCPtr, this);
563  return (cPtr == 0) ? null : new Assignment(cPtr, false);
564  }
565 
567  long cPtr = mainJNI.RoutingModel_mutablePreAssignment(swigCPtr, this);
568  return (cPtr == 0) ? null : new Assignment(cPtr, false);
569  }
570 
574  public boolean writeAssignment(String file_name) {
575  return mainJNI.RoutingModel_writeAssignment(swigCPtr, this, file_name);
576  }
577 
581  public Assignment readAssignment(String file_name) {
582  long cPtr = mainJNI.RoutingModel_readAssignment(swigCPtr, this, file_name);
583  return (cPtr == 0) ? null : new Assignment(cPtr, false);
584  }
585 
590  long cPtr = mainJNI.RoutingModel_restoreAssignment(swigCPtr, this, Assignment.getCPtr(solution), solution);
591  return (cPtr == 0) ? null : new Assignment(cPtr, false);
592  }
593 
597  public Assignment readAssignmentFromRoutes(long[][] routes, boolean ignore_inactive_indices) {
598  long cPtr = mainJNI.RoutingModel_readAssignmentFromRoutes(swigCPtr, this, routes, ignore_inactive_indices);
599  return (cPtr == 0) ? null : new Assignment(cPtr, false);
600  }
601 
605  public boolean routesToAssignment(long[][] routes, boolean ignore_inactive_indices, boolean close_routes, Assignment assignment) {
606  return mainJNI.RoutingModel_routesToAssignment(swigCPtr, this, routes, ignore_inactive_indices, close_routes, Assignment.getCPtr(assignment), assignment);
607  }
608 
612  public void assignmentToRoutes(Assignment assignment, long[][] routes) {
613  mainJNI.RoutingModel_assignmentToRoutes(swigCPtr, this, Assignment.getCPtr(assignment), assignment, routes);
614  }
615 
620  long cPtr = mainJNI.RoutingModel_compactAssignment(swigCPtr, this, Assignment.getCPtr(assignment), assignment);
621  return (cPtr == 0) ? null : new Assignment(cPtr, false);
622  }
623 
628  long cPtr = mainJNI.RoutingModel_compactAndCheckAssignment(swigCPtr, this, Assignment.getCPtr(assignment), assignment);
629  return (cPtr == 0) ? null : new Assignment(cPtr, false);
630  }
631 
635  public void addToAssignment(IntVar var) {
636  mainJNI.RoutingModel_addToAssignment(swigCPtr, this, IntVar.getCPtr(var), var);
637  }
638 
639  public void addIntervalToAssignment(IntervalVar interval) {
640  mainJNI.RoutingModel_addIntervalToAssignment(swigCPtr, this, IntervalVar.getCPtr(interval), interval);
641  }
642 
646  public Assignment PackCumulsOfOptimizerDimensionsFromAssignment(Assignment original_assignment, SWIGTYPE_p_absl__Duration duration_limit) {
647  long cPtr = mainJNI.RoutingModel_PackCumulsOfOptimizerDimensionsFromAssignment(swigCPtr, this, Assignment.getCPtr(original_assignment), original_assignment, SWIGTYPE_p_absl__Duration.getCPtr(duration_limit));
648  return (cPtr == 0) ? null : new Assignment(cPtr, false);
649  }
650 
655  mainJNI.RoutingModel_addLocalSearchFilter(swigCPtr, this, LocalSearchFilter.getCPtr(filter), filter);
656  }
657 
661  public long start(int vehicle) {
662  return mainJNI.RoutingModel_start(swigCPtr, this, vehicle);
663  }
664 
668  public long end(int vehicle) {
669  return mainJNI.RoutingModel_end(swigCPtr, this, vehicle);
670  }
671 
675  public boolean isStart(long index) {
676  return mainJNI.RoutingModel_isStart(swigCPtr, this, index);
677  }
678 
682  public boolean isEnd(long index) {
683  return mainJNI.RoutingModel_isEnd(swigCPtr, this, index);
684  }
685 
689  public int VehicleIndex(int index) {
690  return mainJNI.RoutingModel_VehicleIndex(swigCPtr, this, index);
691  }
692 
696  public long next(Assignment assignment, long index) {
697  return mainJNI.RoutingModel_next(swigCPtr, this, Assignment.getCPtr(assignment), assignment, index);
698  }
699 
703  public boolean isVehicleUsed(Assignment assignment, int vehicle) {
704  return mainJNI.RoutingModel_isVehicleUsed(swigCPtr, this, Assignment.getCPtr(assignment), assignment, vehicle);
705  }
706 
710  public IntVar[] nexts() {
711  return mainJNI.RoutingModel_nexts(swigCPtr, this);
712 }
713 
717  public IntVar[] vehicleVars() {
718  return mainJNI.RoutingModel_vehicleVars(swigCPtr, this);
719 }
720 
724  public IntVar nextVar(long index) {
725  long cPtr = mainJNI.RoutingModel_nextVar(swigCPtr, this, index);
726  return (cPtr == 0) ? null : new IntVar(cPtr, false);
727  }
728 
732  public IntVar activeVar(long index) {
733  long cPtr = mainJNI.RoutingModel_activeVar(swigCPtr, this, index);
734  return (cPtr == 0) ? null : new IntVar(cPtr, false);
735  }
736 
740  public IntVar VehicleCostsConsideredVar(int vehicle) {
741  long cPtr = mainJNI.RoutingModel_VehicleCostsConsideredVar(swigCPtr, this, vehicle);
742  return (cPtr == 0) ? null : new IntVar(cPtr, false);
743  }
744 
748  public IntVar vehicleVar(long index) {
749  long cPtr = mainJNI.RoutingModel_vehicleVar(swigCPtr, this, index);
750  return (cPtr == 0) ? null : new IntVar(cPtr, false);
751  }
752 
756  public IntVar costVar() {
757  long cPtr = mainJNI.RoutingModel_costVar(swigCPtr, this);
758  return (cPtr == 0) ? null : new IntVar(cPtr, false);
759  }
760 
764  public long getArcCostForVehicle(long from_index, long to_index, long vehicle) {
765  return mainJNI.RoutingModel_getArcCostForVehicle(swigCPtr, this, from_index, to_index, vehicle);
766  }
767 
772  return mainJNI.RoutingModel_costsAreHomogeneousAcrossVehicles(swigCPtr, this);
773  }
774 
778  public long getHomogeneousCost(long from_index, long to_index) {
779  return mainJNI.RoutingModel_getHomogeneousCost(swigCPtr, this, from_index, to_index);
780  }
781 
785  public long getArcCostForFirstSolution(long from_index, long to_index) {
786  return mainJNI.RoutingModel_getArcCostForFirstSolution(swigCPtr, this, from_index, to_index);
787  }
788 
792  public long getArcCostForClass(long from_index, long to_index, long cost_class_index) {
793  return mainJNI.RoutingModel_getArcCostForClass(swigCPtr, this, from_index, to_index, cost_class_index);
794  }
795 
799  public int getCostClassIndexOfVehicle(long vehicle) {
800  return mainJNI.RoutingModel_getCostClassIndexOfVehicle(swigCPtr, this, vehicle);
801 }
802 
806  public boolean hasVehicleWithCostClassIndex(int cost_class_index) {
807  return mainJNI.RoutingModel_hasVehicleWithCostClassIndex(swigCPtr, this, cost_class_index);
808  }
809 
813  public int getCostClassesCount() {
814  return mainJNI.RoutingModel_getCostClassesCount(swigCPtr, this);
815  }
816 
821  return mainJNI.RoutingModel_getNonZeroCostClassesCount(swigCPtr, this);
822  }
823 
824  public int getVehicleClassIndexOfVehicle(long vehicle) {
825  return mainJNI.RoutingModel_getVehicleClassIndexOfVehicle(swigCPtr, this, vehicle);
826 }
827 
831  public int getVehicleClassesCount() {
832  return mainJNI.RoutingModel_getVehicleClassesCount(swigCPtr, this);
833  }
834 
838  public int[] getSameVehicleIndicesOfIndex(int node) {
839  return mainJNI.RoutingModel_getSameVehicleIndicesOfIndex(swigCPtr, this, node);
840 }
841 
845  public boolean arcIsMoreConstrainedThanArc(long from, long to1, long to2) {
846  return mainJNI.RoutingModel_arcIsMoreConstrainedThanArc(swigCPtr, this, from, to1, to2);
847  }
848 
852  public String debugOutputAssignment(Assignment solution_assignment, String dimension_to_print) {
853  return mainJNI.RoutingModel_debugOutputAssignment(swigCPtr, this, Assignment.getCPtr(solution_assignment), solution_assignment, dimension_to_print);
854  }
855 
859  public Solver solver() {
860  long cPtr = mainJNI.RoutingModel_solver(swigCPtr, this);
861  return (cPtr == 0) ? null : new Solver(cPtr, false);
862  }
863 
867  public boolean checkLimit() {
868  return mainJNI.RoutingModel_checkLimit(swigCPtr, this);
869  }
870 
874  public SWIGTYPE_p_absl__Duration RemainingTime() {
875  return new SWIGTYPE_p_absl__Duration(mainJNI.RoutingModel_RemainingTime(swigCPtr, this), true);
876  }
877 
881  public int nodes() {
882  return mainJNI.RoutingModel_nodes(swigCPtr, this);
883  }
884 
888  public int vehicles() {
889  return mainJNI.RoutingModel_vehicles(swigCPtr, this);
890  }
891 
895  public long size() {
896  return mainJNI.RoutingModel_size(swigCPtr, this);
897  }
898 
903  return mainJNI.RoutingModel_getNumberOfDecisionsInFirstSolution(swigCPtr, this, search_parameters.toByteArray());
904  }
905 
907  return mainJNI.RoutingModel_getNumberOfRejectsInFirstSolution(swigCPtr, this, search_parameters.toByteArray());
908  }
909 
913  public boolean isMatchingModel() {
914  return mainJNI.RoutingModel_isMatchingModel(swigCPtr, this);
915  }
916 
920  public DecisionBuilder makeGuidedSlackFinalizer(RoutingDimension dimension, LongUnaryOperator initializer) {
921  long cPtr = mainJNI.RoutingModel_makeGuidedSlackFinalizer(swigCPtr, this, RoutingDimension.getCPtr(dimension), dimension, initializer);
922  return (cPtr == 0) ? null : new DecisionBuilder(cPtr, false);
923  }
924 
929  long cPtr = mainJNI.RoutingModel_makeSelfDependentDimensionFinalizer(swigCPtr, this, RoutingDimension.getCPtr(dimension), dimension);
930  return (cPtr == 0) ? null : new DecisionBuilder(cPtr, false);
931  }
932 
933  public void addMatrixDimension(long[][] values, long capacity, boolean fix_start_cumul_to_zero, String name) {
934  mainJNI.RoutingModel_addMatrixDimension(swigCPtr, this, values, capacity, fix_start_cumul_to_zero, name);
935  }
936 
937  // Status
945  public final static int ROUTING_NOT_SOLVED = mainJNI.RoutingModel_ROUTING_NOT_SOLVED_get();
949  public final static int ROUTING_SUCCESS = mainJNI.RoutingModel_ROUTING_SUCCESS_get();
953  public final static int ROUTING_FAIL = mainJNI.RoutingModel_ROUTING_FAIL_get();
957  public final static int ROUTING_FAIL_TIMEOUT = mainJNI.RoutingModel_ROUTING_FAIL_TIMEOUT_get();
961  public final static int ROUTING_INVALID = mainJNI.RoutingModel_ROUTING_INVALID_get();
962 
963  // PickupAndDeliveryPolicy
971  public final static int PICKUP_AND_DELIVERY_NO_ORDER = mainJNI.RoutingModel_PICKUP_AND_DELIVERY_NO_ORDER_get();
975  public final static int PICKUP_AND_DELIVERY_LIFO = mainJNI.RoutingModel_PICKUP_AND_DELIVERY_LIFO_get();
979  public final static int PICKUP_AND_DELIVERY_FIFO = mainJNI.RoutingModel_PICKUP_AND_DELIVERY_FIFO_get();
980 
981 }
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 ...
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.
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.
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
int RegisterPositiveUnaryTransitCallback(LongUnaryOperator callback)
Assignment PackCumulsOfOptimizerDimensionsFromAssignment(Assignment original_assignment, SWIGTYPE_p_absl__Duration duration_limit)
For every dimension in the model with an optimizer in local/global_dimension_optimizers_,...
int VehicleIndex(int index)
Returns the vehicle of the given start/end index, and -1 if the given index is not a vehicle start/en...
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.
IntVar vehicleVar(long index)
Returns the vehicle variable of the node corresponding to index.
int registerPositiveTransitCallback(LongBinaryOperator callback)
IntVar applyLocks(long[] locks)
Applies a lock chain to the next search.
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...
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".
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.
boolean writeAssignment(String file_name)
Writes the current solution to a file containing an AssignmentProto.
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.
void setVisitType(long index, int type)
Set the node visit types and incompatibilities/requirements between the types (see below).
SWIGTYPE_p_std__vectorT_std__unique_ptrT_operations_research__LocalDimensionCumulOptimizer_t_t GetLocalDimensionCumulOptimizers()
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'.
void addSearchMonitor(SearchMonitor monitor)
Adds a search monitor to the search used to solve the routing model.
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)
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 contraint 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.
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.
long [] getDisjunctionIndices(int index)
Returns the variable indices of the nodes in the disjunction of index 'index'.
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.
boolean 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; ...
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.
SWIGTYPE_p_absl__Duration RemainingTime()
Returns the time left in the search limit.
boolean isEnd(long index)
Returns true if 'index' represents the last node of a route.
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)
int getNonZeroCostClassesCount()
Ditto, minus the 'always zero', built-in cost class.
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.
boolean addConstantDimension(long value, long capacity, boolean fix_start_cumul_to_zero, String name)
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 (...
SWIGTYPE_p_std__vectorT_std__unique_ptrT_operations_research__GlobalDimensionCumulOptimizer_t_t GetGlobalDimensionCumulOptimizers()
Returns [global|local]_dimension_optimizers_, which are empty if the model has not been closed.
void addVariableMaximizedByFinalizer(IntVar var)
Adds a variable to maximize in the solution finalizer (see above for information on the solution fina...
void AddVariableTargetToFinalizer(IntVar var, long target)
Add a variable to set the closest possible to the target value in the solution finalizer.
Assignment restoreAssignment(Assignment solution)
Restores an assignment as a solution in the routing model and returns the new solution.
Local Search Filters are used for fast neighbor pruning.
int addDisjunction(long[] indices)
Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active.
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)
Returns a compacted version of the given assignment, in which all vehicles with id lower or equal to ...
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 std::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)
Registers 'callback' and returns its index.
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 the underlying constraint solver.
SWIGTYPE_p_operations_research__LocalDimensionCumulOptimizer GetMutableLocalCumulOptimizer(RoutingDimension dimension)
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.
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.
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().
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.
boolean 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...
RoutingDimension getDimensionOrDie(String dimension_name)
Returns a dimension from its name.
boolean hasDimension(String dimension_name)
Returns true if a dimension exists for a given dimension name.
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.
SWIGTYPE_p_operations_research__GlobalDimensionCumulOptimizer GetMutableGlobalCumulOptimizer(RoutingDimension dimension)
Returns the global/local dimension cumul optimizer for a given dimension, or nullptr if there is none...
long getNumberOfDecisionsInFirstSolution(com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters)
Returns statistics on first solution search, number of decisions sent to filters, number of decisions...
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.
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 addMatrixDimension(long[][] values, long capacity, boolean fix_start_cumul_to_zero, String name)
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.