1# This file was automatically generated by SWIG (https://www.swig.org).
2# Version 4.2.1
3#
4# Do not make changes to this file unless you know what you are doing - modify
5# the SWIG interface file instead.
6
7from sys import version_info as _swig_python_version_info
8# Import the low-level C/C++ module
9if __package__ or "." in __name__:
10 from . import _pywrapcp
11else:
12 import _pywrapcp
13
14try:
15 import builtins as __builtin__
16except ImportError:
17 import __builtin__
18
19def _swig_repr(self):
20 try:
21 strthis = "proxy of " + self.this.__repr__()
22 except __builtin__.Exception:
23 strthis = ""
24 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
25
26
27def _swig_setattr_nondynamic_instance_variable(set):
28 def set_instance_attr(self, name, value):
29 if name == "this":
30 set(self, name, value)
31 elif name == "thisown":
32 self.this.own(value)
33 elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
34 set(self, name, value)
35 else:
36 raise AttributeError("You cannot add instance attributes to %s" % self)
37 return set_instance_attr
38
39
40def _swig_setattr_nondynamic_class_variable(set):
41 def set_class_attr(cls, name, value):
42 if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
43 set(cls, name, value)
44 else:
45 raise AttributeError("You cannot add class attributes to %s" % cls)
46 return set_class_attr
47
48
49def _swig_add_metaclass(metaclass):
50 """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
51 def wrapper(cls):
52 return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
53 return wrapper
54
55
56class _SwigNonDynamicMeta(type):
57 """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
58 __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
59
60
61import weakref
62
63class DefaultPhaseParameters(object):
64 r"""
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.
68 """
69
70 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
71 __repr__ = _swig_repr
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
82 will be chosen.
83 """)
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
87 per variable.
88 """)
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
92 one.
93 """)
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
97 at all.
98 """)
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.
103 """)
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.
108 """)
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.""")
110
111 def __init__(self):
112 _pywrapcp.DefaultPhaseParameters_swiginit(self, _pywrapcp.new_DefaultPhaseParameters())
113 __swig_destroy__ = _pywrapcp.delete_DefaultPhaseParameters
114
115# Register DefaultPhaseParameters in _pywrapcp:
116_pywrapcp.DefaultPhaseParameters_swigregister(DefaultPhaseParameters)
117class Solver(object):
118 r"""
119 Solver Class
120
121 A solver represents the main computation engine. It implements the entire
122 range of Constraint Programming protocols:
123 - Reversibility
124 - Propagation
125 - Search
126
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.
134
135 For the time being, Solver is neither MT_SAFE nor MT_HOT.
136 """
137
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
145 r"""
146 Select the first unbound variable.
147 Variables are considered in the order of the vector of IntVars used
148 to create the selector.
149 """
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
153 r"""
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
157 value.
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.
160 """
161 CHOOSE_MIN_SIZE_HIGHEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MIN
162 r"""
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
166 value.
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.
169 """
170 CHOOSE_MIN_SIZE_LOWEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MAX
171 r"""
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
175 value.
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.
178 """
179 CHOOSE_MIN_SIZE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MAX
180 r"""
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
184 value.
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.
187 """
188 CHOOSE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_LOWEST_MIN
189 r"""
190 Among unbound variables, select the variable with the smallest minimal
191 value.
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.
194 """
195 CHOOSE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_HIGHEST_MAX
196 r"""
197 Among unbound variables, select the variable with the highest maximal
198 value.
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.
201 """
202 CHOOSE_MIN_SIZE = _pywrapcp.Solver_CHOOSE_MIN_SIZE
203 r"""
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.
207 """
208 CHOOSE_MAX_SIZE = _pywrapcp.Solver_CHOOSE_MAX_SIZE
209 r"""
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.
213 """
214 CHOOSE_MAX_REGRET_ON_MIN = _pywrapcp.Solver_CHOOSE_MAX_REGRET_ON_MIN
215 r"""
216 Among unbound variables, select the variable with the largest
217 gap between the first and the second values of the domain.
218 """
219 CHOOSE_PATH = _pywrapcp.Solver_CHOOSE_PATH
220 r"""
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.
223 """
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
235 r"""
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.
239 """
240 SPLIT_LOWER_HALF = _pywrapcp.Solver_SPLIT_LOWER_HALF
241 r"""
242 Split the domain in two around the center, and choose the lower
243 part first.
244 """
245 SPLIT_UPPER_HALF = _pywrapcp.Solver_SPLIT_UPPER_HALF
246 r"""
247 Split the domain in two around the center, and choose the lower
248 part first.
249 """
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
259 r"""
260 Selects the variable with the lowest starting time of all variables,
261 and fixes its starting time to this lowest value.
262 """
263 INTERVAL_SET_TIMES_BACKWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_BACKWARD
264 r"""
265 Selects the variable with the highest ending time of all variables,
266 and fixes the ending time to this highest values.
267 """
268 TWOOPT = _pywrapcp.Solver_TWOOPT
269 r"""
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
272 two-optimal.
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
275 be moved):
276 1 -> [3 -> 2] -> 4 -> 5
277 1 -> [4 -> 3 -> 2] -> 5
278 1 -> 2 -> [4 -> 3] -> 5
279 """
280 OROPT = _pywrapcp.Solver_OROPT
281 r"""
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
286 position.
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
292
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).
296 """
297 RELOCATE = _pywrapcp.Solver_RELOCATE
298 r""" Relocate neighborhood with length of 1 (see OROPT comment)."""
299 EXCHANGE = _pywrapcp.Solver_EXCHANGE
300 r"""
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
304 be moved):
305 1 -> [3] -> [2] -> 4 -> 5
306 1 -> [4] -> 3 -> [2] -> 5
307 1 -> 2 -> [4] -> [3] -> 5
308 """
309 CROSS = _pywrapcp.Solver_CROSS
310 r"""
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
320 """
321 MAKEACTIVE = _pywrapcp.Solver_MAKEACTIVE
322 r"""
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
329 """
330 MAKEINACTIVE = _pywrapcp.Solver_MAKEINACTIVE
331 r"""
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
337 """
338 MAKECHAININACTIVE = _pywrapcp.Solver_MAKECHAININACTIVE
339 r"""
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
346 """
347 SWAPACTIVE = _pywrapcp.Solver_SWAPACTIVE
348 r"""
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
354 """
355 EXTENDEDSWAPACTIVE = _pywrapcp.Solver_EXTENDEDSWAPACTIVE
356 r"""
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
367 """
368 PATHLNS = _pywrapcp.Solver_PATHLNS
369 r"""
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
376 overlap.
377 """
378 FULLPATHLNS = _pywrapcp.Solver_FULLPATHLNS
379 r"""
380 Operator which relaxes one entire path and all inactive nodes, thus
381 defining num_paths neighbors.
382 """
383 UNACTIVELNS = _pywrapcp.Solver_UNACTIVELNS
384 r"""
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.
388 """
389 INCREMENT = _pywrapcp.Solver_INCREMENT
390 r"""
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
398 increment x.
399 """
400 DECREMENT = _pywrapcp.Solver_DECREMENT
401 r"""
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.
405 """
406 SIMPLELNS = _pywrapcp.Solver_SIMPLELNS
407 r"""
408 Operator which defines one neighbor per variable. Each neighbor relaxes
409 one variable.
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.
415 """
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
421 r"""
422 Move is accepted when the current objective value is in the interval
423 objective.Min .. objective.Max.
424 """
425 DELAYED_PRIORITY = _pywrapcp.Solver_DELAYED_PRIORITY
426 r"""
427 DELAYED_PRIORITY is the lowest priority: Demons will be processed after
428 VAR_PRIORITY and NORMAL_PRIORITY demons.
429 """
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."""
434
435 def __init__(self, *args):
436 _pywrapcp.Solver_swiginit(self, _pywrapcp.new_Solver(*args))
437
438 self.__python_constraints = []
439
440
441
442 __swig_destroy__ = _pywrapcp.delete_Solver
443
444 def Parameters(self):
445 r""" Stored Parameters."""
446 return _pywrapcp.Solver_Parameters(self)
447
448 @staticmethod
449 def DefaultSolverParameters():
450 r""" Create a ConstraintSolverParameters proto with all the default values."""
451 return _pywrapcp.Solver_DefaultSolverParameters()
452
453 def AddConstraint(self, c):
454 r"""
455 Adds the constraint 'c' to the model.
456
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
460 different use cases:
461
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.
468
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
481 backtracking.
482
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
487 MyConstraint(...));
488 """
489 return _pywrapcp.Solver_AddConstraint(self, c)
490
491 def Solve(self, *args):
492 return _pywrapcp.Solver_Solve(self, *args)
493
494 def NewSearch(self, *args):
495 return _pywrapcp.Solver_NewSearch(self, *args)
496
497 def NextSolution(self):
498 return _pywrapcp.Solver_NextSolution(self)
499
500 def RestartSearch(self):
501 return _pywrapcp.Solver_RestartSearch(self)
502
503 def EndSearch(self):
504 return _pywrapcp.Solver_EndSearch(self)
505
506 def SolveAndCommit(self, *args):
507 return _pywrapcp.Solver_SolveAndCommit(self, *args)
508
509 def CheckAssignment(self, solution):
510 r""" Checks whether the given assignment satisfies all relevant constraints."""
511 return _pywrapcp.Solver_CheckAssignment(self, solution)
512
513 def CheckConstraint(self, ct):
514 r"""
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.
518 """
519 return _pywrapcp.Solver_CheckConstraint(self, ct)
520
521 def Fail(self):
522 r""" Abandon the current branch in the search tree. A backtrack will follow."""
523 return _pywrapcp.Solver_Fail(self)
524
525 @staticmethod
526 def MemoryUsage():
527 r""" Current memory usage in bytes"""
528 return _pywrapcp.Solver_MemoryUsage()
529
530 def WallTime(self):
531 r"""
532 DEPRECATED: Use Now() instead.
533 Time elapsed, in ms since the creation of the solver.
534 """
535 return _pywrapcp.Solver_WallTime(self)
536
537 def Branches(self):
538 r""" The number of branches explored since the creation of the solver."""
539 return _pywrapcp.Solver_Branches(self)
540
541 def Solutions(self):
542 r""" The number of solutions found since the start of the search."""
543 return _pywrapcp.Solver_Solutions(self)
544
545 def Failures(self):
546 r""" The number of failures encountered since the creation of the solver."""
547 return _pywrapcp.Solver_Failures(self)
548
549 def AcceptedNeighbors(self):
550 r""" The number of accepted neighbors."""
551 return _pywrapcp.Solver_AcceptedNeighbors(self)
552
553 def Stamp(self):
554 r"""
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.
557 """
558 return _pywrapcp.Solver_Stamp(self)
559
560 def FailStamp(self):
561 r""" The fail_stamp() is incremented after each backtrack."""
562 return _pywrapcp.Solver_FailStamp(self)
563
564 def IntVar(self, *args):
565 r"""
566 *Overload 1:*
567 MakeIntVar will create the best range based int var for the bounds given.
568
569 |
570
571 *Overload 2:*
572 MakeIntVar will create a variable with the given sparse domain.
573
574 |
575
576 *Overload 3:*
577 MakeIntVar will create a variable with the given sparse domain.
578
579 |
580
581 *Overload 4:*
582 MakeIntVar will create the best range based int var for the bounds given.
583
584 |
585
586 *Overload 5:*
587 MakeIntVar will create a variable with the given sparse domain.
588
589 |
590
591 *Overload 6:*
592 MakeIntVar will create a variable with the given sparse domain.
593 """
594 return _pywrapcp.Solver_IntVar(self, *args)
595
596 def BoolVar(self, *args):
597 r"""
598 *Overload 1:*
599 MakeBoolVar will create a variable with a {0, 1} domain.
600
601 |
602
603 *Overload 2:*
604 MakeBoolVar will create a variable with a {0, 1} domain.
605 """
606 return _pywrapcp.Solver_BoolVar(self, *args)
607
608 def IntConst(self, *args):
609 r"""
610 *Overload 1:*
611 IntConst will create a constant expression.
612
613 |
614
615 *Overload 2:*
616 IntConst will create a constant expression.
617 """
618 return _pywrapcp.Solver_IntConst(self, *args)
619
620 def Sum(self, vars):
621 r""" sum of all vars."""
622 return _pywrapcp.Solver_Sum(self, vars)
623
624 def ScalProd(self, *args):
625 r"""
626 *Overload 1:*
627 scalar product
628
629 |
630
631 *Overload 2:*
632 scalar product
633 """
634 return _pywrapcp.Solver_ScalProd(self, *args)
635
636 def MonotonicElement(self, values, increasing, index):
637 r"""
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.
644 """
645 return _pywrapcp.Solver_MonotonicElement(self, values, increasing, index)
646
647 def Element(self, *args):
648 r"""
649 *Overload 1:*
650 values[index]
651
652 |
653
654 *Overload 2:*
655 values[index]
656
657 |
658
659 *Overload 3:*
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).
663
664 |
665
666 *Overload 4:*
667 2D version of function-based element expression, values(expr1, expr2).
668
669 |
670
671 *Overload 5:*
672 vars[expr]
673 """
674 return _pywrapcp.Solver_Element(self, *args)
675
676 def IndexExpression(self, vars, value):
677 r"""
678 Returns the expression expr such that vars[expr] == value.
679 It assumes that vars are all different.
680 """
681 return _pywrapcp.Solver_IndexExpression(self, vars, value)
682
683 def Min(self, *args):
684 r"""
685 *Overload 1:*
686 std::min(vars)
687
688 |
689
690 *Overload 2:*
691 std::min (left, right)
692
693 |
694
695 *Overload 3:*
696 std::min(expr, value)
697
698 |
699
700 *Overload 4:*
701 std::min(expr, value)
702 """
703 return _pywrapcp.Solver_Min(self, *args)
704
705 def Max(self, *args):
706 r"""
707 *Overload 1:*
708 std::max(vars)
709
710 |
711
712 *Overload 2:*
713 std::max(left, right)
714
715 |
716
717 *Overload 3:*
718 std::max(expr, value)
719
720 |
721
722 *Overload 4:*
723 std::max(expr, value)
724 """
725 return _pywrapcp.Solver_Max(self, *args)
726
727 def ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost):
728 r""" Convex piecewise function."""
729 return _pywrapcp.Solver_ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost)
730
731 def SemiContinuousExpr(self, expr, fixed_charge, step):
732 r"""
733 Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b)
734 a >= 0 and b >= 0
735 """
736 return _pywrapcp.Solver_SemiContinuousExpr(self, expr, fixed_charge, step)
737
738 def ConditionalExpression(self, condition, expr, unperformed_value):
739 r""" Conditional Expr condition ? expr : unperformed_value"""
740 return _pywrapcp.Solver_ConditionalExpression(self, condition, expr, unperformed_value)
741
742 def TrueConstraint(self):
743 r""" This constraint always succeeds."""
744 return _pywrapcp.Solver_TrueConstraint(self)
745
746 def FalseConstraint(self, *args):
747 return _pywrapcp.Solver_FalseConstraint(self, *args)
748
749 def IsEqualCstCt(self, var, value, boolvar):
750 r""" boolvar == (var == value)"""
751 return _pywrapcp.Solver_IsEqualCstCt(self, var, value, boolvar)
752
753 def IsEqualCstVar(self, var, value):
754 r""" status var of (var == value)"""
755 return _pywrapcp.Solver_IsEqualCstVar(self, var, value)
756
757 def IsEqualCt(self, v1, v2, b):
758 r""" b == (v1 == v2)"""
759 return _pywrapcp.Solver_IsEqualCt(self, v1, v2, b)
760
761 def IsEqualVar(self, v1, v2):
762 r""" status var of (v1 == v2)"""
763 return _pywrapcp.Solver_IsEqualVar(self, v1, v2)
764
765 def IsDifferentCstCt(self, var, value, boolvar):
766 r""" boolvar == (var != value)"""
767 return _pywrapcp.Solver_IsDifferentCstCt(self, var, value, boolvar)
768
769 def IsDifferentCstVar(self, var, value):
770 r""" status var of (var != value)"""
771 return _pywrapcp.Solver_IsDifferentCstVar(self, var, value)
772
773 def IsDifferentVar(self, v1, v2):
774 r""" status var of (v1 != v2)"""
775 return _pywrapcp.Solver_IsDifferentVar(self, v1, v2)
776
777 def IsDifferentCt(self, v1, v2, b):
778 r""" b == (v1 != v2)"""
779 return _pywrapcp.Solver_IsDifferentCt(self, v1, v2, b)
780
781 def IsLessOrEqualCstCt(self, var, value, boolvar):
782 r""" boolvar == (var <= value)"""
783 return _pywrapcp.Solver_IsLessOrEqualCstCt(self, var, value, boolvar)
784
785 def IsLessOrEqualCstVar(self, var, value):
786 r""" status var of (var <= value)"""
787 return _pywrapcp.Solver_IsLessOrEqualCstVar(self, var, value)
788
789 def IsLessOrEqualVar(self, left, right):
790 r""" status var of (left <= right)"""
791 return _pywrapcp.Solver_IsLessOrEqualVar(self, left, right)
792
793 def IsLessOrEqualCt(self, left, right, b):
794 r""" b == (left <= right)"""
795 return _pywrapcp.Solver_IsLessOrEqualCt(self, left, right, b)
796
797 def IsGreaterOrEqualCstCt(self, var, value, boolvar):
798 r""" boolvar == (var >= value)"""
799 return _pywrapcp.Solver_IsGreaterOrEqualCstCt(self, var, value, boolvar)
800
801 def IsGreaterOrEqualCstVar(self, var, value):
802 r""" status var of (var >= value)"""
803 return _pywrapcp.Solver_IsGreaterOrEqualCstVar(self, var, value)
804
805 def IsGreaterOrEqualVar(self, left, right):
806 r""" status var of (left >= right)"""
807 return _pywrapcp.Solver_IsGreaterOrEqualVar(self, left, right)
808
809 def IsGreaterOrEqualCt(self, left, right, b):
810 r""" b == (left >= right)"""
811 return _pywrapcp.Solver_IsGreaterOrEqualCt(self, left, right, b)
812
813 def IsGreaterCstCt(self, v, c, b):
814 r""" b == (v > c)"""
815 return _pywrapcp.Solver_IsGreaterCstCt(self, v, c, b)
816
817 def IsGreaterCstVar(self, var, value):
818 r""" status var of (var > value)"""
819 return _pywrapcp.Solver_IsGreaterCstVar(self, var, value)
820
821 def IsGreaterVar(self, left, right):
822 r""" status var of (left > right)"""
823 return _pywrapcp.Solver_IsGreaterVar(self, left, right)
824
825 def IsGreaterCt(self, left, right, b):
826 r""" b == (left > right)"""
827 return _pywrapcp.Solver_IsGreaterCt(self, left, right, b)
828
829 def IsLessCstCt(self, v, c, b):
830 r""" b == (v < c)"""
831 return _pywrapcp.Solver_IsLessCstCt(self, v, c, b)
832
833 def IsLessCstVar(self, var, value):
834 r""" status var of (var < value)"""
835 return _pywrapcp.Solver_IsLessCstVar(self, var, value)
836
837 def IsLessVar(self, left, right):
838 r""" status var of (left < right)"""
839 return _pywrapcp.Solver_IsLessVar(self, left, right)
840
841 def IsLessCt(self, left, right, b):
842 r""" b == (left < right)"""
843 return _pywrapcp.Solver_IsLessCt(self, left, right, b)
844
845 def SumLessOrEqual(self, vars, cst):
846 r""" Variation on arrays."""
847 return _pywrapcp.Solver_SumLessOrEqual(self, vars, cst)
848
849 def SumGreaterOrEqual(self, vars, cst):
850 return _pywrapcp.Solver_SumGreaterOrEqual(self, vars, cst)
851
852 def SumEquality(self, *args):
853 return _pywrapcp.Solver_SumEquality(self, *args)
854
855 def ScalProdEquality(self, *args):
856 return _pywrapcp.Solver_ScalProdEquality(self, *args)
857
858 def ScalProdGreaterOrEqual(self, *args):
859 return _pywrapcp.Solver_ScalProdGreaterOrEqual(self, *args)
860
861 def ScalProdLessOrEqual(self, *args):
862 return _pywrapcp.Solver_ScalProdLessOrEqual(self, *args)
863
864 def MinEquality(self, vars, min_var):
865 return _pywrapcp.Solver_MinEquality(self, vars, min_var)
866
867 def MaxEquality(self, vars, max_var):
868 return _pywrapcp.Solver_MaxEquality(self, vars, max_var)
869
870 def ElementEquality(self, *args):
871 return _pywrapcp.Solver_ElementEquality(self, *args)
872
873 def AbsEquality(self, var, abs_var):
874 r""" Creates the constraint abs(var) == abs_var."""
875 return _pywrapcp.Solver_AbsEquality(self, var, abs_var)
876
877 def IndexOfConstraint(self, vars, index, target):
878 r"""
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.
883 """
884 return _pywrapcp.Solver_IndexOfConstraint(self, vars, index, target)
885
886 def ConstraintInitialPropagateCallback(self, ct):
887 r"""
888 This method is a specialized case of the MakeConstraintDemon
889 method to call the InitiatePropagate of the constraint 'ct'.
890 """
891 return _pywrapcp.Solver_ConstraintInitialPropagateCallback(self, ct)
892
893 def DelayedConstraintInitialPropagateCallback(self, ct):
894 r"""
895 This method is a specialized case of the MakeConstraintDemon
896 method to call the InitiatePropagate of the constraint 'ct' with
897 low priority.
898 """
899 return _pywrapcp.Solver_DelayedConstraintInitialPropagateCallback(self, ct)
900
901 def ClosureDemon(self, closure):
902 r""" Creates a demon from a closure."""
903 return _pywrapcp.Solver_ClosureDemon(self, closure)
904
905 def BetweenCt(self, expr, l, u):
906 r""" (l <= expr <= u)"""
907 return _pywrapcp.Solver_BetweenCt(self, expr, l, u)
908
909 def IsBetweenCt(self, expr, l, u, b):
910 r""" b == (l <= expr <= u)"""
911 return _pywrapcp.Solver_IsBetweenCt(self, expr, l, u, b)
912
913 def IsBetweenVar(self, v, l, u):
914 return _pywrapcp.Solver_IsBetweenVar(self, v, l, u)
915
916 def MemberCt(self, *args):
917 return _pywrapcp.Solver_MemberCt(self, *args)
918
919 def NotMemberCt(self, *args):
920 r"""
921 *Overload 1:*
922 expr not in set.
923
924 |
925
926 *Overload 2:*
927 expr should not be in the list of forbidden intervals [start[i]..end[i]].
928
929 |
930
931 *Overload 3:*
932 expr should not be in the list of forbidden intervals [start[i]..end[i]].
933 """
934 return _pywrapcp.Solver_NotMemberCt(self, *args)
935
936 def IsMemberCt(self, *args):
937 return _pywrapcp.Solver_IsMemberCt(self, *args)
938
939 def IsMemberVar(self, *args):
940 return _pywrapcp.Solver_IsMemberVar(self, *args)
941
942 def Count(self, *args):
943 r"""
944 *Overload 1:*
945 |{i | vars[i] == value}| == max_count
946
947 |
948
949 *Overload 2:*
950 |{i | vars[i] == value}| == max_count
951 """
952 return _pywrapcp.Solver_Count(self, *args)
953
954 def Distribute(self, *args):
955 r"""
956 *Overload 1:*
957 Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]
958
959 |
960
961 *Overload 2:*
962 Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]
963
964 |
965
966 *Overload 3:*
967 Aggregated version of count: |{i | v[i] == j}| == cards[j]
968
969 |
970
971 *Overload 4:*
972 Aggregated version of count with bounded cardinalities:
973 forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max
974
975 |
976
977 *Overload 5:*
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]
981
982 |
983
984 *Overload 6:*
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]
988
989 |
990
991 *Overload 7:*
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]
995
996 |
997
998 *Overload 8:*
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]
1002 """
1003 return _pywrapcp.Solver_Distribute(self, *args)
1004
1005 def Deviation(self, vars, deviation_var, total_sum):
1006 r"""
1007 Deviation constraint:
1008 sum_i |n * vars[i] - total_sum| <= deviation_var and
1009 sum_i vars[i] == total_sum
1010 n = #vars
1011 """
1012 return _pywrapcp.Solver_Deviation(self, vars, deviation_var, total_sum)
1013
1014 def AllDifferent(self, *args):
1015 r"""
1016 *Overload 1:*
1017 All variables are pairwise different. This corresponds to the
1018 stronger version of the propagation algorithm.
1019
1020 |
1021
1022 *Overload 2:*
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.
1026 """
1027 return _pywrapcp.Solver_AllDifferent(self, *args)
1028
1029 def AllDifferentExcept(self, vars, escape_value):
1030 r"""
1031 All variables are pairwise different, unless they are assigned to
1032 the escape value.
1033 """
1034 return _pywrapcp.Solver_AllDifferentExcept(self, vars, escape_value)
1035
1036 def SortingConstraint(self, vars, sorted):
1037 r"""
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.
1042
1043 This constraint propagates in both directions: from "vars" to
1044 "sorted_vars" and vice-versa.
1045
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.
1050
1051 For more info, please have a look at:
1052 https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf
1053 """
1054 return _pywrapcp.Solver_SortingConstraint(self, vars, sorted)
1055
1056 def LexicalLess(self, left, right):
1057 r"""
1058 Creates a constraint that enforces that left is lexicographically less
1059 than right.
1060 """
1061 return _pywrapcp.Solver_LexicalLess(self, left, right)
1062
1063 def LexicalLessOrEqual(self, left, right):
1064 r"""
1065 Creates a constraint that enforces that left is lexicographically less
1066 than or equal to right.
1067 """
1068 return _pywrapcp.Solver_LexicalLessOrEqual(self, left, right)
1069
1070 def InversePermutationConstraint(self, left, right):
1071 r"""
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.
1076 """
1077 return _pywrapcp.Solver_InversePermutationConstraint(self, left, right)
1078
1079 def NullIntersect(self, first_vars, second_vars):
1080 r"""
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.
1085 """
1086 return _pywrapcp.Solver_NullIntersect(self, first_vars, second_vars)
1087
1088 def NullIntersectExcept(self, first_vars, second_vars, escape_value):
1089 r"""
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.
1095 """
1096 return _pywrapcp.Solver_NullIntersectExcept(self, first_vars, second_vars, escape_value)
1097
1098 def Circuit(self, nexts):
1099 r""" Force the "nexts" variable to create a complete Hamiltonian path."""
1100 return _pywrapcp.Solver_Circuit(self, nexts)
1101
1102 def SubCircuit(self, nexts):
1103 r"""
1104 Force the "nexts" variable to create a complete Hamiltonian path
1105 for those that do not loop upon themselves.
1106 """
1107 return _pywrapcp.Solver_SubCircuit(self, nexts)
1108
1109 def DelayedPathCumul(self, nexts, active, cumuls, transits):
1110 r"""
1111 Delayed version of the same constraint: propagation on the nexts variables
1112 is delayed until all constraints have propagated.
1113 """
1114 return _pywrapcp.Solver_DelayedPathCumul(self, nexts, active, cumuls, transits)
1115
1116 def PathCumul(self, *args):
1117 r"""
1118 *Overload 1:*
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.
1123
1124 |
1125
1126 *Overload 2:*
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
1132 callback.
1133
1134 |
1135
1136 *Overload 3:*
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
1142 callback.
1143 """
1144 return _pywrapcp.Solver_PathCumul(self, *args)
1145
1146 def AllowedAssignments(self, *args):
1147 r"""
1148 *Overload 1:*
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
1152 integer tuple set.
1153
1154 |
1155
1156 *Overload 2:*
1157 Compatibility layer for Python API.
1158 """
1159 return _pywrapcp.Solver_AllowedAssignments(self, *args)
1160
1161 def TransitionConstraint(self, *args):
1162 return _pywrapcp.Solver_TransitionConstraint(self, *args)
1163
1164 def NonOverlappingBoxesConstraint(self, *args):
1165 return _pywrapcp.Solver_NonOverlappingBoxesConstraint(self, *args)
1166
1167 def Pack(self, vars, number_of_bins):
1168 r"""
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.
1174 """
1175 return _pywrapcp.Solver_Pack(self, vars, number_of_bins)
1176
1177 def FixedDurationIntervalVar(self, *args):
1178 r"""
1179 *Overload 1:*
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.
1184
1185 |
1186
1187 *Overload 2:*
1188 Creates a performed interval var with a fixed duration. The duration must
1189 be greater than 0.
1190
1191 |
1192
1193 *Overload 3:*
1194 Creates an interval var with a fixed duration, and performed_variable.
1195 The duration must be greater than 0.
1196 """
1197 return _pywrapcp.Solver_FixedDurationIntervalVar(self, *args)
1198
1199 def FixedInterval(self, start, duration, name):
1200 r""" Creates a fixed and performed interval."""
1201 return _pywrapcp.Solver_FixedInterval(self, start, duration, name)
1202
1203 def IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name):
1204 r"""
1205 Creates an interval var by specifying the bounds on start,
1206 duration, and end.
1207 """
1208 return _pywrapcp.Solver_IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name)
1209
1210 def MirrorInterval(self, interval_var):
1211 r"""
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.
1214 """
1215 return _pywrapcp.Solver_MirrorInterval(self, interval_var)
1216
1217 def FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1218 r"""
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.
1223 """
1224 return _pywrapcp.Solver_FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset)
1225
1226 def FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1227 r"""
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.
1232 """
1233 return _pywrapcp.Solver_FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset)
1234
1235 def FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1236 r"""
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.
1241 """
1242 return _pywrapcp.Solver_FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset)
1243
1244 def FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1245 r"""
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.
1250 """
1251 return _pywrapcp.Solver_FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset)
1252
1253 def IntervalRelaxedMin(self, interval_var):
1254 r"""
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
1258 interval_var.
1259
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
1265 the min side;
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
1268 both sides.
1269
1270 This is very useful to implement propagators that may only modify
1271 the start max or end max.
1272 """
1273 return _pywrapcp.Solver_IntervalRelaxedMin(self, interval_var)
1274
1275 def IntervalRelaxedMax(self, interval_var):
1276 r"""
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
1280 interval_var.
1281
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
1287 the max side;
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
1290 both sides.
1291
1292 This is very useful for implementing propagators that may only modify
1293 the start min or end min.
1294 """
1295 return _pywrapcp.Solver_IntervalRelaxedMax(self, interval_var)
1296
1297 def TemporalDisjunction(self, *args):
1298 r"""
1299 *Overload 1:*
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).
1303
1304 |
1305
1306 *Overload 2:*
1307 This constraint implements a temporal disjunction between two
1308 interval vars.
1309 """
1310 return _pywrapcp.Solver_TemporalDisjunction(self, *args)
1311
1312 def DisjunctiveConstraint(self, intervals, name):
1313 r"""
1314 This constraint forces all interval vars into an non-overlapping
1315 sequence. Intervals with zero duration can be scheduled anywhere.
1316 """
1317 return _pywrapcp.Solver_DisjunctiveConstraint(self, intervals, name)
1318
1319 def Cumulative(self, *args):
1320 r"""
1321 *Overload 1:*
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
1324 capacity.
1325
1326 Intervals and demands should be vectors of equal size.
1327
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.
1331
1332 |
1333
1334 *Overload 2:*
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
1337 capacity.
1338
1339 Intervals and demands should be vectors of equal size.
1340
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.
1344
1345 |
1346
1347 *Overload 3:*
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
1350 capacity.
1351
1352 Intervals and demands should be vectors of equal size.
1353
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.
1357
1358 |
1359
1360 *Overload 4:*
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
1363 capacity.
1364
1365 Intervals and demands should be vectors of equal size.
1366
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.
1370
1371 |
1372
1373 *Overload 5:*
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
1376 capacity.
1377
1378 Intervals and demands should be vectors of equal size.
1379
1380 Demands should be positive.
1381
1382 |
1383
1384 *Overload 6:*
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
1387 capacity.
1388
1389 Intervals and demands should be vectors of equal size.
1390
1391 Demands should be positive.
1392 """
1393 return _pywrapcp.Solver_Cumulative(self, *args)
1394
1395 def Cover(self, vars, target_var):
1396 r"""
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
1401 unperformed too.
1402 """
1403 return _pywrapcp.Solver_Cover(self, vars, target_var)
1404
1405 def Assignment(self, *args):
1406 r"""
1407 *Overload 1:*
1408 This method creates an empty assignment.
1409
1410 |
1411
1412 *Overload 2:*
1413 This method creates an assignment which is a copy of 'a'.
1414 """
1415 return _pywrapcp.Solver_Assignment(self, *args)
1416
1417 def FirstSolutionCollector(self, *args):
1418 r"""
1419 *Overload 1:*
1420 Collect the first solution of the search.
1421
1422 |
1423
1424 *Overload 2:*
1425 Collect the first solution of the search. The variables will need to
1426 be added later.
1427 """
1428 return _pywrapcp.Solver_FirstSolutionCollector(self, *args)
1429
1430 def LastSolutionCollector(self, *args):
1431 r"""
1432 *Overload 1:*
1433 Collect the last solution of the search.
1434
1435 |
1436
1437 *Overload 2:*
1438 Collect the last solution of the search. The variables will need to
1439 be added later.
1440 """
1441 return _pywrapcp.Solver_LastSolutionCollector(self, *args)
1442
1443 def BestValueSolutionCollector(self, *args):
1444 r"""
1445 *Overload 1:*
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).
1450
1451 |
1452
1453 *Overload 2:*
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.
1459 """
1460 return _pywrapcp.Solver_BestValueSolutionCollector(self, *args)
1461
1462 def AllSolutionCollector(self, *args):
1463 r"""
1464 *Overload 1:*
1465 Collect all solutions of the search.
1466
1467 |
1468
1469 *Overload 2:*
1470 Collect all solutions of the search. The variables will need to
1471 be added later.
1472 """
1473 return _pywrapcp.Solver_AllSolutionCollector(self, *args)
1474
1475 def Minimize(self, v, step):
1476 r""" Creates a minimization objective."""
1477 return _pywrapcp.Solver_Minimize(self, v, step)
1478
1479 def Maximize(self, v, step):
1480 r""" Creates a maximization objective."""
1481 return _pywrapcp.Solver_Maximize(self, v, step)
1482
1483 def Optimize(self, maximize, v, step):
1484 r""" Creates a objective with a given sense (true = maximization)."""
1485 return _pywrapcp.Solver_Optimize(self, maximize, v, step)
1486
1487 def WeightedMinimize(self, *args):
1488 r"""
1489 *Overload 1:*
1490 Creates a minimization weighted objective. The actual objective is
1491 scalar_prod(sub_objectives, weights).
1492
1493 |
1494
1495 *Overload 2:*
1496 Creates a minimization weighted objective. The actual objective is
1497 scalar_prod(sub_objectives, weights).
1498 """
1499 return _pywrapcp.Solver_WeightedMinimize(self, *args)
1500
1501 def WeightedMaximize(self, *args):
1502 r"""
1503 *Overload 1:*
1504 Creates a maximization weigthed objective.
1505
1506 |
1507
1508 *Overload 2:*
1509 Creates a maximization weigthed objective.
1510 """
1511 return _pywrapcp.Solver_WeightedMaximize(self, *args)
1512
1513 def WeightedOptimize(self, *args):
1514 r"""
1515 *Overload 1:*
1516 Creates a weighted objective with a given sense (true = maximization).
1517
1518 |
1519
1520 *Overload 2:*
1521 Creates a weighted objective with a given sense (true = maximization).
1522 """
1523 return _pywrapcp.Solver_WeightedOptimize(self, *args)
1524
1525 def TabuSearch(self, maximize, objective, step, vars, keep_tenure, forbid_tenure, tabu_factor):
1526 r"""
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.
1543 """
1544 return _pywrapcp.Solver_TabuSearch(self, maximize, objective, step, vars, keep_tenure, forbid_tenure, tabu_factor)
1545
1546 def SimulatedAnnealing(self, maximize, v, step, initial_temperature):
1547 r""" Creates a Simulated Annealing monitor."""
1548 return _pywrapcp.Solver_SimulatedAnnealing(self, maximize, v, step, initial_temperature)
1549
1550 def LubyRestart(self, scale_factor):
1551 r"""
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...).
1555 """
1556 return _pywrapcp.Solver_LubyRestart(self, scale_factor)
1557
1558 def ConstantRestart(self, frequency):
1559 r"""
1560 This search monitor will restart the search periodically after 'frequency'
1561 failures.
1562 """
1563 return _pywrapcp.Solver_ConstantRestart(self, frequency)
1564
1565 def TimeLimit(self, *args):
1566 return _pywrapcp.Solver_TimeLimit(self, *args)
1567
1568 def BranchesLimit(self, branches):
1569 r"""
1570 Creates a search limit that constrains the number of branches
1571 explored in the search tree.
1572 """
1573 return _pywrapcp.Solver_BranchesLimit(self, branches)
1574
1575 def FailuresLimit(self, failures):
1576 r"""
1577 Creates a search limit that constrains the number of failures
1578 that can happen when exploring the search tree.
1579 """
1580 return _pywrapcp.Solver_FailuresLimit(self, failures)
1581
1582 def SolutionsLimit(self, solutions):
1583 r"""
1584 Creates a search limit that constrains the number of solutions found
1585 during the search.
1586 """
1587 return _pywrapcp.Solver_SolutionsLimit(self, solutions)
1588
1589 def Limit(self, *args):
1590 r"""
1591 *Overload 1:*
1592 Limits the search with the 'time', 'branches', 'failures' and
1593 'solutions' limits. 'smart_time_check' reduces the calls to the wall
1594
1595 |
1596
1597 *Overload 2:*
1598 Creates a search limit from its protobuf description
1599
1600 |
1601
1602 *Overload 3:*
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
1605 argument limits.
1606 """
1607 return _pywrapcp.Solver_Limit(self, *args)
1608
1609 def CustomLimit(self, limiter):
1610 r"""
1611 Callback-based search limit. Search stops when limiter returns true; if
1612 this happens at a leaf the corresponding solution will be rejected.
1613 """
1614 return _pywrapcp.Solver_CustomLimit(self, limiter)
1615
1616 def SearchLog(self, *args):
1617 return _pywrapcp.Solver_SearchLog(self, *args)
1618
1619 def SearchTrace(self, prefix):
1620 r"""
1621 Creates a search monitor that will trace precisely the behavior of the
1622 search. Use this only for low level debugging.
1623 """
1624 return _pywrapcp.Solver_SearchTrace(self, prefix)
1625
1626 def PrintModelVisitor(self):
1627 r""" Prints the model."""
1628 return _pywrapcp.Solver_PrintModelVisitor(self)
1629
1630 def StatisticsModelVisitor(self):
1631 r""" Displays some nice statistics on the model."""
1632 return _pywrapcp.Solver_StatisticsModelVisitor(self)
1633
1634 def AssignVariableValue(self, var, val):
1635 r""" Decisions."""
1636 return _pywrapcp.Solver_AssignVariableValue(self, var, val)
1637
1638 def VariableLessOrEqualValue(self, var, value):
1639 return _pywrapcp.Solver_VariableLessOrEqualValue(self, var, value)
1640
1641 def VariableGreaterOrEqualValue(self, var, value):
1642 return _pywrapcp.Solver_VariableGreaterOrEqualValue(self, var, value)
1643
1644 def SplitVariableDomain(self, var, val, start_with_lower_half):
1645 return _pywrapcp.Solver_SplitVariableDomain(self, var, val, start_with_lower_half)
1646
1647 def AssignVariableValueOrFail(self, var, value):
1648 return _pywrapcp.Solver_AssignVariableValueOrFail(self, var, value)
1649
1650 def AssignVariablesValues(self, vars, values):
1651 return _pywrapcp.Solver_AssignVariablesValues(self, vars, values)
1652
1653 def FailDecision(self):
1654 return _pywrapcp.Solver_FailDecision(self)
1655
1656 def Decision(self, apply, refute):
1657 return _pywrapcp.Solver_Decision(self, apply, refute)
1658
1659 def Compose(self, dbs):
1660 return _pywrapcp.Solver_Compose(self, dbs)
1661
1662 def Try(self, dbs):
1663 return _pywrapcp.Solver_Try(self, dbs)
1664
1665 def DefaultPhase(self, *args):
1666 return _pywrapcp.Solver_DefaultPhase(self, *args)
1667
1668 def ScheduleOrPostpone(self, var, est, marker):
1669 r"""
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.
1675 """
1676 return _pywrapcp.Solver_ScheduleOrPostpone(self, var, est, marker)
1677
1678 def ScheduleOrExpedite(self, var, est, marker):
1679 r"""
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.
1685 """
1686 return _pywrapcp.Solver_ScheduleOrExpedite(self, var, est, marker)
1687
1688 def RankFirstInterval(self, sequence, index):
1689 r"""
1690 Returns a decision that tries to rank first the ith interval var
1691 in the sequence variable.
1692 """
1693 return _pywrapcp.Solver_RankFirstInterval(self, sequence, index)
1694
1695 def RankLastInterval(self, sequence, index):
1696 r"""
1697 Returns a decision that tries to rank last the ith interval var
1698 in the sequence variable.
1699 """
1700 return _pywrapcp.Solver_RankLastInterval(self, sequence, index)
1701
1702 def Phase(self, *args):
1703 return _pywrapcp.Solver_Phase(self, *args)
1704
1705 def DecisionBuilderFromAssignment(self, assignment, db, vars):
1706 r"""
1707 Returns a decision builder for which the left-most leaf corresponds
1708 to assignment, the rest of the tree being explored using 'db'.
1709 """
1710 return _pywrapcp.Solver_DecisionBuilderFromAssignment(self, assignment, db, vars)
1711
1712 def ConstraintAdder(self, ct):
1713 r"""
1714 Returns a decision builder that will add the given constraint to
1715 the model.
1716 """
1717 return _pywrapcp.Solver_ConstraintAdder(self, ct)
1718
1719 def SolveOnce(self, db, monitors):
1720 return _pywrapcp.Solver_SolveOnce(self, db, monitors)
1721
1722 def NestedOptimize(self, *args):
1723 return _pywrapcp.Solver_NestedOptimize(self, *args)
1724
1725 def RestoreAssignment(self, assignment):
1726 r"""
1727 Returns a DecisionBuilder which restores an Assignment
1728 (calls void Assignment::Restore())
1729 """
1730 return _pywrapcp.Solver_RestoreAssignment(self, assignment)
1731
1732 def StoreAssignment(self, assignment):
1733 r"""
1734 Returns a DecisionBuilder which stores an Assignment
1735 (calls void Assignment::Store())
1736 """
1737 return _pywrapcp.Solver_StoreAssignment(self, assignment)
1738
1739 def Operator(self, *args):
1740 return _pywrapcp.Solver_Operator(self, *args)
1741
1742 def RandomLnsOperator(self, *args):
1743 return _pywrapcp.Solver_RandomLnsOperator(self, *args)
1744
1745 def MoveTowardTargetOperator(self, *args):
1746 r"""
1747 *Overload 1:*
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.
1753
1754 |
1755
1756 *Overload 2:*
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.
1763 """
1764 return _pywrapcp.Solver_MoveTowardTargetOperator(self, *args)
1765
1766 def ConcatenateOperators(self, *args):
1767 return _pywrapcp.Solver_ConcatenateOperators(self, *args)
1768
1769 def RandomConcatenateOperators(self, *args):
1770 r"""
1771 *Overload 1:*
1772 Randomized version of local search concatenator; calls a random operator
1773 at each call to MakeNextNeighbor().
1774
1775 |
1776
1777 *Overload 2:*
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.
1781 """
1782 return _pywrapcp.Solver_RandomConcatenateOperators(self, *args)
1783
1784 def NeighborhoodLimit(self, op, limit):
1785 r"""
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.
1791 """
1792 return _pywrapcp.Solver_NeighborhoodLimit(self, op, limit)
1793
1794 def LocalSearchPhase(self, *args):
1795 return _pywrapcp.Solver_LocalSearchPhase(self, *args)
1796
1797 def LocalSearchPhaseParameters(self, *args):
1798 return _pywrapcp.Solver_LocalSearchPhaseParameters(self, *args)
1799
1800 def TopProgressPercent(self):
1801 r"""
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
1804 solve).
1805 """
1806 return _pywrapcp.Solver_TopProgressPercent(self)
1807
1808 def SearchDepth(self):
1809 r"""
1810 Gets the search depth of the current active search. Returns -1 if
1811 there is no active search opened.
1812 """
1813 return _pywrapcp.Solver_SearchDepth(self)
1814
1815 def SearchLeftDepth(self):
1816 r"""
1817 Gets the search left depth of the current active search. Returns -1 if
1818 there is no active search opened.
1819 """
1820 return _pywrapcp.Solver_SearchLeftDepth(self)
1821
1822 def SolveDepth(self):
1823 r"""
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.
1826 """
1827 return _pywrapcp.Solver_SolveDepth(self)
1828
1829 def Rand64(self, size):
1830 r""" Returns a random value between 0 and 'size' - 1;"""
1831 return _pywrapcp.Solver_Rand64(self, size)
1832
1833 def Rand32(self, size):
1834 r""" Returns a random value between 0 and 'size' - 1;"""
1835 return _pywrapcp.Solver_Rand32(self, size)
1836
1837 def ReSeed(self, seed):
1838 r""" Reseed the solver random generator."""
1839 return _pywrapcp.Solver_ReSeed(self, seed)
1840
1841 def LocalSearchProfile(self):
1842 r""" Returns local search profiling information in a human readable format."""
1843 return _pywrapcp.Solver_LocalSearchProfile(self)
1844
1845 def Constraints(self):
1846 r"""
1847 Counts the number of constraints that have been added
1848 to the solver before the search.
1849 """
1850 return _pywrapcp.Solver_Constraints(self)
1851
1852 def Accept(self, visitor):
1853 r""" Accepts the given model visitor."""
1854 return _pywrapcp.Solver_Accept(self, visitor)
1855
1856 def FinishCurrentSearch(self):
1857 r""" Tells the solver to kill or restart the current search."""
1858 return _pywrapcp.Solver_FinishCurrentSearch(self)
1859
1860 def RestartCurrentSearch(self):
1861 return _pywrapcp.Solver_RestartCurrentSearch(self)
1862
1863 def ShouldFail(self):
1864 r"""
1865 These methods are only useful for the SWIG wrappers, which need a way
1866 to externally cause the Solver to fail.
1867 """
1868 return _pywrapcp.Solver_ShouldFail(self)
1869
1870 def __str__(self):
1871 return _pywrapcp.Solver___str__(self)
1872
1873 def Add(self, ct):
1874 if isinstance(ct, PyConstraint):
1875 self.__python_constraints.append(ct)
1876 self.AddConstraint(ct)
1877
1878
1879 def TreeNoCycle(self, nexts, active, callback=0):
1880 return _pywrapcp.Solver_TreeNoCycle(self, nexts, active, callback)
1881
1882 def SearchLogWithCallback(self, period, callback):
1883 return _pywrapcp.Solver_SearchLogWithCallback(self, period, callback)
1884
1885 def ElementFunction(self, values, index):
1886 return _pywrapcp.Solver_ElementFunction(self, values, index)
1887
1888 def VarEvalValStrPhase(self, vars, var_evaluator, val_str):
1889 return _pywrapcp.Solver_VarEvalValStrPhase(self, vars, var_evaluator, val_str)
1890
1891 def VarStrValEvalPhase(self, vars, var_str, val_eval):
1892 return _pywrapcp.Solver_VarStrValEvalPhase(self, vars, var_str, val_eval)
1893
1894 def VarEvalValEvalPhase(self, vars, var_eval, val_eval):
1895 return _pywrapcp.Solver_VarEvalValEvalPhase(self, vars, var_eval, val_eval)
1896
1897 def VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker):
1898 return _pywrapcp.Solver_VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker)
1899
1900 def VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker):
1901 return _pywrapcp.Solver_VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker)
1902
1903 def EvalEvalStrPhase(self, vars, evaluator, str):
1904 return _pywrapcp.Solver_EvalEvalStrPhase(self, vars, evaluator, str)
1905
1906 def EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str):
1907 return _pywrapcp.Solver_EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str)
1908
1909 def GuidedLocalSearch(self, *args):
1910 return _pywrapcp.Solver_GuidedLocalSearch(self, *args)
1911
1912 def SumObjectiveFilter(self, vars, values, filter_enum):
1913 return _pywrapcp.Solver_SumObjectiveFilter(self, vars, values, filter_enum)
1914
1915# Register Solver in _pywrapcp:
1916_pywrapcp.Solver_swigregister(Solver)
1917class BaseObject(object):
1918 r"""
1919 A BaseObject is the root of all reversibly allocated objects.
1920 A DebugString method and the associated << operator are implemented
1921 as a convenience.
1922 """
1923
1924 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1925
1926 def __init__(self):
1927 if self.__class__ == BaseObject:
1928 _self = None
1929 else:
1930 _self = self
1931 _pywrapcp.BaseObject_swiginit(self, _pywrapcp.new_BaseObject(_self, ))
1932 __swig_destroy__ = _pywrapcp.delete_BaseObject
1933
1934 def DebugString(self):
1935 return _pywrapcp.BaseObject_DebugString(self)
1936
1937 def __str__(self):
1938 return _pywrapcp.BaseObject___str__(self)
1939
1940 def __repr__(self):
1941 return _pywrapcp.BaseObject___repr__(self)
1942 def __disown__(self):
1943 self.this.disown()
1944 _pywrapcp.disown_BaseObject(self)
1945 return weakref.proxy(self)
1946
1947# Register BaseObject in _pywrapcp:
1948_pywrapcp.BaseObject_swigregister(BaseObject)
1949class PropagationBaseObject(BaseObject):
1950 r"""
1951 NOLINT
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.
1955 """
1956
1957 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1958 __repr__ = _swig_repr
1959
1960 def __init__(self, s):
1961 if self.__class__ == PropagationBaseObject:
1962 _self = None
1963 else:
1964 _self = self
1965 _pywrapcp.PropagationBaseObject_swiginit(self, _pywrapcp.new_PropagationBaseObject(_self, s))
1966 __swig_destroy__ = _pywrapcp.delete_PropagationBaseObject
1967
1968 def DebugString(self):
1969 return _pywrapcp.PropagationBaseObject_DebugString(self)
1970
1971 def solver(self):
1972 return _pywrapcp.PropagationBaseObject_solver(self)
1973
1974 def Name(self):
1975 r""" Object naming."""
1976 return _pywrapcp.PropagationBaseObject_Name(self)
1977 def __disown__(self):
1978 self.this.disown()
1979 _pywrapcp.disown_PropagationBaseObject(self)
1980 return weakref.proxy(self)
1981
1982# Register PropagationBaseObject in _pywrapcp:
1983_pywrapcp.PropagationBaseObject_swigregister(PropagationBaseObject)
1984class Decision(BaseObject):
1985 r"""
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.
1988 """
1989
1990 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
1991
1992 def __init__(self):
1993 if self.__class__ == Decision:
1994 _self = None
1995 else:
1996 _self = self
1997 _pywrapcp.Decision_swiginit(self, _pywrapcp.new_Decision(_self, ))
1998 __swig_destroy__ = _pywrapcp.delete_Decision
1999
2000 def ApplyWrapper(self, s):
2001 r""" Apply will be called first when the decision is executed."""
2002 return _pywrapcp.Decision_ApplyWrapper(self, s)
2003
2004 def RefuteWrapper(self, s):
2005 r""" Refute will be called after a backtrack."""
2006 return _pywrapcp.Decision_RefuteWrapper(self, s)
2007
2008 def DebugString(self):
2009 return _pywrapcp.Decision_DebugString(self)
2010
2011 def __repr__(self):
2012 return _pywrapcp.Decision___repr__(self)
2013
2014 def __str__(self):
2015 return _pywrapcp.Decision___str__(self)
2016 def __disown__(self):
2017 self.this.disown()
2018 _pywrapcp.disown_Decision(self)
2019 return weakref.proxy(self)
2020
2021# Register Decision in _pywrapcp:
2022_pywrapcp.Decision_swigregister(Decision)
2023class DecisionBuilder(BaseObject):
2024 r"""
2025 A DecisionBuilder is responsible for creating the search tree. The
2026 important method is Next(), which returns the next decision to execute.
2027 """
2028
2029 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2030
2031 def __init__(self):
2032 if self.__class__ == DecisionBuilder:
2033 _self = None
2034 else:
2035 _self = self
2036 _pywrapcp.DecisionBuilder_swiginit(self, _pywrapcp.new_DecisionBuilder(_self, ))
2037 __swig_destroy__ = _pywrapcp.delete_DecisionBuilder
2038
2039 def NextWrapper(self, s):
2040 r"""
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
2044 its work.
2045 """
2046 return _pywrapcp.DecisionBuilder_NextWrapper(self, s)
2047
2048 def DebugString(self):
2049 return _pywrapcp.DecisionBuilder_DebugString(self)
2050
2051 def __repr__(self):
2052 return _pywrapcp.DecisionBuilder___repr__(self)
2053
2054 def __str__(self):
2055 return _pywrapcp.DecisionBuilder___str__(self)
2056 def __disown__(self):
2057 self.this.disown()
2058 _pywrapcp.disown_DecisionBuilder(self)
2059 return weakref.proxy(self)
2060
2061# Register DecisionBuilder in _pywrapcp:
2062_pywrapcp.DecisionBuilder_swigregister(DecisionBuilder)
2063class Demon(BaseObject):
2064 r"""
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.
2074 """
2075
2076 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2077 __repr__ = _swig_repr
2078
2079 def __init__(self):
2080 r"""
2081 This indicates the priority of a demon. Immediate demons are treated
2082 separately and corresponds to variables.
2083 """
2084 if self.__class__ == Demon:
2085 _self = None
2086 else:
2087 _self = self
2088 _pywrapcp.Demon_swiginit(self, _pywrapcp.new_Demon(_self, ))
2089 __swig_destroy__ = _pywrapcp.delete_Demon
2090
2091 def RunWrapper(self, s):
2092 r""" This is the main callback of the demon."""
2093 return _pywrapcp.Demon_RunWrapper(self, s)
2094
2095 def Priority(self):
2096 r"""
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.
2100 """
2101 return _pywrapcp.Demon_Priority(self)
2102
2103 def DebugString(self):
2104 return _pywrapcp.Demon_DebugString(self)
2105
2106 def Inhibit(self, s):
2107 r"""
2108 This method inhibits the demon in the search tree below the
2109 current position.
2110 """
2111 return _pywrapcp.Demon_Inhibit(self, s)
2112
2113 def Desinhibit(self, s):
2114 r""" This method un-inhibits the demon that was previously inhibited."""
2115 return _pywrapcp.Demon_Desinhibit(self, s)
2116 def __disown__(self):
2117 self.this.disown()
2118 _pywrapcp.disown_Demon(self)
2119 return weakref.proxy(self)
2120
2121# Register Demon in _pywrapcp:
2122_pywrapcp.Demon_swigregister(Demon)
2123class Constraint(PropagationBaseObject):
2124 r"""
2125 A constraint is the main modeling object. It provides two methods:
2126 - Post() is responsible for creating the demons and attaching them to
2127 immediate demons().
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.
2131 """
2132
2133 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2134
2135 def __init__(self, solver):
2136 if self.__class__ == Constraint:
2137 _self = None
2138 else:
2139 _self = self
2140 _pywrapcp.Constraint_swiginit(self, _pywrapcp.new_Constraint(_self, solver))
2141 __swig_destroy__ = _pywrapcp.delete_Constraint
2142
2143 def Post(self):
2144 r"""
2145 This method is called when the constraint is processed by the
2146 solver. Its main usage is to attach demons to variables.
2147 """
2148 return _pywrapcp.Constraint_Post(self)
2149
2150 def InitialPropagateWrapper(self):
2151 r"""
2152 This method performs the initial propagation of the
2153 constraint. It is called just after the post.
2154 """
2155 return _pywrapcp.Constraint_InitialPropagateWrapper(self)
2156
2157 def DebugString(self):
2158 return _pywrapcp.Constraint_DebugString(self)
2159
2160 def Var(self):
2161 r"""
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.
2165 """
2166 return _pywrapcp.Constraint_Var(self)
2167
2168 def __repr__(self):
2169 return _pywrapcp.Constraint___repr__(self)
2170
2171 def __str__(self):
2172 return _pywrapcp.Constraint___str__(self)
2173
2174 def __add__(self, *args):
2175 return _pywrapcp.Constraint___add__(self, *args)
2176
2177 def __radd__(self, v):
2178 return _pywrapcp.Constraint___radd__(self, v)
2179
2180 def __sub__(self, *args):
2181 return _pywrapcp.Constraint___sub__(self, *args)
2182
2183 def __rsub__(self, v):
2184 return _pywrapcp.Constraint___rsub__(self, v)
2185
2186 def __mul__(self, *args):
2187 return _pywrapcp.Constraint___mul__(self, *args)
2188
2189 def __rmul__(self, v):
2190 return _pywrapcp.Constraint___rmul__(self, v)
2191
2192 def __floordiv__(self, v):
2193 return _pywrapcp.Constraint___floordiv__(self, v)
2194
2195 def __neg__(self):
2196 return _pywrapcp.Constraint___neg__(self)
2197
2198 def __abs__(self):
2199 return _pywrapcp.Constraint___abs__(self)
2200
2201 def Square(self):
2202 return _pywrapcp.Constraint_Square(self)
2203
2204 def __eq__(self, *args):
2205 return _pywrapcp.Constraint___eq__(self, *args)
2206
2207 def __ne__(self, *args):
2208 return _pywrapcp.Constraint___ne__(self, *args)
2209
2210 def __ge__(self, *args):
2211 return _pywrapcp.Constraint___ge__(self, *args)
2212
2213 def __gt__(self, *args):
2214 return _pywrapcp.Constraint___gt__(self, *args)
2215
2216 def __le__(self, *args):
2217 return _pywrapcp.Constraint___le__(self, *args)
2218
2219 def __lt__(self, *args):
2220 return _pywrapcp.Constraint___lt__(self, *args)
2221
2222 def MapTo(self, vars):
2223 return _pywrapcp.Constraint_MapTo(self, vars)
2224
2225 def IndexOf(self, *args):
2226 return _pywrapcp.Constraint_IndexOf(self, *args)
2227 def __disown__(self):
2228 self.this.disown()
2229 _pywrapcp.disown_Constraint(self)
2230 return weakref.proxy(self)
2231
2232# Register Constraint in _pywrapcp:
2233_pywrapcp.Constraint_swigregister(Constraint)
2234class SearchMonitor(BaseObject):
2235 r""" A search monitor is a simple set of callbacks to monitor all search events"""
2236
2237 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2238 kNoProgress = _pywrapcp.SearchMonitor_kNoProgress
2239
2240 def __init__(self, s):
2241 if self.__class__ == SearchMonitor:
2242 _self = None
2243 else:
2244 _self = self
2245 _pywrapcp.SearchMonitor_swiginit(self, _pywrapcp.new_SearchMonitor(_self, s))
2246 __swig_destroy__ = _pywrapcp.delete_SearchMonitor
2247
2248 def EnterSearch(self):
2249 r""" Beginning of the search."""
2250 return _pywrapcp.SearchMonitor_EnterSearch(self)
2251
2252 def RestartSearch(self):
2253 r""" Restart the search."""
2254 return _pywrapcp.SearchMonitor_RestartSearch(self)
2255
2256 def ExitSearch(self):
2257 r""" End of the search."""
2258 return _pywrapcp.SearchMonitor_ExitSearch(self)
2259
2260 def BeginNextDecision(self, b):
2261 r""" Before calling DecisionBuilder::Next."""
2262 return _pywrapcp.SearchMonitor_BeginNextDecision(self, b)
2263
2264 def EndNextDecision(self, b, d):
2265 r""" After calling DecisionBuilder::Next, along with the returned decision."""
2266 return _pywrapcp.SearchMonitor_EndNextDecision(self, b, d)
2267
2268 def ApplyDecision(self, d):
2269 r""" Before applying the decision."""
2270 return _pywrapcp.SearchMonitor_ApplyDecision(self, d)
2271
2272 def RefuteDecision(self, d):
2273 r""" Before refuting the decision."""
2274 return _pywrapcp.SearchMonitor_RefuteDecision(self, d)
2275
2276 def AfterDecision(self, d, apply):
2277 r"""
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.
2280 """
2281 return _pywrapcp.SearchMonitor_AfterDecision(self, d, apply)
2282
2283 def BeginFail(self):
2284 r""" Just when the failure occurs."""
2285 return _pywrapcp.SearchMonitor_BeginFail(self)
2286
2287 def EndFail(self):
2288 r""" After completing the backtrack."""
2289 return _pywrapcp.SearchMonitor_EndFail(self)
2290
2291 def BeginInitialPropagation(self):
2292 r""" Before the initial propagation."""
2293 return _pywrapcp.SearchMonitor_BeginInitialPropagation(self)
2294
2295 def EndInitialPropagation(self):
2296 r""" After the initial propagation."""
2297 return _pywrapcp.SearchMonitor_EndInitialPropagation(self)
2298
2299 def AcceptSolution(self):
2300 r"""
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.
2304 """
2305 return _pywrapcp.SearchMonitor_AcceptSolution(self)
2306
2307 def AtSolution(self):
2308 r"""
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.
2312 """
2313 return _pywrapcp.SearchMonitor_AtSolution(self)
2314
2315 def NoMoreSolutions(self):
2316 r""" When the search tree is finished."""
2317 return _pywrapcp.SearchMonitor_NoMoreSolutions(self)
2318
2319 def LocalOptimum(self):
2320 r"""
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.
2323 """
2324 return _pywrapcp.SearchMonitor_LocalOptimum(self)
2325
2326 def AcceptDelta(self, delta, deltadelta):
2327
2328 return _pywrapcp.SearchMonitor_AcceptDelta(self, delta, deltadelta)
2329
2330 def AcceptNeighbor(self):
2331 r""" After accepting a neighbor during local search."""
2332 return _pywrapcp.SearchMonitor_AcceptNeighbor(self)
2333
2334 def ProgressPercent(self):
2335 r"""
2336 Returns a percentage representing the propress of the search before
2337 reaching limits.
2338 """
2339 return _pywrapcp.SearchMonitor_ProgressPercent(self)
2340
2341 def solver(self):
2342 return _pywrapcp.SearchMonitor_solver(self)
2343
2344 def __repr__(self):
2345 return _pywrapcp.SearchMonitor___repr__(self)
2346
2347 def __str__(self):
2348 return _pywrapcp.SearchMonitor___str__(self)
2349 def __disown__(self):
2350 self.this.disown()
2351 _pywrapcp.disown_SearchMonitor(self)
2352 return weakref.proxy(self)
2353
2354# Register SearchMonitor in _pywrapcp:
2355_pywrapcp.SearchMonitor_swigregister(SearchMonitor)
2356class IntExpr(PropagationBaseObject):
2357 r"""
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)
2365 """
2366
2367 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2368
2369 def __init__(self, *args, **kwargs):
2370 raise AttributeError("No constructor defined - class is abstract")
2371
2372 def Min(self):
2373 return _pywrapcp.IntExpr_Min(self)
2374
2375 def SetMin(self, m):
2376 return _pywrapcp.IntExpr_SetMin(self, m)
2377
2378 def Max(self):
2379 return _pywrapcp.IntExpr_Max(self)
2380
2381 def SetMax(self, m):
2382 return _pywrapcp.IntExpr_SetMax(self, m)
2383
2384 def SetRange(self, l, u):
2385 r""" This method sets both the min and the max of the expression."""
2386 return _pywrapcp.IntExpr_SetRange(self, l, u)
2387
2388 def SetValue(self, v):
2389 r""" This method sets the value of the expression."""
2390 return _pywrapcp.IntExpr_SetValue(self, v)
2391
2392 def Bound(self):
2393 r""" Returns true if the min and the max of the expression are equal."""
2394 return _pywrapcp.IntExpr_Bound(self)
2395
2396 def IsVar(self):
2397 r""" Returns true if the expression is indeed a variable."""
2398 return _pywrapcp.IntExpr_IsVar(self)
2399
2400 def Var(self):
2401 r""" Creates a variable from the expression."""
2402 return _pywrapcp.IntExpr_Var(self)
2403
2404 def VarWithName(self, name):
2405 r"""
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().
2410 """
2411 return _pywrapcp.IntExpr_VarWithName(self, name)
2412
2413 def WhenRange(self, *args):
2414 r"""
2415 *Overload 1:*
2416 Attach a demon that will watch the min or the max of the expression.
2417
2418 |
2419
2420 *Overload 2:*
2421 Attach a demon that will watch the min or the max of the expression.
2422 """
2423 return _pywrapcp.IntExpr_WhenRange(self, *args)
2424
2425 def __repr__(self):
2426 return _pywrapcp.IntExpr___repr__(self)
2427
2428 def __str__(self):
2429 return _pywrapcp.IntExpr___str__(self)
2430
2431 def __add__(self, *args):
2432 return _pywrapcp.IntExpr___add__(self, *args)
2433
2434 def __radd__(self, v):
2435 return _pywrapcp.IntExpr___radd__(self, v)
2436
2437 def __sub__(self, *args):
2438 return _pywrapcp.IntExpr___sub__(self, *args)
2439
2440 def __rsub__(self, v):
2441 return _pywrapcp.IntExpr___rsub__(self, v)
2442
2443 def __mul__(self, *args):
2444 return _pywrapcp.IntExpr___mul__(self, *args)
2445
2446 def __rmul__(self, v):
2447 return _pywrapcp.IntExpr___rmul__(self, v)
2448
2449 def __floordiv__(self, *args):
2450 return _pywrapcp.IntExpr___floordiv__(self, *args)
2451
2452 def __mod__(self, *args):
2453 return _pywrapcp.IntExpr___mod__(self, *args)
2454
2455 def __neg__(self):
2456 return _pywrapcp.IntExpr___neg__(self)
2457
2458 def __abs__(self):
2459 return _pywrapcp.IntExpr___abs__(self)
2460
2461 def Square(self):
2462 return _pywrapcp.IntExpr_Square(self)
2463
2464 def __eq__(self, *args):
2465 return _pywrapcp.IntExpr___eq__(self, *args)
2466
2467 def __ne__(self, *args):
2468 return _pywrapcp.IntExpr___ne__(self, *args)
2469
2470 def __ge__(self, *args):
2471 return _pywrapcp.IntExpr___ge__(self, *args)
2472
2473 def __gt__(self, *args):
2474 return _pywrapcp.IntExpr___gt__(self, *args)
2475
2476 def __le__(self, *args):
2477 return _pywrapcp.IntExpr___le__(self, *args)
2478
2479 def __lt__(self, *args):
2480 return _pywrapcp.IntExpr___lt__(self, *args)
2481
2482 def MapTo(self, vars):
2483 return _pywrapcp.IntExpr_MapTo(self, vars)
2484
2485 def IndexOf(self, *args):
2486 return _pywrapcp.IntExpr_IndexOf(self, *args)
2487
2488 def IsMember(self, values):
2489 return _pywrapcp.IntExpr_IsMember(self, values)
2490
2491 def Member(self, values):
2492 return _pywrapcp.IntExpr_Member(self, values)
2493
2494 def NotMember(self, starts, ends):
2495 return _pywrapcp.IntExpr_NotMember(self, starts, ends)
2496
2497# Register IntExpr in _pywrapcp:
2498_pywrapcp.IntExpr_swigregister(IntExpr)
2499class IntVarIterator(BaseObject):
2500 r"""
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)) {
2513 use the hole
2514 }
2515 """
2516
2517 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2518
2519 def __init__(self, *args, **kwargs):
2520 raise AttributeError("No constructor defined - class is abstract")
2521 __repr__ = _swig_repr
2522
2523 def Init(self):
2524 r""" This method must be called before each loop."""
2525 return _pywrapcp.IntVarIterator_Init(self)
2526
2527 def Ok(self):
2528 r""" This method indicates if we can call Value() or not."""
2529 return _pywrapcp.IntVarIterator_Ok(self)
2530
2531 def Value(self):
2532 r""" This method returns the current value of the iterator."""
2533 return _pywrapcp.IntVarIterator_Value(self)
2534
2535 def Next(self):
2536 r""" This method moves the iterator to the next value."""
2537 return _pywrapcp.IntVarIterator_Next(self)
2538
2539 def DebugString(self):
2540 r""" Pretty Print."""
2541 return _pywrapcp.IntVarIterator_DebugString(self)
2542
2543 def __iter__(self):
2544 self.Init()
2545 return self
2546
2547 def next(self):
2548 if self.Ok():
2549 result = self.Value()
2550 self.Next()
2551 return result
2552 else:
2553 raise StopIteration()
2554
2555 def __next__(self):
2556 return self.next()
2557
2558
2559# Register IntVarIterator in _pywrapcp:
2560_pywrapcp.IntVarIterator_swigregister(IntVarIterator)
2561class IntVar(IntExpr):
2562 r"""
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.
2566 """
2567
2568 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2569
2570 def __init__(self, *args, **kwargs):
2571 raise AttributeError("No constructor defined - class is abstract")
2572
2573 def IsVar(self):
2574 return _pywrapcp.IntVar_IsVar(self)
2575
2576 def Var(self):
2577 return _pywrapcp.IntVar_Var(self)
2578
2579 def Value(self):
2580 r"""
2581 This method returns the value of the variable. This method checks
2582 before that the variable is bound.
2583 """
2584 return _pywrapcp.IntVar_Value(self)
2585
2586 def RemoveValue(self, v):
2587 r""" This method removes the value 'v' from the domain of the variable."""
2588 return _pywrapcp.IntVar_RemoveValue(self, v)
2589
2590 def RemoveInterval(self, l, u):
2591 r"""
2592 This method removes the interval 'l' .. 'u' from the domain of
2593 the variable. It assumes that 'l' <= 'u'.
2594 """
2595 return _pywrapcp.IntVar_RemoveInterval(self, l, u)
2596
2597 def RemoveValues(self, values):
2598 r""" This method remove the values from the domain of the variable."""
2599 return _pywrapcp.IntVar_RemoveValues(self, values)
2600
2601 def SetValues(self, values):
2602 r""" This method intersects the current domain with the values in the array."""
2603 return _pywrapcp.IntVar_SetValues(self, values)
2604
2605 def WhenBound(self, *args):
2606 r"""
2607 *Overload 1:*
2608 This method attaches a demon that will be awakened when the
2609 variable is bound.
2610
2611 |
2612
2613 *Overload 2:*
2614 This method attaches a closure that will be awakened when the
2615 variable is bound.
2616 """
2617 return _pywrapcp.IntVar_WhenBound(self, *args)
2618
2619 def WhenDomain(self, *args):
2620 r"""
2621 *Overload 1:*
2622 This method attaches a demon that will watch any domain
2623 modification of the domain of the variable.
2624
2625 |
2626
2627 *Overload 2:*
2628 This method attaches a closure that will watch any domain
2629 modification of the domain of the variable.
2630 """
2631 return _pywrapcp.IntVar_WhenDomain(self, *args)
2632
2633 def Size(self):
2634 r""" This method returns the number of values in the domain of the variable."""
2635 return _pywrapcp.IntVar_Size(self)
2636
2637 def Contains(self, v):
2638 r"""
2639 This method returns whether the value 'v' is in the domain of the
2640 variable.
2641 """
2642 return _pywrapcp.IntVar_Contains(self, v)
2643
2644 def HoleIteratorAux(self, reversible):
2645 r"""
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.
2649 """
2650 return _pywrapcp.IntVar_HoleIteratorAux(self, reversible)
2651
2652 def DomainIteratorAux(self, reversible):
2653 r"""
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.
2657 """
2658 return _pywrapcp.IntVar_DomainIteratorAux(self, reversible)
2659
2660 def OldMin(self):
2661 r""" Returns the previous min."""
2662 return _pywrapcp.IntVar_OldMin(self)
2663
2664 def OldMax(self):
2665 r""" Returns the previous max."""
2666 return _pywrapcp.IntVar_OldMax(self)
2667
2668 def __repr__(self):
2669 return _pywrapcp.IntVar___repr__(self)
2670
2671 def __str__(self):
2672 return _pywrapcp.IntVar___str__(self)
2673
2674 def DomainIterator(self):
2675 return iter(self.DomainIteratorAux(False))
2676
2677 def HoleIterator(self):
2678 return iter(self.HoleIteratorAux(False))
2679
2680
2681# Register IntVar in _pywrapcp:
2682_pywrapcp.IntVar_swigregister(IntVar)
2683class SolutionCollector(SearchMonitor):
2684 r"""
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.
2688 """
2689
2690 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2691
2692 def __init__(self, *args, **kwargs):
2693 raise AttributeError("No constructor defined")
2694 __repr__ = _swig_repr
2695
2696 def DebugString(self):
2697 return _pywrapcp.SolutionCollector_DebugString(self)
2698
2699 def Add(self, *args):
2700 return _pywrapcp.SolutionCollector_Add(self, *args)
2701
2702 def AddObjective(self, objective):
2703 return _pywrapcp.SolutionCollector_AddObjective(self, objective)
2704
2705 def EnterSearch(self):
2706 r""" Beginning of the search."""
2707 return _pywrapcp.SolutionCollector_EnterSearch(self)
2708
2709 def SolutionCount(self):
2710 r""" Returns how many solutions were stored during the search."""
2711 return _pywrapcp.SolutionCollector_SolutionCount(self)
2712
2713 def Solution(self, n):
2714 r""" Returns the nth solution."""
2715 return _pywrapcp.SolutionCollector_Solution(self, n)
2716
2717 def WallTime(self, n):
2718 r""" Returns the wall time in ms for the nth solution."""
2719 return _pywrapcp.SolutionCollector_WallTime(self, n)
2720
2721 def Branches(self, n):
2722 r""" Returns the number of branches when the nth solution was found."""
2723 return _pywrapcp.SolutionCollector_Branches(self, n)
2724
2725 def Failures(self, n):
2726 r"""
2727 Returns the number of failures encountered at the time of the nth
2728 solution.
2729 """
2730 return _pywrapcp.SolutionCollector_Failures(self, n)
2731
2732 def ObjectiveValue(self, n):
2733 r""" Returns the objective value of the nth solution."""
2734 return _pywrapcp.SolutionCollector_ObjectiveValue(self, n)
2735
2736 def Value(self, n, var):
2737 r""" This is a shortcut to get the Value of 'var' in the nth solution."""
2738 return _pywrapcp.SolutionCollector_Value(self, n, var)
2739
2740 def StartValue(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)
2743
2744 def EndValue(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)
2747
2748 def DurationValue(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)
2751
2752 def PerformedValue(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)
2755
2756 def ForwardSequence(self, n, var):
2757 r"""
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.
2761 """
2762 return _pywrapcp.SolutionCollector_ForwardSequence(self, n, var)
2763
2764 def BackwardSequence(self, n, var):
2765 r"""
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.
2769 """
2770 return _pywrapcp.SolutionCollector_BackwardSequence(self, n, var)
2771
2772 def Unperformed(self, n, var):
2773 r"""
2774 This is a shortcut to get the list of unperformed of 'var' in the
2775 nth solution.
2776 """
2777 return _pywrapcp.SolutionCollector_Unperformed(self, n, var)
2778
2779# Register SolutionCollector in _pywrapcp:
2780_pywrapcp.SolutionCollector_swigregister(SolutionCollector)
2781class OptimizeVar(object):
2782 r"""
2783 This class encapsulates an objective. It requires the direction
2784 (minimize or maximize), the variable to optimize, and the
2785 improvement step.
2786 """
2787
2788 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2789
2790 def __init__(self, *args, **kwargs):
2791 raise AttributeError("No constructor defined")
2792 __repr__ = _swig_repr
2793
2794 def Best(self):
2795 r""" Returns the best value found during search."""
2796 return _pywrapcp.OptimizeVar_Best(self)
2797
2798 def BeginNextDecision(self, db):
2799 r""" Internal methods."""
2800 return _pywrapcp.OptimizeVar_BeginNextDecision(self, db)
2801
2802 def RefuteDecision(self, d):
2803 return _pywrapcp.OptimizeVar_RefuteDecision(self, d)
2804
2805 def AtSolution(self):
2806 return _pywrapcp.OptimizeVar_AtSolution(self)
2807
2808 def AcceptSolution(self):
2809 return _pywrapcp.OptimizeVar_AcceptSolution(self)
2810
2811 def DebugString(self):
2812 return _pywrapcp.OptimizeVar_DebugString(self)
2813 __swig_destroy__ = _pywrapcp.delete_OptimizeVar
2814
2815# Register OptimizeVar in _pywrapcp:
2816_pywrapcp.OptimizeVar_swigregister(OptimizeVar)
2817class SearchLimit(SearchMonitor):
2818 r""" Base class of all search limits."""
2819
2820 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2821
2822 def __init__(self, *args, **kwargs):
2823 raise AttributeError("No constructor defined - class is abstract")
2824 __repr__ = _swig_repr
2825 __swig_destroy__ = _pywrapcp.delete_SearchLimit
2826
2827 def Crossed(self):
2828 r""" Returns true if the limit has been crossed."""
2829 return _pywrapcp.SearchLimit_Crossed(self)
2830
2831 def Check(self):
2832 r"""
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.
2837 """
2838 return _pywrapcp.SearchLimit_Check(self)
2839
2840 def Init(self):
2841 r""" This method is called when the search limit is initialized."""
2842 return _pywrapcp.SearchLimit_Init(self)
2843
2844 def EnterSearch(self):
2845 r""" Internal methods."""
2846 return _pywrapcp.SearchLimit_EnterSearch(self)
2847
2848 def BeginNextDecision(self, b):
2849 return _pywrapcp.SearchLimit_BeginNextDecision(self, b)
2850
2851 def RefuteDecision(self, d):
2852 return _pywrapcp.SearchLimit_RefuteDecision(self, d)
2853
2854 def DebugString(self):
2855 return _pywrapcp.SearchLimit_DebugString(self)
2856
2857# Register SearchLimit in _pywrapcp:
2858_pywrapcp.SearchLimit_swigregister(SearchLimit)
2859class IntervalVar(PropagationBaseObject):
2860 r"""
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.
2865
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...)
2871 """
2872
2873 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2874
2875 def __init__(self, *args, **kwargs):
2876 raise AttributeError("No constructor defined - class is abstract")
2877
2878 def StartMin(self):
2879 r"""
2880 These methods query, set, and watch the start position of the
2881 interval var.
2882 """
2883 return _pywrapcp.IntervalVar_StartMin(self)
2884
2885 def StartMax(self):
2886 return _pywrapcp.IntervalVar_StartMax(self)
2887
2888 def SetStartMin(self, m):
2889 return _pywrapcp.IntervalVar_SetStartMin(self, m)
2890
2891 def SetStartMax(self, m):
2892 return _pywrapcp.IntervalVar_SetStartMax(self, m)
2893
2894 def SetStartRange(self, mi, ma):
2895 return _pywrapcp.IntervalVar_SetStartRange(self, mi, ma)
2896
2897 def OldStartMin(self):
2898 return _pywrapcp.IntervalVar_OldStartMin(self)
2899
2900 def OldStartMax(self):
2901 return _pywrapcp.IntervalVar_OldStartMax(self)
2902
2903 def WhenStartRange(self, *args):
2904 return _pywrapcp.IntervalVar_WhenStartRange(self, *args)
2905
2906 def WhenStartBound(self, *args):
2907 return _pywrapcp.IntervalVar_WhenStartBound(self, *args)
2908
2909 def DurationMin(self):
2910 r""" These methods query, set, and watch the duration of the interval var."""
2911 return _pywrapcp.IntervalVar_DurationMin(self)
2912
2913 def DurationMax(self):
2914 return _pywrapcp.IntervalVar_DurationMax(self)
2915
2916 def SetDurationMin(self, m):
2917 return _pywrapcp.IntervalVar_SetDurationMin(self, m)
2918
2919 def SetDurationMax(self, m):
2920 return _pywrapcp.IntervalVar_SetDurationMax(self, m)
2921
2922 def SetDurationRange(self, mi, ma):
2923 return _pywrapcp.IntervalVar_SetDurationRange(self, mi, ma)
2924
2925 def OldDurationMin(self):
2926 return _pywrapcp.IntervalVar_OldDurationMin(self)
2927
2928 def OldDurationMax(self):
2929 return _pywrapcp.IntervalVar_OldDurationMax(self)
2930
2931 def WhenDurationRange(self, *args):
2932 return _pywrapcp.IntervalVar_WhenDurationRange(self, *args)
2933
2934 def WhenDurationBound(self, *args):
2935 return _pywrapcp.IntervalVar_WhenDurationBound(self, *args)
2936
2937 def EndMin(self):
2938 r""" These methods query, set, and watch the end position of the interval var."""
2939 return _pywrapcp.IntervalVar_EndMin(self)
2940
2941 def EndMax(self):
2942 return _pywrapcp.IntervalVar_EndMax(self)
2943
2944 def SetEndMin(self, m):
2945 return _pywrapcp.IntervalVar_SetEndMin(self, m)
2946
2947 def SetEndMax(self, m):
2948 return _pywrapcp.IntervalVar_SetEndMax(self, m)
2949
2950 def SetEndRange(self, mi, ma):
2951 return _pywrapcp.IntervalVar_SetEndRange(self, mi, ma)
2952
2953 def OldEndMin(self):
2954 return _pywrapcp.IntervalVar_OldEndMin(self)
2955
2956 def OldEndMax(self):
2957 return _pywrapcp.IntervalVar_OldEndMax(self)
2958
2959 def WhenEndRange(self, *args):
2960 return _pywrapcp.IntervalVar_WhenEndRange(self, *args)
2961
2962 def WhenEndBound(self, *args):
2963 return _pywrapcp.IntervalVar_WhenEndBound(self, *args)
2964
2965 def MustBePerformed(self):
2966 r"""
2967 These methods query, set, and watch the performed status of the
2968 interval var.
2969 """
2970 return _pywrapcp.IntervalVar_MustBePerformed(self)
2971
2972 def MayBePerformed(self):
2973 return _pywrapcp.IntervalVar_MayBePerformed(self)
2974
2975 def CannotBePerformed(self):
2976 return _pywrapcp.IntervalVar_CannotBePerformed(self)
2977
2978 def IsPerformedBound(self):
2979 return _pywrapcp.IntervalVar_IsPerformedBound(self)
2980
2981 def SetPerformed(self, val):
2982 return _pywrapcp.IntervalVar_SetPerformed(self, val)
2983
2984 def WasPerformedBound(self):
2985 return _pywrapcp.IntervalVar_WasPerformedBound(self)
2986
2987 def WhenPerformedBound(self, *args):
2988 return _pywrapcp.IntervalVar_WhenPerformedBound(self, *args)
2989
2990 def WhenAnything(self, *args):
2991 r"""
2992 *Overload 1:*
2993 Attaches a demon awakened when anything about this interval changes.
2994
2995 |
2996
2997 *Overload 2:*
2998 Attaches a closure awakened when anything about this interval changes.
2999 """
3000 return _pywrapcp.IntervalVar_WhenAnything(self, *args)
3001
3002 def StartExpr(self):
3003 r"""
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.
3007 """
3008 return _pywrapcp.IntervalVar_StartExpr(self)
3009
3010 def DurationExpr(self):
3011 return _pywrapcp.IntervalVar_DurationExpr(self)
3012
3013 def EndExpr(self):
3014 return _pywrapcp.IntervalVar_EndExpr(self)
3015
3016 def PerformedExpr(self):
3017 return _pywrapcp.IntervalVar_PerformedExpr(self)
3018
3019 def SafeStartExpr(self, unperformed_value):
3020 r"""
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.
3024 """
3025 return _pywrapcp.IntervalVar_SafeStartExpr(self, unperformed_value)
3026
3027 def SafeDurationExpr(self, unperformed_value):
3028 return _pywrapcp.IntervalVar_SafeDurationExpr(self, unperformed_value)
3029
3030 def SafeEndExpr(self, unperformed_value):
3031 return _pywrapcp.IntervalVar_SafeEndExpr(self, unperformed_value)
3032
3033 def EndsAfterEnd(self, other):
3034 return _pywrapcp.IntervalVar_EndsAfterEnd(self, other)
3035
3036 def EndsAfterEndWithDelay(self, other, delay):
3037 return _pywrapcp.IntervalVar_EndsAfterEndWithDelay(self, other, delay)
3038
3039 def EndsAfterStart(self, other):
3040 return _pywrapcp.IntervalVar_EndsAfterStart(self, other)
3041
3042 def EndsAfterStartWithDelay(self, other, delay):
3043 return _pywrapcp.IntervalVar_EndsAfterStartWithDelay(self, other, delay)
3044
3045 def EndsAtEnd(self, other):
3046 return _pywrapcp.IntervalVar_EndsAtEnd(self, other)
3047
3048 def EndsAtEndWithDelay(self, other, delay):
3049 return _pywrapcp.IntervalVar_EndsAtEndWithDelay(self, other, delay)
3050
3051 def EndsAtStart(self, other):
3052 return _pywrapcp.IntervalVar_EndsAtStart(self, other)
3053
3054 def EndsAtStartWithDelay(self, other, delay):
3055 return _pywrapcp.IntervalVar_EndsAtStartWithDelay(self, other, delay)
3056
3057 def StartsAfterEnd(self, other):
3058 return _pywrapcp.IntervalVar_StartsAfterEnd(self, other)
3059
3060 def StartsAfterEndWithDelay(self, other, delay):
3061 return _pywrapcp.IntervalVar_StartsAfterEndWithDelay(self, other, delay)
3062
3063 def StartsAfterStart(self, other):
3064 return _pywrapcp.IntervalVar_StartsAfterStart(self, other)
3065
3066 def StartsAfterStartWithDelay(self, other, delay):
3067 return _pywrapcp.IntervalVar_StartsAfterStartWithDelay(self, other, delay)
3068
3069 def StartsAtEnd(self, other):
3070 return _pywrapcp.IntervalVar_StartsAtEnd(self, other)
3071
3072 def StartsAtEndWithDelay(self, other, delay):
3073 return _pywrapcp.IntervalVar_StartsAtEndWithDelay(self, other, delay)
3074
3075 def StartsAtStart(self, other):
3076 return _pywrapcp.IntervalVar_StartsAtStart(self, other)
3077
3078 def StartsAtStartWithDelay(self, other, delay):
3079 return _pywrapcp.IntervalVar_StartsAtStartWithDelay(self, other, delay)
3080
3081 def StaysInSync(self, other):
3082 return _pywrapcp.IntervalVar_StaysInSync(self, other)
3083
3084 def StaysInSyncWithDelay(self, other, delay):
3085 return _pywrapcp.IntervalVar_StaysInSyncWithDelay(self, other, delay)
3086
3087 def EndsAfter(self, date):
3088 return _pywrapcp.IntervalVar_EndsAfter(self, date)
3089
3090 def EndsAt(self, date):
3091 return _pywrapcp.IntervalVar_EndsAt(self, date)
3092
3093 def EndsBefore(self, date):
3094 return _pywrapcp.IntervalVar_EndsBefore(self, date)
3095
3096 def StartsAfter(self, date):
3097 return _pywrapcp.IntervalVar_StartsAfter(self, date)
3098
3099 def StartsAt(self, date):
3100 return _pywrapcp.IntervalVar_StartsAt(self, date)
3101
3102 def StartsBefore(self, date):
3103 return _pywrapcp.IntervalVar_StartsBefore(self, date)
3104
3105 def CrossesDate(self, date):
3106 return _pywrapcp.IntervalVar_CrossesDate(self, date)
3107
3108 def AvoidsDate(self, date):
3109 return _pywrapcp.IntervalVar_AvoidsDate(self, date)
3110
3111 def __repr__(self):
3112 return _pywrapcp.IntervalVar___repr__(self)
3113
3114 def __str__(self):
3115 return _pywrapcp.IntervalVar___str__(self)
3116
3117# Register IntervalVar in _pywrapcp:
3118_pywrapcp.IntervalVar_swigregister(IntervalVar)
3119class SequenceVar(PropagationBaseObject):
3120 r"""
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.
3127 """
3128
3129 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3130
3131 def __init__(self, *args, **kwargs):
3132 raise AttributeError("No constructor defined")
3133
3134 def DebugString(self):
3135 return _pywrapcp.SequenceVar_DebugString(self)
3136
3137 def RankFirst(self, index):
3138 r"""
3139 Ranks the index_th interval var first of all unranked interval
3140 vars. After that, it will no longer be considered ranked.
3141 """
3142 return _pywrapcp.SequenceVar_RankFirst(self, index)
3143
3144 def RankNotFirst(self, index):
3145 r"""
3146 Indicates that the index_th interval var will not be ranked first
3147 of all currently unranked interval vars.
3148 """
3149 return _pywrapcp.SequenceVar_RankNotFirst(self, index)
3150
3151 def RankLast(self, index):
3152 r"""
3153 Ranks the index_th interval var first of all unranked interval
3154 vars. After that, it will no longer be considered ranked.
3155 """
3156 return _pywrapcp.SequenceVar_RankLast(self, index)
3157
3158 def RankNotLast(self, index):
3159 r"""
3160 Indicates that the index_th interval var will not be ranked first
3161 of all currently unranked interval vars.
3162 """
3163 return _pywrapcp.SequenceVar_RankNotLast(self, index)
3164
3165 def Interval(self, index):
3166 r""" Returns the index_th interval of the sequence."""
3167 return _pywrapcp.SequenceVar_Interval(self, index)
3168
3169 def Next(self, index):
3170 r""" Returns the next of the index_th interval of the sequence."""
3171 return _pywrapcp.SequenceVar_Next(self, index)
3172
3173 def Size(self):
3174 r""" Returns the number of interval vars in the sequence."""
3175 return _pywrapcp.SequenceVar_Size(self)
3176
3177 def __repr__(self):
3178 return _pywrapcp.SequenceVar___repr__(self)
3179
3180 def __str__(self):
3181 return _pywrapcp.SequenceVar___str__(self)
3182
3183# Register SequenceVar in _pywrapcp:
3184_pywrapcp.SequenceVar_swigregister(SequenceVar)
3185class AssignmentElement(object):
3186 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3187
3188 def __init__(self, *args, **kwargs):
3189 raise AttributeError("No constructor defined")
3190 __repr__ = _swig_repr
3191
3192 def Activate(self):
3193 return _pywrapcp.AssignmentElement_Activate(self)
3194
3195 def Deactivate(self):
3196 return _pywrapcp.AssignmentElement_Deactivate(self)
3197
3198 def Activated(self):
3199 return _pywrapcp.AssignmentElement_Activated(self)
3200 __swig_destroy__ = _pywrapcp.delete_AssignmentElement
3201
3202# Register AssignmentElement in _pywrapcp:
3203_pywrapcp.AssignmentElement_swigregister(AssignmentElement)
3204class IntVarElement(AssignmentElement):
3205 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3206
3207 def __init__(self, *args, **kwargs):
3208 raise AttributeError("No constructor defined")
3209 __repr__ = _swig_repr
3210
3211 def Var(self):
3212 return _pywrapcp.IntVarElement_Var(self)
3213
3214 def Min(self):
3215 return _pywrapcp.IntVarElement_Min(self)
3216
3217 def SetMin(self, m):
3218 return _pywrapcp.IntVarElement_SetMin(self, m)
3219
3220 def Max(self):
3221 return _pywrapcp.IntVarElement_Max(self)
3222
3223 def SetMax(self, m):
3224 return _pywrapcp.IntVarElement_SetMax(self, m)
3225
3226 def Value(self):
3227 return _pywrapcp.IntVarElement_Value(self)
3228
3229 def Bound(self):
3230 return _pywrapcp.IntVarElement_Bound(self)
3231
3232 def SetRange(self, l, u):
3233 return _pywrapcp.IntVarElement_SetRange(self, l, u)
3234
3235 def SetValue(self, v):
3236 return _pywrapcp.IntVarElement_SetValue(self, v)
3237
3238 def __eq__(self, element):
3239 return _pywrapcp.IntVarElement___eq__(self, element)
3240
3241 def __ne__(self, element):
3242 return _pywrapcp.IntVarElement___ne__(self, element)
3243 __swig_destroy__ = _pywrapcp.delete_IntVarElement
3244
3245# Register IntVarElement in _pywrapcp:
3246_pywrapcp.IntVarElement_swigregister(IntVarElement)
3247class IntervalVarElement(AssignmentElement):
3248 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3249
3250 def __init__(self, *args, **kwargs):
3251 raise AttributeError("No constructor defined")
3252 __repr__ = _swig_repr
3253
3254 def Var(self):
3255 return _pywrapcp.IntervalVarElement_Var(self)
3256
3257 def StartMin(self):
3258 return _pywrapcp.IntervalVarElement_StartMin(self)
3259
3260 def StartMax(self):
3261 return _pywrapcp.IntervalVarElement_StartMax(self)
3262
3263 def StartValue(self):
3264 return _pywrapcp.IntervalVarElement_StartValue(self)
3265
3266 def DurationMin(self):
3267 return _pywrapcp.IntervalVarElement_DurationMin(self)
3268
3269 def DurationMax(self):
3270 return _pywrapcp.IntervalVarElement_DurationMax(self)
3271
3272 def DurationValue(self):
3273 return _pywrapcp.IntervalVarElement_DurationValue(self)
3274
3275 def EndMin(self):
3276 return _pywrapcp.IntervalVarElement_EndMin(self)
3277
3278 def EndMax(self):
3279 return _pywrapcp.IntervalVarElement_EndMax(self)
3280
3281 def EndValue(self):
3282 return _pywrapcp.IntervalVarElement_EndValue(self)
3283
3284 def PerformedMin(self):
3285 return _pywrapcp.IntervalVarElement_PerformedMin(self)
3286
3287 def PerformedMax(self):
3288 return _pywrapcp.IntervalVarElement_PerformedMax(self)
3289
3290 def PerformedValue(self):
3291 return _pywrapcp.IntervalVarElement_PerformedValue(self)
3292
3293 def SetStartMin(self, m):
3294 return _pywrapcp.IntervalVarElement_SetStartMin(self, m)
3295
3296 def SetStartMax(self, m):
3297 return _pywrapcp.IntervalVarElement_SetStartMax(self, m)
3298
3299 def SetStartRange(self, mi, ma):
3300 return _pywrapcp.IntervalVarElement_SetStartRange(self, mi, ma)
3301
3302 def SetStartValue(self, v):
3303 return _pywrapcp.IntervalVarElement_SetStartValue(self, v)
3304
3305 def SetDurationMin(self, m):
3306 return _pywrapcp.IntervalVarElement_SetDurationMin(self, m)
3307
3308 def SetDurationMax(self, m):
3309 return _pywrapcp.IntervalVarElement_SetDurationMax(self, m)
3310
3311 def SetDurationRange(self, mi, ma):
3312 return _pywrapcp.IntervalVarElement_SetDurationRange(self, mi, ma)
3313
3314 def SetDurationValue(self, v):
3315 return _pywrapcp.IntervalVarElement_SetDurationValue(self, v)
3316
3317 def SetEndMin(self, m):
3318 return _pywrapcp.IntervalVarElement_SetEndMin(self, m)
3319
3320 def SetEndMax(self, m):
3321 return _pywrapcp.IntervalVarElement_SetEndMax(self, m)
3322
3323 def SetEndRange(self, mi, ma):
3324 return _pywrapcp.IntervalVarElement_SetEndRange(self, mi, ma)
3325
3326 def SetEndValue(self, v):
3327 return _pywrapcp.IntervalVarElement_SetEndValue(self, v)
3328
3329 def SetPerformedMin(self, m):
3330 return _pywrapcp.IntervalVarElement_SetPerformedMin(self, m)
3331
3332 def SetPerformedMax(self, m):
3333 return _pywrapcp.IntervalVarElement_SetPerformedMax(self, m)
3334
3335 def SetPerformedRange(self, mi, ma):
3336 return _pywrapcp.IntervalVarElement_SetPerformedRange(self, mi, ma)
3337
3338 def SetPerformedValue(self, v):
3339 return _pywrapcp.IntervalVarElement_SetPerformedValue(self, v)
3340
3341 def __eq__(self, element):
3342 return _pywrapcp.IntervalVarElement___eq__(self, element)
3343
3344 def __ne__(self, element):
3345 return _pywrapcp.IntervalVarElement___ne__(self, element)
3346 __swig_destroy__ = _pywrapcp.delete_IntervalVarElement
3347
3348# Register IntervalVarElement in _pywrapcp:
3349_pywrapcp.IntervalVarElement_swigregister(IntervalVarElement)
3350class SequenceVarElement(AssignmentElement):
3351 r"""
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.
3365 """
3366
3367 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3368
3369 def __init__(self, *args, **kwargs):
3370 raise AttributeError("No constructor defined")
3371 __repr__ = _swig_repr
3372
3373 def Var(self):
3374 return _pywrapcp.SequenceVarElement_Var(self)
3375
3376 def ForwardSequence(self):
3377 return _pywrapcp.SequenceVarElement_ForwardSequence(self)
3378
3379 def BackwardSequence(self):
3380 return _pywrapcp.SequenceVarElement_BackwardSequence(self)
3381
3382 def Unperformed(self):
3383 return _pywrapcp.SequenceVarElement_Unperformed(self)
3384
3385 def SetSequence(self, forward_sequence, backward_sequence, unperformed):
3386 return _pywrapcp.SequenceVarElement_SetSequence(self, forward_sequence, backward_sequence, unperformed)
3387
3388 def SetForwardSequence(self, forward_sequence):
3389 return _pywrapcp.SequenceVarElement_SetForwardSequence(self, forward_sequence)
3390
3391 def SetBackwardSequence(self, backward_sequence):
3392 return _pywrapcp.SequenceVarElement_SetBackwardSequence(self, backward_sequence)
3393
3394 def SetUnperformed(self, unperformed):
3395 return _pywrapcp.SequenceVarElement_SetUnperformed(self, unperformed)
3396
3397 def __eq__(self, element):
3398 return _pywrapcp.SequenceVarElement___eq__(self, element)
3399
3400 def __ne__(self, element):
3401 return _pywrapcp.SequenceVarElement___ne__(self, element)
3402 __swig_destroy__ = _pywrapcp.delete_SequenceVarElement
3403
3404# Register SequenceVarElement in _pywrapcp:
3405_pywrapcp.SequenceVarElement_swigregister(SequenceVarElement)
3406class Assignment(PropagationBaseObject):
3407 r"""
3408 An Assignment is a variable -> domains mapping, used
3409 to report solutions to the user.
3410 """
3411
3412 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3413
3414 def __init__(self, *args, **kwargs):
3415 raise AttributeError("No constructor defined")
3416 __repr__ = _swig_repr
3417
3418 def Clear(self):
3419 return _pywrapcp.Assignment_Clear(self)
3420
3421 def Empty(self):
3422 return _pywrapcp.Assignment_Empty(self)
3423
3424 def Size(self):
3425 return _pywrapcp.Assignment_Size(self)
3426
3427 def NumIntVars(self):
3428 return _pywrapcp.Assignment_NumIntVars(self)
3429
3430 def NumIntervalVars(self):
3431 return _pywrapcp.Assignment_NumIntervalVars(self)
3432
3433 def NumSequenceVars(self):
3434 return _pywrapcp.Assignment_NumSequenceVars(self)
3435
3436 def Store(self):
3437 return _pywrapcp.Assignment_Store(self)
3438
3439 def Restore(self):
3440 return _pywrapcp.Assignment_Restore(self)
3441
3442 def Load(self, *args):
3443 return _pywrapcp.Assignment_Load(self, *args)
3444
3445 def Save(self, *args):
3446 return _pywrapcp.Assignment_Save(self, *args)
3447
3448 def AddObjective(self, v):
3449 return _pywrapcp.Assignment_AddObjective(self, v)
3450
3451 def Objective(self):
3452 return _pywrapcp.Assignment_Objective(self)
3453
3454 def HasObjective(self):
3455 return _pywrapcp.Assignment_HasObjective(self)
3456
3457 def ObjectiveMin(self):
3458 return _pywrapcp.Assignment_ObjectiveMin(self)
3459
3460 def ObjectiveMax(self):
3461 return _pywrapcp.Assignment_ObjectiveMax(self)
3462
3463 def ObjectiveValue(self):
3464 return _pywrapcp.Assignment_ObjectiveValue(self)
3465
3466 def ObjectiveBound(self):
3467 return _pywrapcp.Assignment_ObjectiveBound(self)
3468
3469 def SetObjectiveMin(self, m):
3470 return _pywrapcp.Assignment_SetObjectiveMin(self, m)
3471
3472 def SetObjectiveMax(self, m):
3473 return _pywrapcp.Assignment_SetObjectiveMax(self, m)
3474
3475 def SetObjectiveValue(self, value):
3476 return _pywrapcp.Assignment_SetObjectiveValue(self, value)
3477
3478 def SetObjectiveRange(self, l, u):
3479 return _pywrapcp.Assignment_SetObjectiveRange(self, l, u)
3480
3481 def Min(self, var):
3482 return _pywrapcp.Assignment_Min(self, var)
3483
3484 def Max(self, var):
3485 return _pywrapcp.Assignment_Max(self, var)
3486
3487 def Value(self, var):
3488 return _pywrapcp.Assignment_Value(self, var)
3489
3490 def Bound(self, var):
3491 return _pywrapcp.Assignment_Bound(self, var)
3492
3493 def SetMin(self, var, m):
3494 return _pywrapcp.Assignment_SetMin(self, var, m)
3495
3496 def SetMax(self, var, m):
3497 return _pywrapcp.Assignment_SetMax(self, var, m)
3498
3499 def SetRange(self, var, l, u):
3500 return _pywrapcp.Assignment_SetRange(self, var, l, u)
3501
3502 def SetValue(self, var, value):
3503 return _pywrapcp.Assignment_SetValue(self, var, value)
3504
3505 def StartMin(self, var):
3506 return _pywrapcp.Assignment_StartMin(self, var)
3507
3508 def StartMax(self, var):
3509 return _pywrapcp.Assignment_StartMax(self, var)
3510
3511 def StartValue(self, var):
3512 return _pywrapcp.Assignment_StartValue(self, var)
3513
3514 def DurationMin(self, var):
3515 return _pywrapcp.Assignment_DurationMin(self, var)
3516
3517 def DurationMax(self, var):
3518 return _pywrapcp.Assignment_DurationMax(self, var)
3519
3520 def DurationValue(self, var):
3521 return _pywrapcp.Assignment_DurationValue(self, var)
3522
3523 def EndMin(self, var):
3524 return _pywrapcp.Assignment_EndMin(self, var)
3525
3526 def EndMax(self, var):
3527 return _pywrapcp.Assignment_EndMax(self, var)
3528
3529 def EndValue(self, var):
3530 return _pywrapcp.Assignment_EndValue(self, var)
3531
3532 def PerformedMin(self, var):
3533 return _pywrapcp.Assignment_PerformedMin(self, var)
3534
3535 def PerformedMax(self, var):
3536 return _pywrapcp.Assignment_PerformedMax(self, var)
3537
3538 def PerformedValue(self, var):
3539 return _pywrapcp.Assignment_PerformedValue(self, var)
3540
3541 def SetStartMin(self, var, m):
3542 return _pywrapcp.Assignment_SetStartMin(self, var, m)
3543
3544 def SetStartMax(self, var, m):
3545 return _pywrapcp.Assignment_SetStartMax(self, var, m)
3546
3547 def SetStartRange(self, var, mi, ma):
3548 return _pywrapcp.Assignment_SetStartRange(self, var, mi, ma)
3549
3550 def SetStartValue(self, var, value):
3551 return _pywrapcp.Assignment_SetStartValue(self, var, value)
3552
3553 def SetDurationMin(self, var, m):
3554 return _pywrapcp.Assignment_SetDurationMin(self, var, m)
3555
3556 def SetDurationMax(self, var, m):
3557 return _pywrapcp.Assignment_SetDurationMax(self, var, m)
3558
3559 def SetDurationRange(self, var, mi, ma):
3560 return _pywrapcp.Assignment_SetDurationRange(self, var, mi, ma)
3561
3562 def SetDurationValue(self, var, value):
3563 return _pywrapcp.Assignment_SetDurationValue(self, var, value)
3564
3565 def SetEndMin(self, var, m):
3566 return _pywrapcp.Assignment_SetEndMin(self, var, m)
3567
3568 def SetEndMax(self, var, m):
3569 return _pywrapcp.Assignment_SetEndMax(self, var, m)
3570
3571 def SetEndRange(self, var, mi, ma):
3572 return _pywrapcp.Assignment_SetEndRange(self, var, mi, ma)
3573
3574 def SetEndValue(self, var, value):
3575 return _pywrapcp.Assignment_SetEndValue(self, var, value)
3576
3577 def SetPerformedMin(self, var, m):
3578 return _pywrapcp.Assignment_SetPerformedMin(self, var, m)
3579
3580 def SetPerformedMax(self, var, m):
3581 return _pywrapcp.Assignment_SetPerformedMax(self, var, m)
3582
3583 def SetPerformedRange(self, var, mi, ma):
3584 return _pywrapcp.Assignment_SetPerformedRange(self, var, mi, ma)
3585
3586 def SetPerformedValue(self, var, value):
3587 return _pywrapcp.Assignment_SetPerformedValue(self, var, value)
3588
3589 def Add(self, *args):
3590 return _pywrapcp.Assignment_Add(self, *args)
3591
3592 def ForwardSequence(self, var):
3593 return _pywrapcp.Assignment_ForwardSequence(self, var)
3594
3595 def BackwardSequence(self, var):
3596 return _pywrapcp.Assignment_BackwardSequence(self, var)
3597
3598 def Unperformed(self, var):
3599 return _pywrapcp.Assignment_Unperformed(self, var)
3600
3601 def SetSequence(self, var, forward_sequence, backward_sequence, unperformed):
3602 return _pywrapcp.Assignment_SetSequence(self, var, forward_sequence, backward_sequence, unperformed)
3603
3604 def SetForwardSequence(self, var, forward_sequence):
3605 return _pywrapcp.Assignment_SetForwardSequence(self, var, forward_sequence)
3606
3607 def SetBackwardSequence(self, var, backward_sequence):
3608 return _pywrapcp.Assignment_SetBackwardSequence(self, var, backward_sequence)
3609
3610 def SetUnperformed(self, var, unperformed):
3611 return _pywrapcp.Assignment_SetUnperformed(self, var, unperformed)
3612
3613 def Activate(self, *args):
3614 return _pywrapcp.Assignment_Activate(self, *args)
3615
3616 def Deactivate(self, *args):
3617 return _pywrapcp.Assignment_Deactivate(self, *args)
3618
3619 def Activated(self, *args):
3620 return _pywrapcp.Assignment_Activated(self, *args)
3621
3622 def DebugString(self):
3623 return _pywrapcp.Assignment_DebugString(self)
3624
3625 def IntVarContainer(self):
3626 return _pywrapcp.Assignment_IntVarContainer(self)
3627
3628 def MutableIntVarContainer(self):
3629 return _pywrapcp.Assignment_MutableIntVarContainer(self)
3630
3631 def IntervalVarContainer(self):
3632 return _pywrapcp.Assignment_IntervalVarContainer(self)
3633
3634 def MutableIntervalVarContainer(self):
3635 return _pywrapcp.Assignment_MutableIntervalVarContainer(self)
3636
3637 def SequenceVarContainer(self):
3638 return _pywrapcp.Assignment_SequenceVarContainer(self)
3639
3640 def MutableSequenceVarContainer(self):
3641 return _pywrapcp.Assignment_MutableSequenceVarContainer(self)
3642
3643 def __eq__(self, assignment):
3644 return _pywrapcp.Assignment___eq__(self, assignment)
3645
3646 def __ne__(self, assignment):
3647 return _pywrapcp.Assignment___ne__(self, assignment)
3648
3649# Register Assignment in _pywrapcp:
3650_pywrapcp.Assignment_swigregister(Assignment)
3651
3652def __lshift__(*args):
3653 return _pywrapcp.__lshift__(*args)
3654class Pack(Constraint):
3655 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3656
3657 def __init__(self, *args, **kwargs):
3658 raise AttributeError("No constructor defined")
3659 __repr__ = _swig_repr
3660
3661 def AddWeightedSumLessOrEqualConstantDimension(self, *args):
3662 r"""
3663 *Overload 1:*
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
3667 penalties...
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
3670 'bounds[b]'.
3671
3672 |
3673
3674 *Overload 2:*
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.
3679
3680 |
3681
3682 *Overload 3:*
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.
3687 """
3688 return _pywrapcp.Pack_AddWeightedSumLessOrEqualConstantDimension(self, *args)
3689
3690 def AddWeightedSumEqualVarDimension(self, *args):
3691 r"""
3692 *Overload 1:*
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].
3695
3696 |
3697
3698 *Overload 2:*
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
3701 loads[b].
3702 """
3703 return _pywrapcp.Pack_AddWeightedSumEqualVarDimension(self, *args)
3704
3705 def AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity):
3706 r"""
3707 This dimension imposes:
3708 forall b in bins,
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
3711 to the bin b.
3712
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
3715 constraint.
3716 """
3717 return _pywrapcp.Pack_AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity)
3718
3719 def AddWeightedSumOfAssignedDimension(self, weights, cost_var):
3720 r"""
3721 This dimension enforces that cost_var == sum of weights[i] for
3722 all objects 'i' assigned to a bin.
3723 """
3724 return _pywrapcp.Pack_AddWeightedSumOfAssignedDimension(self, weights, cost_var)
3725
3726 def AddCountUsedBinDimension(self, count_var):
3727 r"""
3728 This dimension links 'count_var' to the actual number of bins used in the
3729 pack.
3730 """
3731 return _pywrapcp.Pack_AddCountUsedBinDimension(self, count_var)
3732
3733 def AddCountAssignedItemsDimension(self, count_var):
3734 r"""
3735 This dimension links 'count_var' to the actual number of items
3736 assigned to a bin in the pack.
3737 """
3738 return _pywrapcp.Pack_AddCountAssignedItemsDimension(self, count_var)
3739
3740 def Post(self):
3741 return _pywrapcp.Pack_Post(self)
3742
3743 def InitialPropagateWrapper(self):
3744 return _pywrapcp.Pack_InitialPropagateWrapper(self)
3745
3746 def DebugString(self):
3747 return _pywrapcp.Pack_DebugString(self)
3748
3749# Register Pack in _pywrapcp:
3750_pywrapcp.Pack_swigregister(Pack)
3751class DisjunctiveConstraint(Constraint):
3752 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3753
3754 def __init__(self, *args, **kwargs):
3755 raise AttributeError("No constructor defined - class is abstract")
3756 __repr__ = _swig_repr
3757
3758 def SequenceVar(self):
3759 r""" Creates a sequence variable from the constraint."""
3760 return _pywrapcp.DisjunctiveConstraint_SequenceVar(self)
3761
3762 def SetTransitionTime(self, transition_time):
3763 r"""
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.
3768 """
3769 return _pywrapcp.DisjunctiveConstraint_SetTransitionTime(self, transition_time)
3770
3771 def TransitionTime(self, before_index, after_index):
3772 return _pywrapcp.DisjunctiveConstraint_TransitionTime(self, before_index, after_index)
3773
3774# Register DisjunctiveConstraint in _pywrapcp:
3775_pywrapcp.DisjunctiveConstraint_swigregister(DisjunctiveConstraint)
3776class RevInteger(object):
3777 r"""
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.
3783 """
3784
3785 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3786 __repr__ = _swig_repr
3787
3788 def __init__(self, val):
3789 _pywrapcp.RevInteger_swiginit(self, _pywrapcp.new_RevInteger(val))
3790
3791 def Value(self):
3792 return _pywrapcp.RevInteger_Value(self)
3793
3794 def SetValue(self, s, val):
3795 return _pywrapcp.RevInteger_SetValue(self, s, val)
3796 __swig_destroy__ = _pywrapcp.delete_RevInteger
3797
3798# Register RevInteger in _pywrapcp:
3799_pywrapcp.RevInteger_swigregister(RevInteger)
3800class NumericalRevInteger(RevInteger):
3801 r""" Subclass of Rev<T> which adds numerical operations."""
3802
3803 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3804 __repr__ = _swig_repr
3805
3806 def __init__(self, val):
3807 _pywrapcp.NumericalRevInteger_swiginit(self, _pywrapcp.new_NumericalRevInteger(val))
3808
3809 def Add(self, s, to_add):
3810 return _pywrapcp.NumericalRevInteger_Add(self, s, to_add)
3811
3812 def Incr(self, s):
3813 return _pywrapcp.NumericalRevInteger_Incr(self, s)
3814
3815 def Decr(self, s):
3816 return _pywrapcp.NumericalRevInteger_Decr(self, s)
3817 __swig_destroy__ = _pywrapcp.delete_NumericalRevInteger
3818
3819# Register NumericalRevInteger in _pywrapcp:
3820_pywrapcp.NumericalRevInteger_swigregister(NumericalRevInteger)
3821class RevBool(object):
3822 r"""
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.
3828 """
3829
3830 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3831 __repr__ = _swig_repr
3832
3833 def __init__(self, val):
3834 _pywrapcp.RevBool_swiginit(self, _pywrapcp.new_RevBool(val))
3835
3836 def Value(self):
3837 return _pywrapcp.RevBool_Value(self)
3838
3839 def SetValue(self, s, val):
3840 return _pywrapcp.RevBool_SetValue(self, s, val)
3841 __swig_destroy__ = _pywrapcp.delete_RevBool
3842
3843# Register RevBool in _pywrapcp:
3844_pywrapcp.RevBool_swigregister(RevBool)
3845class IntVarContainer(object):
3846 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3847
3848 def __init__(self, *args, **kwargs):
3849 raise AttributeError("No constructor defined")
3850 __repr__ = _swig_repr
3851
3852 def Contains(self, var):
3853 return _pywrapcp.IntVarContainer_Contains(self, var)
3854
3855 def Element(self, index):
3856 return _pywrapcp.IntVarContainer_Element(self, index)
3857
3858 def Size(self):
3859 return _pywrapcp.IntVarContainer_Size(self)
3860
3861 def Store(self):
3862 return _pywrapcp.IntVarContainer_Store(self)
3863
3864 def Restore(self):
3865 return _pywrapcp.IntVarContainer_Restore(self)
3866
3867 def __eq__(self, container):
3868 r"""
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
3871 defined.
3872 """
3873 return _pywrapcp.IntVarContainer___eq__(self, container)
3874
3875 def __ne__(self, container):
3876 return _pywrapcp.IntVarContainer___ne__(self, container)
3877 __swig_destroy__ = _pywrapcp.delete_IntVarContainer
3878
3879# Register IntVarContainer in _pywrapcp:
3880_pywrapcp.IntVarContainer_swigregister(IntVarContainer)
3881class IntervalVarContainer(object):
3882 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3883
3884 def __init__(self, *args, **kwargs):
3885 raise AttributeError("No constructor defined")
3886 __repr__ = _swig_repr
3887
3888 def Contains(self, var):
3889 return _pywrapcp.IntervalVarContainer_Contains(self, var)
3890
3891 def Element(self, index):
3892 return _pywrapcp.IntervalVarContainer_Element(self, index)
3893
3894 def Size(self):
3895 return _pywrapcp.IntervalVarContainer_Size(self)
3896
3897 def Store(self):
3898 return _pywrapcp.IntervalVarContainer_Store(self)
3899
3900 def Restore(self):
3901 return _pywrapcp.IntervalVarContainer_Restore(self)
3902
3903 def __eq__(self, container):
3904 r"""
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
3907 defined.
3908 """
3909 return _pywrapcp.IntervalVarContainer___eq__(self, container)
3910
3911 def __ne__(self, container):
3912 return _pywrapcp.IntervalVarContainer___ne__(self, container)
3913 __swig_destroy__ = _pywrapcp.delete_IntervalVarContainer
3914
3915# Register IntervalVarContainer in _pywrapcp:
3916_pywrapcp.IntervalVarContainer_swigregister(IntervalVarContainer)
3917class SequenceVarContainer(object):
3918 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3919
3920 def __init__(self, *args, **kwargs):
3921 raise AttributeError("No constructor defined")
3922 __repr__ = _swig_repr
3923
3924 def Contains(self, var):
3925 return _pywrapcp.SequenceVarContainer_Contains(self, var)
3926
3927 def Element(self, index):
3928 return _pywrapcp.SequenceVarContainer_Element(self, index)
3929
3930 def Size(self):
3931 return _pywrapcp.SequenceVarContainer_Size(self)
3932
3933 def Store(self):
3934 return _pywrapcp.SequenceVarContainer_Store(self)
3935
3936 def Restore(self):
3937 return _pywrapcp.SequenceVarContainer_Restore(self)
3938
3939 def __eq__(self, container):
3940 r"""
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
3943 defined.
3944 """
3945 return _pywrapcp.SequenceVarContainer___eq__(self, container)
3946
3947 def __ne__(self, container):
3948 return _pywrapcp.SequenceVarContainer___ne__(self, container)
3949 __swig_destroy__ = _pywrapcp.delete_SequenceVarContainer
3950
3951# Register SequenceVarContainer in _pywrapcp:
3952_pywrapcp.SequenceVarContainer_swigregister(SequenceVarContainer)
3953class LocalSearchOperator(BaseObject):
3954 r"""
3955 The base class for all local search operators.
3956
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.
3960
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.
3964
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
3970 information.
3971 """
3972
3973 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3974
3975 def __init__(self, *args, **kwargs):
3976 raise AttributeError("No constructor defined - class is abstract")
3977 __repr__ = _swig_repr
3978
3979 def NextNeighbor(self, delta, deltadelta):
3980 return _pywrapcp.LocalSearchOperator_NextNeighbor(self, delta, deltadelta)
3981
3982 def Start(self, assignment):
3983 return _pywrapcp.LocalSearchOperator_Start(self, assignment)
3984 def __disown__(self):
3985 self.this.disown()
3986 _pywrapcp.disown_LocalSearchOperator(self)
3987 return weakref.proxy(self)
3988
3989# Register LocalSearchOperator in _pywrapcp:
3990_pywrapcp.LocalSearchOperator_swigregister(LocalSearchOperator)
3991class IntVarLocalSearchOperator(LocalSearchOperator):
3992 r"""
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.
3998 """
3999
4000 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4001 __repr__ = _swig_repr
4002
4003 def __init__(self,