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  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 boolean hasDimension(String dimension_name) {
146  return mainJNI.RoutingModel_hasDimension(swigCPtr, this, dimension_name);
147  }
148 
152  public RoutingDimension getDimensionOrDie(String dimension_name) {
153  return new RoutingDimension(mainJNI.RoutingModel_getDimensionOrDie(swigCPtr, this, dimension_name), false);
154  }
155 
159  public RoutingDimension getMutableDimension(String dimension_name) {
160  long cPtr = mainJNI.RoutingModel_getMutableDimension(swigCPtr, this, dimension_name);
161  return (cPtr == 0) ? null : new RoutingDimension(cPtr, false);
162  }
163 
167  public void setPrimaryConstrainedDimension(String dimension_name) {
168  mainJNI.RoutingModel_setPrimaryConstrainedDimension(swigCPtr, this, dimension_name);
169  }
170 
175  return mainJNI.RoutingModel_getPrimaryConstrainedDimension(swigCPtr, this);
176  }
177 
181  public int addDisjunction(long[] indices, long penalty, long max_cardinality) {
182  return mainJNI.RoutingModel_addDisjunction__SWIG_0(swigCPtr, this, indices, penalty, max_cardinality);
183 }
184 
188  public int addDisjunction(long[] indices, long penalty) {
189  return mainJNI.RoutingModel_addDisjunction__SWIG_1(swigCPtr, this, indices, penalty);
190 }
191 
195  public int addDisjunction(long[] indices) {
196  return mainJNI.RoutingModel_addDisjunction__SWIG_2(swigCPtr, this, indices);
197 }
198 
202  public int[] getDisjunctionIndices(long index) {
203  return mainJNI.RoutingModel_getDisjunctionIndices__SWIG_0(swigCPtr, this, index);
204 }
205 
209  public long[] getDisjunctionIndices(int index) {
210  return mainJNI.RoutingModel_getDisjunctionIndices__SWIG_1(swigCPtr, this, index);
211 }
212 
216  public long getDisjunctionPenalty(int index) {
217  return mainJNI.RoutingModel_getDisjunctionPenalty(swigCPtr, this, index);
218  }
219 
223  public long getDisjunctionMaxCardinality(int index) {
224  return mainJNI.RoutingModel_getDisjunctionMaxCardinality(swigCPtr, this, index);
225  }
226 
230  public int getNumberOfDisjunctions() {
231  return mainJNI.RoutingModel_getNumberOfDisjunctions(swigCPtr, this);
232  }
233 
238  mainJNI.RoutingModel_ignoreDisjunctionsAlreadyForcedToZero(swigCPtr, this);
239  }
240 
244  public void addSoftSameVehicleConstraint(long[] indices, long cost) {
245  mainJNI.RoutingModel_addSoftSameVehicleConstraint(swigCPtr, this, indices, cost);
246  }
247 
251  public void setAllowedVehiclesForIndex(int[] vehicles, long index) {
252  mainJNI.RoutingModel_setAllowedVehiclesForIndex(swigCPtr, this, vehicles, index);
253  }
254 
258  public boolean isVehicleAllowedForIndex(int vehicle, long index) {
259  return mainJNI.RoutingModel_isVehicleAllowedForIndex(swigCPtr, this, vehicle, index);
260  }
261 
265  public void addPickupAndDelivery(long pickup, long delivery) {
266  mainJNI.RoutingModel_addPickupAndDelivery(swigCPtr, this, pickup, delivery);
267  }
268 
272  public void addPickupAndDeliverySets(int pickup_disjunction, int delivery_disjunction) {
273  mainJNI.RoutingModel_addPickupAndDeliverySets(swigCPtr, this, pickup_disjunction, delivery_disjunction);
274  }
275 
279  public void setPickupAndDeliveryPolicyOfAllVehicles(int policy) {
280  mainJNI.RoutingModel_setPickupAndDeliveryPolicyOfAllVehicles(swigCPtr, this, policy);
281  }
282 
283  public void setPickupAndDeliveryPolicyOfVehicle(int policy, int vehicle) {
284  mainJNI.RoutingModel_setPickupAndDeliveryPolicyOfVehicle(swigCPtr, this, policy, vehicle);
285  }
286 
287  public int getPickupAndDeliveryPolicyOfVehicle(int vehicle) {
288  return mainJNI.RoutingModel_getPickupAndDeliveryPolicyOfVehicle(swigCPtr, this, vehicle);
289  }
290 
294  public int getNumOfSingletonNodes() {
295  return mainJNI.RoutingModel_getNumOfSingletonNodes(swigCPtr, this);
296  }
297 
298  public void setVisitType(long index, int type, int type_policy) {
299  mainJNI.RoutingModel_setVisitType(swigCPtr, this, index, type, type_policy);
300  }
301 
302  public int getVisitType(long index) {
303  return mainJNI.RoutingModel_getVisitType(swigCPtr, this, index);
304  }
305 
306  public int GetVisitTypePolicy(long index) {
307  return mainJNI.RoutingModel_GetVisitTypePolicy(swigCPtr, this, index);
308  }
309 
310  public int getNumberOfVisitTypes() {
311  return mainJNI.RoutingModel_getNumberOfVisitTypes(swigCPtr, this);
312  }
313 
317  public void AddRequiredTypeAlternativesWhenAddingType(int dependent_type, SWIGTYPE_p_absl__flat_hash_setT_int_t required_type_alternatives) {
318  mainJNI.RoutingModel_AddRequiredTypeAlternativesWhenAddingType(swigCPtr, this, dependent_type, SWIGTYPE_p_absl__flat_hash_setT_int_t.getCPtr(required_type_alternatives));
319  }
320 
324  public void AddRequiredTypeAlternativesWhenRemovingType(int dependent_type, SWIGTYPE_p_absl__flat_hash_setT_int_t required_type_alternatives) {
325  mainJNI.RoutingModel_AddRequiredTypeAlternativesWhenRemovingType(swigCPtr, this, dependent_type, SWIGTYPE_p_absl__flat_hash_setT_int_t.getCPtr(required_type_alternatives));
326  }
327 
331  public SWIGTYPE_p_std__vectorT_absl__flat_hash_setT_int_t_t GetRequiredTypeAlternativesWhenAddingType(int type) {
332  return new SWIGTYPE_p_std__vectorT_absl__flat_hash_setT_int_t_t(mainJNI.RoutingModel_GetRequiredTypeAlternativesWhenAddingType(swigCPtr, this, type), false);
333  }
334 
338  public SWIGTYPE_p_std__vectorT_absl__flat_hash_setT_int_t_t GetRequiredTypeAlternativesWhenRemovingType(int type) {
339  return new SWIGTYPE_p_std__vectorT_absl__flat_hash_setT_int_t_t(mainJNI.RoutingModel_GetRequiredTypeAlternativesWhenRemovingType(swigCPtr, this, type), false);
340  }
341 
345  public long unperformedPenalty(long var_index) {
346  return mainJNI.RoutingModel_unperformedPenalty(swigCPtr, this, var_index);
347  }
348 
352  public long unperformedPenaltyOrValue(long default_value, long var_index) {
353  return mainJNI.RoutingModel_unperformedPenaltyOrValue(swigCPtr, this, default_value, var_index);
354  }
355 
359  public long getDepot() {
360  return mainJNI.RoutingModel_getDepot(swigCPtr, this);
361  }
362 
366  public void setArcCostEvaluatorOfAllVehicles(int evaluator_index) {
367  mainJNI.RoutingModel_setArcCostEvaluatorOfAllVehicles(swigCPtr, this, evaluator_index);
368  }
369 
373  public void setArcCostEvaluatorOfVehicle(int evaluator_index, int vehicle) {
374  mainJNI.RoutingModel_setArcCostEvaluatorOfVehicle(swigCPtr, this, evaluator_index, vehicle);
375  }
376 
380  public void setFixedCostOfAllVehicles(long cost) {
381  mainJNI.RoutingModel_setFixedCostOfAllVehicles(swigCPtr, this, cost);
382  }
383 
387  public void setFixedCostOfVehicle(long cost, int vehicle) {
388  mainJNI.RoutingModel_setFixedCostOfVehicle(swigCPtr, this, cost, vehicle);
389  }
390 
394  public long getFixedCostOfVehicle(int vehicle) {
395  return mainJNI.RoutingModel_getFixedCostOfVehicle(swigCPtr, this, vehicle);
396  }
397 
401  public void setAmortizedCostFactorsOfAllVehicles(long linear_cost_factor, long quadratic_cost_factor) {
402  mainJNI.RoutingModel_setAmortizedCostFactorsOfAllVehicles(swigCPtr, this, linear_cost_factor, quadratic_cost_factor);
403  }
404 
408  public void setAmortizedCostFactorsOfVehicle(long linear_cost_factor, long quadratic_cost_factor, int vehicle) {
409  mainJNI.RoutingModel_setAmortizedCostFactorsOfVehicle(swigCPtr, this, linear_cost_factor, quadratic_cost_factor, vehicle);
410  }
411 
413  return mainJNI.RoutingModel_getAmortizedLinearCostFactorOfVehicles(swigCPtr, this);
414 }
415 
417  return mainJNI.RoutingModel_getAmortizedQuadraticCostFactorOfVehicles(swigCPtr, this);
418 }
419 
420  public void ConsiderEmptyRouteCostsForVehicle(boolean consider_costs, int vehicle) {
421  mainJNI.RoutingModel_ConsiderEmptyRouteCostsForVehicle(swigCPtr, this, consider_costs, vehicle);
422  }
423 
424  public boolean AreEmptyRouteCostsConsideredForVehicle(int vehicle) {
425  return mainJNI.RoutingModel_AreEmptyRouteCostsConsideredForVehicle(swigCPtr, this, vehicle);
426  }
427 
431  public void setFirstSolutionEvaluator(LongBinaryOperator evaluator) {
432  mainJNI.RoutingModel_setFirstSolutionEvaluator(swigCPtr, this, evaluator);
433  }
434 
438  public void addLocalSearchOperator(LocalSearchOperator ls_operator) {
439  mainJNI.RoutingModel_addLocalSearchOperator(swigCPtr, this, LocalSearchOperator.getCPtr(ls_operator), ls_operator);
440  }
441 
445  public void addSearchMonitor(SearchMonitor monitor) {
446  mainJNI.RoutingModel_addSearchMonitor(swigCPtr, this, SearchMonitor.getCPtr(monitor), monitor);
447  }
448 
452  public void addAtSolutionCallback(Runnable callback) {
453  mainJNI.RoutingModel_addAtSolutionCallback(swigCPtr, this, callback);
454  }
455 
460  mainJNI.RoutingModel_addVariableMinimizedByFinalizer(swigCPtr, this, IntVar.getCPtr(var), var);
461  }
462 
467  mainJNI.RoutingModel_addVariableMaximizedByFinalizer(swigCPtr, this, IntVar.getCPtr(var), var);
468  }
469 
473  public void AddWeightedVariableMinimizedByFinalizer(IntVar var, long cost) {
474  mainJNI.RoutingModel_AddWeightedVariableMinimizedByFinalizer(swigCPtr, this, IntVar.getCPtr(var), var, cost);
475  }
476 
480  public void AddVariableTargetToFinalizer(IntVar var, long target) {
481  mainJNI.RoutingModel_AddVariableTargetToFinalizer(swigCPtr, this, IntVar.getCPtr(var), var, target);
482  }
483 
487  public void closeModel() {
488  mainJNI.RoutingModel_closeModel(swigCPtr, this);
489  }
490 
495  mainJNI.RoutingModel_closeModelWithParameters(swigCPtr, this, search_parameters.toByteArray());
496  }
497 
501  public Assignment solve(Assignment assignment) {
502  long cPtr = mainJNI.RoutingModel_solve__SWIG_0(swigCPtr, this, Assignment.getCPtr(assignment), assignment);
503  return (cPtr == 0) ? null : new Assignment(cPtr, false);
504  }
505 
509  public Assignment solve() {
510  long cPtr = mainJNI.RoutingModel_solve__SWIG_1(swigCPtr, this);
511  return (cPtr == 0) ? null : new Assignment(cPtr, false);
512  }
513 
518  long cPtr = mainJNI.RoutingModel_solveWithParameters(swigCPtr, this, search_parameters.toByteArray());
519  return (cPtr == 0) ? null : new Assignment(cPtr, false);
520  }
521 
523  long cPtr = mainJNI.RoutingModel_solveFromAssignmentWithParameters(swigCPtr, this, Assignment.getCPtr(assignment), assignment, search_parameters.toByteArray());
524  return (cPtr == 0) ? null : new Assignment(cPtr, false);
525  }
526 
530  public void setAssignmentFromOtherModelAssignment(Assignment target_assignment, RoutingModel source_model, Assignment source_assignment) {
531  mainJNI.RoutingModel_setAssignmentFromOtherModelAssignment(swigCPtr, this, Assignment.getCPtr(target_assignment), target_assignment, RoutingModel.getCPtr(source_model), source_model, Assignment.getCPtr(source_assignment), source_assignment);
532  }
533 
537  public long computeLowerBound() {
538  return mainJNI.RoutingModel_computeLowerBound(swigCPtr, this);
539  }
540 
544  public int status() {
545  return mainJNI.RoutingModel_status(swigCPtr, this);
546  }
547 
551  public IntVar applyLocks(long[] locks) {
552  long cPtr = mainJNI.RoutingModel_applyLocks(swigCPtr, this, locks);
553  return (cPtr == 0) ? null : new IntVar(cPtr, false);
554  }
555 
559  public boolean applyLocksToAllVehicles(long[][] locks, boolean close_routes) {
560  return mainJNI.RoutingModel_applyLocksToAllVehicles(swigCPtr, this, locks, close_routes);
561  }
562 
567  long cPtr = mainJNI.RoutingModel_preAssignment(swigCPtr, this);
568  return (cPtr == 0) ? null : new Assignment(cPtr, false);
569  }
570 
572  long cPtr = mainJNI.RoutingModel_mutablePreAssignment(swigCPtr, this);
573  return (cPtr == 0) ? null : new Assignment(cPtr, false);
574  }
575 
579  public boolean writeAssignment(String file_name) {
580  return mainJNI.RoutingModel_writeAssignment(swigCPtr, this, file_name);
581  }
582 
586  public Assignment readAssignment(String file_name) {
587  long cPtr = mainJNI.RoutingModel_readAssignment(swigCPtr, this, file_name);
588  return (cPtr == 0) ? null : new Assignment(cPtr, false);
589  }
590 
595  long cPtr = mainJNI.RoutingModel_restoreAssignment(swigCPtr, this, Assignment.getCPtr(solution), solution);
596  return (cPtr == 0) ? null : new Assignment(cPtr, false);
597  }
598 
602  public Assignment readAssignmentFromRoutes(long[][] routes, boolean ignore_inactive_indices) {
603  long cPtr = mainJNI.RoutingModel_readAssignmentFromRoutes(swigCPtr, this, routes, ignore_inactive_indices);
604  return (cPtr == 0) ? null : new Assignment(cPtr, false);
605  }
606 
610  public boolean routesToAssignment(long[][] routes, boolean ignore_inactive_indices, boolean close_routes, Assignment assignment) {
611  return mainJNI.RoutingModel_routesToAssignment(swigCPtr, this, routes, ignore_inactive_indices, close_routes, Assignment.getCPtr(assignment), assignment);
612  }
613 
617  public void assignmentToRoutes(Assignment assignment, long[][] routes) {
618  mainJNI.RoutingModel_assignmentToRoutes(swigCPtr, this, Assignment.getCPtr(assignment), assignment, routes);
619  }
620 
625  long cPtr = mainJNI.RoutingModel_compactAssignment(swigCPtr, this, Assignment.getCPtr(assignment), assignment);
626  return (cPtr == 0) ? null : new Assignment(cPtr, false);
627  }
628 
633  long cPtr = mainJNI.RoutingModel_compactAndCheckAssignment(swigCPtr, this, Assignment.getCPtr(assignment), assignment);
634  return (cPtr == 0) ? null : new Assignment(cPtr, false);
635  }
636 
640  public void addToAssignment(IntVar var) {
641  mainJNI.RoutingModel_addToAssignment(swigCPtr, this, IntVar.getCPtr(var), var);
642  }
643 
644  public void addIntervalToAssignment(IntervalVar interval) {
645  mainJNI.RoutingModel_addIntervalToAssignment(swigCPtr, this, IntervalVar.getCPtr(interval), interval);
646  }
647 
652  mainJNI.RoutingModel_addLocalSearchFilter(swigCPtr, this, LocalSearchFilter.getCPtr(filter), filter);
653  }
654 
658  public long start(int vehicle) {
659  return mainJNI.RoutingModel_start(swigCPtr, this, vehicle);
660  }
661 
665  public long end(int vehicle) {
666  return mainJNI.RoutingModel_end(swigCPtr, this, vehicle);
667  }
668 
672  public boolean isStart(long index) {
673  return mainJNI.RoutingModel_isStart(swigCPtr, this, index);
674  }
675 
679  public boolean isEnd(long index) {
680  return mainJNI.RoutingModel_isEnd(swigCPtr, this, index);
681  }
682 
686  public int VehicleIndex(int index) {
687  return mainJNI.RoutingModel_VehicleIndex(swigCPtr, this, index);
688  }
689 
693  public long next(Assignment assignment, long index) {
694  return mainJNI.RoutingModel_next(swigCPtr, this, Assignment.getCPtr(assignment), assignment, index);
695  }
696 
700  public boolean isVehicleUsed(Assignment assignment, int vehicle) {
701  return mainJNI.RoutingModel_isVehicleUsed(swigCPtr, this, Assignment.getCPtr(assignment), assignment, vehicle);
702  }
703 
707  public IntVar[] nexts() {
708  return mainJNI.RoutingModel_nexts(swigCPtr, this);
709 }
710 
714  public IntVar[] vehicleVars() {
715  return mainJNI.RoutingModel_vehicleVars(swigCPtr, this);
716 }
717 
721  public IntVar nextVar(long index) {
722  long cPtr = mainJNI.RoutingModel_nextVar(swigCPtr, this, index);
723  return (cPtr == 0) ? null : new IntVar(cPtr, false);
724  }
725 
729  public IntVar activeVar(long index) {
730  long cPtr = mainJNI.RoutingModel_activeVar(swigCPtr, this, index);
731  return (cPtr == 0) ? null : new IntVar(cPtr, false);
732  }
733 
737  public IntVar VehicleCostsConsideredVar(int vehicle) {
738  long cPtr = mainJNI.RoutingModel_VehicleCostsConsideredVar(swigCPtr, this, vehicle);
739  return (cPtr == 0) ? null : new IntVar(cPtr, false);
740  }
741 
745  public IntVar vehicleVar(long index) {
746  long cPtr = mainJNI.RoutingModel_vehicleVar(swigCPtr, this, index);
747  return (cPtr == 0) ? null : new IntVar(cPtr, false);
748  }
749 
753  public IntVar costVar() {
754  long cPtr = mainJNI.RoutingModel_costVar(swigCPtr, this);
755  return (cPtr == 0) ? null : new IntVar(cPtr, false);
756  }
757 
761  public long getArcCostForVehicle(long from_index, long to_index, long vehicle) {
762  return mainJNI.RoutingModel_getArcCostForVehicle(swigCPtr, this, from_index, to_index, vehicle);
763  }
764 
769  return mainJNI.RoutingModel_costsAreHomogeneousAcrossVehicles(swigCPtr, this);
770  }
771 
775  public long getHomogeneousCost(long from_index, long to_index) {
776  return mainJNI.RoutingModel_getHomogeneousCost(swigCPtr, this, from_index, to_index);
777  }
778 
782  public long getArcCostForFirstSolution(long from_index, long to_index) {
783  return mainJNI.RoutingModel_getArcCostForFirstSolution(swigCPtr, this, from_index, to_index);
784  }
785 
789  public long getArcCostForClass(long from_index, long to_index, long cost_class_index) {
790  return mainJNI.RoutingModel_getArcCostForClass(swigCPtr, this, from_index, to_index, cost_class_index);
791  }
792 
796  public int getCostClassIndexOfVehicle(long vehicle) {
797  return mainJNI.RoutingModel_getCostClassIndexOfVehicle(swigCPtr, this, vehicle);
798 }
799 
803  public boolean hasVehicleWithCostClassIndex(int cost_class_index) {
804  return mainJNI.RoutingModel_hasVehicleWithCostClassIndex(swigCPtr, this, cost_class_index);
805  }
806 
810  public int getCostClassesCount() {
811  return mainJNI.RoutingModel_getCostClassesCount(swigCPtr, this);
812  }
813 
818  return mainJNI.RoutingModel_getNonZeroCostClassesCount(swigCPtr, this);
819  }
820 
821  public int getVehicleClassIndexOfVehicle(long vehicle) {
822  return mainJNI.RoutingModel_getVehicleClassIndexOfVehicle(swigCPtr, this, vehicle);
823 }
824 
828  public int getVehicleClassesCount() {
829  return mainJNI.RoutingModel_getVehicleClassesCount(swigCPtr, this);
830  }
831 
835  public int[] getSameVehicleIndicesOfIndex(int node) {
836  return mainJNI.RoutingModel_getSameVehicleIndicesOfIndex(swigCPtr, this, node);
837 }
838 
842  public boolean arcIsMoreConstrainedThanArc(long from, long to1, long to2) {
843  return mainJNI.RoutingModel_arcIsMoreConstrainedThanArc(swigCPtr, this, from, to1, to2);
844  }
845 
849  public String debugOutputAssignment(Assignment solution_assignment, String dimension_to_print) {
850  return mainJNI.RoutingModel_debugOutputAssignment(swigCPtr, this, Assignment.getCPtr(solution_assignment), solution_assignment, dimension_to_print);
851  }
852 
856  public Solver solver() {
857  long cPtr = mainJNI.RoutingModel_solver(swigCPtr, this);
858  return (cPtr == 0) ? null : new Solver(cPtr, false);
859  }
860 
864  public boolean checkLimit() {
865  return mainJNI.RoutingModel_checkLimit(swigCPtr, this);
866  }
867 
871  public int nodes() {
872  return mainJNI.RoutingModel_nodes(swigCPtr, this);
873  }
874 
878  public int vehicles() {
879  return mainJNI.RoutingModel_vehicles(swigCPtr, this);
880  }
881 
885  public long size() {
886  return mainJNI.RoutingModel_size(swigCPtr, this);
887  }
888 
893  return mainJNI.RoutingModel_getNumberOfDecisionsInFirstSolution(swigCPtr, this, search_parameters.toByteArray());
894  }
895 
897  return mainJNI.RoutingModel_getNumberOfRejectsInFirstSolution(swigCPtr, this, search_parameters.toByteArray());
898  }
899 
903  public boolean isMatchingModel() {
904  return mainJNI.RoutingModel_isMatchingModel(swigCPtr, this);
905  }
906 
910  public DecisionBuilder makeGuidedSlackFinalizer(RoutingDimension dimension, LongUnaryOperator initializer) {
911  long cPtr = mainJNI.RoutingModel_makeGuidedSlackFinalizer(swigCPtr, this, RoutingDimension.getCPtr(dimension), dimension, initializer);
912  return (cPtr == 0) ? null : new DecisionBuilder(cPtr, false);
913  }
914 
919  long cPtr = mainJNI.RoutingModel_makeSelfDependentDimensionFinalizer(swigCPtr, this, RoutingDimension.getCPtr(dimension), dimension);
920  return (cPtr == 0) ? null : new DecisionBuilder(cPtr, false);
921  }
922 
923  public void addMatrixDimension(long[][] values, long capacity, boolean fix_start_cumul_to_zero, String name) {
924  mainJNI.RoutingModel_addMatrixDimension(swigCPtr, this, values, capacity, fix_start_cumul_to_zero, name);
925  }
926 
927  // Status
935  public final static int ROUTING_NOT_SOLVED = mainJNI.RoutingModel_ROUTING_NOT_SOLVED_get();
939  public final static int ROUTING_SUCCESS = mainJNI.RoutingModel_ROUTING_SUCCESS_get();
943  public final static int ROUTING_FAIL = mainJNI.RoutingModel_ROUTING_FAIL_get();
947  public final static int ROUTING_FAIL_TIMEOUT = mainJNI.RoutingModel_ROUTING_FAIL_TIMEOUT_get();
951  public final static int ROUTING_INVALID = mainJNI.RoutingModel_ROUTING_INVALID_get();
952 
953  // PickupAndDeliveryPolicy
961  public final static int PICKUP_AND_DELIVERY_NO_ORDER = mainJNI.RoutingModel_PICKUP_AND_DELIVERY_NO_ORDER_get();
965  public final static int PICKUP_AND_DELIVERY_LIFO = mainJNI.RoutingModel_PICKUP_AND_DELIVERY_LIFO_get();
969  public final static int PICKUP_AND_DELIVERY_FIFO = mainJNI.RoutingModel_PICKUP_AND_DELIVERY_FIFO_get();
970 
971  // VisitTypePolicy
979  public final static int TYPE_ADDED_TO_VEHICLE = mainJNI.RoutingModel_TYPE_ADDED_TO_VEHICLE_get();
983  public final static int ADDED_TYPE_REMOVED_FROM_VEHICLE = mainJNI.RoutingModel_ADDED_TYPE_REMOVED_FROM_VEHICLE_get();
987  public final static int TYPE_ON_VEHICLE_UP_TO_VISIT = mainJNI.RoutingModel_TYPE_ON_VEHICLE_UP_TO_VISIT_get();
991  public final static int TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = mainJNI.RoutingModel_TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED_get();
992 
993 }
static final int ADDED_TYPE_REMOVED_FROM_VEHICLE
When visited, one instance of type 'T' previously added to the route (TYPE_ADDED_TO_VEHICLE),...
boolean isStart(long index)
Returns true if 'index' represents the first node of a route.
IntVar[] nexts()
Returns all next variables of the model, such that Nexts(i) is the next variable of the node correspo...
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...
A constraint is the main modeling object.
void addLocalSearchFilter(LocalSearchFilter filter)
Adds a custom local search filter to the list of filters used to speed up local search by pruning unf...
Constraint MakePathSpansAndTotalSlacks(RoutingDimension dimension, IntVar[] spans, IntVar[] total_slacks)
For every vehicle of the routing model: - if total_slacks[vehicle] is not nullptr,...
Manager for any NodeIndex <-> variable index conversion.
void setAmortizedCostFactorsOfVehicle(long linear_cost_factor, long quadratic_cost_factor, int vehicle)
Sets the linear and quadratic cost factor of the given vehicle.
void ignoreDisjunctionsAlreadyForcedToZero()
SPECIAL: Makes the solver ignore all the disjunctions whose active variables are all trivially zero (...
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.
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.
void addAtSolutionCallback(Runnable callback)
Adds a callback called each time a solution is found during the search.
int[] getSameVehicleIndicesOfIndex(int node)
Returns variable indices of nodes constrained to be on the same route.
int getVehicleClassIndexOfVehicle(long vehicle)
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...
RoutingModel(long cPtr, boolean cMemoryOwn)
int getNumberOfDisjunctions()
Returns the number of node disjunctions in the model.
long size()
Returns the number of next variables in the model.
void setPickupAndDeliveryPolicyOfAllVehicles(int policy)
Sets the Pickup and delivery policy of all vehicles.
Assignment solve(Assignment assignment)
Solves the current routing model; closes the current model.
IntVar[] vehicleVars()
Returns all vehicle variables of the model, such that VehicleVars(i) is the vehicle variable of the n...
void setVisitType(long index, int type, int type_policy)
void ConsiderEmptyRouteCostsForVehicle(boolean consider_costs, int vehicle)
IntVar applyLocks(long[] locks)
Applies a lock chain to the next search.
String getPrimaryConstrainedDimension()
Get the primary constrained dimension, or an empty string if it is unset.
int getVehicleClassesCount()
Returns the number of different vehicle classes in the model.
void addLocalSearchOperator(LocalSearchOperator ls_operator)
Adds a local search operator to the set of operators used to solve the vehicle routing problem.
boolean isVehicleUsed(Assignment assignment, int vehicle)
Returns true if the route of 'vehicle' is non empty in 'assignment'.
int RegisterPositiveUnaryTransitCallback(LongUnaryOperator callback)
void addMatrixDimension(long[][] values, long capacity, boolean fix_start_cumul_to_zero, String name)
IntVar costVar()
Returns the global cost variable which is being minimized.
static int getKNoDimension()
Constant used to express the "no dimension" index, returned when a dimension name does not correspond...
long computeLowerBound()
Computes a lower bound to the routing problem solving a linear assignment problem.
IntVar VehicleCostsConsideredVar(int vehicle)
Returns the variable specifying whether or not costs are considered for vehicle.
void setFirstSolutionEvaluator(LongBinaryOperator evaluator)
Gets/sets the evaluator used during the search.
int GetVisitTypePolicy(long index)
void setAllowedVehiclesForIndex(int[] vehicles, long index)
Sets the vehicles which can visit a given node.
long getArcCostForFirstSolution(long from_index, long to_index)
Returns the cost of the arc in the context of the first solution strategy.
Assignment compactAssignment(Assignment assignment)
Returns a compacted version of the given assignment, in which all vehicles with id lower or equal to ...
The class IntVar is a subset of IntExpr.
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 costsAreHomogeneousAcrossVehicles()
Whether costs are homogeneous across all vehicles.
void setFixedCostOfVehicle(long cost, int vehicle)
Sets the fixed cost of one vehicle route.
static final int ROUTING_INVALID
Model, model parameters or flags are not valid.
void setFixedCostOfAllVehicles(long cost)
Sets the fixed cost of all vehicle routes.
Assignment readAssignment(String file_name)
Reads an assignment from a file and returns the current solution.
A DecisionBuilder is responsible for creating the search tree.
long getDisjunctionMaxCardinality(int index)
Returns the maximum number of possible active nodes of the node disjunction of index 'index'.
void AddWeightedVariableMinimizedByFinalizer(IntVar var, long cost)
Adds a variable to minimize in the solution finalizer, with a weighted priority: the higher the more ...
void setArcCostEvaluatorOfVehicle(int evaluator_index, int vehicle)
Sets the cost function for a given vehicle route.
int getCostClassesCount()
Returns the number of different cost classes in the model.
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...
RoutingModel(RoutingIndexManager index_manager, com.google.ortools.constraintsolver.RoutingModelParameters parameters)
void setPickupAndDeliveryPolicyOfVehicle(int policy, int vehicle)
int addDisjunction(long[] indices, long penalty)
Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active.
Assignment readAssignmentFromRoutes(long[][] routes, boolean ignore_inactive_indices)
Restores the routes as the current solution.
boolean addDimensionWithVehicleTransits(int[] evaluator_indices, long slack_max, long capacity, boolean fix_start_cumul_to_zero, String name)
boolean hasDimension(String dimension_name)
Returns true if a dimension exists for a given dimension name.
int vehicles()
Returns the number of vehicle routes in the model.
void AddVariableTargetToFinalizer(IntVar var, long target)
Add a variable to set the closest possible to the target value in the solution finalizer.
boolean addDimensionWithVehicleCapacity(int evaluator_index, long slack_max, long[] vehicle_capacities, boolean fix_start_cumul_to_zero, String name)
String debugOutputAssignment(Assignment solution_assignment, String dimension_to_print)
Print some debugging information about an assignment, including the feasible intervals of the CumulVa...
Assignment solveFromAssignmentWithParameters(Assignment assignment, com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters)
static int getKNoDisjunction()
Constant used to express the "no disjunction" index, returned when a node does not appear in any disj...
long getDisjunctionPenalty(int index)
Returns the penalty of the node disjunction of index 'index'.
Assignment compactAndCheckAssignment(Assignment assignment)
Same as CompactAssignment() but also checks the validity of the final compact solution; if it is not ...
boolean writeAssignment(String file_name)
Writes the current solution to a file containing an AssignmentProto.
RoutingModel(RoutingIndexManager index_manager)
Constructor taking an index manager.
RoutingDimension getMutableDimension(String dimension_name)
Returns a dimension from its name.
static final int ROUTING_NOT_SOLVED
Status of the search.
int registerTransitCallback(LongBinaryOperator callback)
IntVar activeVar(long index)
Returns the active variable of the node corresponding to index.
This class represent a reversible FIFO structure.
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.
int getNumOfSingletonNodes()
Returns the number of non-start/end nodes which do not appear in a pickup/delivery pair.
An Assignment is a variable -> domains mapping, used to report solutions to the user.
Definition: Assignment.java:14
void addVariableMinimizedByFinalizer(IntVar var)
Adds a variable to minimize in the solution finalizer.
IntVar nextVar(long index)
Returns the next variable of the node corresponding to index.
Assignment solve()
Solves the current routing model; closes the current model.
boolean isVehicleAllowedForIndex(int vehicle, long index)
Returns true if a vehicle is allowed to visit a given node.
static final int PICKUP_AND_DELIVERY_FIFO
Deliveries must be performed in the same order as pickups.
static final int ROUTING_SUCCESS
Problem solved successfully after calling RoutingModel::Solve().
boolean checkLimit()
Returns true if the search limit has been crossed.
static final int PICKUP_AND_DELIVERY_LIFO
Deliveries must be performed in reverse order of pickups.
void addToAssignment(IntVar var)
Adds an extra variable to the vehicle routing assignment.
DecisionBuilder makeGuidedSlackFinalizer(RoutingDimension dimension, LongUnaryOperator initializer)
The next few members are in the public section only for testing purposes.
void addSearchMonitor(SearchMonitor monitor)
Adds a search monitor to the search used to solve the routing model.
void addPickupAndDeliverySets(int pickup_disjunction, int delivery_disjunction)
Same as AddPickupAndDelivery but notifying that the performed node from the disjunction of index 'pic...
long end(int vehicle)
Returns the variable index of the ending node of a vehicle route.
boolean addDimensionWithVehicleTransitAndCapacity(int[] evaluator_indices, long slack_max, long[] vehicle_capacities, boolean fix_start_cumul_to_zero, String name)
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)...
int registerUnaryTransitCallback(LongUnaryOperator callback)
Registers 'callback' and returns its index.
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...
long[] getAmortizedQuadraticCostFactorOfVehicles()
Assignment restoreAssignment(Assignment solution)
Restores an assignment as a solution in the routing model and returns the new solution.
IntVar vehicleVar(long index)
Returns the vehicle variable of the node corresponding to index.
A search monitor is a simple set of callbacks to monitor all search events.
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; ...
int status()
Returns the current status of the routing model.
DecisionBuilder makeSelfDependentDimensionFinalizer(RoutingDimension dimension)
MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a self-dependent dimension.
long[] getDisjunctionIndices(int index)
Returns the variable indices of the nodes in the disjunction of index 'index'.
static final int ROUTING_FAIL_TIMEOUT
Time limit reached before finding a solution with RoutingModel::Solve().
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.
int addDisjunction(long[] indices)
Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active.
void addIntervalToAssignment(IntervalVar interval)
long getNumberOfDecisionsInFirstSolution(com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters)
Returns statistics on first solution search, number of decisions sent to filters, number of decisions...
long getArcCostForVehicle(long from_index, long to_index, long vehicle)
Returns the cost of the transit arc between two nodes for a given vehicle.
void assignmentToRoutes(Assignment assignment, long[][] routes)
Converts the solution in the given assignment to routes for all vehicles.
static long getKNoPenalty()
Constant used to express a hard constraint instead of a soft penalty.
Assignment mutablePreAssignment()
long next(Assignment assignment, long index)
Assignment inspection Returns the variable index of the node directly after the node corresponding to...
long unperformedPenalty(long var_index)
Get the "unperformed" penalty of a node.
boolean AreEmptyRouteCostsConsideredForVehicle(int vehicle)
long getFixedCostOfVehicle(int vehicle)
Returns the route fixed cost taken into account if the route of the vehicle is not empty,...
long getDepot()
Returns the variable index of the first starting or ending node of all routes.
Dimensions represent quantities accumulated at nodes along the routes.
int nodes()
Sizes and indices Returns the number of nodes in the model.
boolean hasVehicleWithCostClassIndex(int cost_class_index)
Returns true iff the model contains a vehicle with the given cost_class_index.
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...
Local Search Filters are used for fast neighbor pruning.
RoutingDimension getDimensionOrDie(String dimension_name)
Returns a dimension from its name.
void closeModel()
Closes the current routing model; after this method is called, no modification to the model can be do...
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 addConstantDimension(long value, long capacity, boolean fix_start_cumul_to_zero, String name)
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...
long getNumberOfRejectsInFirstSolution(com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters)
Assignment preAssignment()
Returns an assignment used to fix some of the variables of the problem.
int getCostClassIndexOfVehicle(long vehicle)
Get the cost class index of the given vehicle.
int[] getDisjunctionIndices(long index)
Returns the indices of the disjunctions to which an index belongs.
void addSoftSameVehicleConstraint(long[] indices, long cost)
Adds a soft contraint to force a set of variable indices to be on the same vehicle.
static final int TYPE_ADDED_TO_VEHICLE
Set the node visit types and incompatibilities/requirements between the types (see below).
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...
Assignment solveWithParameters(com.google.ortools.constraintsolver.RoutingSearchParameters search_parameters)
Solves the current routing model with the given parameters.
void addPickupAndDelivery(long pickup, long delivery)
Notifies that index1 and index2 form a pair of nodes which should belong to the same route.
Interval variables are often used in scheduling.
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...
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,...
int getPickupAndDeliveryPolicyOfVehicle(int vehicle)
boolean arcIsMoreConstrainedThanArc(long from, long to1, long to2)
Returns whether the arc from->to1 is more constrained than from->to2, taking into account,...
int addDisjunction(long[] indices, long penalty, long max_cardinality)
Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active.
void addVariableMaximizedByFinalizer(IntVar var)
Adds a variable to maximize in the solution finalizer (see above for information on the solution fina...
long[] getAmortizedLinearCostFactorOfVehicles()
static final int ROUTING_FAIL
No solution found to the problem after calling RoutingModel::Solve().
int getNumberOfVisitTypes()
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...
static final int PICKUP_AND_DELIVERY_NO_ORDER
Types of precedence policy applied to pickup and delivery pairs.
int registerPositiveTransitCallback(LongBinaryOperator callback)
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...
Solver solver()
Returns the underlying constraint solver.
boolean isMatchingModel()
Returns true if a vehicle/node matching problem is detected.
Solver Class A solver represents the main computation engine.
Definition: Solver.java:57
int getNonZeroCostClassesCount()
Ditto, minus the 'always zero', built-in cost class.
int getVisitType(long index)
void setPrimaryConstrainedDimension(String dimension_name)
Set the given dimension as "primary constrained".
long start(int vehicle)
Model inspection.
boolean isEnd(long index)
Returns true if 'index' represents the last node of a route.