7from sys
import version_info
as _swig_python_version_info
9if __package__
or "." in __name__:
10 from .
import _pywrapcp
15 import builtins
as __builtin__
21 strthis =
"proxy of " + self.this.__repr__()
22 except __builtin__.Exception:
24 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
28 def set_instance_attr(self, name, value):
30 set(self, name, value)
31 elif name ==
"thisown":
33 elif hasattr(self, name)
and isinstance(getattr(type(self), name), property):
34 set(self, name, value)
36 raise AttributeError(
"You cannot add instance attributes to %s" % self)
37 return set_instance_attr
41 def set_class_attr(cls, name, value):
42 if hasattr(cls, name)
and not isinstance(getattr(cls, name), property):
45 raise AttributeError(
"You cannot add class attributes to %s" % cls)
50 """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
52 return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
57 """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
65 This struct holds all parameters for the default search.
66 DefaultPhaseParameters is only used by Solver::MakeDefaultPhase methods.
67 Note this is for advanced users only.
70 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
72 CHOOSE_MAX_SUM_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_SUM_IMPACT
73 CHOOSE_MAX_AVERAGE_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_AVERAGE_IMPACT
74 CHOOSE_MAX_VALUE_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_VALUE_IMPACT
75 SELECT_MIN_IMPACT = _pywrapcp.DefaultPhaseParameters_SELECT_MIN_IMPACT
76 SELECT_MAX_IMPACT = _pywrapcp.DefaultPhaseParameters_SELECT_MAX_IMPACT
77 NONE = _pywrapcp.DefaultPhaseParameters_NONE
78 NORMAL = _pywrapcp.DefaultPhaseParameters_NORMAL
79 VERBOSE = _pywrapcp.DefaultPhaseParameters_VERBOSE
80 var_selection_schema = property(_pywrapcp.DefaultPhaseParameters_var_selection_schema_get, _pywrapcp.DefaultPhaseParameters_var_selection_schema_set, doc=
r"""
81 This parameter describes how the next variable to instantiate
84 value_selection_schema = property(_pywrapcp.DefaultPhaseParameters_value_selection_schema_get, _pywrapcp.DefaultPhaseParameters_value_selection_schema_set, doc=
r""" This parameter describes which value to select for a given var.""")
85 initialization_splits = property(_pywrapcp.DefaultPhaseParameters_initialization_splits_get, _pywrapcp.DefaultPhaseParameters_initialization_splits_set, doc=
r"""
86 Maximum number of intervals that the initialization of impacts will scan
89 run_all_heuristics = property(_pywrapcp.DefaultPhaseParameters_run_all_heuristics_get, _pywrapcp.DefaultPhaseParameters_run_all_heuristics_set, doc=
r"""
90 The default phase will run heuristics periodically. This parameter
91 indicates if we should run all heuristics, or a randomly selected
94 heuristic_period = property(_pywrapcp.DefaultPhaseParameters_heuristic_period_get, _pywrapcp.DefaultPhaseParameters_heuristic_period_set, doc=
r"""
95 The distance in nodes between each run of the heuristics. A
96 negative or null value will mean that we will not run heuristics
99 heuristic_num_failures_limit = property(_pywrapcp.DefaultPhaseParameters_heuristic_num_failures_limit_get, _pywrapcp.DefaultPhaseParameters_heuristic_num_failures_limit_set, doc=
r""" The failure limit for each heuristic that we run.""")
100 persistent_impact = property(_pywrapcp.DefaultPhaseParameters_persistent_impact_get, _pywrapcp.DefaultPhaseParameters_persistent_impact_set, doc=
r"""
101 Whether to keep the impact from the first search for other searches,
102 or to recompute the impact for each new search.
104 random_seed = property(_pywrapcp.DefaultPhaseParameters_random_seed_get, _pywrapcp.DefaultPhaseParameters_random_seed_set, doc=
r""" Seed used to initialize the random part in some heuristics.""")
105 display_level = property(_pywrapcp.DefaultPhaseParameters_display_level_get, _pywrapcp.DefaultPhaseParameters_display_level_set, doc=
r"""
106 This represents the amount of information displayed by the default search.
107 NONE means no display, VERBOSE means extra information.
109 decision_builder = property(_pywrapcp.DefaultPhaseParameters_decision_builder_get, _pywrapcp.DefaultPhaseParameters_decision_builder_set, doc=
r""" When defined, this overrides the default impact based decision builder.""")
112 _pywrapcp.DefaultPhaseParameters_swiginit(self, _pywrapcp.new_DefaultPhaseParameters())
113 __swig_destroy__ = _pywrapcp.delete_DefaultPhaseParameters
116_pywrapcp.DefaultPhaseParameters_swigregister(DefaultPhaseParameters)
121 A solver represents the main computation engine. It implements the entire
122 range of Constraint Programming protocols:
127 Usually, Constraint Programming code consists of
128 - the creation of the Solver,
129 - the creation of the decision variables of the model,
130 - the creation of the constraints of the model and their addition to the
131 solver() through the AddConstraint() method,
132 - the creation of the main DecisionBuilder class,
133 - the launch of the solve() method with the decision builder.
135 For the time being, Solver is neither MT_SAFE nor MT_HOT.
138 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
139 __repr__ = _swig_repr
140 INT_VAR_DEFAULT = _pywrapcp.Solver_INT_VAR_DEFAULT
141 r""" The default behavior is CHOOSE_FIRST_UNBOUND."""
142 INT_VAR_SIMPLE = _pywrapcp.Solver_INT_VAR_SIMPLE
143 r""" The simple selection is CHOOSE_FIRST_UNBOUND."""
144 CHOOSE_FIRST_UNBOUND = _pywrapcp.Solver_CHOOSE_FIRST_UNBOUND
146 Select the first unbound variable.
147 Variables are considered in the order of the vector of IntVars used
148 to create the selector.
150 CHOOSE_RANDOM = _pywrapcp.Solver_CHOOSE_RANDOM
151 r""" Randomly select one of the remaining unbound variables."""
152 CHOOSE_MIN_SIZE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MIN
154 Among unbound variables, select the variable with the smallest size,
155 i.e., the smallest number of possible values.
156 In case of a tie, the selected variables is the one with the lowest min
158 In case of a tie, the first one is selected, first being defined by the
159 order in the vector of IntVars used to create the selector.
161 CHOOSE_MIN_SIZE_HIGHEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MIN
163 Among unbound variables, select the variable with the smallest size,
164 i.e., the smallest number of possible values.
165 In case of a tie, the selected variable is the one with the highest min
167 In case of a tie, the first one is selected, first being defined by the
168 order in the vector of IntVars used to create the selector.
170 CHOOSE_MIN_SIZE_LOWEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MAX
172 Among unbound variables, select the variable with the smallest size,
173 i.e., the smallest number of possible values.
174 In case of a tie, the selected variables is the one with the lowest max
176 In case of a tie, the first one is selected, first being defined by the
177 order in the vector of IntVars used to create the selector.
179 CHOOSE_MIN_SIZE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MAX
181 Among unbound variables, select the variable with the smallest size,
182 i.e., the smallest number of possible values.
183 In case of a tie, the selected variable is the one with the highest max
185 In case of a tie, the first one is selected, first being defined by the
186 order in the vector of IntVars used to create the selector.
188 CHOOSE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_LOWEST_MIN
190 Among unbound variables, select the variable with the smallest minimal
192 In case of a tie, the first one is selected, "first" defined by the
193 order in the vector of IntVars used to create the selector.
195 CHOOSE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_HIGHEST_MAX
197 Among unbound variables, select the variable with the highest maximal
199 In case of a tie, the first one is selected, first being defined by the
200 order in the vector of IntVars used to create the selector.
202 CHOOSE_MIN_SIZE = _pywrapcp.Solver_CHOOSE_MIN_SIZE
204 Among unbound variables, select the variable with the smallest size.
205 In case of a tie, the first one is selected, first being defined by the
206 order in the vector of IntVars used to create the selector.
208 CHOOSE_MAX_SIZE = _pywrapcp.Solver_CHOOSE_MAX_SIZE
210 Among unbound variables, select the variable with the highest size.
211 In case of a tie, the first one is selected, first being defined by the
212 order in the vector of IntVars used to create the selector.
214 CHOOSE_MAX_REGRET_ON_MIN = _pywrapcp.Solver_CHOOSE_MAX_REGRET_ON_MIN
216 Among unbound variables, select the variable with the largest
217 gap between the first and the second values of the domain.
219 CHOOSE_PATH = _pywrapcp.Solver_CHOOSE_PATH
221 Selects the next unbound variable on a path, the path being defined by
222 the variables: var[i] corresponds to the index of the next of i.
224 INT_VALUE_DEFAULT = _pywrapcp.Solver_INT_VALUE_DEFAULT
225 r""" The default behavior is ASSIGN_MIN_VALUE."""
226 INT_VALUE_SIMPLE = _pywrapcp.Solver_INT_VALUE_SIMPLE
227 r""" The simple selection is ASSIGN_MIN_VALUE."""
228 ASSIGN_MIN_VALUE = _pywrapcp.Solver_ASSIGN_MIN_VALUE
229 r""" Selects the min value of the selected variable."""
230 ASSIGN_MAX_VALUE = _pywrapcp.Solver_ASSIGN_MAX_VALUE
231 r""" Selects the max value of the selected variable."""
232 ASSIGN_RANDOM_VALUE = _pywrapcp.Solver_ASSIGN_RANDOM_VALUE
233 r""" Selects randomly one of the possible values of the selected variable."""
234 ASSIGN_CENTER_VALUE = _pywrapcp.Solver_ASSIGN_CENTER_VALUE
236 Selects the first possible value which is the closest to the center
237 of the domain of the selected variable.
238 The center is defined as (min + max) / 2.
240 SPLIT_LOWER_HALF = _pywrapcp.Solver_SPLIT_LOWER_HALF
242 Split the domain in two around the center, and choose the lower
245 SPLIT_UPPER_HALF = _pywrapcp.Solver_SPLIT_UPPER_HALF
247 Split the domain in two around the center, and choose the lower
250 SEQUENCE_DEFAULT = _pywrapcp.Solver_SEQUENCE_DEFAULT
251 SEQUENCE_SIMPLE = _pywrapcp.Solver_SEQUENCE_SIMPLE
252 CHOOSE_MIN_SLACK_RANK_FORWARD = _pywrapcp.Solver_CHOOSE_MIN_SLACK_RANK_FORWARD
253 CHOOSE_RANDOM_RANK_FORWARD = _pywrapcp.Solver_CHOOSE_RANDOM_RANK_FORWARD
254 INTERVAL_DEFAULT = _pywrapcp.Solver_INTERVAL_DEFAULT
255 r""" The default is INTERVAL_SET_TIMES_FORWARD."""
256 INTERVAL_SIMPLE = _pywrapcp.Solver_INTERVAL_SIMPLE
257 r""" The simple is INTERVAL_SET_TIMES_FORWARD."""
258 INTERVAL_SET_TIMES_FORWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_FORWARD
260 Selects the variable with the lowest starting time of all variables,
261 and fixes its starting time to this lowest value.
263 INTERVAL_SET_TIMES_BACKWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_BACKWARD
265 Selects the variable with the highest ending time of all variables,
266 and fixes the ending time to this highest values.
268 TWOOPT = _pywrapcp.Solver_TWOOPT
270 Operator which reverses a sub-chain of a path. It is called TwoOpt
271 because it breaks two arcs on the path; resulting paths are called
273 Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5
274 (where (1, 5) are first and last nodes of the path and can therefore not
276 1 -> [3 -> 2] -> 4 -> 5
277 1 -> [4 -> 3 -> 2] -> 5
278 1 -> 2 -> [4 -> 3] -> 5
280 OROPT = _pywrapcp.Solver_OROPT
282 Relocate: OROPT and RELOCATE.
283 Operator which moves a sub-chain of a path to another position; the
284 specified chain length is the fixed length of the chains being moved.
285 When this length is 1, the operator simply moves a node to another
287 Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5, for a chain
288 length of 2 (where (1, 5) are first and last nodes of the path and can
289 therefore not be moved):
290 1 -> 4 -> [2 -> 3] -> 5
291 1 -> [3 -> 4] -> 2 -> 5
293 Using Relocate with chain lengths of 1, 2 and 3 together is equivalent
294 to the OrOpt operator on a path. The OrOpt operator is a limited
295 version of 3Opt (breaks 3 arcs on a path).
297 RELOCATE = _pywrapcp.Solver_RELOCATE
298 r""" Relocate neighborhood with length of 1 (see OROPT comment)."""
299 EXCHANGE = _pywrapcp.Solver_EXCHANGE
301 Operator which exchanges the positions of two nodes.
302 Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5
303 (where (1, 5) are first and last nodes of the path and can therefore not
305 1 -> [3] -> [2] -> 4 -> 5
306 1 -> [4] -> 3 -> [2] -> 5
307 1 -> 2 -> [4] -> [3] -> 5
309 CROSS = _pywrapcp.Solver_CROSS
311 Operator which cross exchanges the starting chains of 2 paths, including
312 exchanging the whole paths.
313 First and last nodes are not moved.
314 Possible neighbors for the paths 1 -> 2 -> 3 -> 4 -> 5 and 6 -> 7 -> 8
315 (where (1, 5) and (6, 8) are first and last nodes of the paths and can
316 therefore not be moved):
317 1 -> [7] -> 3 -> 4 -> 5 6 -> [2] -> 8
318 1 -> [7] -> 4 -> 5 6 -> [2 -> 3] -> 8
319 1 -> [7] -> 5 6 -> [2 -> 3 -> 4] -> 8
321 MAKEACTIVE = _pywrapcp.Solver_MAKEACTIVE
323 Operator which inserts an inactive node into a path.
324 Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
325 (where 1 and 4 are first and last nodes of the path) are:
326 1 -> [5] -> 2 -> 3 -> 4
327 1 -> 2 -> [5] -> 3 -> 4
328 1 -> 2 -> 3 -> [5] -> 4
330 MAKEINACTIVE = _pywrapcp.Solver_MAKEINACTIVE
332 Operator which makes path nodes inactive.
333 Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are
334 first and last nodes of the path) are:
335 1 -> 3 -> 4 with 2 inactive
336 1 -> 2 -> 4 with 3 inactive
338 MAKECHAININACTIVE = _pywrapcp.Solver_MAKECHAININACTIVE
340 Operator which makes a "chain" of path nodes inactive.
341 Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are
342 first and last nodes of the path) are:
343 1 -> 3 -> 4 with 2 inactive
344 1 -> 2 -> 4 with 3 inactive
345 1 -> 4 with 2 and 3 inactive
347 SWAPACTIVE = _pywrapcp.Solver_SWAPACTIVE
349 Operator which replaces an active node by an inactive one.
350 Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
351 (where 1 and 4 are first and last nodes of the path) are:
352 1 -> [5] -> 3 -> 4 with 2 inactive
353 1 -> 2 -> [5] -> 4 with 3 inactive
355 EXTENDEDSWAPACTIVE = _pywrapcp.Solver_EXTENDEDSWAPACTIVE
357 Operator which makes an inactive node active and an active one inactive.
358 It is similar to SwapActiveOperator except that it tries to insert the
359 inactive node in all possible positions instead of just the position of
360 the node made inactive.
361 Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
362 (where 1 and 4 are first and last nodes of the path) are:
363 1 -> [5] -> 3 -> 4 with 2 inactive
364 1 -> 3 -> [5] -> 4 with 2 inactive
365 1 -> [5] -> 2 -> 4 with 3 inactive
366 1 -> 2 -> [5] -> 4 with 3 inactive
368 PATHLNS = _pywrapcp.Solver_PATHLNS
370 Operator which relaxes two sub-chains of three consecutive arcs each.
371 Each sub-chain is defined by a start node and the next three arcs. Those
372 six arcs are relaxed to build a new neighbor.
373 PATHLNS explores all possible pairs of starting nodes and so defines
374 n^2 neighbors, n being the number of nodes.
375 Note that the two sub-chains can be part of the same path; they even may
378 FULLPATHLNS = _pywrapcp.Solver_FULLPATHLNS
380 Operator which relaxes one entire path and all inactive nodes, thus
381 defining num_paths neighbors.
383 UNACTIVELNS = _pywrapcp.Solver_UNACTIVELNS
385 Operator which relaxes all inactive nodes and one sub-chain of six
386 consecutive arcs. That way the path can be improved by inserting
387 inactive nodes or swapping arcs.
389 INCREMENT = _pywrapcp.Solver_INCREMENT
391 Operator which defines one neighbor per variable. Each neighbor tries to
392 increment by one the value of the corresponding variable. When a new
393 solution is found the neighborhood is rebuilt from scratch, i.e., tries
394 to increment values in the variable order.
395 Consider for instance variables x and y. x is incremented one by one to
396 its max, and when it is not possible to increment x anymore, y is
397 incremented once. If this is a solution, then next neighbor tries to
400 DECREMENT = _pywrapcp.Solver_DECREMENT
402 Operator which defines a neighborhood to decrement values.
403 The behavior is the same as INCREMENT, except values are decremented
404 instead of incremented.
406 SIMPLELNS = _pywrapcp.Solver_SIMPLELNS
408 Operator which defines one neighbor per variable. Each neighbor relaxes
410 When a new solution is found the neighborhood is rebuilt from scratch.
411 Consider for instance variables x and y. First x is relaxed and the
412 solver is looking for the best possible solution (with only x relaxed).
413 Then y is relaxed, and the solver is looking for a new solution.
414 If a new solution is found, then the next variable to be relaxed is x.
416 GE = _pywrapcp.Solver_GE
417 r""" Move is accepted when the current objective value >= objective.Min."""
418 LE = _pywrapcp.Solver_LE
419 r""" Move is accepted when the current objective value <= objective.Max."""
420 EQ = _pywrapcp.Solver_EQ
422 Move is accepted when the current objective value is in the interval
423 objective.Min .. objective.Max.
425 DELAYED_PRIORITY = _pywrapcp.Solver_DELAYED_PRIORITY
427 DELAYED_PRIORITY is the lowest priority: Demons will be processed after
428 VAR_PRIORITY and NORMAL_PRIORITY demons.
430 VAR_PRIORITY = _pywrapcp.Solver_VAR_PRIORITY
431 r""" VAR_PRIORITY is between DELAYED_PRIORITY and NORMAL_PRIORITY."""
432 NORMAL_PRIORITY = _pywrapcp.Solver_NORMAL_PRIORITY
433 r""" NORMAL_PRIORITY is the highest priority: Demons will be processed first."""
436 _pywrapcp.Solver_swiginit(self, _pywrapcp.new_Solver(*args))
442 __swig_destroy__ = _pywrapcp.delete_Solver
445 r""" Stored Parameters."""
446 return _pywrapcp.Solver_Parameters(self)
450 r""" Create a ConstraintSolverParameters proto with all the default values."""
451 return _pywrapcp.Solver_DefaultSolverParameters()
455 Adds the constraint 'c' to the model.
457 After calling this method, and until there is a backtrack that undoes the
458 addition, any assignment of variables to values must satisfy the given
459 constraint in order to be considered feasible. There are two fairly
462 - the most common use case is modeling: the given constraint is really
463 part of the problem that the user is trying to solve. In this use case,
464 AddConstraint is called outside of search (i.e., with state() ==
465 OUTSIDE_SEARCH). Most users should only use AddConstraint in this
466 way. In this case, the constraint will belong to the model forever: it
467 cannot be removed by backtracking.
469 - a rarer use case is that 'c' is not a real constraint of the model. It
470 may be a constraint generated by a branching decision (a constraint whose
471 goal is to restrict the search space), a symmetry breaking constraint (a
472 constraint that does restrict the search space, but in a way that cannot
473 have an impact on the quality of the solutions in the subtree), or an
474 inferred constraint that, while having no semantic value to the model (it
475 does not restrict the set of solutions), is worth having because we
476 believe it may strengthen the propagation. In these cases, it happens
477 that the constraint is added during the search (i.e., with state() ==
478 IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is
479 added during a search, it applies only to the subtree of the search tree
480 rooted at the current node, and will be automatically removed by
483 This method does not take ownership of the constraint. If the constraint
484 has been created by any factory method (Solver::MakeXXX), it will
485 automatically be deleted. However, power users who implement their own
486 constraints should do: solver.AddConstraint(solver.RevAlloc(new
489 return _pywrapcp.Solver_AddConstraint(self, c)
492 return _pywrapcp.Solver_Solve(self, *args)
495 return _pywrapcp.Solver_NewSearch(self, *args)
498 return _pywrapcp.Solver_NextSolution(self)
501 return _pywrapcp.Solver_RestartSearch(self)
504 return _pywrapcp.Solver_EndSearch(self)
507 return _pywrapcp.Solver_SolveAndCommit(self, *args)
510 r""" Checks whether the given assignment satisfies all relevant constraints."""
511 return _pywrapcp.Solver_CheckAssignment(self, solution)
515 Checks whether adding this constraint will lead to an immediate
516 failure. It will return false if the model is already inconsistent, or if
517 adding the constraint makes it inconsistent.
519 return _pywrapcp.Solver_CheckConstraint(self, ct)
522 r""" Abandon the current branch in the search tree. A backtrack will follow."""
523 return _pywrapcp.Solver_Fail(self)
527 r""" Current memory usage in bytes"""
528 return _pywrapcp.Solver_MemoryUsage()
532 DEPRECATED: Use Now() instead.
533 Time elapsed, in ms since the creation of the solver.
535 return _pywrapcp.Solver_WallTime(self)
538 r""" The number of branches explored since the creation of the solver."""
539 return _pywrapcp.Solver_Branches(self)
542 r""" The number of solutions found since the start of the search."""
543 return _pywrapcp.Solver_Solutions(self)
546 r""" The number of failures encountered since the creation of the solver."""
547 return _pywrapcp.Solver_Failures(self)
550 r""" The number of accepted neighbors."""
551 return _pywrapcp.Solver_AcceptedNeighbors(self)
555 The stamp indicates how many moves in the search tree we have performed.
556 It is useful to detect if we need to update same lazy structures.
558 return _pywrapcp.Solver_Stamp(self)
561 r""" The fail_stamp() is incremented after each backtrack."""
562 return _pywrapcp.Solver_FailStamp(self)
567 MakeIntVar will create the best range based int var for the bounds given.
572 MakeIntVar will create a variable with the given sparse domain.
577 MakeIntVar will create a variable with the given sparse domain.
582 MakeIntVar will create the best range based int var for the bounds given.
587 MakeIntVar will create a variable with the given sparse domain.
592 MakeIntVar will create a variable with the given sparse domain.
594 return _pywrapcp.Solver_IntVar(self, *args)
599 MakeBoolVar will create a variable with a {0, 1} domain.
604 MakeBoolVar will create a variable with a {0, 1} domain.
606 return _pywrapcp.Solver_BoolVar(self, *args)
611 IntConst will create a constant expression.
616 IntConst will create a constant expression.
618 return _pywrapcp.Solver_IntConst(self, *args)
621 r""" sum of all vars."""
622 return _pywrapcp.Solver_Sum(self, vars)
634 return _pywrapcp.Solver_ScalProd(self, *args)
638 Function based element. The constraint takes ownership of the
639 callback. The callback must be monotonic. It must be able to
640 cope with any possible value in the domain of 'index'
641 (potentially negative ones too). Furtermore, monotonicity is not
642 checked. Thus giving a non-monotonic function, or specifying an
643 incorrect increasing parameter will result in undefined behavior.
645 return _pywrapcp.Solver_MonotonicElement(self, values, increasing, index)
660 Function-based element. The constraint takes ownership of the
661 callback. The callback must be able to cope with any possible
662 value in the domain of 'index' (potentially negative ones too).
667 2D version of function-based element expression, values(expr1, expr2).
674 return _pywrapcp.Solver_Element(self, *args)
678 Returns the expression expr such that vars[expr] == value.
679 It assumes that vars are all different.
681 return _pywrapcp.Solver_IndexExpression(self, vars, value)
691 std::min (left, right)
696 std::min(expr, value)
701 std::min(expr, value)
703 return _pywrapcp.Solver_Min(self, *args)
713 std::max(left, right)
718 std::max(expr, value)
723 std::max(expr, value)
725 return _pywrapcp.Solver_Max(self, *args)
728 r""" Convex piecewise function."""
729 return _pywrapcp.Solver_ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost)
733 Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b)
736 return _pywrapcp.Solver_SemiContinuousExpr(self, expr, fixed_charge, step)
739 r""" Conditional Expr condition ? expr : unperformed_value"""
740 return _pywrapcp.Solver_ConditionalExpression(self, condition, expr, unperformed_value)
743 r""" This constraint always succeeds."""
744 return _pywrapcp.Solver_TrueConstraint(self)
747 return _pywrapcp.Solver_FalseConstraint(self, *args)
750 r""" boolvar == (var == value)"""
751 return _pywrapcp.Solver_IsEqualCstCt(self, var, value, boolvar)
754 r""" status var of (var == value)"""
755 return _pywrapcp.Solver_IsEqualCstVar(self, var, value)
758 r""" b == (v1 == v2)"""
759 return _pywrapcp.Solver_IsEqualCt(self, v1, v2, b)
762 r""" status var of (v1 == v2)"""
763 return _pywrapcp.Solver_IsEqualVar(self, v1, v2)
766 r""" boolvar == (var != value)"""
767 return _pywrapcp.Solver_IsDifferentCstCt(self, var, value, boolvar)
770 r""" status var of (var != value)"""
771 return _pywrapcp.Solver_IsDifferentCstVar(self, var, value)
774 r""" status var of (v1 != v2)"""
775 return _pywrapcp.Solver_IsDifferentVar(self, v1, v2)
778 r""" b == (v1 != v2)"""
779 return _pywrapcp.Solver_IsDifferentCt(self, v1, v2, b)
782 r""" boolvar == (var <= value)"""
783 return _pywrapcp.Solver_IsLessOrEqualCstCt(self, var, value, boolvar)
786 r""" status var of (var <= value)"""
787 return _pywrapcp.Solver_IsLessOrEqualCstVar(self, var, value)
790 r""" status var of (left <= right)"""
791 return _pywrapcp.Solver_IsLessOrEqualVar(self, left, right)
794 r""" b == (left <= right)"""
795 return _pywrapcp.Solver_IsLessOrEqualCt(self, left, right, b)
798 r""" boolvar == (var >= value)"""
799 return _pywrapcp.Solver_IsGreaterOrEqualCstCt(self, var, value, boolvar)
802 r""" status var of (var >= value)"""
803 return _pywrapcp.Solver_IsGreaterOrEqualCstVar(self, var, value)
806 r""" status var of (left >= right)"""
807 return _pywrapcp.Solver_IsGreaterOrEqualVar(self, left, right)
810 r""" b == (left >= right)"""
811 return _pywrapcp.Solver_IsGreaterOrEqualCt(self, left, right, b)
815 return _pywrapcp.Solver_IsGreaterCstCt(self, v, c, b)
818 r""" status var of (var > value)"""
819 return _pywrapcp.Solver_IsGreaterCstVar(self, var, value)
822 r""" status var of (left > right)"""
823 return _pywrapcp.Solver_IsGreaterVar(self, left, right)
826 r""" b == (left > right)"""
827 return _pywrapcp.Solver_IsGreaterCt(self, left, right, b)
831 return _pywrapcp.Solver_IsLessCstCt(self, v, c, b)
834 r""" status var of (var < value)"""
835 return _pywrapcp.Solver_IsLessCstVar(self, var, value)
838 r""" status var of (left < right)"""
839 return _pywrapcp.Solver_IsLessVar(self, left, right)
842 r""" b == (left < right)"""
843 return _pywrapcp.Solver_IsLessCt(self, left, right, b)
846 r""" Variation on arrays."""
847 return _pywrapcp.Solver_SumLessOrEqual(self, vars, cst)
850 return _pywrapcp.Solver_SumGreaterOrEqual(self, vars, cst)
853 return _pywrapcp.Solver_SumEquality(self, *args)
856 return _pywrapcp.Solver_ScalProdEquality(self, *args)
859 return _pywrapcp.Solver_ScalProdGreaterOrEqual(self, *args)
862 return _pywrapcp.Solver_ScalProdLessOrEqual(self, *args)
865 return _pywrapcp.Solver_MinEquality(self, vars, min_var)
868 return _pywrapcp.Solver_MaxEquality(self, vars, max_var)
871 return _pywrapcp.Solver_ElementEquality(self, *args)
874 r""" Creates the constraint abs(var) == abs_var."""
875 return _pywrapcp.Solver_AbsEquality(self, var, abs_var)
879 This constraint is a special case of the element constraint with
880 an array of integer variables, where the variables are all
881 different and the index variable is constrained such that
882 vars[index] == target.
884 return _pywrapcp.Solver_IndexOfConstraint(self, vars, index, target)
888 This method is a specialized case of the MakeConstraintDemon
889 method to call the InitiatePropagate of the constraint 'ct'.
891 return _pywrapcp.Solver_ConstraintInitialPropagateCallback(self, ct)
895 This method is a specialized case of the MakeConstraintDemon
896 method to call the InitiatePropagate of the constraint 'ct' with
899 return _pywrapcp.Solver_DelayedConstraintInitialPropagateCallback(self, ct)
902 r""" Creates a demon from a closure."""
903 return _pywrapcp.Solver_ClosureDemon(self, closure)
906 r""" (l <= expr <= u)"""
907 return _pywrapcp.Solver_BetweenCt(self, expr, l, u)
910 r""" b == (l <= expr <= u)"""
911 return _pywrapcp.Solver_IsBetweenCt(self, expr, l, u, b)
914 return _pywrapcp.Solver_IsBetweenVar(self, v, l, u)
917 return _pywrapcp.Solver_MemberCt(self, *args)
927 expr should not be in the list of forbidden intervals [start[i]..end[i]].
932 expr should not be in the list of forbidden intervals [start[i]..end[i]].
934 return _pywrapcp.Solver_NotMemberCt(self, *args)
937 return _pywrapcp.Solver_IsMemberCt(self, *args)
940 return _pywrapcp.Solver_IsMemberVar(self, *args)
945 |{i | vars[i] == value}| == max_count
950 |{i | vars[i] == value}| == max_count
952 return _pywrapcp.Solver_Count(self, *args)
957 Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]
962 Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]
967 Aggregated version of count: |{i | v[i] == j}| == cards[j]
972 Aggregated version of count with bounded cardinalities:
973 forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max
978 Aggregated version of count with bounded cardinalities:
979 forall j in 0 .. card_size - 1:
980 card_min[j] <= |{i | v[i] == j}| <= card_max[j]
985 Aggregated version of count with bounded cardinalities:
986 forall j in 0 .. card_size - 1:
987 card_min[j] <= |{i | v[i] == j}| <= card_max[j]
992 Aggregated version of count with bounded cardinalities:
993 forall j in 0 .. card_size - 1:
994 card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
999 Aggregated version of count with bounded cardinalities:
1000 forall j in 0 .. card_size - 1:
1001 card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
1003 return _pywrapcp.Solver_Distribute(self, *args)
1007 Deviation constraint:
1008 sum_i |n * vars[i] - total_sum| <= deviation_var and
1009 sum_i vars[i] == total_sum
1012 return _pywrapcp.Solver_Deviation(self, vars, deviation_var, total_sum)
1017 All variables are pairwise different. This corresponds to the
1018 stronger version of the propagation algorithm.
1023 All variables are pairwise different. If 'stronger_propagation'
1024 is true, stronger, and potentially slower propagation will
1025 occur. This API will be deprecated in the future.
1027 return _pywrapcp.Solver_AllDifferent(self, *args)
1031 All variables are pairwise different, unless they are assigned to
1034 return _pywrapcp.Solver_AllDifferentExcept(self, vars, escape_value)
1038 Creates a constraint binding the arrays of variables "vars" and
1039 "sorted_vars": sorted_vars[0] must be equal to the minimum of all
1040 variables in vars, and so on: the value of sorted_vars[i] must be
1041 equal to the i-th value of variables invars.
1043 This constraint propagates in both directions: from "vars" to
1044 "sorted_vars" and vice-versa.
1046 Behind the scenes, this constraint maintains that:
1047 - sorted is always increasing.
1048 - whatever the values of vars, there exists a permutation that
1049 injects its values into the sorted variables.
1051 For more info, please have a look at:
1052 https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf
1054 return _pywrapcp.Solver_SortingConstraint(self, vars, sorted)
1058 Creates a constraint that enforces that left is lexicographically less
1061 return _pywrapcp.Solver_LexicalLess(self, left, right)
1065 Creates a constraint that enforces that left is lexicographically less
1066 than or equal to right.
1068 return _pywrapcp.Solver_LexicalLessOrEqual(self, left, right)
1072 Creates a constraint that enforces that 'left' and 'right' both
1073 represent permutations of [0..left.size()-1], and that 'right' is
1074 the inverse permutation of 'left', i.e. for all i in
1075 [0..left.size()-1], right[left[i]] = i.
1077 return _pywrapcp.Solver_InversePermutationConstraint(self, left, right)
1081 Creates a constraint that states that all variables in the first
1082 vector are different from all variables in the second
1083 group. Thus the set of values in the first vector does not
1084 intersect with the set of values in the second vector.
1086 return _pywrapcp.Solver_NullIntersect(self, first_vars, second_vars)
1090 Creates a constraint that states that all variables in the first
1091 vector are different from all variables from the second group,
1092 unless they are assigned to the escape value. Thus the set of
1093 values in the first vector minus the escape value does not
1094 intersect with the set of values in the second vector.
1096 return _pywrapcp.Solver_NullIntersectExcept(self, first_vars, second_vars, escape_value)
1099 r""" Force the "nexts" variable to create a complete Hamiltonian path."""
1100 return _pywrapcp.Solver_Circuit(self, nexts)
1104 Force the "nexts" variable to create a complete Hamiltonian path
1105 for those that do not loop upon themselves.
1107 return _pywrapcp.Solver_SubCircuit(self, nexts)
1111 Delayed version of the same constraint: propagation on the nexts variables
1112 is delayed until all constraints have propagated.
1114 return _pywrapcp.Solver_DelayedPathCumul(self, nexts, active, cumuls, transits)
1119 Creates a constraint which accumulates values along a path such that:
1120 cumuls[next[i]] = cumuls[i] + transits[i].
1121 Active variables indicate if the corresponding next variable is active;
1122 this could be useful to model unperformed nodes in a routing problem.
1127 Creates a constraint which accumulates values along a path such that:
1128 cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]).
1129 Active variables indicate if the corresponding next variable is active;
1130 this could be useful to model unperformed nodes in a routing problem.
1131 Ownership of transit_evaluator is taken and it must be a repeatable
1137 Creates a constraint which accumulates values along a path such that:
1138 cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i].
1139 Active variables indicate if the corresponding next variable is active;
1140 this could be useful to model unperformed nodes in a routing problem.
1141 Ownership of transit_evaluator is taken and it must be a repeatable
1144 return _pywrapcp.Solver_PathCumul(self, *args)
1149 This method creates a constraint where the graph of the relation
1150 between the variables is given in extension. There are 'arity'
1151 variables involved in the relation and the graph is given by a
1157 Compatibility layer for Python API.
1159 return _pywrapcp.Solver_AllowedAssignments(self, *args)
1162 return _pywrapcp.Solver_TransitionConstraint(self, *args)
1165 return _pywrapcp.Solver_NonOverlappingBoxesConstraint(self, *args)
1167 def Pack(self, vars, number_of_bins):
1169 This constraint packs all variables onto 'number_of_bins'
1170 variables. For any given variable, a value of 'number_of_bins'
1171 indicates that the variable is not assigned to any bin.
1172 Dimensions, i.e., cumulative constraints on this packing, can be
1173 added directly from the pack class.
1175 return _pywrapcp.Solver_Pack(self, vars, number_of_bins)
1180 Creates an interval var with a fixed duration. The duration must
1181 be greater than 0. If optional is true, then the interval can be
1182 performed or unperformed. If optional is false, then the interval
1183 is always performed.
1188 Creates a performed interval var with a fixed duration. The duration must
1194 Creates an interval var with a fixed duration, and performed_variable.
1195 The duration must be greater than 0.
1197 return _pywrapcp.Solver_FixedDurationIntervalVar(self, *args)
1200 r""" Creates a fixed and performed interval."""
1201 return _pywrapcp.Solver_FixedInterval(self, start, duration, name)
1203 def IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name):
1205 Creates an interval var by specifying the bounds on start,
1208 return _pywrapcp.Solver_IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name)
1212 Creates an interval var that is the mirror image of the given one, that
1213 is, the interval var obtained by reversing the axis.
1215 return _pywrapcp.Solver_MirrorInterval(self, interval_var)
1219 Creates an interval var with a fixed duration whose start is
1220 synchronized with the start of another interval, with a given
1221 offset. The performed status is also in sync with the performed
1222 status of the given interval variable.
1224 return _pywrapcp.Solver_FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset)
1228 Creates an interval var with a fixed duration whose start is
1229 synchronized with the end of another interval, with a given
1230 offset. The performed status is also in sync with the performed
1231 status of the given interval variable.
1233 return _pywrapcp.Solver_FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset)
1237 Creates an interval var with a fixed duration whose end is
1238 synchronized with the start of another interval, with a given
1239 offset. The performed status is also in sync with the performed
1240 status of the given interval variable.
1242 return _pywrapcp.Solver_FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset)
1246 Creates an interval var with a fixed duration whose end is
1247 synchronized with the end of another interval, with a given
1248 offset. The performed status is also in sync with the performed
1249 status of the given interval variable.
1251 return _pywrapcp.Solver_FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset)
1255 Creates and returns an interval variable that wraps around the given one,
1256 relaxing the min start and end. Relaxing means making unbounded when
1257 optional. If the variable is non-optional, this method returns
1260 More precisely, such an interval variable behaves as follows:
1261 When the underlying must be performed, the returned interval variable
1262 behaves exactly as the underlying;
1263 When the underlying may or may not be performed, the returned interval
1264 variable behaves like the underlying, except that it is unbounded on
1266 When the underlying cannot be performed, the returned interval variable
1267 is of duration 0 and must be performed in an interval unbounded on
1270 This is very useful to implement propagators that may only modify
1271 the start max or end max.
1273 return _pywrapcp.Solver_IntervalRelaxedMin(self, interval_var)
1277 Creates and returns an interval variable that wraps around the given one,
1278 relaxing the max start and end. Relaxing means making unbounded when
1279 optional. If the variable is non optional, this method returns
1282 More precisely, such an interval variable behaves as follows:
1283 When the underlying must be performed, the returned interval variable
1284 behaves exactly as the underlying;
1285 When the underlying may or may not be performed, the returned interval
1286 variable behaves like the underlying, except that it is unbounded on
1288 When the underlying cannot be performed, the returned interval variable
1289 is of duration 0 and must be performed in an interval unbounded on
1292 This is very useful for implementing propagators that may only modify
1293 the start min or end min.
1295 return _pywrapcp.Solver_IntervalRelaxedMax(self, interval_var)
1300 This constraint implements a temporal disjunction between two
1301 interval vars t1 and t2. 'alt' indicates which alternative was
1302 chosen (alt == 0 is equivalent to t1 before t2).
1307 This constraint implements a temporal disjunction between two
1310 return _pywrapcp.Solver_TemporalDisjunction(self, *args)
1314 This constraint forces all interval vars into an non-overlapping
1315 sequence. Intervals with zero duration can be scheduled anywhere.
1317 return _pywrapcp.Solver_DisjunctiveConstraint(self, intervals, name)
1322 This constraint forces that, for any integer t, the sum of the demands
1323 corresponding to an interval containing t does not exceed the given
1326 Intervals and demands should be vectors of equal size.
1328 Demands should only contain non-negative values. Zero values are
1329 supported, and the corresponding intervals are filtered out, as they
1330 neither impact nor are impacted by this constraint.
1335 This constraint forces that, for any integer t, the sum of the demands
1336 corresponding to an interval containing t does not exceed the given
1339 Intervals and demands should be vectors of equal size.
1341 Demands should only contain non-negative values. Zero values are
1342 supported, and the corresponding intervals are filtered out, as they
1343 neither impact nor are impacted by this constraint.
1348 This constraint forces that, for any integer t, the sum of the demands
1349 corresponding to an interval containing t does not exceed the given
1352 Intervals and demands should be vectors of equal size.
1354 Demands should only contain non-negative values. Zero values are
1355 supported, and the corresponding intervals are filtered out, as they
1356 neither impact nor are impacted by this constraint.
1361 This constraint enforces that, for any integer t, the sum of the demands
1362 corresponding to an interval containing t does not exceed the given
1365 Intervals and demands should be vectors of equal size.
1367 Demands should only contain non-negative values. Zero values are
1368 supported, and the corresponding intervals are filtered out, as they
1369 neither impact nor are impacted by this constraint.
1374 This constraint enforces that, for any integer t, the sum of demands
1375 corresponding to an interval containing t does not exceed the given
1378 Intervals and demands should be vectors of equal size.
1380 Demands should be positive.
1385 This constraint enforces that, for any integer t, the sum of demands
1386 corresponding to an interval containing t does not exceed the given
1389 Intervals and demands should be vectors of equal size.
1391 Demands should be positive.
1393 return _pywrapcp.Solver_Cumulative(self, *args)
1397 This constraint states that the target_var is the convex hull of
1398 the intervals. If none of the interval variables is performed,
1399 then the target var is unperformed too. Also, if the target
1400 variable is unperformed, then all the intervals variables are
1403 return _pywrapcp.Solver_Cover(self, vars, target_var)
1408 This method creates an empty assignment.
1413 This method creates an assignment which is a copy of 'a'.
1415 return _pywrapcp.Solver_Assignment(self, *args)
1420 Collect the first solution of the search.
1425 Collect the first solution of the search. The variables will need to
1428 return _pywrapcp.Solver_FirstSolutionCollector(self, *args)
1433 Collect the last solution of the search.
1438 Collect the last solution of the search. The variables will need to
1441 return _pywrapcp.Solver_LastSolutionCollector(self, *args)
1446 Collect the solution corresponding to the optimal value of the objective
1447 of 'assignment'; if 'assignment' does not have an objective no solution is
1448 collected. This collector only collects one solution corresponding to the
1449 best objective value (the first one found).
1454 Collect the solution corresponding to the optimal value of the
1455 objective of the internal assignment; if this assignment does not have an
1456 objective no solution is collected. This collector only collects one
1457 solution corresponding to the best objective value (the first one found).
1458 The variables and objective(s) will need to be added later.
1460 return _pywrapcp.Solver_BestValueSolutionCollector(self, *args)
1465 Collect all solutions of the search.
1470 Collect all solutions of the search. The variables will need to
1473 return _pywrapcp.Solver_AllSolutionCollector(self, *args)
1476 r""" Creates a minimization objective."""
1477 return _pywrapcp.Solver_Minimize(self, v, step)
1480 r""" Creates a maximization objective."""
1481 return _pywrapcp.Solver_Maximize(self, v, step)
1484 r""" Creates a objective with a given sense (true = maximization)."""
1485 return _pywrapcp.Solver_Optimize(self, maximize, v, step)
1490 Creates a minimization weighted objective. The actual objective is
1491 scalar_prod(sub_objectives, weights).
1496 Creates a minimization weighted objective. The actual objective is
1497 scalar_prod(sub_objectives, weights).
1499 return _pywrapcp.Solver_WeightedMinimize(self, *args)
1504 Creates a maximization weigthed objective.
1509 Creates a maximization weigthed objective.
1511 return _pywrapcp.Solver_WeightedMaximize(self, *args)
1516 Creates a weighted objective with a given sense (true = maximization).
1521 Creates a weighted objective with a given sense (true = maximization).
1523 return _pywrapcp.Solver_WeightedOptimize(self, *args)
1525 def TabuSearch(self, maximize, objective, step, vars, keep_tenure, forbid_tenure, tabu_factor):
1527 MetaHeuristics which try to get the search out of local optima.
1528 Creates a Tabu Search monitor.
1529 In the context of local search the behavior is similar to MakeOptimize(),
1530 creating an objective in a given sense. The behavior differs once a local
1531 optimum is reached: thereafter solutions which degrade the value of the
1532 objective are allowed if they are not "tabu". A solution is "tabu" if it
1533 doesn't respect the following rules:
1534 - improving the best solution found so far
1535 - variables in the "keep" list must keep their value, variables in the
1536 "forbid" list must not take the value they have in the list.
1537 Variables with new values enter the tabu lists after each new solution
1538 found and leave the lists after a given number of iterations (called
1539 tenure). Only the variables passed to the method can enter the lists.
1540 The tabu criterion is softened by the tabu factor which gives the number
1541 of "tabu" violations which is tolerated; a factor of 1 means no violations
1542 allowed; a factor of 0 means all violations are allowed.
1544 return _pywrapcp.Solver_TabuSearch(self, maximize, objective, step, vars, keep_tenure, forbid_tenure, tabu_factor)
1547 r""" Creates a Simulated Annealing monitor."""
1548 return _pywrapcp.Solver_SimulatedAnnealing(self, maximize, v, step, initial_temperature)
1552 This search monitor will restart the search periodically.
1553 At the iteration n, it will restart after scale_factor * Luby(n) failures
1554 where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).
1556 return _pywrapcp.Solver_LubyRestart(self, scale_factor)
1560 This search monitor will restart the search periodically after 'frequency'
1563 return _pywrapcp.Solver_ConstantRestart(self, frequency)
1566 return _pywrapcp.Solver_TimeLimit(self, *args)
1570 Creates a search limit that constrains the number of branches
1571 explored in the search tree.
1573 return _pywrapcp.Solver_BranchesLimit(self, branches)
1577 Creates a search limit that constrains the number of failures
1578 that can happen when exploring the search tree.
1580 return _pywrapcp.Solver_FailuresLimit(self, failures)
1584 Creates a search limit that constrains the number of solutions found
1587 return _pywrapcp.Solver_SolutionsLimit(self, solutions)
1592 Limits the search with the 'time', 'branches', 'failures' and
1593 'solutions' limits. 'smart_time_check' reduces the calls to the wall
1598 Creates a search limit from its protobuf description
1603 Creates a search limit that is reached when either of the underlying limit
1604 is reached. That is, the returned limit is more stringent than both
1607 return _pywrapcp.Solver_Limit(self, *args)
1611 Callback-based search limit. Search stops when limiter returns true; if
1612 this happens at a leaf the corresponding solution will be rejected.
1614 return _pywrapcp.Solver_CustomLimit(self, limiter)
1617 return _pywrapcp.Solver_SearchLog(self, *args)
1621 Creates a search monitor that will trace precisely the behavior of the
1622 search. Use this only for low level debugging.
1624 return _pywrapcp.Solver_SearchTrace(self, prefix)
1627 r""" Prints the model."""
1628 return _pywrapcp.Solver_PrintModelVisitor(self)
1631 r""" Displays some nice statistics on the model."""
1632 return _pywrapcp.Solver_StatisticsModelVisitor(self)
1636 return _pywrapcp.Solver_AssignVariableValue(self, var, val)
1639 return _pywrapcp.Solver_VariableLessOrEqualValue(self, var, value)
1642 return _pywrapcp.Solver_VariableGreaterOrEqualValue(self, var, value)
1645 return _pywrapcp.Solver_SplitVariableDomain(self, var, val, start_with_lower_half)
1648 return _pywrapcp.Solver_AssignVariableValueOrFail(self, var, value)
1651 return _pywrapcp.Solver_AssignVariablesValues(self, vars, values)
1654 return _pywrapcp.Solver_FailDecision(self)
1657 return _pywrapcp.Solver_Decision(self, apply, refute)
1660 return _pywrapcp.Solver_Compose(self, dbs)
1663 return _pywrapcp.Solver_Try(self, dbs)
1666 return _pywrapcp.Solver_DefaultPhase(self, *args)
1670 Returns a decision that tries to schedule a task at a given time.
1671 On the Apply branch, it will set that interval var as performed and set
1672 its start to 'est'. On the Refute branch, it will just update the
1673 'marker' to 'est' + 1. This decision is used in the
1674 INTERVAL_SET_TIMES_FORWARD strategy.
1676 return _pywrapcp.Solver_ScheduleOrPostpone(self, var, est, marker)
1680 Returns a decision that tries to schedule a task at a given time.
1681 On the Apply branch, it will set that interval var as performed and set
1682 its end to 'est'. On the Refute branch, it will just update the
1683 'marker' to 'est' - 1. This decision is used in the
1684 INTERVAL_SET_TIMES_BACKWARD strategy.
1686 return _pywrapcp.Solver_ScheduleOrExpedite(self, var, est, marker)
1690 Returns a decision that tries to rank first the ith interval var
1691 in the sequence variable.
1693 return _pywrapcp.Solver_RankFirstInterval(self, sequence, index)
1697 Returns a decision that tries to rank last the ith interval var
1698 in the sequence variable.
1700 return _pywrapcp.Solver_RankLastInterval(self, sequence, index)
1703 return _pywrapcp.Solver_Phase(self, *args)
1707 Returns a decision builder for which the left-most leaf corresponds
1708 to assignment, the rest of the tree being explored using 'db'.
1710 return _pywrapcp.Solver_DecisionBuilderFromAssignment(self, assignment, db, vars)
1714 Returns a decision builder that will add the given constraint to
1717 return _pywrapcp.Solver_ConstraintAdder(self, ct)
1720 return _pywrapcp.Solver_SolveOnce(self, db, monitors)
1723 return _pywrapcp.Solver_NestedOptimize(self, *args)
1727 Returns a DecisionBuilder which restores an Assignment
1728 (calls void Assignment::Restore())
1730 return _pywrapcp.Solver_RestoreAssignment(self, assignment)
1734 Returns a DecisionBuilder which stores an Assignment
1735 (calls void Assignment::Store())
1737 return _pywrapcp.Solver_StoreAssignment(self, assignment)
1740 return _pywrapcp.Solver_Operator(self, *args)
1743 return _pywrapcp.Solver_RandomLnsOperator(self, *args)
1748 Creates a local search operator that tries to move the assignment of some
1749 variables toward a target. The target is given as an Assignment. This
1750 operator generates neighbors in which the only difference compared to the
1751 current state is that one variable that belongs to the target assignment
1752 is set to its target value.
1757 Creates a local search operator that tries to move the assignment of some
1758 variables toward a target. The target is given either as two vectors: a
1759 vector of variables and a vector of associated target values. The two
1760 vectors should be of the same length. This operator generates neighbors in
1761 which the only difference compared to the current state is that one
1762 variable that belongs to the given vector is set to its target value.
1764 return _pywrapcp.Solver_MoveTowardTargetOperator(self, *args)
1767 return _pywrapcp.Solver_ConcatenateOperators(self, *args)
1772 Randomized version of local search concatenator; calls a random operator
1773 at each call to MakeNextNeighbor().
1778 Randomized version of local search concatenator; calls a random operator
1779 at each call to MakeNextNeighbor(). The provided seed is used to
1780 initialize the random number generator.
1782 return _pywrapcp.Solver_RandomConcatenateOperators(self, *args)
1786 Creates a local search operator that wraps another local search
1787 operator and limits the number of neighbors explored (i.e., calls
1788 to MakeNextNeighbor from the current solution (between two calls
1789 to Start()). When this limit is reached, MakeNextNeighbor()
1790 returns false. The counter is cleared when Start() is called.
1792 return _pywrapcp.Solver_NeighborhoodLimit(self, op, limit)
1795 return _pywrapcp.Solver_LocalSearchPhase(self, *args)
1798 return _pywrapcp.Solver_LocalSearchPhaseParameters(self, *args)
1802 Returns a percentage representing the propress of the search before
1803 reaching the limits of the top-level search (can be called from a nested
1806 return _pywrapcp.Solver_TopProgressPercent(self)
1810 Gets the search depth of the current active search. Returns -1 if
1811 there is no active search opened.
1813 return _pywrapcp.Solver_SearchDepth(self)
1817 Gets the search left depth of the current active search. Returns -1 if
1818 there is no active search opened.
1820 return _pywrapcp.Solver_SearchLeftDepth(self)
1824 Gets the number of nested searches. It returns 0 outside search,
1825 1 during the top level search, 2 or more in case of nested searches.
1827 return _pywrapcp.Solver_SolveDepth(self)
1830 r""" Returns a random value between 0 and 'size' - 1;"""
1831 return _pywrapcp.Solver_Rand64(self, size)
1834 r""" Returns a random value between 0 and 'size' - 1;"""
1835 return _pywrapcp.Solver_Rand32(self, size)
1838 r""" Reseed the solver random generator."""
1839 return _pywrapcp.Solver_ReSeed(self, seed)
1842 r""" Returns local search profiling information in a human readable format."""
1843 return _pywrapcp.Solver_LocalSearchProfile(self)
1847 Counts the number of constraints that have been added
1848 to the solver before the search.
1850 return _pywrapcp.Solver_Constraints(self)
1853 r""" Accepts the given model visitor."""
1854 return _pywrapcp.Solver_Accept(self, visitor)
1857 r""" Tells the solver to kill or restart the current search."""
1858 return _pywrapcp.Solver_FinishCurrentSearch(self)
1861 return _pywrapcp.Solver_RestartCurrentSearch(self)
1865 These methods are only useful for the SWIG wrappers, which need a way
1866 to externally cause the Solver to fail.
1868 return _pywrapcp.Solver_ShouldFail(self)
1871 return _pywrapcp.Solver___str__(self)
1874 if isinstance(ct, PyConstraint):
1880 return _pywrapcp.Solver_TreeNoCycle(self, nexts, active, callback)
1883 return _pywrapcp.Solver_SearchLogWithCallback(self, period, callback)
1886 return _pywrapcp.Solver_ElementFunction(self, values, index)
1889 return _pywrapcp.Solver_VarEvalValStrPhase(self, vars, var_evaluator, val_str)
1892 return _pywrapcp.Solver_VarStrValEvalPhase(self, vars, var_str, val_eval)
1895 return _pywrapcp.Solver_VarEvalValEvalPhase(self, vars, var_eval, val_eval)
1898 return _pywrapcp.Solver_VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker)
1901 return _pywrapcp.Solver_VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker)
1904 return _pywrapcp.Solver_EvalEvalStrPhase(self, vars, evaluator, str)
1907 return _pywrapcp.Solver_EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str)
1910 return _pywrapcp.Solver_GuidedLocalSearch(self, *args)
1913 return _pywrapcp.Solver_SumObjectiveFilter(self, vars, values, filter_enum)
1916_pywrapcp.Solver_swigregister(Solver)
1919 A BaseObject is the root of all reversibly allocated objects.
1920 A DebugString method and the associated << operator are implemented
1924 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
1931 _pywrapcp.BaseObject_swiginit(self, _pywrapcp.new_BaseObject(_self, ))
1932 __swig_destroy__ = _pywrapcp.delete_BaseObject
1935 return _pywrapcp.BaseObject_DebugString(self)
1938 return _pywrapcp.BaseObject___str__(self)
1941 return _pywrapcp.BaseObject___repr__(self)
1944 _pywrapcp.disown_BaseObject(self)
1945 return weakref.proxy(self)
1948_pywrapcp.BaseObject_swigregister(BaseObject)
1952 The PropagationBaseObject is a subclass of BaseObject that is also
1953 friend to the Solver class. It allows accessing methods useful when
1954 writing new constraints or new expressions.
1957 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
1958 __repr__ = _swig_repr
1965 _pywrapcp.PropagationBaseObject_swiginit(self, _pywrapcp.new_PropagationBaseObject(_self, s))
1966 __swig_destroy__ = _pywrapcp.delete_PropagationBaseObject
1969 return _pywrapcp.PropagationBaseObject_DebugString(self)
1972 return _pywrapcp.PropagationBaseObject_solver(self)
1975 r""" Object naming."""
1976 return _pywrapcp.PropagationBaseObject_Name(self)
1979 _pywrapcp.disown_PropagationBaseObject(self)
1980 return weakref.proxy(self)
1983_pywrapcp.PropagationBaseObject_swigregister(PropagationBaseObject)
1986 A Decision represents a choice point in the search tree. The two main
1987 methods are Apply() to go left, or Refute() to go right.
1990 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
1997 _pywrapcp.Decision_swiginit(self, _pywrapcp.new_Decision(_self, ))
1998 __swig_destroy__ = _pywrapcp.delete_Decision
2001 r""" Apply will be called first when the decision is executed."""
2002 return _pywrapcp.Decision_ApplyWrapper(self, s)
2005 r""" Refute will be called after a backtrack."""
2006 return _pywrapcp.Decision_RefuteWrapper(self, s)
2009 return _pywrapcp.Decision_DebugString(self)
2012 return _pywrapcp.Decision___repr__(self)
2015 return _pywrapcp.Decision___str__(self)
2018 _pywrapcp.disown_Decision(self)
2019 return weakref.proxy(self)
2022_pywrapcp.Decision_swigregister(Decision)
2025 A DecisionBuilder is responsible for creating the search tree. The
2026 important method is Next(), which returns the next decision to execute.
2029 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
2036 _pywrapcp.DecisionBuilder_swiginit(self, _pywrapcp.new_DecisionBuilder(_self, ))
2037 __swig_destroy__ = _pywrapcp.delete_DecisionBuilder
2041 This is the main method of the decision builder class. It must
2042 return a decision (an instance of the class Decision). If it
2043 returns nullptr, this means that the decision builder has finished
2046 return _pywrapcp.DecisionBuilder_NextWrapper(self, s)
2049 return _pywrapcp.DecisionBuilder_DebugString(self)
2052 return _pywrapcp.DecisionBuilder___repr__(self)
2055 return _pywrapcp.DecisionBuilder___str__(self)
2058 _pywrapcp.disown_DecisionBuilder(self)
2059 return weakref.proxy(self)
2062_pywrapcp.DecisionBuilder_swigregister(DecisionBuilder)
2065 A Demon is the base element of a propagation queue. It is the main
2066 object responsible for implementing the actual propagation
2067 of the constraint and pruning the inconsistent values in the domains
2068 of the variables. The main concept is that demons are listeners that are
2069 attached to the variables and listen to their modifications.
2070 There are two methods:
2071 - Run() is the actual method called when the demon is processed.
2072 - priority() returns its priority. Standard priorities are slow, normal
2073 or fast. "immediate" is reserved for variables and is treated separately.
2076 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
2077 __repr__ = _swig_repr
2081 This indicates the priority of a demon. Immediate demons are treated
2082 separately and corresponds to variables.
2088 _pywrapcp.Demon_swiginit(self, _pywrapcp.new_Demon(_self, ))
2089 __swig_destroy__ = _pywrapcp.delete_Demon
2092 r""" This is the main callback of the demon."""
2093 return _pywrapcp.Demon_RunWrapper(self, s)
2097 This method returns the priority of the demon. Usually a demon is
2098 fast, slow or normal. Immediate demons are reserved for internal
2099 use to maintain variables.
2101 return _pywrapcp.Demon_Priority(self)
2104 return _pywrapcp.Demon_DebugString(self)
2108 This method inhibits the demon in the search tree below the
2111 return _pywrapcp.Demon_Inhibit(self, s)
2114 r""" This method un-inhibits the demon that was previously inhibited."""
2115 return _pywrapcp.Demon_Desinhibit(self, s)
2118 _pywrapcp.disown_Demon(self)
2119 return weakref.proxy(self)
2122_pywrapcp.Demon_swigregister(Demon)
2125 A constraint is the main modeling object. It provides two methods:
2126 - Post() is responsible for creating the demons and attaching them to
2128 - InitialPropagate() is called once just after Post and performs
2129 the initial propagation. The subsequent propagations will be performed
2130 by the demons Posted during the post() method.
2133 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
2140 _pywrapcp.Constraint_swiginit(self, _pywrapcp.new_Constraint(_self, solver))
2141 __swig_destroy__ = _pywrapcp.delete_Constraint
2145 This method is called when the constraint is processed by the
2146 solver. Its main usage is to attach demons to variables.
2148 return _pywrapcp.Constraint_Post(self)
2152 This method performs the initial propagation of the
2153 constraint. It is called just after the post.
2155 return _pywrapcp.Constraint_InitialPropagateWrapper(self)
2158 return _pywrapcp.Constraint_DebugString(self)
2162 Creates a Boolean variable representing the status of the constraint
2163 (false = constraint is violated, true = constraint is satisfied). It
2164 returns nullptr if the constraint does not support this API.
2166 return _pywrapcp.Constraint_Var(self)
2169 return _pywrapcp.Constraint___repr__(self)
2172 return _pywrapcp.Constraint___str__(self)
2175 return _pywrapcp.Constraint___add__(self, *args)
2178 return _pywrapcp.Constraint___radd__(self, v)
2181 return _pywrapcp.Constraint___sub__(self, *args)
2184 return _pywrapcp.Constraint___rsub__(self, v)
2187 return _pywrapcp.Constraint___mul__(self, *args)
2190 return _pywrapcp.Constraint___rmul__(self, v)
2193 return _pywrapcp.Constraint___floordiv__(self, v)
2196 return _pywrapcp.Constraint___neg__(self)
2199 return _pywrapcp.Constraint___abs__(self)
2202 return _pywrapcp.Constraint_Square(self)
2205 return _pywrapcp.Constraint___eq__(self, *args)
2208 return _pywrapcp.Constraint___ne__(self, *args)
2211 return _pywrapcp.Constraint___ge__(self, *args)
2214 return _pywrapcp.Constraint___gt__(self, *args)
2217 return _pywrapcp.Constraint___le__(self, *args)
2220 return _pywrapcp.Constraint___lt__(self, *args)
2223 return _pywrapcp.Constraint_MapTo(self, vars)
2226 return _pywrapcp.Constraint_IndexOf(self, *args)
2229 _pywrapcp.disown_Constraint(self)
2230 return weakref.proxy(self)
2233_pywrapcp.Constraint_swigregister(Constraint)
2235 r""" A search monitor is a simple set of callbacks to monitor all search events"""
2237 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
2238 kNoProgress = _pywrapcp.SearchMonitor_kNoProgress
2245 _pywrapcp.SearchMonitor_swiginit(self, _pywrapcp.new_SearchMonitor(_self, s))
2246 __swig_destroy__ = _pywrapcp.delete_SearchMonitor
2249 r""" Beginning of the search."""
2250 return _pywrapcp.SearchMonitor_EnterSearch(self)
2253 r""" Restart the search."""
2254 return _pywrapcp.SearchMonitor_RestartSearch(self)
2257 r""" End of the search."""
2258 return _pywrapcp.SearchMonitor_ExitSearch(self)
2261 r""" Before calling DecisionBuilder::Next."""
2262 return _pywrapcp.SearchMonitor_BeginNextDecision(self, b)
2265 r""" After calling DecisionBuilder::Next, along with the returned decision."""
2266 return _pywrapcp.SearchMonitor_EndNextDecision(self, b, d)
2269 r""" Before applying the decision."""
2270 return _pywrapcp.SearchMonitor_ApplyDecision(self, d)
2273 r""" Before refuting the decision."""
2274 return _pywrapcp.SearchMonitor_RefuteDecision(self, d)
2278 Just after refuting or applying the decision, apply is true after Apply.
2279 This is called only if the Apply() or Refute() methods have not failed.
2281 return _pywrapcp.SearchMonitor_AfterDecision(self, d, apply)
2284 r""" Just when the failure occurs."""
2285 return _pywrapcp.SearchMonitor_BeginFail(self)
2288 r""" After completing the backtrack."""
2289 return _pywrapcp.SearchMonitor_EndFail(self)
2292 r""" Before the initial propagation."""
2293 return _pywrapcp.SearchMonitor_BeginInitialPropagation(self)
2296 r""" After the initial propagation."""
2297 return _pywrapcp.SearchMonitor_EndInitialPropagation(self)
2301 This method is called when a solution is found. It asserts whether the
2302 solution is valid. A value of false indicates that the solution
2303 should be discarded.
2305 return _pywrapcp.SearchMonitor_AcceptSolution(self)
2309 This method is called when a valid solution is found. If the
2310 return value is true, then search will resume after. If the result
2311 is false, then search will stop there.
2313 return _pywrapcp.SearchMonitor_AtSolution(self)
2316 r""" When the search tree is finished."""
2317 return _pywrapcp.SearchMonitor_NoMoreSolutions(self)
2321 When a local optimum is reached. If 'true' is returned, the last solution
2322 is discarded and the search proceeds with the next one.
2324 return _pywrapcp.SearchMonitor_LocalOptimum(self)
2328 return _pywrapcp.SearchMonitor_AcceptDelta(self, delta, deltadelta)
2331 r""" After accepting a neighbor during local search."""
2332 return _pywrapcp.SearchMonitor_AcceptNeighbor(self)
2336 Returns a percentage representing the propress of the search before
2339 return _pywrapcp.SearchMonitor_ProgressPercent(self)
2342 return _pywrapcp.SearchMonitor_solver(self)
2345 return _pywrapcp.SearchMonitor___repr__(self)
2348 return _pywrapcp.SearchMonitor___str__(self)
2351 _pywrapcp.disown_SearchMonitor(self)
2352 return weakref.proxy(self)
2355_pywrapcp.SearchMonitor_swigregister(SearchMonitor)
2358 The class IntExpr is the base of all integer expressions in
2359 constraint programming.
2360 It contains the basic protocol for an expression:
2361 - setting and modifying its bound
2362 - querying if it is bound
2363 - listening to events modifying its bounds
2364 - casting it into a variable (instance of IntVar)
2367 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
2370 raise AttributeError(
"No constructor defined - class is abstract")
2373 return _pywrapcp.IntExpr_Min(self)
2376 return _pywrapcp.IntExpr_SetMin(self, m)
2379 return _pywrapcp.IntExpr_Max(self)
2382 return _pywrapcp.IntExpr_SetMax(self, m)
2385 r""" This method sets both the min and the max of the expression."""
2386 return _pywrapcp.IntExpr_SetRange(self, l, u)
2389 r""" This method sets the value of the expression."""
2390 return _pywrapcp.IntExpr_SetValue(self, v)
2393 r""" Returns true if the min and the max of the expression are equal."""
2394 return _pywrapcp.IntExpr_Bound(self)
2397 r""" Returns true if the expression is indeed a variable."""
2398 return _pywrapcp.IntExpr_IsVar(self)
2401 r""" Creates a variable from the expression."""
2402 return _pywrapcp.IntExpr_Var(self)
2406 Creates a variable from the expression and set the name of the
2407 resulting var. If the expression is already a variable, then it
2408 will set the name of the expression, possibly overwriting it.
2409 This is just a shortcut to Var() followed by set_name().
2411 return _pywrapcp.IntExpr_VarWithName(self, name)
2416 Attach a demon that will watch the min or the max of the expression.
2421 Attach a demon that will watch the min or the max of the expression.
2423 return _pywrapcp.IntExpr_WhenRange(self, *args)
2426 return _pywrapcp.IntExpr___repr__(self)
2429 return _pywrapcp.IntExpr___str__(self)
2432 return _pywrapcp.IntExpr___add__(self, *args)
2435 return _pywrapcp.IntExpr___radd__(self, v)
2438 return _pywrapcp.IntExpr___sub__(self, *args)
2441 return _pywrapcp.IntExpr___rsub__(self, v)
2444 return _pywrapcp.IntExpr___mul__(self, *args)
2447 return _pywrapcp.IntExpr___rmul__(self, v)
2450 return _pywrapcp.IntExpr___floordiv__(self, *args)
2453 return _pywrapcp.IntExpr___mod__(self, *args)
2456 return _pywrapcp.IntExpr___neg__(self)
2459 return _pywrapcp.IntExpr___abs__(self)
2462 return _pywrapcp.IntExpr_Square(self)
2465 return _pywrapcp.IntExpr___eq__(self, *args)
2468 return _pywrapcp.IntExpr___ne__(self, *args)
2471 return _pywrapcp.IntExpr___ge__(self, *args)
2474 return _pywrapcp.IntExpr___gt__(self, *args)
2477 return _pywrapcp.IntExpr___le__(self, *args)
2480 return _pywrapcp.IntExpr___lt__(self, *args)
2483 return _pywrapcp.IntExpr_MapTo(self, vars)
2486 return _pywrapcp.IntExpr_IndexOf(self, *args)
2489 return _pywrapcp.IntExpr_IsMember(self, values)
2492 return _pywrapcp.IntExpr_Member(self, values)
2495 return _pywrapcp.IntExpr_NotMember(self, starts, ends)
2498_pywrapcp.IntExpr_swigregister(IntExpr)
2501 The class Iterator has two direct subclasses. HoleIterators
2502 iterates over all holes, that is value removed between the
2503 current min and max of the variable since the last time the
2504 variable was processed in the queue. DomainIterators iterates
2505 over all elements of the variable domain. Both iterators are not
2506 robust to domain changes. Hole iterators can also report values outside
2507 the current min and max of the variable.
2508 HoleIterators should only be called from a demon attached to the
2509 variable that has created this iterator.
2510 IntVar* current_var;
2511 std::unique_ptr<IntVarIterator> it(current_var->MakeHoleIterator(false));
2512 for (const int64_t hole : InitAndGetValues(it)) {
2517 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
2520 raise AttributeError(
"No constructor defined - class is abstract")
2521 __repr__ = _swig_repr
2524 r""" This method must be called before each loop."""
2525 return _pywrapcp.IntVarIterator_Init(self)
2528 r""" This method indicates if we can call Value() or not."""
2529 return _pywrapcp.IntVarIterator_Ok(self)
2532 r""" This method returns the current value of the iterator."""
2533 return _pywrapcp.IntVarIterator_Value(self)
2536 r""" This method moves the iterator to the next value."""
2537 return _pywrapcp.IntVarIterator_Next(self)
2540 r""" Pretty Print."""
2541 return _pywrapcp.IntVarIterator_DebugString(self)
2549 result = self.
Value()
2553 raise StopIteration()
2560_pywrapcp.IntVarIterator_swigregister(IntVarIterator)
2563 The class IntVar is a subset of IntExpr. In addition to the
2564 IntExpr protocol, it offers persistence, removing values from the domains,
2565 and a finer model for events.
2568 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
2571 raise AttributeError(
"No constructor defined - class is abstract")
2574 return _pywrapcp.IntVar_IsVar(self)
2577 return _pywrapcp.IntVar_Var(self)
2581 This method returns the value of the variable. This method checks
2582 before that the variable is bound.
2584 return _pywrapcp.IntVar_Value(self)
2587 r""" This method removes the value 'v' from the domain of the variable."""
2588 return _pywrapcp.IntVar_RemoveValue(self, v)
2592 This method removes the interval 'l' .. 'u' from the domain of
2593 the variable. It assumes that 'l' <= 'u'.
2595 return _pywrapcp.IntVar_RemoveInterval(self, l, u)
2598 r""" This method remove the values from the domain of the variable."""
2599 return _pywrapcp.IntVar_RemoveValues(self, values)
2602 r""" This method intersects the current domain with the values in the array."""
2603 return _pywrapcp.IntVar_SetValues(self, values)
2608 This method attaches a demon that will be awakened when the
2614 This method attaches a closure that will be awakened when the
2617 return _pywrapcp.IntVar_WhenBound(self, *args)
2622 This method attaches a demon that will watch any domain
2623 modification of the domain of the variable.
2628 This method attaches a closure that will watch any domain
2629 modification of the domain of the variable.
2631 return _pywrapcp.IntVar_WhenDomain(self, *args)
2634 r""" This method returns the number of values in the domain of the variable."""
2635 return _pywrapcp.IntVar_Size(self)
2639 This method returns whether the value 'v' is in the domain of the
2642 return _pywrapcp.IntVar_Contains(self, v)
2646 Creates a hole iterator. When 'reversible' is false, the returned
2647 object is created on the normal C++ heap and the solver does NOT
2648 take ownership of the object.
2650 return _pywrapcp.IntVar_HoleIteratorAux(self, reversible)
2654 Creates a domain iterator. When 'reversible' is false, the
2655 returned object is created on the normal C++ heap and the solver
2656 does NOT take ownership of the object.
2658 return _pywrapcp.IntVar_DomainIteratorAux(self, reversible)
2661 r""" Returns the previous min."""
2662 return _pywrapcp.IntVar_OldMin(self)
2665 r""" Returns the previous max."""
2666 return _pywrapcp.IntVar_OldMax(self)
2669 return _pywrapcp.IntVar___repr__(self)
2672 return _pywrapcp.IntVar___str__(self)
2682_pywrapcp.IntVar_swigregister(IntVar)
2685 This class is the root class of all solution collectors.
2686 It implements a basic query API to be used independently
2687 of the collector used.
2690 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
2693 raise AttributeError(
"No constructor defined")
2694 __repr__ = _swig_repr
2697 return _pywrapcp.SolutionCollector_DebugString(self)
2700 return _pywrapcp.SolutionCollector_Add(self, *args)
2703 return _pywrapcp.SolutionCollector_AddObjective(self, objective)
2706 r""" Beginning of the search."""
2707 return _pywrapcp.SolutionCollector_EnterSearch(self)
2710 r""" Returns how many solutions were stored during the search."""
2711 return _pywrapcp.SolutionCollector_SolutionCount(self)
2714 r""" Returns the nth solution."""
2715 return _pywrapcp.SolutionCollector_Solution(self, n)
2718 r""" Returns the wall time in ms for the nth solution."""
2719 return _pywrapcp.SolutionCollector_WallTime(self, n)
2722 r""" Returns the number of branches when the nth solution was found."""
2723 return _pywrapcp.SolutionCollector_Branches(self, n)
2727 Returns the number of failures encountered at the time of the nth
2730 return _pywrapcp.SolutionCollector_Failures(self, n)
2733 r""" Returns the objective value of the nth solution."""
2734 return _pywrapcp.SolutionCollector_ObjectiveValue(self, n)
2737 r""" This is a shortcut to get the Value of 'var' in the nth solution."""
2738 return _pywrapcp.SolutionCollector_Value(self, n, var)
2741 r""" This is a shortcut to get the StartValue of 'var' in the nth solution."""
2742 return _pywrapcp.SolutionCollector_StartValue(self, n, var)
2745 r""" This is a shortcut to get the EndValue of 'var' in the nth solution."""
2746 return _pywrapcp.SolutionCollector_EndValue(self, n, var)
2749 r""" This is a shortcut to get the DurationValue of 'var' in the nth solution."""
2750 return _pywrapcp.SolutionCollector_DurationValue(self, n, var)
2753 r""" This is a shortcut to get the PerformedValue of 'var' in the nth solution."""
2754 return _pywrapcp.SolutionCollector_PerformedValue(self, n, var)
2758 This is a shortcut to get the ForwardSequence of 'var' in the
2759 nth solution. The forward sequence is the list of ranked interval
2760 variables starting from the start of the sequence.
2762 return _pywrapcp.SolutionCollector_ForwardSequence(self, n, var)
2766 This is a shortcut to get the BackwardSequence of 'var' in the
2767 nth solution. The backward sequence is the list of ranked interval
2768 variables starting from the end of the sequence.
2770 return _pywrapcp.SolutionCollector_BackwardSequence(self, n, var)
2774 This is a shortcut to get the list of unperformed of 'var' in the
2777 return _pywrapcp.SolutionCollector_Unperformed(self, n, var)
2780_pywrapcp.SolutionCollector_swigregister(SolutionCollector)
2783 This class encapsulates an objective. It requires the direction
2784 (minimize or maximize), the variable to optimize, and the
2788 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
2791 raise AttributeError(
"No constructor defined")
2792 __repr__ = _swig_repr
2795 r""" Returns the best value found during search."""
2796 return _pywrapcp.OptimizeVar_Best(self)
2799 r""" Internal methods."""
2800 return _pywrapcp.OptimizeVar_BeginNextDecision(self, db)
2803 return _pywrapcp.OptimizeVar_RefuteDecision(self, d)
2806 return _pywrapcp.OptimizeVar_AtSolution(self)
2809 return _pywrapcp.OptimizeVar_AcceptSolution(self)
2812 return _pywrapcp.OptimizeVar_DebugString(self)
2813 __swig_destroy__ = _pywrapcp.delete_OptimizeVar
2816_pywrapcp.OptimizeVar_swigregister(OptimizeVar)
2818 r""" Base class of all search limits."""
2820 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
2823 raise AttributeError(
"No constructor defined - class is abstract")
2824 __repr__ = _swig_repr
2825 __swig_destroy__ = _pywrapcp.delete_SearchLimit
2828 r""" Returns true if the limit has been crossed."""
2829 return _pywrapcp.SearchLimit_Crossed(self)
2833 This method is called to check the status of the limit. A return
2834 value of true indicates that we have indeed crossed the limit. In
2835 that case, this method will not be called again and the remaining
2836 search will be discarded.
2838 return _pywrapcp.SearchLimit_Check(self)
2841 r""" This method is called when the search limit is initialized."""
2842 return _pywrapcp.SearchLimit_Init(self)
2845 r""" Internal methods."""
2846 return _pywrapcp.SearchLimit_EnterSearch(self)
2849 return _pywrapcp.SearchLimit_BeginNextDecision(self, b)
2852 return _pywrapcp.SearchLimit_RefuteDecision(self, d)
2855 return _pywrapcp.SearchLimit_DebugString(self)
2858_pywrapcp.SearchLimit_swigregister(SearchLimit)
2861 Interval variables are often used in scheduling. The main characteristics
2862 of an IntervalVar are the start position, duration, and end
2863 date. All these characteristics can be queried and set, and demons can
2864 be posted on their modifications.
2866 An important aspect is optionality: an IntervalVar can be performed or not.
2867 If unperformed, then it simply does not exist, and its characteristics
2868 cannot be accessed any more. An interval var is automatically marked
2869 as unperformed when it is not consistent anymore (start greater
2870 than end, duration < 0...)
2873 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
2876 raise AttributeError(
"No constructor defined - class is abstract")
2880 These methods query, set, and watch the start position of the
2883 return _pywrapcp.IntervalVar_StartMin(self)
2886 return _pywrapcp.IntervalVar_StartMax(self)
2889 return _pywrapcp.IntervalVar_SetStartMin(self, m)
2892 return _pywrapcp.IntervalVar_SetStartMax(self, m)
2895 return _pywrapcp.IntervalVar_SetStartRange(self, mi, ma)
2898 return _pywrapcp.IntervalVar_OldStartMin(self)
2901 return _pywrapcp.IntervalVar_OldStartMax(self)
2904 return _pywrapcp.IntervalVar_WhenStartRange(self, *args)
2907 return _pywrapcp.IntervalVar_WhenStartBound(self, *args)
2910 r""" These methods query, set, and watch the duration of the interval var."""
2911 return _pywrapcp.IntervalVar_DurationMin(self)
2914 return _pywrapcp.IntervalVar_DurationMax(self)
2917 return _pywrapcp.IntervalVar_SetDurationMin(self, m)
2920 return _pywrapcp.IntervalVar_SetDurationMax(self, m)
2923 return _pywrapcp.IntervalVar_SetDurationRange(self, mi, ma)
2926 return _pywrapcp.IntervalVar_OldDurationMin(self)
2929 return _pywrapcp.IntervalVar_OldDurationMax(self)
2932 return _pywrapcp.IntervalVar_WhenDurationRange(self, *args)
2935 return _pywrapcp.IntervalVar_WhenDurationBound(self, *args)
2938 r""" These methods query, set, and watch the end position of the interval var."""
2939 return _pywrapcp.IntervalVar_EndMin(self)
2942 return _pywrapcp.IntervalVar_EndMax(self)
2945 return _pywrapcp.IntervalVar_SetEndMin(self, m)
2948 return _pywrapcp.IntervalVar_SetEndMax(self, m)
2951 return _pywrapcp.IntervalVar_SetEndRange(self, mi, ma)
2954 return _pywrapcp.IntervalVar_OldEndMin(self)
2957 return _pywrapcp.IntervalVar_OldEndMax(self)
2960 return _pywrapcp.IntervalVar_WhenEndRange(self, *args)
2963 return _pywrapcp.IntervalVar_WhenEndBound(self, *args)
2967 These methods query, set, and watch the performed status of the
2970 return _pywrapcp.IntervalVar_MustBePerformed(self)
2973 return _pywrapcp.IntervalVar_MayBePerformed(self)
2976 return _pywrapcp.IntervalVar_CannotBePerformed(self)
2979 return _pywrapcp.IntervalVar_IsPerformedBound(self)
2982 return _pywrapcp.IntervalVar_SetPerformed(self, val)
2985 return _pywrapcp.IntervalVar_WasPerformedBound(self)
2988 return _pywrapcp.IntervalVar_WhenPerformedBound(self, *args)
2993 Attaches a demon awakened when anything about this interval changes.
2998 Attaches a closure awakened when anything about this interval changes.
3000 return _pywrapcp.IntervalVar_WhenAnything(self, *args)
3004 These methods create expressions encapsulating the start, end
3005 and duration of the interval var. Please note that these must not
3006 be used if the interval var is unperformed.
3008 return _pywrapcp.IntervalVar_StartExpr(self)
3011 return _pywrapcp.IntervalVar_DurationExpr(self)
3014 return _pywrapcp.IntervalVar_EndExpr(self)
3017 return _pywrapcp.IntervalVar_PerformedExpr(self)
3021 These methods create expressions encapsulating the start, end
3022 and duration of the interval var. If the interval var is
3023 unperformed, they will return the unperformed_value.
3025 return _pywrapcp.IntervalVar_SafeStartExpr(self, unperformed_value)
3028 return _pywrapcp.IntervalVar_SafeDurationExpr(self, unperformed_value)
3031 return _pywrapcp.IntervalVar_SafeEndExpr(self, unperformed_value)
3034 return _pywrapcp.IntervalVar_EndsAfterEnd(self, other)
3037 return _pywrapcp.IntervalVar_EndsAfterEndWithDelay(self, other, delay)
3040 return _pywrapcp.IntervalVar_EndsAfterStart(self, other)
3043 return _pywrapcp.IntervalVar_EndsAfterStartWithDelay(self, other, delay)
3046 return _pywrapcp.IntervalVar_EndsAtEnd(self, other)
3049 return _pywrapcp.IntervalVar_EndsAtEndWithDelay(self, other, delay)
3052 return _pywrapcp.IntervalVar_EndsAtStart(self, other)
3055 return _pywrapcp.IntervalVar_EndsAtStartWithDelay(self, other, delay)
3058 return _pywrapcp.IntervalVar_StartsAfterEnd(self, other)
3061 return _pywrapcp.IntervalVar_StartsAfterEndWithDelay(self, other, delay)
3064 return _pywrapcp.IntervalVar_StartsAfterStart(self, other)
3067 return _pywrapcp.IntervalVar_StartsAfterStartWithDelay(self, other, delay)
3070 return _pywrapcp.IntervalVar_StartsAtEnd(self, other)
3073 return _pywrapcp.IntervalVar_StartsAtEndWithDelay(self, other, delay)
3076 return _pywrapcp.IntervalVar_StartsAtStart(self, other)
3079 return _pywrapcp.IntervalVar_StartsAtStartWithDelay(self, other, delay)
3082 return _pywrapcp.IntervalVar_StaysInSync(self, other)
3085 return _pywrapcp.IntervalVar_StaysInSyncWithDelay(self, other, delay)
3088 return _pywrapcp.IntervalVar_EndsAfter(self, date)
3091 return _pywrapcp.IntervalVar_EndsAt(self, date)
3094 return _pywrapcp.IntervalVar_EndsBefore(self, date)
3097 return _pywrapcp.IntervalVar_StartsAfter(self, date)
3100 return _pywrapcp.IntervalVar_StartsAt(self, date)
3103 return _pywrapcp.IntervalVar_StartsBefore(self, date)
3106 return _pywrapcp.IntervalVar_CrossesDate(self, date)
3109 return _pywrapcp.IntervalVar_AvoidsDate(self, date)
3112 return _pywrapcp.IntervalVar___repr__(self)
3115 return _pywrapcp.IntervalVar___str__(self)
3118_pywrapcp.IntervalVar_swigregister(IntervalVar)
3121 A sequence variable is a variable whose domain is a set of possible
3122 orderings of the interval variables. It allows ordering of tasks. It
3123 has two sets of methods: ComputePossibleFirstsAndLasts(), which
3124 returns the list of interval variables that can be ranked first or
3125 last; and RankFirst/RankNotFirst/RankLast/RankNotLast, which can be
3126 used to create the search decision.
3129 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3132 raise AttributeError(
"No constructor defined")
3135 return _pywrapcp.SequenceVar_DebugString(self)
3139 Ranks the index_th interval var first of all unranked interval
3140 vars. After that, it will no longer be considered ranked.
3142 return _pywrapcp.SequenceVar_RankFirst(self, index)
3146 Indicates that the index_th interval var will not be ranked first
3147 of all currently unranked interval vars.
3149 return _pywrapcp.SequenceVar_RankNotFirst(self, index)
3153 Ranks the index_th interval var first of all unranked interval
3154 vars. After that, it will no longer be considered ranked.
3156 return _pywrapcp.SequenceVar_RankLast(self, index)
3160 Indicates that the index_th interval var will not be ranked first
3161 of all currently unranked interval vars.
3163 return _pywrapcp.SequenceVar_RankNotLast(self, index)
3166 r""" Returns the index_th interval of the sequence."""
3167 return _pywrapcp.SequenceVar_Interval(self, index)
3170 r""" Returns the next of the index_th interval of the sequence."""
3171 return _pywrapcp.SequenceVar_Next(self, index)
3174 r""" Returns the number of interval vars in the sequence."""
3175 return _pywrapcp.SequenceVar_Size(self)
3178 return _pywrapcp.SequenceVar___repr__(self)
3181 return _pywrapcp.SequenceVar___str__(self)
3184_pywrapcp.SequenceVar_swigregister(SequenceVar)
3186 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3189 raise AttributeError(
"No constructor defined")
3190 __repr__ = _swig_repr
3193 return _pywrapcp.AssignmentElement_Activate(self)
3196 return _pywrapcp.AssignmentElement_Deactivate(self)
3199 return _pywrapcp.AssignmentElement_Activated(self)
3200 __swig_destroy__ = _pywrapcp.delete_AssignmentElement
3203_pywrapcp.AssignmentElement_swigregister(AssignmentElement)
3205 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3208 raise AttributeError(
"No constructor defined")
3209 __repr__ = _swig_repr
3212 return _pywrapcp.IntVarElement_Var(self)
3215 return _pywrapcp.IntVarElement_Min(self)
3218 return _pywrapcp.IntVarElement_SetMin(self, m)
3221 return _pywrapcp.IntVarElement_Max(self)
3224 return _pywrapcp.IntVarElement_SetMax(self, m)
3227 return _pywrapcp.IntVarElement_Value(self)
3230 return _pywrapcp.IntVarElement_Bound(self)
3233 return _pywrapcp.IntVarElement_SetRange(self, l, u)
3236 return _pywrapcp.IntVarElement_SetValue(self, v)
3239 return _pywrapcp.IntVarElement___eq__(self, element)
3242 return _pywrapcp.IntVarElement___ne__(self, element)
3243 __swig_destroy__ = _pywrapcp.delete_IntVarElement
3246_pywrapcp.IntVarElement_swigregister(IntVarElement)
3248 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3251 raise AttributeError(
"No constructor defined")
3252 __repr__ = _swig_repr
3255 return _pywrapcp.IntervalVarElement_Var(self)
3258 return _pywrapcp.IntervalVarElement_StartMin(self)
3261 return _pywrapcp.IntervalVarElement_StartMax(self)
3264 return _pywrapcp.IntervalVarElement_StartValue(self)
3267 return _pywrapcp.IntervalVarElement_DurationMin(self)
3270 return _pywrapcp.IntervalVarElement_DurationMax(self)
3273 return _pywrapcp.IntervalVarElement_DurationValue(self)
3276 return _pywrapcp.IntervalVarElement_EndMin(self)
3279 return _pywrapcp.IntervalVarElement_EndMax(self)
3282 return _pywrapcp.IntervalVarElement_EndValue(self)
3285 return _pywrapcp.IntervalVarElement_PerformedMin(self)
3288 return _pywrapcp.IntervalVarElement_PerformedMax(self)
3291 return _pywrapcp.IntervalVarElement_PerformedValue(self)
3294 return _pywrapcp.IntervalVarElement_SetStartMin(self, m)
3297 return _pywrapcp.IntervalVarElement_SetStartMax(self, m)
3300 return _pywrapcp.IntervalVarElement_SetStartRange(self, mi, ma)
3303 return _pywrapcp.IntervalVarElement_SetStartValue(self, v)
3306 return _pywrapcp.IntervalVarElement_SetDurationMin(self, m)
3309 return _pywrapcp.IntervalVarElement_SetDurationMax(self, m)
3312 return _pywrapcp.IntervalVarElement_SetDurationRange(self, mi, ma)
3315 return _pywrapcp.IntervalVarElement_SetDurationValue(self, v)
3318 return _pywrapcp.IntervalVarElement_SetEndMin(self, m)
3321 return _pywrapcp.IntervalVarElement_SetEndMax(self, m)
3324 return _pywrapcp.IntervalVarElement_SetEndRange(self, mi, ma)
3327 return _pywrapcp.IntervalVarElement_SetEndValue(self, v)
3330 return _pywrapcp.IntervalVarElement_SetPerformedMin(self, m)
3333 return _pywrapcp.IntervalVarElement_SetPerformedMax(self, m)
3336 return _pywrapcp.IntervalVarElement_SetPerformedRange(self, mi, ma)
3339 return _pywrapcp.IntervalVarElement_SetPerformedValue(self, v)
3342 return _pywrapcp.IntervalVarElement___eq__(self, element)
3345 return _pywrapcp.IntervalVarElement___ne__(self, element)
3346 __swig_destroy__ = _pywrapcp.delete_IntervalVarElement
3349_pywrapcp.IntervalVarElement_swigregister(IntervalVarElement)
3352 The SequenceVarElement stores a partial representation of ranked
3353 interval variables in the underlying sequence variable.
3354 This representation consists of three vectors:
3355 - the forward sequence. That is the list of interval variables
3356 ranked first in the sequence. The first element of the backward
3357 sequence is the first interval in the sequence variable.
3358 - the backward sequence. That is the list of interval variables
3359 ranked last in the sequence. The first element of the backward
3360 sequence is the last interval in the sequence variable.
3361 - The list of unperformed interval variables.
3362 Furthermore, if all performed variables are ranked, then by
3363 convention, the forward_sequence will contain all such variables
3364 and the backward_sequence will be empty.
3367 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3370 raise AttributeError(
"No constructor defined")
3371 __repr__ = _swig_repr
3374 return _pywrapcp.SequenceVarElement_Var(self)
3377 return _pywrapcp.SequenceVarElement_ForwardSequence(self)
3380 return _pywrapcp.SequenceVarElement_BackwardSequence(self)
3383 return _pywrapcp.SequenceVarElement_Unperformed(self)
3385 def SetSequence(self, forward_sequence, backward_sequence, unperformed):
3386 return _pywrapcp.SequenceVarElement_SetSequence(self, forward_sequence, backward_sequence, unperformed)
3389 return _pywrapcp.SequenceVarElement_SetForwardSequence(self, forward_sequence)
3392 return _pywrapcp.SequenceVarElement_SetBackwardSequence(self, backward_sequence)
3395 return _pywrapcp.SequenceVarElement_SetUnperformed(self, unperformed)
3398 return _pywrapcp.SequenceVarElement___eq__(self, element)
3401 return _pywrapcp.SequenceVarElement___ne__(self, element)
3402 __swig_destroy__ = _pywrapcp.delete_SequenceVarElement
3405_pywrapcp.SequenceVarElement_swigregister(SequenceVarElement)
3408 An Assignment is a variable -> domains mapping, used
3409 to report solutions to the user.
3412 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3415 raise AttributeError(
"No constructor defined")
3416 __repr__ = _swig_repr
3419 return _pywrapcp.Assignment_Clear(self)
3422 return _pywrapcp.Assignment_Empty(self)
3425 return _pywrapcp.Assignment_Size(self)
3428 return _pywrapcp.Assignment_NumIntVars(self)
3431 return _pywrapcp.Assignment_NumIntervalVars(self)
3434 return _pywrapcp.Assignment_NumSequenceVars(self)
3437 return _pywrapcp.Assignment_Store(self)
3440 return _pywrapcp.Assignment_Restore(self)
3443 return _pywrapcp.Assignment_Load(self, *args)
3446 return _pywrapcp.Assignment_Save(self, *args)
3449 return _pywrapcp.Assignment_AddObjective(self, v)
3452 return _pywrapcp.Assignment_Objective(self)
3455 return _pywrapcp.Assignment_HasObjective(self)
3458 return _pywrapcp.Assignment_ObjectiveMin(self)
3461 return _pywrapcp.Assignment_ObjectiveMax(self)
3464 return _pywrapcp.Assignment_ObjectiveValue(self)
3467 return _pywrapcp.Assignment_ObjectiveBound(self)
3470 return _pywrapcp.Assignment_SetObjectiveMin(self, m)
3473 return _pywrapcp.Assignment_SetObjectiveMax(self, m)
3476 return _pywrapcp.Assignment_SetObjectiveValue(self, value)
3479 return _pywrapcp.Assignment_SetObjectiveRange(self, l, u)
3482 return _pywrapcp.Assignment_Min(self, var)
3485 return _pywrapcp.Assignment_Max(self, var)
3488 return _pywrapcp.Assignment_Value(self, var)
3491 return _pywrapcp.Assignment_Bound(self, var)
3494 return _pywrapcp.Assignment_SetMin(self, var, m)
3497 return _pywrapcp.Assignment_SetMax(self, var, m)
3500 return _pywrapcp.Assignment_SetRange(self, var, l, u)
3503 return _pywrapcp.Assignment_SetValue(self, var, value)
3506 return _pywrapcp.Assignment_StartMin(self, var)
3509 return _pywrapcp.Assignment_StartMax(self, var)
3512 return _pywrapcp.Assignment_StartValue(self, var)
3515 return _pywrapcp.Assignment_DurationMin(self, var)
3518 return _pywrapcp.Assignment_DurationMax(self, var)
3521 return _pywrapcp.Assignment_DurationValue(self, var)
3524 return _pywrapcp.Assignment_EndMin(self, var)
3527 return _pywrapcp.Assignment_EndMax(self, var)
3530 return _pywrapcp.Assignment_EndValue(self, var)
3533 return _pywrapcp.Assignment_PerformedMin(self, var)
3536 return _pywrapcp.Assignment_PerformedMax(self, var)
3539 return _pywrapcp.Assignment_PerformedValue(self, var)
3542 return _pywrapcp.Assignment_SetStartMin(self, var, m)
3545 return _pywrapcp.Assignment_SetStartMax(self, var, m)
3548 return _pywrapcp.Assignment_SetStartRange(self, var, mi, ma)
3551 return _pywrapcp.Assignment_SetStartValue(self, var, value)
3554 return _pywrapcp.Assignment_SetDurationMin(self, var, m)
3557 return _pywrapcp.Assignment_SetDurationMax(self, var, m)
3560 return _pywrapcp.Assignment_SetDurationRange(self, var, mi, ma)
3563 return _pywrapcp.Assignment_SetDurationValue(self, var, value)
3566 return _pywrapcp.Assignment_SetEndMin(self, var, m)
3569 return _pywrapcp.Assignment_SetEndMax(self, var, m)
3572 return _pywrapcp.Assignment_SetEndRange(self, var, mi, ma)
3575 return _pywrapcp.Assignment_SetEndValue(self, var, value)
3578 return _pywrapcp.Assignment_SetPerformedMin(self, var, m)
3581 return _pywrapcp.Assignment_SetPerformedMax(self, var, m)
3584 return _pywrapcp.Assignment_SetPerformedRange(self, var, mi, ma)
3587 return _pywrapcp.Assignment_SetPerformedValue(self, var, value)
3590 return _pywrapcp.Assignment_Add(self, *args)
3593 return _pywrapcp.Assignment_ForwardSequence(self, var)
3596 return _pywrapcp.Assignment_BackwardSequence(self, var)
3599 return _pywrapcp.Assignment_Unperformed(self, var)
3601 def SetSequence(self, var, forward_sequence, backward_sequence, unperformed):
3602 return _pywrapcp.Assignment_SetSequence(self, var, forward_sequence, backward_sequence, unperformed)
3605 return _pywrapcp.Assignment_SetForwardSequence(self, var, forward_sequence)
3608 return _pywrapcp.Assignment_SetBackwardSequence(self, var, backward_sequence)
3611 return _pywrapcp.Assignment_SetUnperformed(self, var, unperformed)
3614 return _pywrapcp.Assignment_Activate(self, *args)
3617 return _pywrapcp.Assignment_Deactivate(self, *args)
3620 return _pywrapcp.Assignment_Activated(self, *args)
3623 return _pywrapcp.Assignment_DebugString(self)
3626 return _pywrapcp.Assignment_IntVarContainer(self)
3629 return _pywrapcp.Assignment_MutableIntVarContainer(self)
3632 return _pywrapcp.Assignment_IntervalVarContainer(self)
3635 return _pywrapcp.Assignment_MutableIntervalVarContainer(self)
3638 return _pywrapcp.Assignment_SequenceVarContainer(self)
3641 return _pywrapcp.Assignment_MutableSequenceVarContainer(self)
3644 return _pywrapcp.Assignment___eq__(self, assignment)
3647 return _pywrapcp.Assignment___ne__(self, assignment)
3650_pywrapcp.Assignment_swigregister(Assignment)
3653 return _pywrapcp.__lshift__(*args)
3655 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3658 raise AttributeError(
"No constructor defined")
3659 __repr__ = _swig_repr
3664 Dimensions are additional constraints than can restrict what is
3665 possible with the pack constraint. It can be used to set capacity
3666 limits, to count objects per bin, to compute unassigned
3668 This dimension imposes that for all bins b, the weighted sum
3669 (weights[i]) of all objects i assigned to 'b' is less or equal
3675 This dimension imposes that for all bins b, the weighted sum
3676 (weights->Run(i)) of all objects i assigned to 'b' is less or
3677 equal to 'bounds[b]'. Ownership of the callback is transferred to
3678 the pack constraint.
3683 This dimension imposes that for all bins b, the weighted sum
3684 (weights->Run(i, b) of all objects i assigned to 'b' is less or
3685 equal to 'bounds[b]'. Ownership of the callback is transferred to
3686 the pack constraint.
3688 return _pywrapcp.Pack_AddWeightedSumLessOrEqualConstantDimension(self, *args)
3693 This dimension imposes that for all bins b, the weighted sum
3694 (weights[i]) of all objects i assigned to 'b' is equal to loads[b].
3699 This dimension imposes that for all bins b, the weighted sum
3700 (weights->Run(i, b)) of all objects i assigned to 'b' is equal to
3703 return _pywrapcp.Pack_AddWeightedSumEqualVarDimension(self, *args)
3707 This dimension imposes:
3709 sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b]
3710 where is_assigned(i, b) is true if and only if item i is assigned
3713 This can be used to model shapes of items by linking variables of
3714 the same item on parallel dimensions with an allowed assignment
3717 return _pywrapcp.Pack_AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity)
3721 This dimension enforces that cost_var == sum of weights[i] for
3722 all objects 'i' assigned to a bin.
3724 return _pywrapcp.Pack_AddWeightedSumOfAssignedDimension(self, weights, cost_var)
3728 This dimension links 'count_var' to the actual number of bins used in the
3731 return _pywrapcp.Pack_AddCountUsedBinDimension(self, count_var)
3735 This dimension links 'count_var' to the actual number of items
3736 assigned to a bin in the pack.
3738 return _pywrapcp.Pack_AddCountAssignedItemsDimension(self, count_var)
3741 return _pywrapcp.Pack_Post(self)
3744 return _pywrapcp.Pack_InitialPropagateWrapper(self)
3747 return _pywrapcp.Pack_DebugString(self)
3750_pywrapcp.Pack_swigregister(Pack)
3752 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3755 raise AttributeError(
"No constructor defined - class is abstract")
3756 __repr__ = _swig_repr
3759 r""" Creates a sequence variable from the constraint."""
3760 return _pywrapcp.DisjunctiveConstraint_SequenceVar(self)
3764 Add a transition time between intervals. It forces the distance between
3765 the end of interval a and start of interval b that follows it to be at
3766 least transition_time(a, b). This function must always return
3767 a positive or null value.
3769 return _pywrapcp.DisjunctiveConstraint_SetTransitionTime(self, transition_time)
3772 return _pywrapcp.DisjunctiveConstraint_TransitionTime(self, before_index, after_index)
3775_pywrapcp.DisjunctiveConstraint_swigregister(DisjunctiveConstraint)
3778 This class adds reversibility to a POD type.
3779 It contains the stamp optimization. i.e. the SaveValue call is done
3780 only once per node of the search tree. Please note that actual
3781 stamps always starts at 1, thus an initial value of 0 will always
3782 trigger the first SaveValue.
3785 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3786 __repr__ = _swig_repr
3789 _pywrapcp.RevInteger_swiginit(self, _pywrapcp.new_RevInteger(val))
3792 return _pywrapcp.RevInteger_Value(self)
3795 return _pywrapcp.RevInteger_SetValue(self, s, val)
3796 __swig_destroy__ = _pywrapcp.delete_RevInteger
3799_pywrapcp.RevInteger_swigregister(RevInteger)
3801 r""" Subclass of Rev<T> which adds numerical operations."""
3803 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3804 __repr__ = _swig_repr
3807 _pywrapcp.NumericalRevInteger_swiginit(self, _pywrapcp.new_NumericalRevInteger(val))
3810 return _pywrapcp.NumericalRevInteger_Add(self, s, to_add)
3813 return _pywrapcp.NumericalRevInteger_Incr(self, s)
3816 return _pywrapcp.NumericalRevInteger_Decr(self, s)
3817 __swig_destroy__ = _pywrapcp.delete_NumericalRevInteger
3820_pywrapcp.NumericalRevInteger_swigregister(NumericalRevInteger)
3823 This class adds reversibility to a POD type.
3824 It contains the stamp optimization. i.e. the SaveValue call is done
3825 only once per node of the search tree. Please note that actual
3826 stamps always starts at 1, thus an initial value of 0 will always
3827 trigger the first SaveValue.
3830 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3831 __repr__ = _swig_repr
3834 _pywrapcp.RevBool_swiginit(self, _pywrapcp.new_RevBool(val))
3837 return _pywrapcp.RevBool_Value(self)
3840 return _pywrapcp.RevBool_SetValue(self, s, val)
3841 __swig_destroy__ = _pywrapcp.delete_RevBool
3844_pywrapcp.RevBool_swigregister(RevBool)
3846 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3849 raise AttributeError(
"No constructor defined")
3850 __repr__ = _swig_repr
3853 return _pywrapcp.IntVarContainer_Contains(self, var)
3856 return _pywrapcp.IntVarContainer_Element(self, index)
3859 return _pywrapcp.IntVarContainer_Size(self)
3862 return _pywrapcp.IntVarContainer_Store(self)
3865 return _pywrapcp.IntVarContainer_Restore(self)
3869 Returns true if this and 'container' both represent the same V* -> E map.
3870 Runs in linear time; requires that the == operator on the type E is well
3873 return _pywrapcp.IntVarContainer___eq__(self, container)
3876 return _pywrapcp.IntVarContainer___ne__(self, container)
3877 __swig_destroy__ = _pywrapcp.delete_IntVarContainer
3880_pywrapcp.IntVarContainer_swigregister(IntVarContainer)
3882 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3885 raise AttributeError(
"No constructor defined")
3886 __repr__ = _swig_repr
3889 return _pywrapcp.IntervalVarContainer_Contains(self, var)
3892 return _pywrapcp.IntervalVarContainer_Element(self, index)
3895 return _pywrapcp.IntervalVarContainer_Size(self)
3898 return _pywrapcp.IntervalVarContainer_Store(self)
3901 return _pywrapcp.IntervalVarContainer_Restore(self)
3905 Returns true if this and 'container' both represent the same V* -> E map.
3906 Runs in linear time; requires that the == operator on the type E is well
3909 return _pywrapcp.IntervalVarContainer___eq__(self, container)
3912 return _pywrapcp.IntervalVarContainer___ne__(self, container)
3913 __swig_destroy__ = _pywrapcp.delete_IntervalVarContainer
3916_pywrapcp.IntervalVarContainer_swigregister(IntervalVarContainer)
3918 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3921 raise AttributeError(
"No constructor defined")
3922 __repr__ = _swig_repr
3925 return _pywrapcp.SequenceVarContainer_Contains(self, var)
3928 return _pywrapcp.SequenceVarContainer_Element(self, index)
3931 return _pywrapcp.SequenceVarContainer_Size(self)
3934 return _pywrapcp.SequenceVarContainer_Store(self)
3937 return _pywrapcp.SequenceVarContainer_Restore(self)
3941 Returns true if this and 'container' both represent the same V* -> E map.
3942 Runs in linear time; requires that the == operator on the type E is well
3945 return _pywrapcp.SequenceVarContainer___eq__(self, container)
3948 return _pywrapcp.SequenceVarContainer___ne__(self, container)
3949 __swig_destroy__ = _pywrapcp.delete_SequenceVarContainer
3952_pywrapcp.SequenceVarContainer_swigregister(SequenceVarContainer)
3955 The base class for all local search operators.
3957 A local search operator is an object that defines the neighborhood of a
3958 solution. In other words, a neighborhood is the set of solutions which can
3959 be reached from a given solution using an operator.
3961 The behavior of the LocalSearchOperator class is similar to iterators.
3962 The operator is synchronized with an assignment (gives the
3963 current values of the variables); this is done in the Start() method.
3965 Then one can iterate over the neighbors using the MakeNextNeighbor method.
3966 This method returns an assignment which represents the incremental changes
3967 to the current solution. It also returns a second assignment representing
3968 the changes to the last solution defined by the neighborhood operator; this
3969 assignment is empty if the neighborhood operator cannot track this
3973 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
3976 raise AttributeError(
"No constructor defined - class is abstract")
3977 __repr__ = _swig_repr
3980 return _pywrapcp.LocalSearchOperator_NextNeighbor(self, delta, deltadelta)
3983 return _pywrapcp.LocalSearchOperator_Start(self, assignment)
3986 _pywrapcp.disown_LocalSearchOperator(self)
3987 return weakref.proxy(self)
3990_pywrapcp.LocalSearchOperator_swigregister(LocalSearchOperator)
3993 Specialization of LocalSearchOperator built from an array of IntVars
3994 which specifies the scope of the operator.
3995 This class also takes care of storing current variable values in Start(),
3996 keeps track of changes done by the operator and builds the delta.
3997 The Deactivate() method can be used to perform Large Neighborhood Search.
4000 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4001 __repr__ = _swig_repr
4008 _pywrapcp.IntVarLocalSearchOperator_swiginit(self, _pywrapcp.new_IntVarLocalSearchOperator(_self, vars, keep_inverse_values))
4009 __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchOperator
4013 This method should not be overridden. Override OnStart() instead which is
4014 called before exiting this method.
4016 return _pywrapcp.IntVarLocalSearchOperator_Start(self, assignment)
4019 return _pywrapcp.IntVarLocalSearchOperator_IsIncremental(self)
4022 return _pywrapcp.IntVarLocalSearchOperator_Size(self)
4026 Returns the value in the current assignment of the variable of given
4029 return _pywrapcp.IntVarLocalSearchOperator_Value(self, index)
4032 r""" Returns the variable of given index."""
4033 return _pywrapcp.IntVarLocalSearchOperator_Var(self, index)
4036 return _pywrapcp.IntVarLocalSearchOperator_OldValue(self, index)
4039 return _pywrapcp.IntVarLocalSearchOperator_PrevValue(self, index)
4042 return _pywrapcp.IntVarLocalSearchOperator_SetValue(self, index, value)
4045 return _pywrapcp.IntVarLocalSearchOperator_Activated(self, index)
4048 return _pywrapcp.IntVarLocalSearchOperator_Activate(self, index)
4051 return _pywrapcp.IntVarLocalSearchOperator_Deactivate(self, index)
4054 return _pywrapcp.IntVarLocalSearchOperator_AddVars(self, vars)
4058 Called by Start() after synchronizing the operator with the current
4059 assignment. Should be overridden instead of Start() to avoid calling
4060 IntVarLocalSearchOperator::Start explicitly.
4062 return _pywrapcp.IntVarLocalSearchOperator_OnStart(self)
4066 OnStart() should really be protected, but then SWIG doesn't see it. So we
4067 make it public, but only subclasses should access to it (to override it).
4068 Redefines MakeNextNeighbor to export a simpler interface. The calls to
4069 ApplyChanges() and RevertChanges() are factored in this method, hiding
4070 both delta and deltadelta from subclasses which only need to override
4072 Therefore this method should not be overridden. Override MakeOneNeighbor()
4075 return _pywrapcp.IntVarLocalSearchOperator_NextNeighbor(self, delta, deltadelta)
4079 Creates a new neighbor. It returns false when the neighborhood is
4080 completely explored.
4081 MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.
4083 return _pywrapcp.IntVarLocalSearchOperator_OneNeighbor(self)
4086 _pywrapcp.disown_IntVarLocalSearchOperator(self)
4087 return weakref.proxy(self)
4090_pywrapcp.IntVarLocalSearchOperator_swigregister(IntVarLocalSearchOperator)
4093 This is the base class for building an Lns operator. An Lns fragment is a
4094 collection of variables which will be relaxed. Fragments are built with
4095 NextFragment(), which returns false if there are no more fragments to build.
4096 Optionally one can override InitFragments, which is called from
4097 LocalSearchOperator::Start to initialize fragment data.
4099 Here's a sample relaxing one variable at a time:
4101 class OneVarLns : public BaseLns {
4103 OneVarLns(const std::vector<IntVar*>& vars) : BaseLns(vars), index_(0) {}
4104 virtual ~OneVarLns() {}
4105 virtual void InitFragments() { index_ = 0; }
4106 virtual bool NextFragment() {
4107 const int size = Size();
4108 if (index_ < size) {
4109 AppendToFragment(index_);
4122 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4123 __repr__ = _swig_repr
4130 _pywrapcp.BaseLns_swiginit(self, _pywrapcp.new_BaseLns(_self, vars))
4131 __swig_destroy__ = _pywrapcp.delete_BaseLns
4134 return _pywrapcp.BaseLns_InitFragments(self)
4137 return _pywrapcp.BaseLns_NextFragment(self)
4140 return _pywrapcp.BaseLns_AppendToFragment(self, index)
4143 return _pywrapcp.BaseLns_FragmentSize(self)
4146 return _pywrapcp.BaseLns___getitem__(self, index)
4149 return _pywrapcp.BaseLns___len__(self)
4152 _pywrapcp.disown_BaseLns(self)
4153 return weakref.proxy(self)
4156_pywrapcp.BaseLns_swigregister(BaseLns)
4159 Defines operators which change the value of variables;
4160 each neighbor corresponds to *one* modified variable.
4161 Sub-classes have to define ModifyValue which determines what the new
4162 variable value is going to be (given the current value and the variable).
4165 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4166 __repr__ = _swig_repr
4173 _pywrapcp.ChangeValue_swiginit(self, _pywrapcp.new_ChangeValue(_self, vars))
4174 __swig_destroy__ = _pywrapcp.delete_ChangeValue
4177 return _pywrapcp.ChangeValue_ModifyValue(self, index, value)
4180 r""" This method should not be overridden. Override ModifyValue() instead."""
4181 return _pywrapcp.ChangeValue_OneNeighbor(self)
4184 _pywrapcp.disown_ChangeValue(self)
4185 return weakref.proxy(self)
4188_pywrapcp.ChangeValue_swigregister(ChangeValue)
4191 Base class of the local search operators dedicated to path modifications
4192 (a path is a set of nodes linked together by arcs).
4193 This family of neighborhoods supposes they are handling next variables
4194 representing the arcs (var[i] represents the node immediately after i on
4196 Several services are provided:
4197 - arc manipulators (SetNext(), ReverseChain(), MoveChain())
4198 - path inspectors (Next(), Prev(), IsPathEnd())
4199 - path iterators: operators need a given number of nodes to define a
4200 neighbor; this class provides the iteration on a given number of (base)
4201 nodes which can be used to define a neighbor (through the BaseNode method)
4202 Subclasses only need to override MakeNeighbor to create neighbors using
4203 the services above (no direct manipulation of assignments).
4206 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4209 raise AttributeError(
"No constructor defined - class is abstract")
4210 __repr__ = _swig_repr
4213 return _pywrapcp.PathOperator_Neighbor(self)
4216_pywrapcp.PathOperator_swigregister(PathOperator)
4219 Classes to which this template function can be applied to as of 04/2014.
4220 Usage: LocalSearchOperator* op = MakeLocalSearchOperator<Relocate>(...);
4225 class MakeActiveOperator;
4226 class MakeInactiveOperator;
4227 class MakeChainInactiveOperator;
4228 class SwapActiveOperator;
4229 class ExtendedSwapActiveOperator;
4230 class MakeActiveAndRelocate;
4231 class RelocateAndMakeActiveOperator;
4232 class RelocateAndMakeInactiveOperator;
4233 Local Search Filters are used for fast neighbor pruning.
4234 Filtering a move is done in several phases:
4235 - in the Relax phase, filters determine which parts of their internals
4236 will be changed by the candidate, and modify intermediary State
4237 - in the Accept phase, filters check that the candidate is feasible,
4238 - if the Accept phase succeeds, the solver may decide to trigger a
4239 Synchronize phase that makes filters change their internal representation
4240 to the last candidate,
4241 - otherwise (Accept fails or the solver does not want to synchronize),
4242 a Revert phase makes filters erase any intermediary State generated by the
4243 Relax and Accept phases.
4244 A given filter has phases called with the following pattern:
4245 (Relax.Accept.Synchronize | Relax.Accept.Revert | Relax.Revert)*.
4246 Filters's Revert() is always called in the reverse order their Accept() was
4247 called, to allow late filters to use state done/undone by early filters'
4251 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4254 raise AttributeError(
"No constructor defined - class is abstract")
4255 __repr__ = _swig_repr
4257 def Accept(self, delta, deltadelta, objective_min, objective_max):
4259 Accepts a "delta" given the assignment with which the filter has been
4260 synchronized; the delta holds the variables which have been modified and
4262 If the filter represents a part of the global objective, its contribution
4263 must be between objective_min and objective_max.
4264 Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1,
4265 for the assignment (a,1), (b,0), the delta (b,1) will be rejected
4266 but the delta (a,0) will be accepted.
4267 TODO(user): Remove arguments when there are no more need for those.
4269 return _pywrapcp.LocalSearchFilter_Accept(self, delta, deltadelta, objective_min, objective_max)
4272 return _pywrapcp.LocalSearchFilter_IsIncremental(self)
4276 Synchronizes the filter with the current solution, delta being the
4277 difference with the solution passed to the previous call to Synchronize()
4278 or IncrementalSynchronize(). 'delta' can be used to incrementally
4279 synchronizing the filter with the new solution by only considering the
4282 return _pywrapcp.LocalSearchFilter_Synchronize(self, assignment, delta)
4283 __swig_destroy__ = _pywrapcp.delete_LocalSearchFilter
4286_pywrapcp.LocalSearchFilter_swigregister(LocalSearchFilter)
4289 Filter manager: when a move is made, filters are executed to decide whether
4290 the solution is feasible and compute parts of the new cost. This class
4291 schedules filter execution and composes costs as a sum.
4294 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4295 __repr__ = _swig_repr
4298 return _pywrapcp.LocalSearchFilterManager_DebugString(self)
4301 _pywrapcp.LocalSearchFilterManager_swiginit(self, _pywrapcp.new_LocalSearchFilterManager(*args))
4303 def Accept(self, monitor, delta, deltadelta, objective_min, objective_max):
4305 Returns true iff all filters return true, and the sum of their accepted
4306 objectives is between objective_min and objective_max.
4307 The monitor has its Begin/EndFiltering events triggered.
4309 return _pywrapcp.LocalSearchFilterManager_Accept(self, monitor, delta, deltadelta, objective_min, objective_max)
4312 r""" Synchronizes all filters to assignment."""
4313 return _pywrapcp.LocalSearchFilterManager_Synchronize(self, assignment, delta)
4314 __swig_destroy__ = _pywrapcp.delete_LocalSearchFilterManager
4317_pywrapcp.LocalSearchFilterManager_swigregister(LocalSearchFilterManager)
4319 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4320 __repr__ = _swig_repr
4327 _pywrapcp.IntVarLocalSearchFilter_swiginit(self, _pywrapcp.new_IntVarLocalSearchFilter(_self, vars))
4328 __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchFilter
4332 This method should not be overridden. Override OnSynchronize() instead
4333 which is called before exiting this method.
4335 return _pywrapcp.IntVarLocalSearchFilter_Synchronize(self, assignment, delta)
4338 return _pywrapcp.IntVarLocalSearchFilter_Size(self)
4341 return _pywrapcp.IntVarLocalSearchFilter_Value(self, index)
4344 return _pywrapcp.IntVarLocalSearchFilter_IndexFromVar(self, var)
4347 _pywrapcp.disown_IntVarLocalSearchFilter(self)
4348 return weakref.proxy(self)
4351_pywrapcp.IntVarLocalSearchFilter_swigregister(IntVarLocalSearchFilter)
4353 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4356 raise AttributeError(
"No constructor defined - class is abstract")
4357 __repr__ = _swig_repr
4360 return _pywrapcp.BooleanVar_Min(self)
4363 return _pywrapcp.BooleanVar_SetMin(self, m)
4366 return _pywrapcp.BooleanVar_Max(self)
4369 return _pywrapcp.BooleanVar_SetMax(self, m)
4372 return _pywrapcp.BooleanVar_SetRange(self, mi, ma)
4375 return _pywrapcp.BooleanVar_Bound(self)
4378 return _pywrapcp.BooleanVar_Value(self)
4381 return _pywrapcp.BooleanVar_RemoveValue(self, v)
4384 return _pywrapcp.BooleanVar_RemoveInterval(self, l, u)
4387 return _pywrapcp.BooleanVar_WhenBound(self, d)
4390 return _pywrapcp.BooleanVar_WhenRange(self, d)
4393 return _pywrapcp.BooleanVar_WhenDomain(self, d)
4396 return _pywrapcp.BooleanVar_Size(self)
4399 return _pywrapcp.BooleanVar_Contains(self, v)
4402 return _pywrapcp.BooleanVar_HoleIteratorAux(self, reversible)
4405 return _pywrapcp.BooleanVar_DomainIteratorAux(self, reversible)
4408 return _pywrapcp.BooleanVar_DebugString(self)
4411_pywrapcp.BooleanVar_swigregister(BooleanVar)
4417 except Exception
as e:
4418 if 'CP Solver fail' in str(e):
4426 except Exception
as e:
4427 if 'CP Solver fail' in str(e):
4439 return self.Next(solver)
4440 except Exception
as e:
4441 if 'CP Solver fail' in str(e):
4442 return solver.FailDecision()
4447 return "PyDecisionBuilder"
4454 except Exception
as e:
4455 if 'CP Solver fail' in str(e):
4476 return Solver.DELAYED_PRIORITY
if self.
__delayed else Solver.NORMAL_PRIORITY
4479 return 'PyConstraintDemon'
4498 return self.
solver().ConstraintInitialPropagateCallback(self)
4501 return self.
solver().DelayedConstraintInitialPropagateCallback(self)
4505 self.InitialPropagate()
4506 except Exception
as e:
4507 if 'CP Solver fail' in str(e):
4508 self.
solver().ShouldFail()
4513 return "PyConstraint"
4517 Manager for any NodeIndex <-> variable index conversion. The routing solver
4518 uses variable indices internally and through its API. These variable indices
4519 are tricky to manage directly because one Node can correspond to a multitude
4520 of variables, depending on the number of times they appear in the model, and
4521 if they're used as start and/or end points. This class aims to simplify
4522 variable index usage, allowing users to use NodeIndex instead.
4528 auto starts_ends = ...; /// These are NodeIndex.
4529 RoutingIndexManager manager(10, 4, starts_ends); // 10 nodes, 4 vehicles.
4530 RoutingModel model(manager);
4532 Then, use 'manager.NodeToIndex(node)' whenever model requires a variable
4535 Note: the mapping between node indices and variables indices is subject to
4536 change so no assumption should be made on it. The only guarantee is that
4537 indices range between 0 and n-1, where n = number of vehicles * 2 (for start
4538 and end nodes) + number of non-start or end nodes.
4541 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4542 __repr__ = _swig_repr
4545 _pywrapcp.RoutingIndexManager_swiginit(self, _pywrapcp.new_RoutingIndexManager(*args))
4548 return _pywrapcp.RoutingIndexManager_GetNumberOfNodes(self)
4551 return _pywrapcp.RoutingIndexManager_GetNumberOfVehicles(self)
4554 return _pywrapcp.RoutingIndexManager_GetNumberOfIndices(self)
4557 return _pywrapcp.RoutingIndexManager_GetStartIndex(self, vehicle)
4560 return _pywrapcp.RoutingIndexManager_GetEndIndex(self, vehicle)
4563 return _pywrapcp.RoutingIndexManager_NodeToIndex(self, node)
4566 return _pywrapcp.RoutingIndexManager_IndexToNode(self, index)
4567 __swig_destroy__ = _pywrapcp.delete_RoutingIndexManager
4570_pywrapcp.RoutingIndexManager_swigregister(RoutingIndexManager)
4573 return _pywrapcp.DefaultRoutingModelParameters()
4576 return _pywrapcp.DefaultRoutingSearchParameters()
4580 Returns an empty std::string if the routing search parameters are valid, and
4581 a non-empty, human readable error description if they're not.
4583 return _pywrapcp.FindErrorInRoutingSearchParameters(search_parameters)
4584BOOL_UNSPECIFIED = _pywrapcp.BOOL_UNSPECIFIED
4585BOOL_FALSE = _pywrapcp.BOOL_FALSE
4586BOOL_TRUE = _pywrapcp.BOOL_TRUE
4588 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4589 __repr__ = _swig_repr
4592 _pywrapcp.FirstSolutionStrategy_swiginit(self, _pywrapcp.new_FirstSolutionStrategy())
4593 __swig_destroy__ = _pywrapcp.delete_FirstSolutionStrategy
4596_pywrapcp.FirstSolutionStrategy_swigregister(FirstSolutionStrategy)
4598 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4599 __repr__ = _swig_repr
4602 _pywrapcp.LocalSearchMetaheuristic_swiginit(self, _pywrapcp.new_LocalSearchMetaheuristic())
4603 __swig_destroy__ = _pywrapcp.delete_LocalSearchMetaheuristic
4606_pywrapcp.LocalSearchMetaheuristic_swigregister(LocalSearchMetaheuristic)
4608 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4609 __repr__ = _swig_repr
4612 _pywrapcp.PathsMetadata_swiginit(self, _pywrapcp.new_PathsMetadata(manager))
4615 return _pywrapcp.PathsMetadata_IsStart(self, node)
4618 return _pywrapcp.PathsMetadata_IsEnd(self, node)
4621 return _pywrapcp.PathsMetadata_GetPath(self, start_or_end_node)
4624 return _pywrapcp.PathsMetadata_NumPaths(self)
4627 return _pywrapcp.PathsMetadata_Paths(self)
4630 return _pywrapcp.PathsMetadata_Starts(self)
4633 return _pywrapcp.PathsMetadata_Ends(self)
4634 __swig_destroy__ = _pywrapcp.delete_PathsMetadata
4637_pywrapcp.PathsMetadata_swigregister(PathsMetadata)
4639 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
4640 __repr__ = _swig_repr
4641 ROUTING_NOT_SOLVED = _pywrapcp.RoutingModel_ROUTING_NOT_SOLVED
4642 r""" Problem not solved yet (before calling RoutingModel::Solve())."""
4643 ROUTING_SUCCESS = _pywrapcp.RoutingModel_ROUTING_SUCCESS
4644 r""" Problem solved successfully after calling RoutingModel::Solve()."""
4645 ROUTING_PARTIAL_SUCCESS_LOCAL_OPTIMUM_NOT_REACHED = _pywrapcp.RoutingModel_ROUTING_PARTIAL_SUCCESS_LOCAL_OPTIMUM_NOT_REACHED
4647 Problem solved successfully after calling RoutingModel::Solve(), except
4648 that a local optimum has not been reached. Leaving more time would allow
4649 improving the solution.
4651 ROUTING_FAIL = _pywrapcp.RoutingModel_ROUTING_FAIL
4652 r""" No solution found to the problem after calling RoutingModel::Solve()."""
4653 ROUTING_FAIL_TIMEOUT = _pywrapcp.RoutingModel_ROUTING_FAIL_TIMEOUT
4654 r""" Time limit reached before finding a solution with RoutingModel::Solve()."""
4655 ROUTING_INVALID = _pywrapcp.RoutingModel_ROUTING_INVALID
4656 r""" Model, model parameters or flags are not valid."""
4657 ROUTING_INFEASIBLE = _pywrapcp.RoutingModel_ROUTING_INFEASIBLE
4658 r""" Problem proven to be infeasible."""
4659 ROUTING_OPTIMAL = _pywrapcp.RoutingModel_ROUTING_OPTIMAL
4660 r""" Problem has been solved to optimality."""
4661 PICKUP_AND_DELIVERY_NO_ORDER = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_NO_ORDER
4662 r""" Any precedence is accepted."""
4663 PICKUP_AND_DELIVERY_LIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_LIFO
4664 r""" Deliveries must be performed in reverse order of pickups."""
4665 PICKUP_AND_DELIVERY_FIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_FIFO
4666 r""" Deliveries must be performed in the same order as pickups."""
4669 _pywrapcp.RoutingModel_swiginit(self, _pywrapcp.new_RoutingModel(*args))
4670 __swig_destroy__ = _pywrapcp.delete_RoutingModel
4671 kTransitEvaluatorSignUnknown = _pywrapcp.RoutingModel_kTransitEvaluatorSignUnknown
4672 kTransitEvaluatorSignPositiveOrZero = _pywrapcp.RoutingModel_kTransitEvaluatorSignPositiveOrZero
4673 kTransitEvaluatorSignNegativeOrZero = _pywrapcp.RoutingModel_kTransitEvaluatorSignNegativeOrZero
4677 Registers 'callback' and returns its index.
4678 The sign parameter allows to notify the solver that the callback only
4679 return values of the given sign. This can help the solver, but passing
4680 an incorrect sign may crash in non-opt compilation mode, and yield
4681 incorrect results in opt.
4683 return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)
4686 return _pywrapcp.RoutingModel_RegisterUnaryTransitCallback(self, *args)
4689 return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values)
4692 return _pywrapcp.RoutingModel_RegisterTransitCallback(self, *args)
4695 return _pywrapcp.RoutingModel_TransitCallback(self, callback_index)
4698 return _pywrapcp.RoutingModel_UnaryTransitCallbackOrNull(self, callback_index)
4700 def AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name):
4703 Methods to add dimensions to routes; dimensions represent quantities
4704 accumulated at nodes along the routes. They represent quantities such as
4705 weights or volumes carried along the route, or distance or times.
4706 Quantities at a node are represented by "cumul" variables and the increase
4707 or decrease of quantities between nodes are represented by "transit"
4708 variables. These variables are linked as follows:
4709 if j == next(i), cumul(j) = cumul(i) + transit(i, j) + slack(i)
4710 where slack is a positive slack variable (can represent waiting times for
4712 Setting the value of fix_start_cumul_to_zero to true will force the
4713 "cumul" variable of the start node of all vehicles to be equal to 0.
4714 Creates a dimension where the transit variable is constrained to be
4715 equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the
4716 slack variable and 'capacity' is the upper bound of the cumul variables.
4717 'name' is the name used to reference the dimension; this name is used to
4718 get cumul and transit variables from the routing model.
4719 Returns false if a dimension with the same name has already been created
4720 (and doesn't create the new dimension).
4721 Takes ownership of the callback 'evaluator'.
4723 return _pywrapcp.RoutingModel_AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name)
4726 return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name)
4729 return _pywrapcp.RoutingModel_AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
4732 return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
4736 Creates a dimension where the transit variable is constrained to be
4737 equal to 'value'; 'capacity' is the upper bound of the cumul variables.
4738 'name' is the name used to reference the dimension; this name is used to
4739 get cumul and transit variables from the routing model.
4740 Returns a pair consisting of an index to the registered unary transit
4741 callback and a bool denoting whether the dimension has been created.
4742 It is false if a dimension with the same name has already been created
4743 (and doesn't create the new dimension but still register a new callback).
4745 return _pywrapcp.RoutingModel_AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name)
4748 return _pywrapcp.RoutingModel_AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name)
4752 Creates a dimension where the transit variable is constrained to be
4753 equal to 'values[i]' for node i; 'capacity' is the upper bound of
4754 the cumul variables. 'name' is the name used to reference the dimension;
4755 this name is used to get cumul and transit variables from the routing
4757 Returns a pair consisting of an index to the registered unary transit
4758 callback and a bool denoting whether the dimension has been created.
4759 It is false if a dimension with the same name has already been created
4760 (and doesn't create the new dimension but still register a new callback).
4762 return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)
4766 Creates a dimension where the transit variable is constrained to be
4767 equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of
4768 the cumul variables. 'name' is the name used to reference the dimension;
4769 this name is used to get cumul and transit variables from the routing
4771 Returns a pair consisting of an index to the registered transit callback
4772 and a bool denoting whether the dimension has been created.
4773 It is false if a dimension with the same name has already been created
4774 (and doesn't create the new dimension but still register a new callback).
4776 return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)
4779 r""" Outputs the names of all dimensions added to the routing engine."""
4780 return _pywrapcp.RoutingModel_GetAllDimensionNames(self)
4783 r""" Returns all dimensions of the model."""
4784 return _pywrapcp.RoutingModel_GetDimensions(self)
4787 r""" Returns dimensions with soft or vehicle span costs."""
4788 return _pywrapcp.RoutingModel_GetDimensionsWithSoftOrSpanCosts(self)
4791 r""" Returns dimensions for which all transit evaluators are unary."""
4792 return _pywrapcp.RoutingModel_GetUnaryDimensions(self)
4795 r""" Returns the dimensions which have [global|local]_dimension_optimizers_."""
4796 return _pywrapcp.RoutingModel_GetDimensionsWithGlobalCumulOptimizers(self)
4799 return _pywrapcp.RoutingModel_GetDimensionsWithLocalCumulOptimizers(self)
4802 r""" Returns whether the given dimension has global/local cumul optimizers."""
4803 return _pywrapcp.RoutingModel_HasGlobalCumulOptimizer(self, dimension)
4806 return _pywrapcp.RoutingModel_HasLocalCumulOptimizer(self, dimension)
4810 Returns the global/local dimension cumul optimizer for a given dimension,
4811 or nullptr if there is none.
4813 return _pywrapcp.RoutingModel_GetMutableGlobalCumulLPOptimizer(self, dimension)
4816 return _pywrapcp.RoutingModel_GetMutableGlobalCumulMPOptimizer(self, dimension)
4819 return _pywrapcp.RoutingModel_GetMutableLocalCumulLPOptimizer(self, dimension)
4822 return _pywrapcp.RoutingModel_GetMutableLocalCumulMPOptimizer(self, dimension)
4825 r""" Returns true if a dimension exists for a given dimension name."""
4826 return _pywrapcp.RoutingModel_HasDimension(self, dimension_name)
4829 r""" Returns a dimension from its name. Dies if the dimension does not exist."""
4830 return _pywrapcp.RoutingModel_GetDimensionOrDie(self, dimension_name)
4834 Returns a dimension from its name. Returns nullptr if the dimension does
4837 return _pywrapcp.RoutingModel_GetMutableDimension(self, dimension_name)
4841 Set the given dimension as "primary constrained". As of August 2013, this
4842 is only used by ArcIsMoreConstrainedThanArc().
4843 "dimension" must be the name of an existing dimension, or be empty, in
4844 which case there will not be a primary dimension after this call.
4846 return _pywrapcp.RoutingModel_SetPrimaryConstrainedDimension(self, dimension_name)
4849 r""" Get the primary constrained dimension, or an empty string if it is unset."""
4850 return _pywrapcp.RoutingModel_GetPrimaryConstrainedDimension(self)
4853 return _pywrapcp.RoutingModel_GetResourceGroup(self, rg_index)
4857 Returns the indices of resource groups for this dimension. This method can
4858 only be called after the model has been closed.
4860 return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndices(self, dimension)
4864 Returns the index of the resource group attached to the dimension.
4865 DCHECKS that there's exactly one resource group for this dimension.
4867 return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndex(self, dimension)
4871 Adds a disjunction constraint on the indices: exactly 'max_cardinality' of
4872 the indices are active. Start and end indices of any vehicle cannot be
4873 part of a disjunction.
4875 If a penalty is given, at most 'max_cardinality' of the indices can be
4876 active, and if less are active, 'penalty' is payed per inactive index.
4877 This is equivalent to adding the constraint:
4878 p + Sum(i)active[i] == max_cardinality
4879 where p is an integer variable, and the following cost to the cost
4882 'penalty' must be positive to make the disjunction optional; a negative
4883 penalty will force 'max_cardinality' indices of the disjunction to be
4884 performed, and therefore p == 0.
4885 Note: passing a vector with a single index will model an optional index
4886 with a penalty cost if it is not visited.
4888 return _pywrapcp.RoutingModel_AddDisjunction(self, *args)
4891 r""" Returns the indices of the disjunctions to which an index belongs."""
4892 return _pywrapcp.RoutingModel_GetDisjunctionIndices(self, index)
4895 r""" Returns the penalty of the node disjunction of index 'index'."""
4896 return _pywrapcp.RoutingModel_GetDisjunctionPenalty(self, index)
4900 Returns the maximum number of possible active nodes of the node
4901 disjunction of index 'index'.
4903 return _pywrapcp.RoutingModel_GetDisjunctionMaxCardinality(self, index)
4906 r""" Returns the number of node disjunctions in the model."""
4907 return _pywrapcp.RoutingModel_GetNumberOfDisjunctions(self)
4911 Returns true if the model contains mandatory disjunctions (ones with
4912 kNoPenalty as penalty).
4914 return _pywrapcp.RoutingModel_HasMandatoryDisjunctions(self)
4918 Returns true if the model contains at least one disjunction which is
4919 constrained by its max_cardinality.
4921 return _pywrapcp.RoutingModel_HasMaxCardinalityConstrainedDisjunctions(self)
4925 Returns the list of all perfect binary disjunctions, as pairs of variable
4926 indices: a disjunction is "perfect" when its variables do not appear in
4927 any other disjunction. Each pair is sorted (lowest variable index first),
4928 and the output vector is also sorted (lowest pairs first).
4930 return _pywrapcp.RoutingModel_GetPerfectBinaryDisjunctions(self)
4934 SPECIAL: Makes the solver ignore all the disjunctions whose active
4935 variables are all trivially zero (i.e. Max() == 0), by setting their
4936 max_cardinality to 0.
4937 This can be useful when using the BaseBinaryDisjunctionNeighborhood
4938 operators, in the context of arc-based routing.
4940 return _pywrapcp.RoutingModel_IgnoreDisjunctionsAlreadyForcedToZero(self)
4944 Adds a soft constraint to force a set of variable indices to be on the
4945 same vehicle. If all nodes are not on the same vehicle, each extra vehicle
4946 used adds 'cost' to the cost function.
4948 return _pywrapcp.RoutingModel_AddSoftSameVehicleConstraint(self, indices, cost)
4952 Sets the vehicles which can visit a given node. If the node is in a
4953 disjunction, this will not prevent it from being unperformed.
4954 Specifying an empty vector of vehicles has no effect (all vehicles
4955 will be allowed to visit the node).
4957 return _pywrapcp.RoutingModel_SetAllowedVehiclesForIndex(self, vehicles, index)
4960 r""" Returns true if a vehicle is allowed to visit a given node."""
4961 return _pywrapcp.RoutingModel_IsVehicleAllowedForIndex(self, vehicle, index)
4965 Notifies that index1 and index2 form a pair of nodes which should belong
4966 to the same route. This methods helps the search find better solutions,
4967 especially in the local search phase.
4968 It should be called each time you have an equality constraint linking
4969 the vehicle variables of two node (including for instance pickup and
4971 Solver* const solver = routing.solver();
4972 int64_t index1 = manager.NodeToIndex(node1);
4973 int64_t index2 = manager.NodeToIndex(node2);
4974 solver->AddConstraint(solver->MakeEquality(
4975 routing.VehicleVar(index1),
4976 routing.VehicleVar(index2)));
4977 routing.AddPickupAndDelivery(index1, index2);
4979 return _pywrapcp.RoutingModel_AddPickupAndDelivery(self, pickup, delivery)
4983 Same as AddPickupAndDelivery but notifying that the performed node from
4984 the disjunction of index 'pickup_disjunction' is on the same route as the
4985 performed node from the disjunction of index 'delivery_disjunction'.
4987 return _pywrapcp.RoutingModel_AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction)
4990 r""" Returns the pickup and delivery positions where the node is a pickup."""
4991 return _pywrapcp.RoutingModel_GetPickupPositions(self, node_index)
4994 r""" Returns the pickup and delivery positions where the node is a delivery."""
4995 return _pywrapcp.RoutingModel_GetDeliveryPositions(self, node_index)
4998 r""" Returns whether the node is a pickup (resp. delivery)."""
4999 return _pywrapcp.RoutingModel_IsPickup(self, node_index)
5002 return _pywrapcp.RoutingModel_IsDelivery(self, node_index)
5006 Sets the Pickup and delivery policy of all vehicles. It is equivalent to
5007 calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.
5009 return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfAllVehicles(self, policy)
5012 return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle)
5015 return _pywrapcp.RoutingModel_GetPickupAndDeliveryPolicyOfVehicle(self, vehicle)
5019 Returns the number of non-start/end nodes which do not appear in a
5020 pickup/delivery pair.
5022 return _pywrapcp.RoutingModel_GetNumOfSingletonNodes(self)
5023 TYPE_ADDED_TO_VEHICLE = _pywrapcp.RoutingModel_TYPE_ADDED_TO_VEHICLE
5024 r""" When visited, the number of types 'T' on the vehicle increases by one."""
5025 ADDED_TYPE_REMOVED_FROM_VEHICLE = _pywrapcp.RoutingModel_ADDED_TYPE_REMOVED_FROM_VEHICLE
5027 When visited, one instance of type 'T' previously added to the route
5028 (TYPE_ADDED_TO_VEHICLE), if any, is removed from the vehicle.
5029 If the type was not previously added to the route or all added instances
5030 have already been removed, this visit has no effect on the types.
5032 TYPE_ON_VEHICLE_UP_TO_VISIT = _pywrapcp.RoutingModel_TYPE_ON_VEHICLE_UP_TO_VISIT
5034 With the following policy, the visit enforces that type 'T' is
5035 considered on the route from its start until this node is visited.
5037 TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = _pywrapcp.RoutingModel_TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
5039 The visit doesn't have an impact on the number of types 'T' on the
5040 route, as it's (virtually) added and removed directly.
5041 This policy can be used for visits which are part of an incompatibility
5042 or requirement set without affecting the type count on the route.
5046 return _pywrapcp.RoutingModel_SetVisitType(self, index, type, type_policy)
5049 return _pywrapcp.RoutingModel_GetVisitType(self, index)
5052 return _pywrapcp.RoutingModel_GetSingleNodesOfType(self, type)
5055 return _pywrapcp.RoutingModel_GetPairIndicesOfType(self, type)
5058 return _pywrapcp.RoutingModel_GetVisitTypePolicy(self, index)
5062 This function should be called once all node visit types have been set and
5063 prior to adding any incompatibilities/requirements.
5066 return _pywrapcp.RoutingModel_CloseVisitTypes(self)
5069 return _pywrapcp.RoutingModel_GetNumberOfVisitTypes(self)
5074 Two nodes with "hard" incompatible types cannot share the same route at
5075 all, while with a "temporal" incompatibility they can't be on the same
5076 route at the same time.
5078 return _pywrapcp.RoutingModel_AddHardTypeIncompatibility(self, type1, type2)
5081 return _pywrapcp.RoutingModel_AddTemporalTypeIncompatibility(self, type1, type2)
5084 r""" Returns visit types incompatible with a given type."""
5085 return _pywrapcp.RoutingModel_GetHardTypeIncompatibilitiesOfType(self, type)
5088 return _pywrapcp.RoutingModel_GetTemporalTypeIncompatibilitiesOfType(self, type)
5092 Returns true iff any hard (resp. temporal) type incompatibilities have
5093 been added to the model.
5095 return _pywrapcp.RoutingModel_HasHardTypeIncompatibilities(self)
5098 return _pywrapcp.RoutingModel_HasTemporalTypeIncompatibilities(self)
5103 NOTE: As of 2019-04, cycles in the requirement graph are not supported,
5104 and lead to the dependent nodes being skipped if possible (otherwise
5105 the model is considered infeasible).
5106 The following functions specify that "dependent_type" requires at least
5107 one of the types in "required_type_alternatives".
5109 For same-vehicle requirements, a node of dependent type type_D requires at
5110 least one node of type type_R among the required alternatives on the same
5113 return _pywrapcp.RoutingModel_AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives)
5117 If type_D depends on type_R when adding type_D, any node_D of type_D and
5118 VisitTypePolicy TYPE_ADDED_TO_VEHICLE or
5119 TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its
5120 vehicle at the time node_D is visited.
5122 return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives)
5126 The following requirements apply when visiting dependent nodes that remove
5127 their type from the route, i.e. type_R must be on the vehicle when type_D
5128 of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE,
5129 TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is
5132 return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives)
5136 Returns the set of same-vehicle requirement alternatives for the given
5139 return _pywrapcp.RoutingModel_GetSameVehicleRequiredTypeAlternativesOfType(self, type)
5142 r""" Returns the set of requirement alternatives when adding the given type."""
5143 return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenAddingType(self, type)
5146 r""" Returns the set of requirement alternatives when removing the given type."""
5147 return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenRemovingType(self, type)
5151 Returns true iff any same-route (resp. temporal) type requirements have
5152 been added to the model.
5154 return _pywrapcp.RoutingModel_HasSameVehicleTypeRequirements(self)
5157 return _pywrapcp.RoutingModel_HasTemporalTypeRequirements(self)
5161 Returns true iff the model has any incompatibilities or requirements set
5164 return _pywrapcp.RoutingModel_HasTypeRegulations(self)
5168 Get the "unperformed" penalty of a node. This is only well defined if the
5169 node is only part of a single Disjunction, and that disjunction has a
5170 penalty. For forced active nodes returns max int64_t. In all other cases,
5173 return _pywrapcp.RoutingModel_UnperformedPenalty(self, var_index)
5177 Same as above except that it returns default_value instead of 0 when
5178 penalty is not well defined (default value is passed as first argument to
5179 simplify the usage of the method in a callback).
5181 return _pywrapcp.RoutingModel_UnperformedPenaltyOrValue(self, default_value, var_index)
5185 Returns the variable index of the first starting or ending node of all
5186 routes. If all routes start and end at the same node (single depot), this
5187 is the node returned.
5189 return _pywrapcp.RoutingModel_GetDepot(self)
5193 Constrains the maximum number of active vehicles, aka the number of
5194 vehicles which do not have an empty route. For instance, this can be used
5195 to limit the number of routes in the case where there are fewer drivers
5196 than vehicles and that the fleet of vehicle is heterogeneous.
5198 return _pywrapcp.RoutingModel_SetMaximumNumberOfActiveVehicles(self, max_active_vehicles)
5201 r""" Returns the maximum number of active vehicles."""
5202 return _pywrapcp.RoutingModel_GetMaximumNumberOfActiveVehicles(self)
5206 Sets the cost function of the model such that the cost of a segment of a
5207 route between node 'from' and 'to' is evaluator(from, to), whatever the
5208 route or vehicle performing the route.
5210 return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfAllVehicles(self, evaluator_index)
5213 r""" Sets the cost function for a given vehicle route."""
5214 return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle)
5218 Sets the fixed cost of all vehicle routes. It is equivalent to calling
5219 SetFixedCostOfVehicle on all vehicle routes.
5221 return _pywrapcp.RoutingModel_SetFixedCostOfAllVehicles(self, cost)
5224 r""" Sets the fixed cost of one vehicle route."""
5225 return _pywrapcp.RoutingModel_SetFixedCostOfVehicle(self, cost, vehicle)
5229 Returns the route fixed cost taken into account if the route of the
5230 vehicle is not empty, aka there's at least one node on the route other
5231 than the first and last nodes.
5233 return _pywrapcp.RoutingModel_GetFixedCostOfVehicle(self, vehicle)
5236 return _pywrapcp.RoutingModel_SetPathEnergyCostOfVehicle(self, force, distance, unit_cost, vehicle)
5240 The following methods set the linear and quadratic cost factors of
5241 vehicles (must be positive values). The default value of these parameters
5242 is zero for all vehicles.
5244 When set, the cost_ of the model will contain terms aiming at reducing the
5245 number of vehicles used in the model, by adding the following to the
5246 objective for every vehicle v:
5247 INDICATOR(v used in the model) *
5248 [linear_cost_factor_of_vehicle_[v]
5249 - quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)]
5250 i.e. for every used vehicle, we add the linear factor as fixed cost, and
5251 subtract the square of the route length multiplied by the quadratic
5252 factor. This second term aims at making the routes as dense as possible.
5254 Sets the linear and quadratic cost factor of all vehicles.
5256 return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor)
5259 r""" Sets the linear and quadratic cost factor of the given vehicle."""
5260 return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle)
5263 return _pywrapcp.RoutingModel_GetAmortizedLinearCostFactorOfVehicles(self)
5266 return _pywrapcp.RoutingModel_GetAmortizedQuadraticCostFactorOfVehicles(self)
5269 return _pywrapcp.RoutingModel_SetVehicleUsedWhenEmpty(self, is_used, vehicle)
5272 return _pywrapcp.RoutingModel_IsVehicleUsedWhenEmpty(self, vehicle)
5276 Gets/sets the evaluator used during the search. Only relevant when
5277 RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY.
5278 Takes ownership of evaluator.
5280 return _pywrapcp.RoutingModel_SetFirstSolutionEvaluator(self, evaluator)
5284 Adds a local search operator to the set of operators used to solve the
5285 vehicle routing problem.
5287 return _pywrapcp.RoutingModel_AddLocalSearchOperator(self, ls_operator)
5290 r""" Adds a search monitor to the search used to solve the routing model."""
5291 return _pywrapcp.RoutingModel_AddSearchMonitor(self, monitor)
5295 Adds a callback called each time a solution is found during the search.
5296 This is a shortcut to creating a monitor to call the callback on
5297 AtSolution() and adding it with AddSearchMonitor.
5298 If track_unchecked_neighbors is true, the callback will also be called on
5299 AcceptUncheckedNeighbor() events, which is useful to grab solutions
5300 obtained when solver_parameters.check_solution_period > 1 (aka fastLS).
5302 return _pywrapcp.RoutingModel_AddAtSolutionCallback(self, callback, track_unchecked_neighbors)
5306 Adds a variable to minimize in the solution finalizer. The solution
5307 finalizer is called each time a solution is found during the search and
5308 allows to instantiate secondary variables (such as dimension cumul
5311 return _pywrapcp.RoutingModel_AddVariableMinimizedByFinalizer(self, var)
5315 Adds a variable to maximize in the solution finalizer (see above for
5316 information on the solution finalizer).
5318 return _pywrapcp.RoutingModel_AddVariableMaximizedByFinalizer(self, var)
5322 Adds a variable to minimize in the solution finalizer, with a weighted
5323 priority: the higher the more priority it has.
5325 return _pywrapcp.RoutingModel_AddWeightedVariableMinimizedByFinalizer(self, var, cost)
5329 Adds a variable to maximize in the solution finalizer, with a weighted
5330 priority: the higher the more priority it has.
5332 return _pywrapcp.RoutingModel_AddWeightedVariableMaximizedByFinalizer(self, var, cost)
5336 Add a variable to set the closest possible to the target value in the
5339 return _pywrapcp.RoutingModel_AddVariableTargetToFinalizer(self, var, target)
5343 Same as above with a weighted priority: the higher the cost, the more
5344 priority it has to be set close to the target value.
5346 return _pywrapcp.RoutingModel_AddWeightedVariableTargetToFinalizer(self, var, target, cost)
5350 Closes the current routing model; after this method is called, no
5351 modification to the model can be done, but RoutesToAssignment becomes
5352 available. Note that CloseModel() is automatically called by Solve() and
5353 other methods that produce solution.
5354 This is equivalent to calling
5355 CloseModelWithParameters(DefaultRoutingSearchParameters()).
5357 return _pywrapcp.RoutingModel_CloseModel(self)
5361 Same as above taking search parameters (as of 10/2015 some the parameters
5362 have to be set when closing the model).
5364 return _pywrapcp.RoutingModel_CloseModelWithParameters(self, search_parameters)
5368 Solves the current routing model; closes the current model.
5369 This is equivalent to calling
5370 SolveWithParameters(DefaultRoutingSearchParameters())
5372 SolveFromAssignmentWithParameters(assignment,
5373 DefaultRoutingSearchParameters()).
5375 return _pywrapcp.RoutingModel_Solve(self, assignment)
5379 Solves the current routing model with the given parameters. If 'solutions'
5380 is specified, it will contain the k best solutions found during the search
5381 (from worst to best, including the one returned by this method), where k
5382 corresponds to the 'number_of_solutions_to_collect' in
5383 'search_parameters'. Note that the Assignment returned by the method and
5384 the ones in solutions are owned by the underlying solver and should not be
5387 return _pywrapcp.RoutingModel_SolveWithParameters(self, search_parameters, solutions)
5391 Same as above, except that if assignment is not null, it will be used as
5392 the initial solution.
5394 return _pywrapcp.RoutingModel_SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions)
5398 Improves a given assignment using unchecked local search.
5399 If check_solution_in_cp is true the final solution will be checked with
5401 As of 11/2023, only works with greedy descent.
5403 return _pywrapcp.RoutingModel_FastSolveFromAssignmentWithParameters(self, assignment, search_parameters, check_solution_in_cp, touched)
5407 Same as above but will try all assignments in order as first solutions
5410 return _pywrapcp.RoutingModel_SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions)
5414 Solves the current routing model by using an Iterated Local Search
5417 return _pywrapcp.RoutingModel_SolveWithIteratedLocalSearch(self, search_parameters)
5421 Given a "source_model" and its "source_assignment", resets
5422 "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_
5423 if costs aren't homogeneous across vehicles) of "this" model, with the
5424 values set according to those in "other_assignment".
5425 The objective_element of target_assignment is set to this->cost_.
5427 return _pywrapcp.RoutingModel_SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment)
5431 Computes a lower bound to the routing problem solving a linear assignment
5432 problem. The routing model must be closed before calling this method.
5433 Note that problems with node disjunction constraints (including optional
5434 nodes) and non-homogenous costs are not supported (the method returns 0 in
5437 return _pywrapcp.RoutingModel_ComputeLowerBound(self)
5441 Returns the current lower bound found by internal solvers during the
5444 return _pywrapcp.RoutingModel_objective_lower_bound(self)
5447 r""" Returns the current status of the routing model."""
5448 return _pywrapcp.RoutingModel_status(self)
5451 r""" Returns the value of the internal enable_deep_serialization_ parameter."""
5452 return _pywrapcp.RoutingModel_enable_deep_serialization(self)
5456 Applies a lock chain to the next search. 'locks' represents an ordered
5457 vector of nodes representing a partial route which will be fixed during
5458 the next search; it will constrain next variables such that:
5459 next[locks[i]] == locks[i+1].
5461 Returns the next variable at the end of the locked chain; this variable is
5462 not locked. An assignment containing the locks can be obtained by calling
5465 return _pywrapcp.RoutingModel_ApplyLocks(self, locks)
5469 Applies lock chains to all vehicles to the next search, such that locks[p]
5470 is the lock chain for route p. Returns false if the locks do not contain
5471 valid routes; expects that the routes do not contain the depots,
5472 i.e. there are empty vectors in place of empty routes.
5473 If close_routes is set to true, adds the end nodes to the route of each
5474 vehicle and deactivates other nodes.
5475 An assignment containing the locks can be obtained by calling
5478 return _pywrapcp.RoutingModel_ApplyLocksToAllVehicles(self, locks, close_routes)
5482 Returns an assignment used to fix some of the variables of the problem.
5483 In practice, this assignment locks partial routes of the problem. This
5484 can be used in the context of locking the parts of the routes which have
5485 already been driven in online routing problems.
5487 return _pywrapcp.RoutingModel_PreAssignment(self)
5490 return _pywrapcp.RoutingModel_MutablePreAssignment(self)
5494 Writes the current solution to a file containing an AssignmentProto.
5495 Returns false if the file cannot be opened or if there is no current
5498 return _pywrapcp.RoutingModel_WriteAssignment(self, file_name)
5502 Reads an assignment from a file and returns the current solution.
5503 Returns nullptr if the file cannot be opened or if the assignment is not
5506 return _pywrapcp.RoutingModel_ReadAssignment(self, file_name)
5510 Restores an assignment as a solution in the routing model and returns the
5511 new solution. Returns nullptr if the assignment is not valid.
5513 return _pywrapcp.RoutingModel_RestoreAssignment(self, solution)
5517 Restores the routes as the current solution. Returns nullptr if the
5518 solution cannot be restored (routes do not contain a valid solution). Note
5519 that calling this method will run the solver to assign values to the
5520 dimension variables; this may take considerable amount of time, especially
5521 when using dimensions with slack.
5523 return _pywrapcp.RoutingModel_ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices)
5527 Fills an assignment from a specification of the routes of the
5528 vehicles. The routes are specified as lists of variable indices that
5529 appear on the routes of the vehicles. The indices of the outer vector in
5530 'routes' correspond to vehicles IDs, the inner vector contains the
5531 variable indices on the routes for the given vehicle. The inner vectors
5532 must not contain the start and end indices, as these are determined by the
5533 routing model. Sets the value of NextVars in the assignment, adding the
5534 variables to the assignment if necessary. The method does not touch other
5535 variables in the assignment. The method can only be called after the model
5536 is closed. With ignore_inactive_indices set to false, this method will
5537 fail (return nullptr) in case some of the route contain indices that are
5538 deactivated in the model; when set to true, these indices will be
5539 skipped. Returns true if routes were successfully
5540 loaded. However, such assignment still might not be a valid
5541 solution to the routing problem due to more complex constraints;
5542 it is advisible to call solver()->CheckSolution() afterwards.
5544 return _pywrapcp.RoutingModel_RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment)
5548 Converts the solution in the given assignment to routes for all vehicles.
5549 Expects that assignment contains a valid solution (i.e. routes for all
5550 vehicles end with an end index for that vehicle).
5552 return _pywrapcp.RoutingModel_AssignmentToRoutes(self, assignment, routes)
5556 Converts the solution in the given assignment to routes for all vehicles.
5557 If the returned vector is route_indices, route_indices[i][j] is the index
5558 for jth location visited on route i. Note that contrary to
5559 AssignmentToRoutes, the vectors do include start and end locations.
5560 Returns a compacted version of the given assignment, in which all vehicles
5561 with id lower or equal to some N have non-empty routes, and all vehicles
5562 with id greater than N have empty routes. Does not take ownership of the
5564 If found, the cost of the compact assignment is the same as in the
5565 original assignment and it preserves the values of 'active' variables.
5566 Returns nullptr if a compact assignment was not found.
5567 This method only works in homogenous mode, and it only swaps equivalent
5568 vehicles (vehicles with the same start and end nodes). When creating the
5569 compact assignment, the empty plan is replaced by the route assigned to
5570 the compatible vehicle with the highest id. Note that with more complex
5571 constraints on vehicle variables, this method might fail even if a compact
5573 This method changes the vehicle and dimension variables as necessary.
5574 While compacting the solution, only basic checks on vehicle variables are
5575 performed; if one of these checks fails no attempts to repair it are made
5576 (instead, the method returns nullptr).
5578 return _pywrapcp.RoutingModel_CompactAssignment(self, assignment)
5582 Same as CompactAssignment() but also checks the validity of the final
5583 compact solution; if it is not valid, no attempts to repair it are made
5584 (instead, the method returns nullptr).
5586 return _pywrapcp.RoutingModel_CompactAndCheckAssignment(self, assignment)
5589 r""" Adds an extra variable to the vehicle routing assignment."""
5590 return _pywrapcp.RoutingModel_AddToAssignment(self, var)
5593 return _pywrapcp.RoutingModel_AddIntervalToAssignment(self, interval)
5597 For every dimension in the model with an optimizer in
5598 local/global_dimension_optimizers_, this method tries to pack the cumul
5599 values of the dimension, such that:
5600 - The cumul costs (span costs, soft lower and upper bound costs, etc) are
5602 - The cumuls of the ends of the routes are minimized for this given
5604 - Given these minimal end cumuls, the route start cumuls are maximized.
5605 Returns the assignment resulting from allocating these packed cumuls with
5606 the solver, and nullptr if these cumuls could not be set by the solver.
5608 return _pywrapcp.RoutingModel_PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached)
5613 Returns neighbors of all nodes for every cost class. The result is cached
5614 and is computed once. The number of neighbors considered is based on a
5615 ratio of non-vehicle nodes, specified by neighbors_ratio, with a minimum
5616 of min-neighbors node considered.
5621 Returns parameters.num_neighbors neighbors of all nodes for every cost
5622 class. The result is cached and is computed once.
5627 Returns parameters.num_neighbors neighbors of all nodes for every cost
5628 class. The result is cached and is computed once.
5630 return _pywrapcp.RoutingModel_GetOrCreateNodeNeighborsByCostClass(self, *args)
5634 Adds a custom local search filter to the list of filters used to speed up
5635 local search by pruning unfeasible variable assignments.
5636 Calling this method after the routing model has been closed (CloseModel()
5637 or Solve() has been called) has no effect.
5638 The routing model does not take ownership of the filter.
5640 return _pywrapcp.RoutingModel_AddLocalSearchFilter(self, filter)
5645 Returns the variable index of the starting node of a vehicle route.
5647 return _pywrapcp.RoutingModel_Start(self, vehicle)
5650 r""" Returns the variable index of the ending node of a vehicle route."""
5651 return _pywrapcp.RoutingModel_End(self, vehicle)
5654 r""" Returns true if 'index' represents the first node of a route."""
5655 return _pywrapcp.RoutingModel_IsStart(self, index)
5658 r""" Returns true if 'index' represents the last node of a route."""
5659 return _pywrapcp.RoutingModel_IsEnd(self, index)
5663 Returns the vehicle of the given start/end index, and -1 if the given
5664 index is not a vehicle start/end.
5666 return _pywrapcp.RoutingModel_VehicleIndex(self, index)
5670 Assignment inspection
5671 Returns the variable index of the node directly after the node
5672 corresponding to 'index' in 'assignment'.
5674 return _pywrapcp.RoutingModel_Next(self, assignment, index)
5677 r""" Returns true if the route of 'vehicle' is non empty in 'assignment'."""
5678 return _pywrapcp.RoutingModel_IsVehicleUsed(self, assignment, vehicle)
5682 Returns the next variable of the node corresponding to index. Note that
5683 NextVar(index) == index is equivalent to ActiveVar(index) == 0.
5685 return _pywrapcp.RoutingModel_NextVar(self, index)
5688 r""" Returns the active variable of the node corresponding to index."""
5689 return _pywrapcp.RoutingModel_ActiveVar(self, index)
5693 Returns the active variable of the vehicle. It will be equal to 1 iff the
5694 route of the vehicle is not empty, 0 otherwise.
5696 return _pywrapcp.RoutingModel_ActiveVehicleVar(self, vehicle)
5700 Returns the variable specifying whether or not the given vehicle route is
5701 considered for costs and constraints. It will be equal to 1 iff the route
5702 of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.
5704 return _pywrapcp.RoutingModel_VehicleRouteConsideredVar(self, vehicle)
5708 Returns the vehicle variable of the node corresponding to index. Note that
5709 VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.
5711 return _pywrapcp.RoutingModel_VehicleVar(self, index)
5715 Returns the resource variable for the given vehicle index in the given
5716 resource group. If a vehicle doesn't require a resource from the
5717 corresponding resource group, then ResourceVar(v, r_g) == -1.
5719 return _pywrapcp.RoutingModel_ResourceVar(self, vehicle, resource_group)
5722 r""" Returns the global cost variable which is being minimized."""
5723 return _pywrapcp.RoutingModel_CostVar(self)
5727 Returns the cost of the transit arc between two nodes for a given vehicle.
5728 Input are variable indices of node. This returns 0 if vehicle < 0.
5730 return _pywrapcp.RoutingModel_GetArcCostForVehicle(self, from_index, to_index, vehicle)
5733 r""" Whether costs are homogeneous across all vehicles."""
5734 return _pywrapcp.RoutingModel_CostsAreHomogeneousAcrossVehicles(self)
5738 Returns the cost of the segment between two nodes supposing all vehicle
5739 costs are the same (returns the cost for the first vehicle otherwise).
5741 return _pywrapcp.RoutingModel_GetHomogeneousCost(self, from_index, to_index)
5745 Returns the cost of the arc in the context of the first solution strategy.
5746 This is typically a simplification of the actual cost; see the .cc.
5748 return _pywrapcp.RoutingModel_GetArcCostForFirstSolution(self, from_index, to_index)
5752 Returns the cost of the segment between two nodes for a given cost
5753 class. Input are variable indices of nodes and the cost class.
5754 Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the
5755 returned cost won't necessarily be zero: only some of the components
5756 of the cost that depend on the cost class will be omited. See the code
5759 return _pywrapcp.RoutingModel_GetArcCostForClass(self, from_index, to_index, cost_class_index)
5762 r""" Get the cost class index of the given vehicle."""
5763 return _pywrapcp.RoutingModel_GetCostClassIndexOfVehicle(self, vehicle)
5767 Returns true iff the model contains a vehicle with the given
5770 return _pywrapcp.RoutingModel_HasVehicleWithCostClassIndex(self, cost_class_index)
5773 r""" Returns the number of different cost classes in the model."""
5774 return _pywrapcp.RoutingModel_GetCostClassesCount(self)
5777 r""" Ditto, minus the 'always zero', built-in cost class."""
5778 return _pywrapcp.RoutingModel_GetNonZeroCostClassesCount(self)
5781 return _pywrapcp.RoutingModel_GetVehicleClassIndexOfVehicle(self, vehicle)
5785 Returns a vehicle of the given vehicle class, and -1 if there are no
5786 vehicles for this class.
5788 return _pywrapcp.RoutingModel_GetVehicleOfClass(self, vehicle_class)
5791 r""" Returns the number of different vehicle classes in the model."""
5792 return _pywrapcp.RoutingModel_GetVehicleClassesCount(self)
5795 r""" Returns variable indices of nodes constrained to be on the same route."""
5796 return _pywrapcp.RoutingModel_GetSameVehicleIndicesOfIndex(self, node)
5799 return _pywrapcp.RoutingModel_GetVehicleTypeContainer(self)
5803 Returns whether the arc from->to1 is more constrained than from->to2,
5804 taking into account, in order:
5805 - whether the destination node isn't an end node
5806 - whether the destination node is mandatory
5807 - whether the destination node is bound to the same vehicle as the source
5808 - the "primary constrained" dimension (see SetPrimaryConstrainedDimension)
5809 It then breaks ties using, in order:
5810 - the arc cost (taking unperformed penalties into account)
5811 - the size of the vehicle vars of "to1" and "to2" (lowest size wins)
5812 - the value: the lowest value of the indices to1 and to2 wins.
5813 See the .cc for details.
5814 The more constrained arc is typically preferable when building a
5815 first solution. This method is intended to be used as a callback for the
5816 BestValueByComparisonSelector value selector.
5818 from: the variable index of the source node
5819 to1: the variable index of the first candidate destination node.
5820 to2: the variable index of the second candidate destination node.
5822 return _pywrapcp.RoutingModel_ArcIsMoreConstrainedThanArc(self, _from, to1, to2)
5826 Print some debugging information about an assignment, including the
5827 feasible intervals of the CumulVar for dimension "dimension_to_print"
5828 at each step of the routes.
5829 If "dimension_to_print" is omitted, all dimensions will be printed.
5831 return _pywrapcp.RoutingModel_DebugOutputAssignment(self, solution_assignment, dimension_to_print)
5835 Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair
5836 containing the minimum and maximum of the CumulVar of the jth node on
5838 - cumul_bounds[i][j].first is the minimum.
5839 - cumul_bounds[i][j].second is the maximum.
5840 Checks if an assignment is feasible.
5842 return _pywrapcp.RoutingModel_CheckIfAssignmentIsFeasible(self, assignment, call_at_solution_monitors)
5846 Returns the underlying constraint solver. Can be used to add extra
5847 constraints and/or modify search algorithms.
5849 return _pywrapcp.RoutingModel_solver(self)
5853 Returns true if the search limit has been crossed with the given time
5856 return _pywrapcp.RoutingModel_CheckLimit(self, *args)
5859 r""" Returns the time left in the search limit."""
5860 return _pywrapcp.RoutingModel_RemainingTime(self)
5863 r""" Updates the time limit of the search limit."""
5864 return _pywrapcp.RoutingModel_UpdateTimeLimit(self, time_limit)
5867 r""" Returns the time buffer to safely return a solution."""
5868 return _pywrapcp.RoutingModel_TimeBuffer(self)
5871 r""" Returns the atomic<bool> to stop the CP-SAT solver."""
5872 return _pywrapcp.RoutingModel_GetMutableCPSatInterrupt(self)
5875 r""" Returns the atomic<bool> to stop the CP solver."""
5876 return _pywrapcp.RoutingModel_GetMutableCPInterrupt(self)
5879 r""" Cancels the current search."""
5880 return _pywrapcp.RoutingModel_CancelSearch(self)
5885 Returns the number of nodes in the model.
5887 return _pywrapcp.RoutingModel_nodes(self)
5890 r""" Returns the number of vehicle routes in the model."""
5891 return _pywrapcp.RoutingModel_vehicles(self)
5894 r""" Returns the number of next variables in the model."""
5895 return _pywrapcp.RoutingModel_Size(self)
5899 Returns statistics on first solution search, number of decisions sent to
5900 filters, number of decisions rejected by filters.
5902 return _pywrapcp.RoutingModel_GetNumberOfDecisionsInFirstSolution(self, search_parameters)
5905 return _pywrapcp.RoutingModel_GetNumberOfRejectsInFirstSolution(self, search_parameters)
5908 r""" Returns the automatic first solution strategy selected."""
5909 return _pywrapcp.RoutingModel_GetAutomaticFirstSolutionStrategy(self)
5912 r""" Returns true if a vehicle/node matching problem is detected."""
5913 return _pywrapcp.RoutingModel_IsMatchingModel(self)
5917 Returns true if routes are interdependent. This means that any
5918 modification to a route might impact another.
5920 return _pywrapcp.RoutingModel_AreRoutesInterdependent(self, parameters)
5924 The next few members are in the public section only for testing purposes.
5926 MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a
5927 dimension using a callback to choose which values to start with.
5928 The finalizer works only when all next variables in the model have
5929 been fixed. It has the following two characteristics:
5930 1. It follows the routes defined by the nexts variables when choosing a
5931 variable to make a decision on.
5932 2. When it comes to choose a value for the slack of node i, the decision
5933 builder first calls the callback with argument i, and supposingly the
5934 returned value is x it creates decisions slack[i] = x, slack[i] = x +
5935 1, slack[i] = x - 1, slack[i] = x + 2, etc.
5937 return _pywrapcp.RoutingModel_MakeGuidedSlackFinalizer(self, dimension, initializer)
5941 MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a
5942 self-dependent dimension. It makes an extensive use of the caches of the
5943 state dependent transits.
5944 In detail, MakeSelfDependentDimensionFinalizer returns a composition of a
5945 local search decision builder with a greedy descent operator for the cumul
5946 of the start of each route and a guided slack finalizer. Provided there
5947 are no time windows and the maximum slacks are large enough, once the
5948 cumul of the start of route is fixed, the guided finalizer can find
5949 optimal values of the slacks for the rest of the route in time
5950 proportional to the length of the route. Therefore the composed finalizer
5951 generally works in time O(log(t)*n*m), where t is the latest possible
5952 departute time, n is the number of nodes in the network and m is the
5955 return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension)
5958 return _pywrapcp.RoutingModel_GetPathsMetadata(self)
5961_pywrapcp.RoutingModel_swigregister(RoutingModel)
5962cvar = _pywrapcp.cvar
5963RoutingModel.kNoPenalty = _pywrapcp.cvar.RoutingModel_kNoPenalty
5964RoutingModel.kNoDisjunction = _pywrapcp.cvar.RoutingModel_kNoDisjunction
5965RoutingModel.kNoDimension = _pywrapcp.cvar.RoutingModel_kNoDimension
5968 r""" Routing model visitor."""
5970 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
5971 __repr__ = _swig_repr
5974 _pywrapcp.RoutingModelVisitor_swiginit(self, _pywrapcp.new_RoutingModelVisitor())
5975 __swig_destroy__ = _pywrapcp.delete_RoutingModelVisitor
5978_pywrapcp.RoutingModelVisitor_swigregister(RoutingModelVisitor)
5979RoutingModelVisitor.kLightElement = _pywrapcp.cvar.RoutingModelVisitor_kLightElement
5980RoutingModelVisitor.kLightElement2 = _pywrapcp.cvar.RoutingModelVisitor_kLightElement2
5981RoutingModelVisitor.kRemoveValues = _pywrapcp.cvar.RoutingModelVisitor_kRemoveValues
5985 GlobalVehicleBreaksConstraint ensures breaks constraints are enforced on
5986 all vehicles in the dimension passed to its constructor.
5987 It is intended to be used for dimensions representing time.
5988 A break constraint ensures break intervals fit on the route of a vehicle.
5989 For a given vehicle, it forces break intervals to be disjoint from visit
5990 intervals, where visit intervals start at CumulVar(node) and last for
5991 node_visit_transit[node]. Moreover, it ensures that there is enough time
5992 between two consecutive nodes of a route to do transit and vehicle breaks,
5993 i.e. if Next(nodeA) = nodeB, CumulVar(nodeA) = tA and CumulVar(nodeB) = tB,
5994 then SlackVar(nodeA) >= sum_{breaks [tA, tB)} duration(break).
5997 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
5998 __repr__ = _swig_repr
6001 _pywrapcp.GlobalVehicleBreaksConstraint_swiginit(self, _pywrapcp.new_GlobalVehicleBreaksConstraint(dimension))
6004 return _pywrapcp.GlobalVehicleBreaksConstraint_DebugString(self)
6007 return _pywrapcp.GlobalVehicleBreaksConstraint_Post(self)
6010 return _pywrapcp.GlobalVehicleBreaksConstraint_InitialPropagateWrapper(self)
6011 __swig_destroy__ = _pywrapcp.delete_GlobalVehicleBreaksConstraint
6014_pywrapcp.GlobalVehicleBreaksConstraint_swigregister(GlobalVehicleBreaksConstraint)
6016 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
6019 raise AttributeError(
"No constructor defined - class is abstract")
6020 __repr__ = _swig_repr
6021 __swig_destroy__ = _pywrapcp.delete_TypeRegulationsChecker
6024 return _pywrapcp.TypeRegulationsChecker_CheckVehicle(self, vehicle, next_accessor)
6027_pywrapcp.TypeRegulationsChecker_swigregister(TypeRegulationsChecker)
6029 r""" Checker for type incompatibilities."""
6031 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
6032 __repr__ = _swig_repr
6034 def __init__(self, model, check_hard_incompatibilities):
6035 _pywrapcp.TypeIncompatibilityChecker_swiginit(self, _pywrapcp.new_TypeIncompatibilityChecker(model, check_hard_incompatibilities))
6036 __swig_destroy__ = _pywrapcp.delete_TypeIncompatibilityChecker
6039_pywrapcp.TypeIncompatibilityChecker_swigregister(TypeIncompatibilityChecker)
6041 r""" Checker for type requirements."""
6043 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
6044 __repr__ = _swig_repr
6047 _pywrapcp.TypeRequirementChecker_swiginit(self, _pywrapcp.new_TypeRequirementChecker(model))
6048 __swig_destroy__ = _pywrapcp.delete_TypeRequirementChecker
6051_pywrapcp.TypeRequirementChecker_swigregister(TypeRequirementChecker)
6054 The following constraint ensures that incompatibilities and requirements
6055 between types are respected.
6057 It verifies both "hard" and "temporal" incompatibilities.
6058 Two nodes with hard incompatible types cannot be served by the same vehicle
6059 at all, while with a temporal incompatibility they can't be on the same
6060 route at the same time.
6061 The VisitTypePolicy of a node determines how visiting it impacts the type
6065 - three temporally incompatible types T1 T2 and T3
6066 - 2 pairs of nodes a1/r1 and a2/r2 of type T1 and T2 respectively, with
6067 - a1 and a2 of VisitTypePolicy TYPE_ADDED_TO_VEHICLE
6068 - r1 and r2 of policy ADDED_TYPE_REMOVED_FROM_VEHICLE
6069 - 3 nodes A, UV and AR of type T3, respectively with type policies
6070 TYPE_ADDED_TO_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT and
6071 TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
6073 UV --> a1 --> r1 --> a2 --> r2, a1 --> r1 --> a2 --> r2 --> A and
6074 a1 --> r1 --> AR --> a2 --> r2 are acceptable, whereas the configurations
6075 a1 --> a2 --> r1 --> ..., or A --> a1 --> r1 --> ..., or
6076 a1 --> r1 --> UV --> ... are not feasible.
6078 It also verifies same-vehicle and temporal type requirements.
6079 A node of type T_d with a same-vehicle requirement for type T_r needs to be
6080 served by the same vehicle as a node of type T_r.
6081 Temporal requirements, on the other hand, can take effect either when the
6082 dependent type is being added to the route or when it's removed from it,
6083 which is determined by the dependent node's VisitTypePolicy.
6084 In the above example:
6085 - If T3 is required on the same vehicle as T1, A, AR or UV must be on the
6087 - If T2 is required when adding T1, a2 must be visited *before* a1, and if
6088 r2 is also visited on the route, it must be *after* a1, i.e. T2 must be on
6089 the vehicle when a1 is visited:
6090 ... --> a2 --> ... --> a1 --> ... --> r2 --> ...
6091 - If T3 is required when removing T1, T3 needs to be on the vehicle when
6093 ... --> A --> ... --> r1 --> ... OR ... --> r1 --> ... --> UV --> ...
6096 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
6097 __repr__ = _swig_repr
6100 _pywrapcp.TypeRegulationsConstraint_swiginit(self, _pywrapcp.new_TypeRegulationsConstraint(model))
6103 return _pywrapcp.TypeRegulationsConstraint_Post(self)
6106 return _pywrapcp.TypeRegulationsConstraint_InitialPropagateWrapper(self)
6107 __swig_destroy__ = _pywrapcp.delete_TypeRegulationsConstraint
6110_pywrapcp.TypeRegulationsConstraint_swigregister(TypeRegulationsConstraint)
6113 A structure meant to store soft bounds and associated violation constants.
6114 It is 'Simple' because it has one BoundCost per element,
6115 in contrast to 'Multiple'. Design notes:
6116 - it is meant to store model information to be shared through pointers,
6117 so it disallows copy and assign to avoid accidental duplication.
6118 - it keeps soft bounds as an array of structs to help cache,
6119 because code that uses such bounds typically use both bound and cost.
6120 - soft bounds are named pairs, prevents some mistakes.
6121 - using operator[] to access elements is not interesting,
6122 because the structure will be accessed through pointers, moreover having
6123 to type bound_cost reminds the user of the order if they do a copy
6124 assignment of the element.
6127 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
6128 __repr__ = _swig_repr
6129 bound = property(_pywrapcp.BoundCost_bound_get, _pywrapcp.BoundCost_bound_set)
6130 cost = property(_pywrapcp.BoundCost_cost_get, _pywrapcp.BoundCost_cost_set)
6133 _pywrapcp.BoundCost_swiginit(self, _pywrapcp.new_BoundCost(*args))
6134 __swig_destroy__ = _pywrapcp.delete_BoundCost
6137_pywrapcp.BoundCost_swigregister(BoundCost)
6139 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
6140 __repr__ = _swig_repr
6143 _pywrapcp.SimpleBoundCosts_swiginit(self, _pywrapcp.new_SimpleBoundCosts(num_bounds, default_bound_cost))
6146 return _pywrapcp.SimpleBoundCosts_bound_cost(self, element)
6149 return _pywrapcp.SimpleBoundCosts_size(self)
6150 __swig_destroy__ = _pywrapcp.delete_SimpleBoundCosts
6153_pywrapcp.SimpleBoundCosts_swigregister(SimpleBoundCosts)
6156 Dimensions represent quantities accumulated at nodes along the routes. They
6157 represent quantities such as weights or volumes carried along the route, or
6160 Quantities at a node are represented by "cumul" variables and the increase
6161 or decrease of quantities between nodes are represented by "transit"
6162 variables. These variables are linked as follows:
6165 cumuls(j) = cumuls(i) + transits(i) + slacks(i) +
6166 state_dependent_transits(i)
6168 where slack is a positive slack variable (can represent waiting times for
6169 a time dimension), and state_dependent_transits is a non-purely functional
6170 version of transits_. Favour transits over state_dependent_transits when
6171 possible, because purely functional callbacks allow more optimisations and
6172 make the model faster and easier to solve.
6173 for a given vehicle, it is passed as an external vector, it would be better
6174 to have this information here.
6177 thisown = property(
lambda x: x.this.own(),
lambda x, v: x.this.own(v), doc=
"The membership flag")
6180 raise AttributeError(
"No constructor defined")
6181 __repr__ = _swig_repr
6182 __swig_destroy__ = _pywrapcp.delete_RoutingDimension
6185 r""" Returns the model on which the dimension was created."""
6186 return _pywrapcp.RoutingDimension_model(self)
6190 Returns the transition value for a given pair of nodes (as var index);
6191 this value is the one taken by the corresponding transit variable when
6192 the 'next' variable for 'from_index' is bound to 'to_index'.
6194 return _pywrapcp.RoutingDimension_GetTransitValue(self, from_index, to_index, vehicle)
6198 Same as above but taking a vehicle class of the dimension instead of a
6199 vehicle (the class of a vehicle can be obtained with vehicle_to_class()).
6201 return _pywrapcp.RoutingDimension_GetTransitValueFromClass(self, from_index, to_index, vehicle_class)
6205 Get the cumul, transit and slack variables for the given node (given as
6208 return _pywrapcp.RoutingDimension_CumulVar(self, index)
6211 return _pywrapcp.RoutingDimension_TransitVar(self, index)
6214 return _pywrapcp.RoutingDimension_FixedTransitVar(self, index)
6217 return _pywrapcp.RoutingDimension_SlackVar(self, index)
6221 Sets an upper bound on the dimension span on a given vehicle. This is the
6222 preferred way to limit the "length" of the route of a vehicle according to
6225 return _pywrapcp.RoutingDimension_SetSpanUpperBoundForVehicle(self, upper_bound, vehicle)
6229 Sets a cost proportional to the dimension span on a given vehicle,
6230 or on all vehicles at once. "coefficient" must be nonnegative.
6231 This is handy to model costs proportional to idle time when the dimension
6233 The cost for a vehicle is
6234 span_cost = coefficient * (dimension end value - dimension start value).
6236 return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForVehicle(self, coefficient, vehicle)
6239 return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForAllVehicles(self, coefficient)
6243 Sets a cost proportional to the dimension total slack on a given vehicle,
6244 or on all vehicles at once. "coefficient" must be nonnegative.
6245 This is handy to model costs only proportional to idle time when the
6246 dimension represents time.
6247 The cost for a vehicle is
6248 slack_cost = coefficient *
6249 (dimension end value - dimension start value - total_transit).
6251 return _pywrapcp.RoutingDimension_SetSlackCostCoefficientForVehicle(self, coefficient, vehicle)
6254 return _pywrapcp.RoutingDimension_SetSlackCostCoefficientForAllVehicles(self, coefficient)
6258 Sets a cost proportional to the *global* dimension span, that is the
6259 difference between the largest value of route end cumul variables and
6260 the smallest value of route start cumul variables.
6263 coefficient * (Max(dimension end value) - Min(dimension start value)).
6265 return _pywrapcp.RoutingDimension_SetGlobalSpanCostCoefficient(self, coefficient)
6269 Sets a soft upper bound to the cumul variable of a given variable index.
6270 If the value of the cumul variable is greater than the bound, a cost
6271 proportional to the difference between this value and the bound is added
6272 to the cost function of the model:
6273 cumulVar <= upper_bound -> cost = 0
6274 cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound)
6275 This is also handy to model tardiness costs when the dimension represents
6278 return _pywrapcp.RoutingDimension_SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient)
6282 Returns true if a soft upper bound has been set for a given variable
6285 return _pywrapcp.RoutingDimension_HasCumulVarSoftUpperBound(self, index)
6289 Returns the soft upper bound of a cumul variable for a given variable
6290 index. The "hard" upper bound of the variable is returned if no soft upper
6293 return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBound(self, index)
6297 Returns the cost coefficient of the soft upper bound of a cumul variable
6298 for a given variable index. If no soft upper bound has been set, 0 is
6301 return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBoundCoefficient(self, index)
6305 Sets a soft lower bound to the cumul variable of a given variable index.
6306 If the value of the cumul variable is less than the bound, a cost
6307 proportional to the difference between this value and the bound is added
6308 to the cost function of the model:
6309 cumulVar > lower_bound -> cost = 0
6310 cumulVar <= lower_bound -> cost = coefficient * (lower_bound -
6312 This is also handy to model earliness costs when the dimension represents
6315 return _pywrapcp.RoutingDimension_SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient)
6319 Returns true if a soft lower bound has been set for a given variable
6322 return _pywrapcp.RoutingDimension_HasCumulVarSoftLowerBound(self, index)
6326 Returns the soft lower bound of a cumul variable for a given variable
6327 index. The "hard" lower bound of the variable is returned if no soft lower
6330 return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBound(self, index)
6334 Returns the cost coefficient of the soft lower bound of a cumul variable
6335 for a given variable index. If no soft lower bound has been set, 0 is
6338 return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBoundCoefficient(self, index)
6342 Sets the breaks for a given vehicle. Breaks are represented by
6343 IntervalVars. They may interrupt transits between nodes and increase
6344 the value of corresponding slack variables.
6345 A break may take place before the start of a vehicle, after the end of
6346 a vehicle, or during a travel i -> j.
6348 In that case, the interval [break.Start(), break.End()) must be a subset
6349 of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In
6350 other words, a break may not overlap any node n's visit, given by
6351 [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)).
6352 This formula considers post_travel(_, start) and pre_travel(end, _) to be
6353 0; pre_travel will never be called on any (_, start) and post_travel will
6354 never we called on any (end, _). If pre_travel_evaluator or
6355 post_travel_evaluator is -1, it will be taken as a function that always
6357 Deprecated, sets pre_travel(i, j) = node_visit_transit[i].
6359 return _pywrapcp.RoutingDimension_SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits)
6363 With breaks supposed to be consecutive, this forces the distance between
6364 breaks of size at least minimum_break_duration to be at most distance.
6365 This supposes that the time until route start and after route end are
6368 return _pywrapcp.RoutingDimension_SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle)
6372 Sets up vehicle_break_intervals_, vehicle_break_distance_duration_,
6373 pre_travel_evaluators and post_travel_evaluators.
6375 return _pywrapcp.RoutingDimension_InitializeBreaks(self)
6378 r""" Returns true if any break interval or break distance was defined."""
6379 return _pywrapcp.RoutingDimension_HasBreakConstraints(self)
6382 return _pywrapcp.RoutingDimension_GetPreTravelEvaluatorOfVehicle(self, vehicle)
6385 return _pywrapcp.RoutingDimension_GetPostTravelEvaluatorOfVehicle(self, vehicle)
6388 r""" Returns the parent in the dependency tree if any or nullptr otherwise."""
6389 return _pywrapcp.RoutingDimension_base_dimension(self)
6393 It makes sense to use the function only for self-dependent dimension.
6394 For such dimensions the value of the slack of a node determines the
6395 transition cost of the next transit. Provided that
6396 1. cumul[node] is fixed,
6397 2. next[node] and next[next[node]] (if exists) are fixed,
6398 the value of slack[node] for which cumul[next[node]] + transit[next[node]]
6399 is minimized can be found in O(1) using this function.
6401 return _pywrapcp.RoutingDimension_ShortestTransitionSlack(self, node)
6404 r""" Returns the name of the dimension."""
6405 return _pywrapcp.RoutingDimension_name(self)
6408 return _pywrapcp.RoutingDimension_SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index)
6411 return _pywrapcp.RoutingDimension_HasPickupToDeliveryLimits(self)
6414 return _pywrapcp.RoutingDimension_AddNodePrecedence(self, first_node, second_node, offset)
6417 return _pywrapcp.RoutingDimension_GetSpanUpperBoundForVehicle(self, vehicle)
6420 return _pywrapcp.RoutingDimension_GetSpanCostCoefficientForVehicle(self, vehicle)
6423 return _pywrapcp.RoutingDimension_GetSlackCostCoefficientForVehicle(self, vehicle)
6426 return _pywrapcp.RoutingDimension_global_span_cost_coefficient(self)
6429 return _pywrapcp.RoutingDimension_GetGlobalOptimizerOffset(self)
6432 return _pywrapcp.RoutingDimension_GetLocalOptimizerOffsetForVehicle(self, vehicle)
6436 If the span of vehicle on this dimension is larger than bound,
6437 the cost will be increased by cost * (span - bound).
6439 return _pywrapcp.RoutingDimension_SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)
6442 return _pywrapcp.RoutingDimension_HasSoftSpanUpperBounds(self)
6445 return _pywrapcp.RoutingDimension_GetSoftSpanUpperBoundForVehicle(self, vehicle)
6449 If the span of vehicle on this dimension is larger than bound,
6450 the cost will be increased by cost * (span - bound)^2.
6452 return _pywrapcp.RoutingDimension_SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)
6455 return _pywrapcp.RoutingDimension_HasQuadraticCostSoftSpanUpperBounds(self)
6458 return _pywrapcp.RoutingDimension_GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle)
6461_pywrapcp.RoutingDimension_swigregister(RoutingDimension)
6465 Attempts to solve the model using the cp-sat solver. As of 5/2019, will
6466 solve the TSP corresponding to the model if it has a single vehicle.
6467 Therefore the resulting solution might not actually be feasible. Will return
6468 false if a solution could not be found.
6470 return _pywrapcp.SolveModelWithSat(model, search_parameters, initial_solution, solution)