ortools.constraint_solver.pywrapcp

   1# This file was automatically generated by SWIG (https://www.swig.org).
   2# Version 4.3.0
   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        r"""Solver API"""
 437        _pywrapcp.Solver_swiginit(self, _pywrapcp.new_Solver(*args))
 438
 439        self.__python_constraints = []
 440
 441
 442
 443    __swig_destroy__ = _pywrapcp.delete_Solver
 444
 445    def Parameters(self):
 446        r"""Stored Parameters."""
 447        return _pywrapcp.Solver_Parameters(self)
 448
 449    @staticmethod
 450    def DefaultSolverParameters():
 451        r"""Create a ConstraintSolverParameters proto with all the default values."""
 452        return _pywrapcp.Solver_DefaultSolverParameters()
 453
 454    def AddConstraint(self, c):
 455        r"""
 456        Adds the constraint 'c' to the model.
 457
 458        After calling this method, and until there is a backtrack that undoes the
 459        addition, any assignment of variables to values must satisfy the given
 460        constraint in order to be considered feasible. There are two fairly
 461        different use cases:
 462
 463        - the most common use case is modeling: the given constraint is really
 464        part of the problem that the user is trying to solve. In this use case,
 465        AddConstraint is called outside of search (i.e., with state() ==
 466        OUTSIDE_SEARCH). Most users should only use AddConstraint in this
 467        way. In this case, the constraint will belong to the model forever: it
 468        cannot be removed by backtracking.
 469
 470        - a rarer use case is that 'c' is not a real constraint of the model. It
 471        may be a constraint generated by a branching decision (a constraint whose
 472        goal is to restrict the search space), a symmetry breaking constraint (a
 473        constraint that does restrict the search space, but in a way that cannot
 474        have an impact on the quality of the solutions in the subtree), or an
 475        inferred constraint that, while having no semantic value to the model (it
 476        does not restrict the set of solutions), is worth having because we
 477        believe it may strengthen the propagation. In these cases, it happens
 478        that the constraint is added during the search (i.e., with state() ==
 479        IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is
 480        added during a search, it applies only to the subtree of the search tree
 481        rooted at the current node, and will be automatically removed by
 482        backtracking.
 483
 484        This method does not take ownership of the constraint. If the constraint
 485        has been created by any factory method (Solver::MakeXXX), it will
 486        automatically be deleted. However, power users who implement their own
 487        constraints should do: solver.AddConstraint(solver.RevAlloc(new
 488        MyConstraint(...));
 489        """
 490        return _pywrapcp.Solver_AddConstraint(self, c)
 491
 492    def Solve(self, *args):
 493        r"""
 494         Solves the problem using the given DecisionBuilder and returns true if a
 495         solution was found and accepted.
 496
 497         These methods are the ones most users should use to search for a solution.
 498         Note that the definition of 'solution' is subtle. A solution here is
 499         defined as a leaf of the search tree with respect to the given decision
 500         builder for which there is no failure. What this means is that, contrary
 501         to intuition, a solution may not have all variables of the model bound.
 502         It is the responsibility of the decision builder to keep returning
 503         decisions until all variables are indeed bound. The most extreme
 504         counterexample is calling Solve with a trivial decision builder whose
 505         Next() method always returns nullptr. In this case, Solve immediately
 506         returns 'true', since not assigning any variable to any value is a
 507         solution, unless the root node propagation discovers that the model is
 508         infeasible.
 509
 510         This function must be called either from outside of search,
 511         or from within the Next() method of a decision builder.
 512
 513         Solve will terminate whenever any of the following event arise:
 514        A search monitor asks the solver to terminate the search by calling
 515           solver()->FinishCurrentSearch().
 516        A solution is found that is accepted by all search monitors, and none of
 517           the search monitors decides to search for another one.
 518
 519         Upon search termination, there will be a series of backtracks all the way
 520         to the top level. This means that a user cannot expect to inspect the
 521         solution by querying variables after a call to Solve(): all the
 522         information will be lost. In order to do something with the solution, the
 523         user must either:
 524
 525        Use a search monitor that can process such a leaf. See, in particular,
 526             the SolutionCollector class.
 527        Do not use Solve. Instead, use the more fine-grained approach using
 528             methods NewSearch(...), NextSolution(), and EndSearch().
 529
 530         :type db: :py:class:`DecisionBuilder`
 531         :param db: The decision builder that will generate the search tree.
 532         :type monitors: std::vector< operations_research::SearchMonitor * >
 533         :param monitors: A vector of search monitors that will be notified of
 534             various events during the search. In their reaction to these events, such
 535             monitors may influence the search.
 536        """
 537        return _pywrapcp.Solver_Solve(self, *args)
 538
 539    def NewSearch(self, *args):
 540        r"""
 541         Decomposed search.
 542         The code for a top level search should look like
 543         solver->NewSearch(db);
 544         while (solver->NextSolution()) {
 545        .. use the current solution
 546         }
 547         solver()->EndSearch();
 548        """
 549        return _pywrapcp.Solver_NewSearch(self, *args)
 550
 551    def NextSolution(self):
 552        return _pywrapcp.Solver_NextSolution(self)
 553
 554    def RestartSearch(self):
 555        return _pywrapcp.Solver_RestartSearch(self)
 556
 557    def EndSearch(self):
 558        return _pywrapcp.Solver_EndSearch(self)
 559
 560    def SolveAndCommit(self, *args):
 561        r"""
 562        SolveAndCommit using a decision builder and up to three
 563          search monitors, usually one for the objective, one for the limits
 564          and one to collect solutions.
 565
 566        The difference between a SolveAndCommit() and a Solve() method
 567        call is the fact that SolveAndCommit will not backtrack all
 568        modifications at the end of the search. This method is only
 569        usable during the Next() method of a decision builder.
 570        """
 571        return _pywrapcp.Solver_SolveAndCommit(self, *args)
 572
 573    def CheckAssignment(self, solution):
 574        r"""Checks whether the given assignment satisfies all relevant constraints."""
 575        return _pywrapcp.Solver_CheckAssignment(self, solution)
 576
 577    def CheckConstraint(self, ct):
 578        r"""
 579        Checks whether adding this constraint will lead to an immediate
 580        failure. It will return false if the model is already inconsistent, or if
 581        adding the constraint makes it inconsistent.
 582        """
 583        return _pywrapcp.Solver_CheckConstraint(self, ct)
 584
 585    def Fail(self):
 586        r"""Abandon the current branch in the search tree. A backtrack will follow."""
 587        return _pywrapcp.Solver_Fail(self)
 588
 589    @staticmethod
 590    def MemoryUsage():
 591        r"""Current memory usage in bytes"""
 592        return _pywrapcp.Solver_MemoryUsage()
 593
 594    def WallTime(self):
 595        r"""
 596        DEPRECATED: Use Now() instead.
 597        Time elapsed, in ms since the creation of the solver.
 598        """
 599        return _pywrapcp.Solver_WallTime(self)
 600
 601    def Branches(self):
 602        r"""The number of branches explored since the creation of the solver."""
 603        return _pywrapcp.Solver_Branches(self)
 604
 605    def Solutions(self):
 606        r"""The number of solutions found since the start of the search."""
 607        return _pywrapcp.Solver_Solutions(self)
 608
 609    def Failures(self):
 610        r"""The number of failures encountered since the creation of the solver."""
 611        return _pywrapcp.Solver_Failures(self)
 612
 613    def AcceptedNeighbors(self):
 614        r"""The number of accepted neighbors."""
 615        return _pywrapcp.Solver_AcceptedNeighbors(self)
 616
 617    def Stamp(self):
 618        r"""
 619        The stamp indicates how many moves in the search tree we have performed.
 620        It is useful to detect if we need to update same lazy structures.
 621        """
 622        return _pywrapcp.Solver_Stamp(self)
 623
 624    def FailStamp(self):
 625        r"""The fail_stamp() is incremented after each backtrack."""
 626        return _pywrapcp.Solver_FailStamp(self)
 627
 628    def IntVar(self, *args):
 629        r"""
 630        *Overload 1:*
 631        MakeIntVar will create the best range based int var for the bounds given.
 632
 633        |
 634
 635        *Overload 2:*
 636        MakeIntVar will create a variable with the given sparse domain.
 637
 638        |
 639
 640        *Overload 3:*
 641        MakeIntVar will create a variable with the given sparse domain.
 642
 643        |
 644
 645        *Overload 4:*
 646        MakeIntVar will create the best range based int var for the bounds given.
 647
 648        |
 649
 650        *Overload 5:*
 651        MakeIntVar will create a variable with the given sparse domain.
 652
 653        |
 654
 655        *Overload 6:*
 656        MakeIntVar will create a variable with the given sparse domain.
 657        """
 658        return _pywrapcp.Solver_IntVar(self, *args)
 659
 660    def BoolVar(self, *args):
 661        r"""
 662        *Overload 1:*
 663        MakeBoolVar will create a variable with a {0, 1} domain.
 664
 665        |
 666
 667        *Overload 2:*
 668        MakeBoolVar will create a variable with a {0, 1} domain.
 669        """
 670        return _pywrapcp.Solver_BoolVar(self, *args)
 671
 672    def IntConst(self, *args):
 673        r"""
 674        *Overload 1:*
 675        IntConst will create a constant expression.
 676
 677        |
 678
 679        *Overload 2:*
 680        IntConst will create a constant expression.
 681        """
 682        return _pywrapcp.Solver_IntConst(self, *args)
 683
 684    def Sum(self, vars):
 685        r"""sum of all vars."""
 686        return _pywrapcp.Solver_Sum(self, vars)
 687
 688    def ScalProd(self, *args):
 689        r"""
 690        *Overload 1:*
 691        scalar product
 692
 693        |
 694
 695        *Overload 2:*
 696        scalar product
 697        """
 698        return _pywrapcp.Solver_ScalProd(self, *args)
 699
 700    def MonotonicElement(self, values, increasing, index):
 701        r"""
 702        Function based element. The constraint takes ownership of the
 703        callback.  The callback must be monotonic. It must be able to
 704        cope with any possible value in the domain of 'index'
 705        (potentially negative ones too). Furtermore, monotonicity is not
 706        checked. Thus giving a non-monotonic function, or specifying an
 707        incorrect increasing parameter will result in undefined behavior.
 708        """
 709        return _pywrapcp.Solver_MonotonicElement(self, values, increasing, index)
 710
 711    def Element(self, *args):
 712        r"""
 713        *Overload 1:*
 714        values[index]
 715
 716        |
 717
 718        *Overload 2:*
 719        values[index]
 720
 721        |
 722
 723        *Overload 3:*
 724        Function-based element. The constraint takes ownership of the
 725        callback. The callback must be able to cope with any possible
 726        value in the domain of 'index' (potentially negative ones too).
 727
 728        |
 729
 730        *Overload 4:*
 731        2D version of function-based element expression, values(expr1, expr2).
 732
 733        |
 734
 735        *Overload 5:*
 736        vars[expr]
 737        """
 738        return _pywrapcp.Solver_Element(self, *args)
 739
 740    def IndexExpression(self, vars, value):
 741        r"""
 742        Returns the expression expr such that vars[expr] == value.
 743        It assumes that vars are all different.
 744        """
 745        return _pywrapcp.Solver_IndexExpression(self, vars, value)
 746
 747    def Min(self, *args):
 748        r"""
 749        *Overload 1:*
 750        std::min(vars)
 751
 752        |
 753
 754        *Overload 2:*
 755        std::min (left, right)
 756
 757        |
 758
 759        *Overload 3:*
 760        std::min(expr, value)
 761
 762        |
 763
 764        *Overload 4:*
 765        std::min(expr, value)
 766        """
 767        return _pywrapcp.Solver_Min(self, *args)
 768
 769    def Max(self, *args):
 770        r"""
 771        *Overload 1:*
 772        std::max(vars)
 773
 774        |
 775
 776        *Overload 2:*
 777        std::max(left, right)
 778
 779        |
 780
 781        *Overload 3:*
 782        std::max(expr, value)
 783
 784        |
 785
 786        *Overload 4:*
 787        std::max(expr, value)
 788        """
 789        return _pywrapcp.Solver_Max(self, *args)
 790
 791    def ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost):
 792        r"""Convex piecewise function."""
 793        return _pywrapcp.Solver_ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost)
 794
 795    def SemiContinuousExpr(self, expr, fixed_charge, step):
 796        r"""
 797        Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b)
 798        a >= 0 and b >= 0
 799        """
 800        return _pywrapcp.Solver_SemiContinuousExpr(self, expr, fixed_charge, step)
 801
 802    def ConditionalExpression(self, condition, expr, unperformed_value):
 803        r"""Conditional Expr condition ? expr : unperformed_value"""
 804        return _pywrapcp.Solver_ConditionalExpression(self, condition, expr, unperformed_value)
 805
 806    def TrueConstraint(self):
 807        r"""This constraint always succeeds."""
 808        return _pywrapcp.Solver_TrueConstraint(self)
 809
 810    def FalseConstraint(self, *args):
 811        r"""This constraint always fails."""
 812        return _pywrapcp.Solver_FalseConstraint(self, *args)
 813
 814    def IsEqualCstCt(self, var, value, boolvar):
 815        r"""boolvar == (var == value)"""
 816        return _pywrapcp.Solver_IsEqualCstCt(self, var, value, boolvar)
 817
 818    def IsEqualCstVar(self, var, value):
 819        r"""status var of (var == value)"""
 820        return _pywrapcp.Solver_IsEqualCstVar(self, var, value)
 821
 822    def IsEqualCt(self, v1, v2, b):
 823        r"""b == (v1 == v2)"""
 824        return _pywrapcp.Solver_IsEqualCt(self, v1, v2, b)
 825
 826    def IsEqualVar(self, v1, v2):
 827        r"""status var of (v1 == v2)"""
 828        return _pywrapcp.Solver_IsEqualVar(self, v1, v2)
 829
 830    def IsDifferentCstCt(self, var, value, boolvar):
 831        r"""boolvar == (var != value)"""
 832        return _pywrapcp.Solver_IsDifferentCstCt(self, var, value, boolvar)
 833
 834    def IsDifferentCstVar(self, var, value):
 835        r"""status var of (var != value)"""
 836        return _pywrapcp.Solver_IsDifferentCstVar(self, var, value)
 837
 838    def IsDifferentVar(self, v1, v2):
 839        r"""status var of (v1 != v2)"""
 840        return _pywrapcp.Solver_IsDifferentVar(self, v1, v2)
 841
 842    def IsDifferentCt(self, v1, v2, b):
 843        r"""b == (v1 != v2)"""
 844        return _pywrapcp.Solver_IsDifferentCt(self, v1, v2, b)
 845
 846    def IsLessOrEqualCstCt(self, var, value, boolvar):
 847        r"""boolvar == (var <= value)"""
 848        return _pywrapcp.Solver_IsLessOrEqualCstCt(self, var, value, boolvar)
 849
 850    def IsLessOrEqualCstVar(self, var, value):
 851        r"""status var of (var <= value)"""
 852        return _pywrapcp.Solver_IsLessOrEqualCstVar(self, var, value)
 853
 854    def IsLessOrEqualVar(self, left, right):
 855        r"""status var of (left <= right)"""
 856        return _pywrapcp.Solver_IsLessOrEqualVar(self, left, right)
 857
 858    def IsLessOrEqualCt(self, left, right, b):
 859        r"""b == (left <= right)"""
 860        return _pywrapcp.Solver_IsLessOrEqualCt(self, left, right, b)
 861
 862    def IsGreaterOrEqualCstCt(self, var, value, boolvar):
 863        r"""boolvar == (var >= value)"""
 864        return _pywrapcp.Solver_IsGreaterOrEqualCstCt(self, var, value, boolvar)
 865
 866    def IsGreaterOrEqualCstVar(self, var, value):
 867        r"""status var of (var >= value)"""
 868        return _pywrapcp.Solver_IsGreaterOrEqualCstVar(self, var, value)
 869
 870    def IsGreaterOrEqualVar(self, left, right):
 871        r"""status var of (left >= right)"""
 872        return _pywrapcp.Solver_IsGreaterOrEqualVar(self, left, right)
 873
 874    def IsGreaterOrEqualCt(self, left, right, b):
 875        r"""b == (left >= right)"""
 876        return _pywrapcp.Solver_IsGreaterOrEqualCt(self, left, right, b)
 877
 878    def IsGreaterCstCt(self, v, c, b):
 879        r"""b == (v > c)"""
 880        return _pywrapcp.Solver_IsGreaterCstCt(self, v, c, b)
 881
 882    def IsGreaterCstVar(self, var, value):
 883        r"""status var of (var > value)"""
 884        return _pywrapcp.Solver_IsGreaterCstVar(self, var, value)
 885
 886    def IsGreaterVar(self, left, right):
 887        r"""status var of (left > right)"""
 888        return _pywrapcp.Solver_IsGreaterVar(self, left, right)
 889
 890    def IsGreaterCt(self, left, right, b):
 891        r"""b == (left > right)"""
 892        return _pywrapcp.Solver_IsGreaterCt(self, left, right, b)
 893
 894    def IsLessCstCt(self, v, c, b):
 895        r"""b == (v < c)"""
 896        return _pywrapcp.Solver_IsLessCstCt(self, v, c, b)
 897
 898    def IsLessCstVar(self, var, value):
 899        r"""status var of (var < value)"""
 900        return _pywrapcp.Solver_IsLessCstVar(self, var, value)
 901
 902    def IsLessVar(self, left, right):
 903        r"""status var of (left < right)"""
 904        return _pywrapcp.Solver_IsLessVar(self, left, right)
 905
 906    def IsLessCt(self, left, right, b):
 907        r"""b == (left < right)"""
 908        return _pywrapcp.Solver_IsLessCt(self, left, right, b)
 909
 910    def SumLessOrEqual(self, vars, cst):
 911        r"""Variation on arrays."""
 912        return _pywrapcp.Solver_SumLessOrEqual(self, vars, cst)
 913
 914    def SumGreaterOrEqual(self, vars, cst):
 915        return _pywrapcp.Solver_SumGreaterOrEqual(self, vars, cst)
 916
 917    def SumEquality(self, *args):
 918        return _pywrapcp.Solver_SumEquality(self, *args)
 919
 920    def ScalProdEquality(self, *args):
 921        return _pywrapcp.Solver_ScalProdEquality(self, *args)
 922
 923    def ScalProdGreaterOrEqual(self, *args):
 924        return _pywrapcp.Solver_ScalProdGreaterOrEqual(self, *args)
 925
 926    def ScalProdLessOrEqual(self, *args):
 927        return _pywrapcp.Solver_ScalProdLessOrEqual(self, *args)
 928
 929    def MinEquality(self, vars, min_var):
 930        return _pywrapcp.Solver_MinEquality(self, vars, min_var)
 931
 932    def MaxEquality(self, vars, max_var):
 933        return _pywrapcp.Solver_MaxEquality(self, vars, max_var)
 934
 935    def ElementEquality(self, *args):
 936        return _pywrapcp.Solver_ElementEquality(self, *args)
 937
 938    def AbsEquality(self, var, abs_var):
 939        r"""Creates the constraint abs(var) == abs_var."""
 940        return _pywrapcp.Solver_AbsEquality(self, var, abs_var)
 941
 942    def IndexOfConstraint(self, vars, index, target):
 943        r"""
 944        This constraint is a special case of the element constraint with
 945        an array of integer variables, where the variables are all
 946        different and the index variable is constrained such that
 947        vars[index] == target.
 948        """
 949        return _pywrapcp.Solver_IndexOfConstraint(self, vars, index, target)
 950
 951    def ConstraintInitialPropagateCallback(self, ct):
 952        r"""
 953        This method is a specialized case of the MakeConstraintDemon
 954        method to call the InitiatePropagate of the constraint 'ct'.
 955        """
 956        return _pywrapcp.Solver_ConstraintInitialPropagateCallback(self, ct)
 957
 958    def DelayedConstraintInitialPropagateCallback(self, ct):
 959        r"""
 960        This method is a specialized case of the MakeConstraintDemon
 961        method to call the InitiatePropagate of the constraint 'ct' with
 962        low priority.
 963        """
 964        return _pywrapcp.Solver_DelayedConstraintInitialPropagateCallback(self, ct)
 965
 966    def ClosureDemon(self, closure):
 967        r"""Creates a demon from a closure."""
 968        return _pywrapcp.Solver_ClosureDemon(self, closure)
 969
 970    def BetweenCt(self, expr, l, u):
 971        r"""(l <= expr <= u)"""
 972        return _pywrapcp.Solver_BetweenCt(self, expr, l, u)
 973
 974    def IsBetweenCt(self, expr, l, u, b):
 975        r"""b == (l <= expr <= u)"""
 976        return _pywrapcp.Solver_IsBetweenCt(self, expr, l, u, b)
 977
 978    def IsBetweenVar(self, v, l, u):
 979        return _pywrapcp.Solver_IsBetweenVar(self, v, l, u)
 980
 981    def MemberCt(self, *args):
 982        r"""
 983        expr in set. Propagation is lazy, i.e. this constraint does not
 984        creates holes in the domain of the variable.
 985        """
 986        return _pywrapcp.Solver_MemberCt(self, *args)
 987
 988    def NotMemberCt(self, *args):
 989        r"""
 990        *Overload 1:*
 991        expr not in set.
 992
 993        |
 994
 995        *Overload 2:*
 996        expr should not be in the list of forbidden intervals [start[i]..end[i]].
 997
 998        |
 999
1000        *Overload 3:*
1001        expr should not be in the list of forbidden intervals [start[i]..end[i]].
1002        """
1003        return _pywrapcp.Solver_NotMemberCt(self, *args)
1004
1005    def IsMemberCt(self, *args):
1006        r"""boolvar == (expr in set)"""
1007        return _pywrapcp.Solver_IsMemberCt(self, *args)
1008
1009    def IsMemberVar(self, *args):
1010        return _pywrapcp.Solver_IsMemberVar(self, *args)
1011
1012    def Count(self, *args):
1013        r"""
1014        *Overload 1:*
1015        |{i | vars[i] == value}| == max_count
1016
1017        |
1018
1019        *Overload 2:*
1020        |{i | vars[i] == value}| == max_count
1021        """
1022        return _pywrapcp.Solver_Count(self, *args)
1023
1024    def Distribute(self, *args):
1025        r"""
1026        *Overload 1:*
1027        Aggregated version of count:  |{i | v[i] == values[j]}| == cards[j]
1028
1029        |
1030
1031        *Overload 2:*
1032        Aggregated version of count:  |{i | v[i] == values[j]}| == cards[j]
1033
1034        |
1035
1036        *Overload 3:*
1037        Aggregated version of count:  |{i | v[i] == j}| == cards[j]
1038
1039        |
1040
1041        *Overload 4:*
1042        Aggregated version of count with bounded cardinalities:
1043        forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max
1044
1045        |
1046
1047        *Overload 5:*
1048        Aggregated version of count with bounded cardinalities:
1049        forall j in 0 .. card_size - 1:
1050           card_min[j] <= |{i | v[i] == j}| <= card_max[j]
1051
1052        |
1053
1054        *Overload 6:*
1055        Aggregated version of count with bounded cardinalities:
1056        forall j in 0 .. card_size - 1:
1057           card_min[j] <= |{i | v[i] == j}| <= card_max[j]
1058
1059        |
1060
1061        *Overload 7:*
1062        Aggregated version of count with bounded cardinalities:
1063        forall j in 0 .. card_size - 1:
1064           card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
1065
1066        |
1067
1068        *Overload 8:*
1069        Aggregated version of count with bounded cardinalities:
1070        forall j in 0 .. card_size - 1:
1071           card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
1072        """
1073        return _pywrapcp.Solver_Distribute(self, *args)
1074
1075    def Deviation(self, vars, deviation_var, total_sum):
1076        r"""
1077        Deviation constraint:
1078        sum_i |n * vars[i] - total_sum| <= deviation_var and
1079        sum_i vars[i] == total_sum
1080        n = #vars
1081        """
1082        return _pywrapcp.Solver_Deviation(self, vars, deviation_var, total_sum)
1083
1084    def AllDifferent(self, *args):
1085        r"""
1086        *Overload 1:*
1087        All variables are pairwise different. This corresponds to the
1088        stronger version of the propagation algorithm.
1089
1090        |
1091
1092        *Overload 2:*
1093        All variables are pairwise different.  If 'stronger_propagation'
1094        is true, stronger, and potentially slower propagation will
1095        occur. This API will be deprecated in the future.
1096        """
1097        return _pywrapcp.Solver_AllDifferent(self, *args)
1098
1099    def AllDifferentExcept(self, vars, escape_value):
1100        r"""
1101        All variables are pairwise different, unless they are assigned to
1102        the escape value.
1103        """
1104        return _pywrapcp.Solver_AllDifferentExcept(self, vars, escape_value)
1105
1106    def SortingConstraint(self, vars, sorted):
1107        r"""
1108        Creates a constraint binding the arrays of variables "vars" and
1109        "sorted_vars": sorted_vars[0] must be equal to the minimum of all
1110        variables in vars, and so on: the value of sorted_vars[i] must be
1111        equal to the i-th value of variables invars.
1112
1113        This constraint propagates in both directions: from "vars" to
1114        "sorted_vars" and vice-versa.
1115
1116        Behind the scenes, this constraint maintains that:
1117          - sorted is always increasing.
1118          - whatever the values of vars, there exists a permutation that
1119            injects its values into the sorted variables.
1120
1121        For more info, please have a look at:
1122          https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf
1123        """
1124        return _pywrapcp.Solver_SortingConstraint(self, vars, sorted)
1125
1126    def LexicalLess(self, left, right):
1127        r"""
1128        Creates a constraint that enforces that left is lexicographically less
1129        than right.
1130        """
1131        return _pywrapcp.Solver_LexicalLess(self, left, right)
1132
1133    def LexicalLessOrEqual(self, left, right):
1134        r"""
1135        Creates a constraint that enforces that left is lexicographically less
1136        than or equal to right.
1137        """
1138        return _pywrapcp.Solver_LexicalLessOrEqual(self, left, right)
1139
1140    def InversePermutationConstraint(self, left, right):
1141        r"""
1142        Creates a constraint that enforces that 'left' and 'right' both
1143        represent permutations of [0..left.size()-1], and that 'right' is
1144        the inverse permutation of 'left', i.e. for all i in
1145        [0..left.size()-1], right[left[i]] = i.
1146        """
1147        return _pywrapcp.Solver_InversePermutationConstraint(self, left, right)
1148
1149    def NullIntersect(self, first_vars, second_vars):
1150        r"""
1151        Creates a constraint that states that all variables in the first
1152        vector are different from all variables in the second
1153        group. Thus the set of values in the first vector does not
1154        intersect with the set of values in the second vector.
1155        """
1156        return _pywrapcp.Solver_NullIntersect(self, first_vars, second_vars)
1157
1158    def NullIntersectExcept(self, first_vars, second_vars, escape_value):
1159        r"""
1160        Creates a constraint that states that all variables in the first
1161        vector are different from all variables from the second group,
1162        unless they are assigned to the escape value. Thus the set of
1163        values in the first vector minus the escape value does not
1164        intersect with the set of values in the second vector.
1165        """
1166        return _pywrapcp.Solver_NullIntersectExcept(self, first_vars, second_vars, escape_value)
1167
1168    def Circuit(self, nexts):
1169        r"""Force the "nexts" variable to create a complete Hamiltonian path."""
1170        return _pywrapcp.Solver_Circuit(self, nexts)
1171
1172    def SubCircuit(self, nexts):
1173        r"""
1174        Force the "nexts" variable to create a complete Hamiltonian path
1175        for those that do not loop upon themselves.
1176        """
1177        return _pywrapcp.Solver_SubCircuit(self, nexts)
1178
1179    def DelayedPathCumul(self, nexts, active, cumuls, transits):
1180        r"""
1181        Delayed version of the same constraint: propagation on the nexts variables
1182        is delayed until all constraints have propagated.
1183        """
1184        return _pywrapcp.Solver_DelayedPathCumul(self, nexts, active, cumuls, transits)
1185
1186    def PathCumul(self, *args):
1187        r"""
1188        *Overload 1:*
1189        Creates a constraint which accumulates values along a path such that:
1190        cumuls[next[i]] = cumuls[i] + transits[i].
1191        Active variables indicate if the corresponding next variable is active;
1192        this could be useful to model unperformed nodes in a routing problem.
1193
1194        |
1195
1196        *Overload 2:*
1197        Creates a constraint which accumulates values along a path such that:
1198        cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]).
1199        Active variables indicate if the corresponding next variable is active;
1200        this could be useful to model unperformed nodes in a routing problem.
1201        Ownership of transit_evaluator is taken and it must be a repeatable
1202        callback.
1203
1204        |
1205
1206        *Overload 3:*
1207        Creates a constraint which accumulates values along a path such that:
1208        cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i].
1209        Active variables indicate if the corresponding next variable is active;
1210        this could be useful to model unperformed nodes in a routing problem.
1211        Ownership of transit_evaluator is taken and it must be a repeatable
1212        callback.
1213        """
1214        return _pywrapcp.Solver_PathCumul(self, *args)
1215
1216    def AllowedAssignments(self, *args):
1217        r"""
1218        *Overload 1:*
1219        This method creates a constraint where the graph of the relation
1220        between the variables is given in extension. There are 'arity'
1221        variables involved in the relation and the graph is given by a
1222        integer tuple set.
1223
1224        |
1225
1226        *Overload 2:*
1227        Compatibility layer for Python API.
1228        """
1229        return _pywrapcp.Solver_AllowedAssignments(self, *args)
1230
1231    def TransitionConstraint(self, *args):
1232        r"""
1233        *Overload 1:*
1234        This constraint create a finite automaton that will check the
1235        sequence of variables vars. It uses a transition table called
1236        'transition_table'. Each transition is a triple
1237           (current_state, variable_value, new_state).
1238        The initial state is given, and the set of accepted states is decribed
1239        by 'final_states'. These states are hidden inside the constraint.
1240        Only the transitions (i.e. the variables) are visible.
1241
1242        |
1243
1244        *Overload 2:*
1245        This constraint create a finite automaton that will check the
1246        sequence of variables vars. It uses a transition table called
1247        'transition_table'. Each transition is a triple
1248           (current_state, variable_value, new_state).
1249        The initial state is given, and the set of accepted states is decribed
1250        by 'final_states'. These states are hidden inside the constraint.
1251        Only the transitions (i.e. the variables) are visible.
1252        """
1253        return _pywrapcp.Solver_TransitionConstraint(self, *args)
1254
1255    def NonOverlappingBoxesConstraint(self, *args):
1256        r"""
1257        This constraint states that all the boxes must not overlap.
1258        The coordinates of box i are:
1259          (x_vars[i], y_vars[i]),
1260          (x_vars[i], y_vars[i] + y_size[i]),
1261          (x_vars[i] + x_size[i], y_vars[i]),
1262          (x_vars[i] + x_size[i], y_vars[i] + y_size[i]).
1263        The sizes must be non-negative. Boxes with a zero dimension can be
1264        pushed like any box.
1265        """
1266        return _pywrapcp.Solver_NonOverlappingBoxesConstraint(self, *args)
1267
1268    def Pack(self, vars, number_of_bins):
1269        r"""
1270        This constraint packs all variables onto 'number_of_bins'
1271        variables.  For any given variable, a value of 'number_of_bins'
1272        indicates that the variable is not assigned to any bin.
1273        Dimensions, i.e., cumulative constraints on this packing, can be
1274        added directly from the pack class.
1275        """
1276        return _pywrapcp.Solver_Pack(self, vars, number_of_bins)
1277
1278    def FixedDurationIntervalVar(self, *args):
1279        r"""
1280        *Overload 1:*
1281        Creates an interval var with a fixed duration. The duration must
1282        be greater than 0. If optional is true, then the interval can be
1283        performed or unperformed. If optional is false, then the interval
1284        is always performed.
1285
1286        |
1287
1288        *Overload 2:*
1289        Creates a performed interval var with a fixed duration. The duration must
1290        be greater than 0.
1291
1292        |
1293
1294        *Overload 3:*
1295        Creates an interval var with a fixed duration, and performed_variable.
1296        The duration must be greater than 0.
1297        """
1298        return _pywrapcp.Solver_FixedDurationIntervalVar(self, *args)
1299
1300    def FixedInterval(self, start, duration, name):
1301        r"""Creates a fixed and performed interval."""
1302        return _pywrapcp.Solver_FixedInterval(self, start, duration, name)
1303
1304    def IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name):
1305        r"""
1306        Creates an interval var by specifying the bounds on start,
1307        duration, and end.
1308        """
1309        return _pywrapcp.Solver_IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name)
1310
1311    def MirrorInterval(self, interval_var):
1312        r"""
1313        Creates an interval var that is the mirror image of the given one, that
1314        is, the interval var obtained by reversing the axis.
1315        """
1316        return _pywrapcp.Solver_MirrorInterval(self, interval_var)
1317
1318    def FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1319        r"""
1320        Creates an interval var with a fixed duration whose start is
1321        synchronized with the start of another interval, with a given
1322        offset. The performed status is also in sync with the performed
1323        status of the given interval variable.
1324        """
1325        return _pywrapcp.Solver_FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset)
1326
1327    def FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1328        r"""
1329        Creates an interval var with a fixed duration whose start is
1330        synchronized with the end of another interval, with a given
1331        offset. The performed status is also in sync with the performed
1332        status of the given interval variable.
1333        """
1334        return _pywrapcp.Solver_FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset)
1335
1336    def FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1337        r"""
1338        Creates an interval var with a fixed duration whose end is
1339        synchronized with the start of another interval, with a given
1340        offset. The performed status is also in sync with the performed
1341        status of the given interval variable.
1342        """
1343        return _pywrapcp.Solver_FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset)
1344
1345    def FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1346        r"""
1347        Creates an interval var with a fixed duration whose end is
1348        synchronized with the end of another interval, with a given
1349        offset. The performed status is also in sync with the performed
1350        status of the given interval variable.
1351        """
1352        return _pywrapcp.Solver_FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset)
1353
1354    def IntervalRelaxedMin(self, interval_var):
1355        r"""
1356         Creates and returns an interval variable that wraps around the given one,
1357         relaxing the min start and end. Relaxing means making unbounded when
1358         optional. If the variable is non-optional, this method returns
1359         interval_var.
1360
1361         More precisely, such an interval variable behaves as follows:
1362        When the underlying must be performed, the returned interval variable
1363             behaves exactly as the underlying;
1364        When the underlying may or may not be performed, the returned interval
1365             variable behaves like the underlying, except that it is unbounded on
1366             the min side;
1367        When the underlying cannot be performed, the returned interval variable
1368             is of duration 0 and must be performed in an interval unbounded on
1369             both sides.
1370
1371         This is very useful to implement propagators that may only modify
1372         the start max or end max.
1373        """
1374        return _pywrapcp.Solver_IntervalRelaxedMin(self, interval_var)
1375
1376    def IntervalRelaxedMax(self, interval_var):
1377        r"""
1378         Creates and returns an interval variable that wraps around the given one,
1379         relaxing the max start and end. Relaxing means making unbounded when
1380         optional. If the variable is non optional, this method returns
1381         interval_var.
1382
1383         More precisely, such an interval variable behaves as follows:
1384        When the underlying must be performed, the returned interval variable
1385             behaves exactly as the underlying;
1386        When the underlying may or may not be performed, the returned interval
1387             variable behaves like the underlying, except that it is unbounded on
1388             the max side;
1389        When the underlying cannot be performed, the returned interval variable
1390             is of duration 0 and must be performed in an interval unbounded on
1391             both sides.
1392
1393         This is very useful for implementing propagators that may only modify
1394         the start min or end min.
1395        """
1396        return _pywrapcp.Solver_IntervalRelaxedMax(self, interval_var)
1397
1398    def TemporalDisjunction(self, *args):
1399        r"""
1400        *Overload 1:*
1401        This constraint implements a temporal disjunction between two
1402        interval vars t1 and t2. 'alt' indicates which alternative was
1403        chosen (alt == 0 is equivalent to t1 before t2).
1404
1405        |
1406
1407        *Overload 2:*
1408        This constraint implements a temporal disjunction between two
1409        interval vars.
1410        """
1411        return _pywrapcp.Solver_TemporalDisjunction(self, *args)
1412
1413    def DisjunctiveConstraint(self, intervals, name):
1414        r"""
1415        This constraint forces all interval vars into an non-overlapping
1416        sequence. Intervals with zero duration can be scheduled anywhere.
1417        """
1418        return _pywrapcp.Solver_DisjunctiveConstraint(self, intervals, name)
1419
1420    def Cumulative(self, *args):
1421        r"""
1422        *Overload 1:*
1423        This constraint forces that, for any integer t, the sum of the demands
1424        corresponding to an interval containing t does not exceed the given
1425        capacity.
1426
1427        Intervals and demands should be vectors of equal size.
1428
1429        Demands should only contain non-negative values. Zero values are
1430        supported, and the corresponding intervals are filtered out, as they
1431        neither impact nor are impacted by this constraint.
1432
1433        |
1434
1435        *Overload 2:*
1436        This constraint forces that, for any integer t, the sum of the demands
1437        corresponding to an interval containing t does not exceed the given
1438        capacity.
1439
1440        Intervals and demands should be vectors of equal size.
1441
1442        Demands should only contain non-negative values. Zero values are
1443        supported, and the corresponding intervals are filtered out, as they
1444        neither impact nor are impacted by this constraint.
1445
1446        |
1447
1448        *Overload 3:*
1449        This constraint forces that, for any integer t, the sum of the demands
1450        corresponding to an interval containing t does not exceed the given
1451        capacity.
1452
1453        Intervals and demands should be vectors of equal size.
1454
1455        Demands should only contain non-negative values. Zero values are
1456        supported, and the corresponding intervals are filtered out, as they
1457        neither impact nor are impacted by this constraint.
1458
1459        |
1460
1461        *Overload 4:*
1462        This constraint enforces that, for any integer t, the sum of the demands
1463        corresponding to an interval containing t does not exceed the given
1464        capacity.
1465
1466        Intervals and demands should be vectors of equal size.
1467
1468        Demands should only contain non-negative values. Zero values are
1469        supported, and the corresponding intervals are filtered out, as they
1470        neither impact nor are impacted by this constraint.
1471
1472        |
1473
1474        *Overload 5:*
1475        This constraint enforces that, for any integer t, the sum of demands
1476        corresponding to an interval containing t does not exceed the given
1477        capacity.
1478
1479        Intervals and demands should be vectors of equal size.
1480
1481        Demands should be positive.
1482
1483        |
1484
1485        *Overload 6:*
1486        This constraint enforces that, for any integer t, the sum of demands
1487        corresponding to an interval containing t does not exceed the given
1488        capacity.
1489
1490        Intervals and demands should be vectors of equal size.
1491
1492        Demands should be positive.
1493        """
1494        return _pywrapcp.Solver_Cumulative(self, *args)
1495
1496    def Cover(self, vars, target_var):
1497        r"""
1498        This constraint states that the target_var is the convex hull of
1499        the intervals. If none of the interval variables is performed,
1500        then the target var is unperformed too. Also, if the target
1501        variable is unperformed, then all the intervals variables are
1502        unperformed too.
1503        """
1504        return _pywrapcp.Solver_Cover(self, vars, target_var)
1505
1506    def Assignment(self, *args):
1507        r"""
1508        *Overload 1:*
1509        This method creates an empty assignment.
1510
1511        |
1512
1513        *Overload 2:*
1514        This method creates an assignment which is a copy of 'a'.
1515        """
1516        return _pywrapcp.Solver_Assignment(self, *args)
1517
1518    def FirstSolutionCollector(self, *args):
1519        r"""
1520        *Overload 1:*
1521        Collect the first solution of the search.
1522
1523        |
1524
1525        *Overload 2:*
1526        Collect the first solution of the search. The variables will need to
1527        be added later.
1528        """
1529        return _pywrapcp.Solver_FirstSolutionCollector(self, *args)
1530
1531    def LastSolutionCollector(self, *args):
1532        r"""
1533        *Overload 1:*
1534        Collect the last solution of the search.
1535
1536        |
1537
1538        *Overload 2:*
1539        Collect the last solution of the search. The variables will need to
1540        be added later.
1541        """
1542        return _pywrapcp.Solver_LastSolutionCollector(self, *args)
1543
1544    def BestValueSolutionCollector(self, *args):
1545        r"""
1546        *Overload 1:*
1547        Collect the solution corresponding to the optimal value of the objective
1548        of 'assignment'; if 'assignment' does not have an objective no solution is
1549        collected. This collector only collects one solution corresponding to the
1550        best objective value (the first one found).
1551
1552        |
1553
1554        *Overload 2:*
1555        Collect the solution corresponding to the optimal value of the
1556        objective of the internal assignment; if this assignment does not have an
1557        objective no solution is collected. This collector only collects one
1558        solution corresponding to the best objective value (the first one found).
1559        The variables and objective(s) will need to be added later.
1560        """
1561        return _pywrapcp.Solver_BestValueSolutionCollector(self, *args)
1562
1563    def AllSolutionCollector(self, *args):
1564        r"""
1565        *Overload 1:*
1566        Collect all solutions of the search.
1567
1568        |
1569
1570        *Overload 2:*
1571        Collect all solutions of the search. The variables will need to
1572        be added later.
1573        """
1574        return _pywrapcp.Solver_AllSolutionCollector(self, *args)
1575
1576    def Minimize(self, v, step):
1577        r"""Creates a minimization objective."""
1578        return _pywrapcp.Solver_Minimize(self, v, step)
1579
1580    def Maximize(self, v, step):
1581        r"""Creates a maximization objective."""
1582        return _pywrapcp.Solver_Maximize(self, v, step)
1583
1584    def Optimize(self, maximize, v, step):
1585        r"""Creates a objective with a given sense (true = maximization)."""
1586        return _pywrapcp.Solver_Optimize(self, maximize, v, step)
1587
1588    def WeightedMinimize(self, *args):
1589        r"""
1590        *Overload 1:*
1591        Creates a minimization weighted objective. The actual objective is
1592        scalar_prod(sub_objectives, weights).
1593
1594        |
1595
1596        *Overload 2:*
1597        Creates a minimization weighted objective. The actual objective is
1598        scalar_prod(sub_objectives, weights).
1599        """
1600        return _pywrapcp.Solver_WeightedMinimize(self, *args)
1601
1602    def WeightedMaximize(self, *args):
1603        r"""
1604        *Overload 1:*
1605        Creates a maximization weigthed objective.
1606
1607        |
1608
1609        *Overload 2:*
1610        Creates a maximization weigthed objective.
1611        """
1612        return _pywrapcp.Solver_WeightedMaximize(self, *args)
1613
1614    def WeightedOptimize(self, *args):
1615        r"""
1616        *Overload 1:*
1617        Creates a weighted objective with a given sense (true = maximization).
1618
1619        |
1620
1621        *Overload 2:*
1622        Creates a weighted objective with a given sense (true = maximization).
1623        """
1624        return _pywrapcp.Solver_WeightedOptimize(self, *args)
1625
1626    def TabuSearch(self, maximize, objective, step, vars, keep_tenure, forbid_tenure, tabu_factor):
1627        r"""
1628        MetaHeuristics which try to get the search out of local optima.
1629        Creates a Tabu Search monitor.
1630        In the context of local search the behavior is similar to MakeOptimize(),
1631        creating an objective in a given sense. The behavior differs once a local
1632        optimum is reached: thereafter solutions which degrade the value of the
1633        objective are allowed if they are not "tabu". A solution is "tabu" if it
1634        doesn't respect the following rules:
1635        - improving the best solution found so far
1636        - variables in the "keep" list must keep their value, variables in the
1637        "forbid" list must not take the value they have in the list.
1638        Variables with new values enter the tabu lists after each new solution
1639        found and leave the lists after a given number of iterations (called
1640        tenure). Only the variables passed to the method can enter the lists.
1641        The tabu criterion is softened by the tabu factor which gives the number
1642        of "tabu" violations which is tolerated; a factor of 1 means no violations
1643        allowed; a factor of 0 means all violations are allowed.
1644        """
1645        return _pywrapcp.Solver_TabuSearch(self, maximize, objective, step, vars, keep_tenure, forbid_tenure, tabu_factor)
1646
1647    def SimulatedAnnealing(self, maximize, v, step, initial_temperature):
1648        r"""Creates a Simulated Annealing monitor."""
1649        return _pywrapcp.Solver_SimulatedAnnealing(self, maximize, v, step, initial_temperature)
1650
1651    def LubyRestart(self, scale_factor):
1652        r"""
1653        This search monitor will restart the search periodically.
1654        At the iteration n, it will restart after scale_factor * Luby(n) failures
1655        where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).
1656        """
1657        return _pywrapcp.Solver_LubyRestart(self, scale_factor)
1658
1659    def ConstantRestart(self, frequency):
1660        r"""
1661        This search monitor will restart the search periodically after 'frequency'
1662        failures.
1663        """
1664        return _pywrapcp.Solver_ConstantRestart(self, frequency)
1665
1666    def TimeLimit(self, *args):
1667        r"""Creates a search limit that constrains the running time."""
1668        return _pywrapcp.Solver_TimeLimit(self, *args)
1669
1670    def BranchesLimit(self, branches):
1671        r"""
1672        Creates a search limit that constrains the number of branches
1673        explored in the search tree.
1674        """
1675        return _pywrapcp.Solver_BranchesLimit(self, branches)
1676
1677    def FailuresLimit(self, failures):
1678        r"""
1679        Creates a search limit that constrains the number of failures
1680        that can happen when exploring the search tree.
1681        """
1682        return _pywrapcp.Solver_FailuresLimit(self, failures)
1683
1684    def SolutionsLimit(self, solutions):
1685        r"""
1686        Creates a search limit that constrains the number of solutions found
1687        during the search.
1688        """
1689        return _pywrapcp.Solver_SolutionsLimit(self, solutions)
1690
1691    def Limit(self, *args):
1692        r"""
1693        *Overload 1:*
1694        Limits the search with the 'time', 'branches', 'failures' and
1695        'solutions' limits. 'smart_time_check' reduces the calls to the wall
1696
1697        |
1698
1699        *Overload 2:*
1700        Creates a search limit from its protobuf description
1701
1702        |
1703
1704        *Overload 3:*
1705        Creates a search limit that is reached when either of the underlying limit
1706        is reached. That is, the returned limit is more stringent than both
1707        argument limits.
1708        """
1709        return _pywrapcp.Solver_Limit(self, *args)
1710
1711    def CustomLimit(self, limiter):
1712        r"""
1713        Callback-based search limit. Search stops when limiter returns true; if
1714        this happens at a leaf the corresponding solution will be rejected.
1715        """
1716        return _pywrapcp.Solver_CustomLimit(self, limiter)
1717
1718    def SearchLog(self, *args):
1719        r"""
1720        *Overload 1:*
1721         The SearchMonitors below will display a periodic search log
1722         on LOG(INFO) every branch_period branches explored.
1723
1724        |
1725
1726        *Overload 2:*
1727         At each solution, this monitor also display the var value.
1728
1729        |
1730
1731        *Overload 3:*
1732         At each solution, this monitor will also display result of
1733        ``display_callback``.
1734
1735        |
1736
1737        *Overload 4:*
1738         At each solution, this monitor will display the 'var' value and the
1739         result of ``display_callback``.
1740
1741        |
1742
1743        *Overload 5:*
1744         At each solution, this monitor will display the 'vars' values and the
1745         result of ``display_callback``.
1746
1747        |
1748
1749        *Overload 6:*
1750         OptimizeVar Search Logs
1751         At each solution, this monitor will also display the 'opt_var' value.
1752
1753        |
1754
1755        *Overload 7:*
1756         Creates a search monitor that will also print the result of the
1757         display callback.
1758        """
1759        return _pywrapcp.Solver_SearchLog(self, *args)
1760
1761    def SearchTrace(self, prefix):
1762        r"""
1763        Creates a search monitor that will trace precisely the behavior of the
1764        search. Use this only for low level debugging.
1765        """
1766        return _pywrapcp.Solver_SearchTrace(self, prefix)
1767
1768    def PrintModelVisitor(self):
1769        r"""Prints the model."""
1770        return _pywrapcp.Solver_PrintModelVisitor(self)
1771
1772    def StatisticsModelVisitor(self):
1773        r"""Displays some nice statistics on the model."""
1774        return _pywrapcp.Solver_StatisticsModelVisitor(self)
1775
1776    def AssignVariableValue(self, var, val):
1777        r"""Decisions."""
1778        return _pywrapcp.Solver_AssignVariableValue(self, var, val)
1779
1780    def VariableLessOrEqualValue(self, var, value):
1781        return _pywrapcp.Solver_VariableLessOrEqualValue(self, var, value)
1782
1783    def VariableGreaterOrEqualValue(self, var, value):
1784        return _pywrapcp.Solver_VariableGreaterOrEqualValue(self, var, value)
1785
1786    def SplitVariableDomain(self, var, val, start_with_lower_half):
1787        return _pywrapcp.Solver_SplitVariableDomain(self, var, val, start_with_lower_half)
1788
1789    def AssignVariableValueOrFail(self, var, value):
1790        return _pywrapcp.Solver_AssignVariableValueOrFail(self, var, value)
1791
1792    def AssignVariablesValues(self, vars, values):
1793        return _pywrapcp.Solver_AssignVariablesValues(self, vars, values)
1794
1795    def FailDecision(self):
1796        return _pywrapcp.Solver_FailDecision(self)
1797
1798    def Decision(self, apply, refute):
1799        return _pywrapcp.Solver_Decision(self, apply, refute)
1800
1801    def Compose(self, dbs):
1802        return _pywrapcp.Solver_Compose(self, dbs)
1803
1804    def Try(self, dbs):
1805        return _pywrapcp.Solver_Try(self, dbs)
1806
1807    def DefaultPhase(self, *args):
1808        return _pywrapcp.Solver_DefaultPhase(self, *args)
1809
1810    def ScheduleOrPostpone(self, var, est, marker):
1811        r"""
1812        Returns a decision that tries to schedule a task at a given time.
1813        On the Apply branch, it will set that interval var as performed and set
1814        its start to 'est'. On the Refute branch, it will just update the
1815        'marker' to 'est' + 1. This decision is used in the
1816        INTERVAL_SET_TIMES_FORWARD strategy.
1817        """
1818        return _pywrapcp.Solver_ScheduleOrPostpone(self, var, est, marker)
1819
1820    def ScheduleOrExpedite(self, var, est, marker):
1821        r"""
1822        Returns a decision that tries to schedule a task at a given time.
1823        On the Apply branch, it will set that interval var as performed and set
1824        its end to 'est'. On the Refute branch, it will just update the
1825        'marker' to 'est' - 1. This decision is used in the
1826        INTERVAL_SET_TIMES_BACKWARD strategy.
1827        """
1828        return _pywrapcp.Solver_ScheduleOrExpedite(self, var, est, marker)
1829
1830    def RankFirstInterval(self, sequence, index):
1831        r"""
1832        Returns a decision that tries to rank first the ith interval var
1833        in the sequence variable.
1834        """
1835        return _pywrapcp.Solver_RankFirstInterval(self, sequence, index)
1836
1837    def RankLastInterval(self, sequence, index):
1838        r"""
1839        Returns a decision that tries to rank last the ith interval var
1840        in the sequence variable.
1841        """
1842        return _pywrapcp.Solver_RankLastInterval(self, sequence, index)
1843
1844    def Phase(self, *args):
1845        r"""
1846        *Overload 1:*
1847        Phases on IntVar arrays.
1848        for all other functions that have several homonyms in this .h).
1849
1850        |
1851
1852        *Overload 2:*
1853        Scheduling phases.
1854        """
1855        return _pywrapcp.Solver_Phase(self, *args)
1856
1857    def DecisionBuilderFromAssignment(self, assignment, db, vars):
1858        r"""
1859        Returns a decision builder for which the left-most leaf corresponds
1860        to assignment, the rest of the tree being explored using 'db'.
1861        """
1862        return _pywrapcp.Solver_DecisionBuilderFromAssignment(self, assignment, db, vars)
1863
1864    def ConstraintAdder(self, ct):
1865        r"""
1866        Returns a decision builder that will add the given constraint to
1867        the model.
1868        """
1869        return _pywrapcp.Solver_ConstraintAdder(self, ct)
1870
1871    def SolveOnce(self, db, monitors):
1872        return _pywrapcp.Solver_SolveOnce(self, db, monitors)
1873
1874    def NestedOptimize(self, *args):
1875        r"""
1876        NestedOptimize will collapse a search tree described by a
1877        decision builder 'db' and a set of monitors and wrap it into a
1878        single point. If there are no solutions to this nested tree, then
1879        NestedOptimize will fail. If there are solutions, it will find
1880        the best as described by the mandatory objective in the solution
1881        as well as the optimization direction, instantiate all variables
1882        to this solution, and return nullptr.
1883        """
1884        return _pywrapcp.Solver_NestedOptimize(self, *args)
1885
1886    def RestoreAssignment(self, assignment):
1887        r"""
1888        Returns a DecisionBuilder which restores an Assignment
1889        (calls void Assignment::Restore())
1890        """
1891        return _pywrapcp.Solver_RestoreAssignment(self, assignment)
1892
1893    def StoreAssignment(self, assignment):
1894        r"""
1895        Returns a DecisionBuilder which stores an Assignment
1896        (calls void Assignment::Store())
1897        """
1898        return _pywrapcp.Solver_StoreAssignment(self, assignment)
1899
1900    def Operator(self, *args):
1901        r"""Local Search Operators."""
1902        return _pywrapcp.Solver_Operator(self, *args)
1903
1904    def RandomLnsOperator(self, *args):
1905        r"""
1906        Creates a large neighborhood search operator which creates fragments (set
1907        of relaxed variables) with up to number_of_variables random variables
1908        (sampling with replacement is performed meaning that at most
1909        number_of_variables variables are selected). Warning: this operator will
1910        always return neighbors; using it without a search limit will result in a
1911        non-ending search.
1912        Optionally a random seed can be specified.
1913        """
1914        return _pywrapcp.Solver_RandomLnsOperator(self, *args)
1915
1916    def MoveTowardTargetOperator(self, *args):
1917        r"""
1918        *Overload 1:*
1919        Creates a local search operator that tries to move the assignment of some
1920        variables toward a target. The target is given as an Assignment. This
1921        operator generates neighbors in which the only difference compared to the
1922        current state is that one variable that belongs to the target assignment
1923        is set to its target value.
1924
1925        |
1926
1927        *Overload 2:*
1928        Creates a local search operator that tries to move the assignment of some
1929        variables toward a target. The target is given either as two vectors: a
1930        vector of variables and a vector of associated target values. The two
1931        vectors should be of the same length. This operator generates neighbors in
1932        which the only difference compared to the current state is that one
1933        variable that belongs to the given vector is set to its target value.
1934        """
1935        return _pywrapcp.Solver_MoveTowardTargetOperator(self, *args)
1936
1937    def ConcatenateOperators(self, *args):
1938        r"""
1939        Creates a local search operator which concatenates a vector of operators.
1940        Each operator from the vector is called sequentially. By default, when a
1941        neighbor is found the neighborhood exploration restarts from the last
1942        active operator (the one which produced the neighbor).
1943        This can be overridden by setting restart to true to force the exploration
1944        to start from the first operator in the vector.
1945
1946        The default behavior can also be overridden using an evaluation callback
1947        to set the order in which the operators are explored (the callback is
1948        called in LocalSearchOperator::Start()). The first argument of the
1949        callback is the index of the operator which produced the last move, the
1950        second argument is the index of the operator to be evaluated. Ownership of
1951        the callback is taken by ConcatenateOperators.
1952
1953        Example:
1954
1955         const int kPriorities = {10, 100, 10, 0};
1956         int64_t Evaluate(int active_operator, int current_operator) {
1957           return kPriorities[current_operator];
1958         }
1959
1960         LocalSearchOperator* concat =
1961           solver.ConcatenateOperators(operators,
1962                                       NewPermanentCallback(&Evaluate));
1963
1964        The elements of the vector operators will be sorted by increasing priority
1965        and explored in that order (tie-breaks are handled by keeping the relative
1966        operator order in the vector). This would result in the following order:
1967        operators[3], operators[0], operators[2], operators[1].
1968        """
1969        return _pywrapcp.Solver_ConcatenateOperators(self, *args)
1970
1971    def RandomConcatenateOperators(self, *args):
1972        r"""
1973        *Overload 1:*
1974        Randomized version of local search concatenator; calls a random operator
1975        at each call to MakeNextNeighbor().
1976
1977        |
1978
1979        *Overload 2:*
1980        Randomized version of local search concatenator; calls a random operator
1981        at each call to MakeNextNeighbor(). The provided seed is used to
1982        initialize the random number generator.
1983        """
1984        return _pywrapcp.Solver_RandomConcatenateOperators(self, *args)
1985
1986    def NeighborhoodLimit(self, op, limit):
1987        r"""
1988        Creates a local search operator that wraps another local search
1989        operator and limits the number of neighbors explored (i.e., calls
1990        to MakeNextNeighbor from the current solution (between two calls
1991        to Start()). When this limit is reached, MakeNextNeighbor()
1992        returns false. The counter is cleared when Start() is called.
1993        """
1994        return _pywrapcp.Solver_NeighborhoodLimit(self, op, limit)
1995
1996    def LocalSearchPhase(self, *args):
1997        r"""
1998        *Overload 1:*
1999        Local Search decision builders factories.
2000        Local search is used to improve a given solution. This initial solution
2001        can be specified either by an Assignment or by a DecisionBulder, and the
2002        corresponding variables, the initial solution being the first solution
2003        found by the DecisionBuilder.
2004        The LocalSearchPhaseParameters parameter holds the actual definition of
2005        the local search phase:
2006        - a local search operator used to explore the neighborhood of the current
2007          solution,
2008        - a decision builder to instantiate unbound variables once a neighbor has
2009          been defined; in the case of LNS-based operators instantiates fragment
2010          variables; search monitors can be added to this sub-search by wrapping
2011          the decision builder with MakeSolveOnce.
2012        - a search limit specifying how long local search looks for neighbors
2013          before accepting one; the last neighbor is always taken and in the case
2014          of a greedy search, this corresponds to the best local neighbor;
2015          first-accept (which is the default behavior) can be modeled using a
2016          solution found limit of 1,
2017        - a vector of local search filters used to speed up the search by pruning
2018          unfeasible neighbors.
2019        Metaheuristics can be added by defining specialized search monitors;
2020        currently down/up-hill climbing is available through OptimizeVar, as well
2021        as Guided Local Search, Tabu Search and Simulated Annealing.
2022
2023        |
2024
2025        *Overload 2:*
2026        Variant with a sub_decison_builder specific to the first solution.
2027        """
2028        return _pywrapcp.Solver_LocalSearchPhase(self, *args)
2029
2030    def LocalSearchPhaseParameters(self, *args):
2031        r"""Local Search Phase Parameters"""
2032        return _pywrapcp.Solver_LocalSearchPhaseParameters(self, *args)
2033
2034    def TopProgressPercent(self):
2035        r"""
2036        Returns a percentage representing the propress of the search before
2037        reaching the limits of the top-level search (can be called from a nested
2038        solve).
2039        """
2040        return _pywrapcp.Solver_TopProgressPercent(self)
2041
2042    def SearchDepth(self):
2043        r"""
2044        Gets the search depth of the current active search. Returns -1 if
2045        there is no active search opened.
2046        """
2047        return _pywrapcp.Solver_SearchDepth(self)
2048
2049    def SearchLeftDepth(self):
2050        r"""
2051        Gets the search left depth of the current active search. Returns -1 if
2052        there is no active search opened.
2053        """
2054        return _pywrapcp.Solver_SearchLeftDepth(self)
2055
2056    def SolveDepth(self):
2057        r"""
2058        Gets the number of nested searches. It returns 0 outside search,
2059        1 during the top level search, 2 or more in case of nested searches.
2060        """
2061        return _pywrapcp.Solver_SolveDepth(self)
2062
2063    def Rand64(self, size):
2064        r"""Returns a random value between 0 and 'size' - 1;"""
2065        return _pywrapcp.Solver_Rand64(self, size)
2066
2067    def Rand32(self, size):
2068        r"""Returns a random value between 0 and 'size' - 1;"""
2069        return _pywrapcp.Solver_Rand32(self, size)
2070
2071    def ReSeed(self, seed):
2072        r"""Reseed the solver random generator."""
2073        return _pywrapcp.Solver_ReSeed(self, seed)
2074
2075    def LocalSearchProfile(self):
2076        r"""Returns local search profiling information in a human readable format."""
2077        return _pywrapcp.Solver_LocalSearchProfile(self)
2078
2079    def Constraints(self):
2080        r"""
2081        Counts the number of constraints that have been added
2082        to the solver before the search.
2083        """
2084        return _pywrapcp.Solver_Constraints(self)
2085
2086    def Accept(self, visitor):
2087        r"""Accepts the given model visitor."""
2088        return _pywrapcp.Solver_Accept(self, visitor)
2089
2090    def FinishCurrentSearch(self):
2091        r"""Tells the solver to kill or restart the current search."""
2092        return _pywrapcp.Solver_FinishCurrentSearch(self)
2093
2094    def RestartCurrentSearch(self):
2095        return _pywrapcp.Solver_RestartCurrentSearch(self)
2096
2097    def ShouldFail(self):
2098        r"""
2099        These methods are only useful for the SWIG wrappers, which need a way
2100        to externally cause the Solver to fail.
2101        """
2102        return _pywrapcp.Solver_ShouldFail(self)
2103
2104    def __str__(self):
2105        return _pywrapcp.Solver___str__(self)
2106
2107    def Add(self, ct):
2108      if isinstance(ct, PyConstraint):
2109        self.__python_constraints.append(ct)
2110      self.AddConstraint(ct)
2111
2112
2113    def TreeNoCycle(self, nexts, active, callback=0):
2114        return _pywrapcp.Solver_TreeNoCycle(self, nexts, active, callback)
2115
2116    def SearchLogWithCallback(self, period, callback):
2117        return _pywrapcp.Solver_SearchLogWithCallback(self, period, callback)
2118
2119    def ElementFunction(self, values, index):
2120        return _pywrapcp.Solver_ElementFunction(self, values, index)
2121
2122    def VarEvalValStrPhase(self, vars, var_evaluator, val_str):
2123        return _pywrapcp.Solver_VarEvalValStrPhase(self, vars, var_evaluator, val_str)
2124
2125    def VarStrValEvalPhase(self, vars, var_str, val_eval):
2126        return _pywrapcp.Solver_VarStrValEvalPhase(self, vars, var_str, val_eval)
2127
2128    def VarEvalValEvalPhase(self, vars, var_eval, val_eval):
2129        return _pywrapcp.Solver_VarEvalValEvalPhase(self, vars, var_eval, val_eval)
2130
2131    def VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker):
2132        return _pywrapcp.Solver_VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker)
2133
2134    def VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker):
2135        return _pywrapcp.Solver_VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker)
2136
2137    def EvalEvalStrPhase(self, vars, evaluator, str):
2138        return _pywrapcp.Solver_EvalEvalStrPhase(self, vars, evaluator, str)
2139
2140    def EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str):
2141        return _pywrapcp.Solver_EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str)
2142
2143    def GuidedLocalSearch(self, maximize, objective, objective_function, step, vars, penalty_factor):
2144        return _pywrapcp.Solver_GuidedLocalSearch(self, maximize, objective, objective_function, step, vars, penalty_factor)
2145
2146    def SumObjectiveFilter(self, vars, values, filter_enum):
2147        return _pywrapcp.Solver_SumObjectiveFilter(self, vars, values, filter_enum)
2148
2149# Register Solver in _pywrapcp:
2150_pywrapcp.Solver_swigregister(Solver)
2151class BaseObject(object):
2152    r"""
2153    A BaseObject is the root of all reversibly allocated objects.
2154    A DebugString method and the associated << operator are implemented
2155    as a convenience.
2156    """
2157
2158    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2159
2160    def __init__(self):
2161        if self.__class__ == BaseObject:
2162            _self = None
2163        else:
2164            _self = self
2165        _pywrapcp.BaseObject_swiginit(self, _pywrapcp.new_BaseObject(_self, ))
2166    __swig_destroy__ = _pywrapcp.delete_BaseObject
2167
2168    def DebugString(self):
2169        return _pywrapcp.BaseObject_DebugString(self)
2170
2171    def __str__(self):
2172        return _pywrapcp.BaseObject___str__(self)
2173
2174    def __repr__(self):
2175        return _pywrapcp.BaseObject___repr__(self)
2176    def __disown__(self):
2177        self.this.disown()
2178        _pywrapcp.disown_BaseObject(self)
2179        return weakref.proxy(self)
2180
2181# Register BaseObject in _pywrapcp:
2182_pywrapcp.BaseObject_swigregister(BaseObject)
2183class PropagationBaseObject(BaseObject):
2184    r"""
2185    NOLINT
2186    The PropagationBaseObject is a subclass of BaseObject that is also
2187    friend to the Solver class. It allows accessing methods useful when
2188    writing new constraints or new expressions.
2189    """
2190
2191    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2192    __repr__ = _swig_repr
2193
2194    def __init__(self, s):
2195        if self.__class__ == PropagationBaseObject:
2196            _self = None
2197        else:
2198            _self = self
2199        _pywrapcp.PropagationBaseObject_swiginit(self, _pywrapcp.new_PropagationBaseObject(_self, s))
2200    __swig_destroy__ = _pywrapcp.delete_PropagationBaseObject
2201
2202    def DebugString(self):
2203        return _pywrapcp.PropagationBaseObject_DebugString(self)
2204
2205    def solver(self):
2206        return _pywrapcp.PropagationBaseObject_solver(self)
2207
2208    def Name(self):
2209        r"""Object naming."""
2210        return _pywrapcp.PropagationBaseObject_Name(self)
2211    def __disown__(self):
2212        self.this.disown()
2213        _pywrapcp.disown_PropagationBaseObject(self)
2214        return weakref.proxy(self)
2215
2216# Register PropagationBaseObject in _pywrapcp:
2217_pywrapcp.PropagationBaseObject_swigregister(PropagationBaseObject)
2218class Decision(BaseObject):
2219    r"""
2220    A Decision represents a choice point in the search tree. The two main
2221    methods are Apply() to go left, or Refute() to go right.
2222    """
2223
2224    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2225
2226    def __init__(self):
2227        if self.__class__ == Decision:
2228            _self = None
2229        else:
2230            _self = self
2231        _pywrapcp.Decision_swiginit(self, _pywrapcp.new_Decision(_self, ))
2232    __swig_destroy__ = _pywrapcp.delete_Decision
2233
2234    def ApplyWrapper(self, s):
2235        r"""Apply will be called first when the decision is executed."""
2236        return _pywrapcp.Decision_ApplyWrapper(self, s)
2237
2238    def RefuteWrapper(self, s):
2239        r"""Refute will be called after a backtrack."""
2240        return _pywrapcp.Decision_RefuteWrapper(self, s)
2241
2242    def DebugString(self):
2243        return _pywrapcp.Decision_DebugString(self)
2244
2245    def __repr__(self):
2246        return _pywrapcp.Decision___repr__(self)
2247
2248    def __str__(self):
2249        return _pywrapcp.Decision___str__(self)
2250    def __disown__(self):
2251        self.this.disown()
2252        _pywrapcp.disown_Decision(self)
2253        return weakref.proxy(self)
2254
2255# Register Decision in _pywrapcp:
2256_pywrapcp.Decision_swigregister(Decision)
2257class DecisionBuilder(BaseObject):
2258    r"""
2259    A DecisionBuilder is responsible for creating the search tree. The
2260    important method is Next(), which returns the next decision to execute.
2261    """
2262
2263    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2264
2265    def __init__(self):
2266        if self.__class__ == DecisionBuilder:
2267            _self = None
2268        else:
2269            _self = self
2270        _pywrapcp.DecisionBuilder_swiginit(self, _pywrapcp.new_DecisionBuilder(_self, ))
2271    __swig_destroy__ = _pywrapcp.delete_DecisionBuilder
2272
2273    def NextWrapper(self, s):
2274        r"""
2275        This is the main method of the decision builder class. It must
2276        return a decision (an instance of the class Decision). If it
2277        returns nullptr, this means that the decision builder has finished
2278        its work.
2279        """
2280        return _pywrapcp.DecisionBuilder_NextWrapper(self, s)
2281
2282    def DebugString(self):
2283        return _pywrapcp.DecisionBuilder_DebugString(self)
2284
2285    def __repr__(self):
2286        return _pywrapcp.DecisionBuilder___repr__(self)
2287
2288    def __str__(self):
2289        return _pywrapcp.DecisionBuilder___str__(self)
2290    def __disown__(self):
2291        self.this.disown()
2292        _pywrapcp.disown_DecisionBuilder(self)
2293        return weakref.proxy(self)
2294
2295# Register DecisionBuilder in _pywrapcp:
2296_pywrapcp.DecisionBuilder_swigregister(DecisionBuilder)
2297class Demon(BaseObject):
2298    r"""
2299    A Demon is the base element of a propagation queue. It is the main
2300      object responsible for implementing the actual propagation
2301      of the constraint and pruning the inconsistent values in the domains
2302      of the variables. The main concept is that demons are listeners that are
2303      attached to the variables and listen to their modifications.
2304    There are two methods:
2305     - Run() is the actual method called when the demon is processed.
2306     - priority() returns its priority. Standard priorities are slow, normal
2307       or fast. "immediate" is reserved for variables and is treated separately.
2308    """
2309
2310    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2311    __repr__ = _swig_repr
2312
2313    def __init__(self):
2314        r"""
2315        This indicates the priority of a demon. Immediate demons are treated
2316        separately and corresponds to variables.
2317        """
2318        if self.__class__ == Demon:
2319            _self = None
2320        else:
2321            _self = self
2322        _pywrapcp.Demon_swiginit(self, _pywrapcp.new_Demon(_self, ))
2323    __swig_destroy__ = _pywrapcp.delete_Demon
2324
2325    def RunWrapper(self, s):
2326        r"""This is the main callback of the demon."""
2327        return _pywrapcp.Demon_RunWrapper(self, s)
2328
2329    def Priority(self):
2330        r"""
2331        This method returns the priority of the demon. Usually a demon is
2332        fast, slow or normal. Immediate demons are reserved for internal
2333        use to maintain variables.
2334        """
2335        return _pywrapcp.Demon_Priority(self)
2336
2337    def DebugString(self):
2338        return _pywrapcp.Demon_DebugString(self)
2339
2340    def Inhibit(self, s):
2341        r"""
2342        This method inhibits the demon in the search tree below the
2343        current position.
2344        """
2345        return _pywrapcp.Demon_Inhibit(self, s)
2346
2347    def Desinhibit(self, s):
2348        r"""This method un-inhibits the demon that was previously inhibited."""
2349        return _pywrapcp.Demon_Desinhibit(self, s)
2350    def __disown__(self):
2351        self.this.disown()
2352        _pywrapcp.disown_Demon(self)
2353        return weakref.proxy(self)
2354
2355# Register Demon in _pywrapcp:
2356_pywrapcp.Demon_swigregister(Demon)
2357class Constraint(PropagationBaseObject):
2358    r"""
2359    A constraint is the main modeling object. It provides two methods:
2360      - Post() is responsible for creating the demons and attaching them to
2361        immediate demons().
2362      - InitialPropagate() is called once just after Post and performs
2363        the initial propagation. The subsequent propagations will be performed
2364        by the demons Posted during the post() method.
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, solver):
2370        if self.__class__ == Constraint:
2371            _self = None
2372        else:
2373            _self = self
2374        _pywrapcp.Constraint_swiginit(self, _pywrapcp.new_Constraint(_self, solver))
2375    __swig_destroy__ = _pywrapcp.delete_Constraint
2376
2377    def Post(self):
2378        r"""
2379        This method is called when the constraint is processed by the
2380        solver. Its main usage is to attach demons to variables.
2381        """
2382        return _pywrapcp.Constraint_Post(self)
2383
2384    def InitialPropagateWrapper(self):
2385        r"""
2386        This method performs the initial propagation of the
2387        constraint. It is called just after the post.
2388        """
2389        return _pywrapcp.Constraint_InitialPropagateWrapper(self)
2390
2391    def DebugString(self):
2392        return _pywrapcp.Constraint_DebugString(self)
2393
2394    def Var(self):
2395        r"""
2396        Creates a Boolean variable representing the status of the constraint
2397        (false = constraint is violated, true = constraint is satisfied). It
2398        returns nullptr if the constraint does not support this API.
2399        """
2400        return _pywrapcp.Constraint_Var(self)
2401
2402    def __repr__(self):
2403        return _pywrapcp.Constraint___repr__(self)
2404
2405    def __str__(self):
2406        return _pywrapcp.Constraint___str__(self)
2407
2408    def __add__(self, *args):
2409        return _pywrapcp.Constraint___add__(self, *args)
2410
2411    def __radd__(self, v):
2412        return _pywrapcp.Constraint___radd__(self, v)
2413
2414    def __sub__(self, *args):
2415        return _pywrapcp.Constraint___sub__(self, *args)
2416
2417    def __rsub__(self, v):
2418        return _pywrapcp.Constraint___rsub__(self, v)
2419
2420    def __mul__(self, *args):
2421        return _pywrapcp.Constraint___mul__(self, *args)
2422
2423    def __rmul__(self, v):
2424        return _pywrapcp.Constraint___rmul__(self, v)
2425
2426    def __floordiv__(self, v):
2427        return _pywrapcp.Constraint___floordiv__(self, v)
2428
2429    def __neg__(self):
2430        return _pywrapcp.Constraint___neg__(self)
2431
2432    def __abs__(self):
2433        return _pywrapcp.Constraint___abs__(self)
2434
2435    def Square(self):
2436        return _pywrapcp.Constraint_Square(self)
2437
2438    def __eq__(self, *args):
2439        return _pywrapcp.Constraint___eq__(self, *args)
2440
2441    def __ne__(self, *args):
2442        return _pywrapcp.Constraint___ne__(self, *args)
2443
2444    def __ge__(self, *args):
2445        return _pywrapcp.Constraint___ge__(self, *args)
2446
2447    def __gt__(self, *args):
2448        return _pywrapcp.Constraint___gt__(self, *args)
2449
2450    def __le__(self, *args):
2451        return _pywrapcp.Constraint___le__(self, *args)
2452
2453    def __lt__(self, *args):
2454        return _pywrapcp.Constraint___lt__(self, *args)
2455
2456    def MapTo(self, vars):
2457        return _pywrapcp.Constraint_MapTo(self, vars)
2458
2459    def IndexOf(self, *args):
2460        return _pywrapcp.Constraint_IndexOf(self, *args)
2461    def __disown__(self):
2462        self.this.disown()
2463        _pywrapcp.disown_Constraint(self)
2464        return weakref.proxy(self)
2465
2466# Register Constraint in _pywrapcp:
2467_pywrapcp.Constraint_swigregister(Constraint)
2468class SearchMonitor(BaseObject):
2469    r"""A search monitor is a simple set of callbacks to monitor all search events"""
2470
2471    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2472    kNoProgress = _pywrapcp.SearchMonitor_kNoProgress
2473
2474    def __init__(self, s):
2475        if self.__class__ == SearchMonitor:
2476            _self = None
2477        else:
2478            _self = self
2479        _pywrapcp.SearchMonitor_swiginit(self, _pywrapcp.new_SearchMonitor(_self, s))
2480    __swig_destroy__ = _pywrapcp.delete_SearchMonitor
2481
2482    def EnterSearch(self):
2483        r"""Beginning of the search."""
2484        return _pywrapcp.SearchMonitor_EnterSearch(self)
2485
2486    def RestartSearch(self):
2487        r"""Restart the search."""
2488        return _pywrapcp.SearchMonitor_RestartSearch(self)
2489
2490    def ExitSearch(self):
2491        r"""End of the search."""
2492        return _pywrapcp.SearchMonitor_ExitSearch(self)
2493
2494    def BeginNextDecision(self, b):
2495        r"""Before calling DecisionBuilder::Next."""
2496        return _pywrapcp.SearchMonitor_BeginNextDecision(self, b)
2497
2498    def EndNextDecision(self, b, d):
2499        r"""After calling DecisionBuilder::Next, along with the returned decision."""
2500        return _pywrapcp.SearchMonitor_EndNextDecision(self, b, d)
2501
2502    def ApplyDecision(self, d):
2503        r"""Before applying the decision."""
2504        return _pywrapcp.SearchMonitor_ApplyDecision(self, d)
2505
2506    def RefuteDecision(self, d):
2507        r"""Before refuting the decision."""
2508        return _pywrapcp.SearchMonitor_RefuteDecision(self, d)
2509
2510    def AfterDecision(self, d, apply):
2511        r"""
2512        Just after refuting or applying the decision, apply is true after Apply.
2513        This is called only if the Apply() or Refute() methods have not failed.
2514        """
2515        return _pywrapcp.SearchMonitor_AfterDecision(self, d, apply)
2516
2517    def BeginFail(self):
2518        r"""Just when the failure occurs."""
2519        return _pywrapcp.SearchMonitor_BeginFail(self)
2520
2521    def EndFail(self):
2522        r"""After completing the backtrack."""
2523        return _pywrapcp.SearchMonitor_EndFail(self)
2524
2525    def BeginInitialPropagation(self):
2526        r"""Before the initial propagation."""
2527        return _pywrapcp.SearchMonitor_BeginInitialPropagation(self)
2528
2529    def EndInitialPropagation(self):
2530        r"""After the initial propagation."""
2531        return _pywrapcp.SearchMonitor_EndInitialPropagation(self)
2532
2533    def AcceptSolution(self):
2534        r"""
2535        This method is called when a solution is found. It asserts whether the
2536        solution is valid. A value of false indicates that the solution
2537        should be discarded.
2538        """
2539        return _pywrapcp.SearchMonitor_AcceptSolution(self)
2540
2541    def AtSolution(self):
2542        r"""
2543        This method is called when a valid solution is found. If the
2544        return value is true, then search will resume after. If the result
2545        is false, then search will stop there.
2546        """
2547        return _pywrapcp.SearchMonitor_AtSolution(self)
2548
2549    def NoMoreSolutions(self):
2550        r"""When the search tree is finished."""
2551        return _pywrapcp.SearchMonitor_NoMoreSolutions(self)
2552
2553    def LocalOptimum(self):
2554        r"""
2555        When a local optimum is reached. If 'true' is returned, the last solution
2556        is discarded and the search proceeds with the next one.
2557        """
2558        return _pywrapcp.SearchMonitor_LocalOptimum(self)
2559
2560    def AcceptDelta(self, delta, deltadelta):
2561        
2562        return _pywrapcp.SearchMonitor_AcceptDelta(self, delta, deltadelta)
2563
2564    def AcceptNeighbor(self):
2565        r"""After accepting a neighbor during local search."""
2566        return _pywrapcp.SearchMonitor_AcceptNeighbor(self)
2567
2568    def ProgressPercent(self):
2569        r"""
2570        Returns a percentage representing the propress of the search before
2571        reaching limits.
2572        """
2573        return _pywrapcp.SearchMonitor_ProgressPercent(self)
2574
2575    def solver(self):
2576        return _pywrapcp.SearchMonitor_solver(self)
2577
2578    def __repr__(self):
2579        return _pywrapcp.SearchMonitor___repr__(self)
2580
2581    def __str__(self):
2582        return _pywrapcp.SearchMonitor___str__(self)
2583    def __disown__(self):
2584        self.this.disown()
2585        _pywrapcp.disown_SearchMonitor(self)
2586        return weakref.proxy(self)
2587
2588# Register SearchMonitor in _pywrapcp:
2589_pywrapcp.SearchMonitor_swigregister(SearchMonitor)
2590class IntExpr(PropagationBaseObject):
2591    r"""
2592    The class IntExpr is the base of all integer expressions in
2593    constraint programming.
2594    It contains the basic protocol for an expression:
2595      - setting and modifying its bound
2596      - querying if it is bound
2597      - listening to events modifying its bounds
2598      - casting it into a variable (instance of IntVar)
2599    """
2600
2601    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2602
2603    def __init__(self, *args, **kwargs):
2604        raise AttributeError("No constructor defined - class is abstract")
2605
2606    def Min(self):
2607        return _pywrapcp.IntExpr_Min(self)
2608
2609    def SetMin(self, m):
2610        return _pywrapcp.IntExpr_SetMin(self, m)
2611
2612    def Max(self):
2613        return _pywrapcp.IntExpr_Max(self)
2614
2615    def SetMax(self, m):
2616        return _pywrapcp.IntExpr_SetMax(self, m)
2617
2618    def SetRange(self, l, u):
2619        r"""This method sets both the min and the max of the expression."""
2620        return _pywrapcp.IntExpr_SetRange(self, l, u)
2621
2622    def SetValue(self, v):
2623        r"""This method sets the value of the expression."""
2624        return _pywrapcp.IntExpr_SetValue(self, v)
2625
2626    def Bound(self):
2627        r"""Returns true if the min and the max of the expression are equal."""
2628        return _pywrapcp.IntExpr_Bound(self)
2629
2630    def IsVar(self):
2631        r"""Returns true if the expression is indeed a variable."""
2632        return _pywrapcp.IntExpr_IsVar(self)
2633
2634    def Var(self):
2635        r"""Creates a variable from the expression."""
2636        return _pywrapcp.IntExpr_Var(self)
2637
2638    def VarWithName(self, name):
2639        r"""
2640        Creates a variable from the expression and set the name of the
2641        resulting var. If the expression is already a variable, then it
2642        will set the name of the expression, possibly overwriting it.
2643        This is just a shortcut to Var() followed by set_name().
2644        """
2645        return _pywrapcp.IntExpr_VarWithName(self, name)
2646
2647    def WhenRange(self, *args):
2648        r"""
2649        *Overload 1:*
2650        Attach a demon that will watch the min or the max of the expression.
2651
2652        |
2653
2654        *Overload 2:*
2655        Attach a demon that will watch the min or the max of the expression.
2656        """
2657        return _pywrapcp.IntExpr_WhenRange(self, *args)
2658
2659    def __repr__(self):
2660        return _pywrapcp.IntExpr___repr__(self)
2661
2662    def __str__(self):
2663        return _pywrapcp.IntExpr___str__(self)
2664
2665    def __add__(self, *args):
2666        return _pywrapcp.IntExpr___add__(self, *args)
2667
2668    def __radd__(self, v):
2669        return _pywrapcp.IntExpr___radd__(self, v)
2670
2671    def __sub__(self, *args):
2672        return _pywrapcp.IntExpr___sub__(self, *args)
2673
2674    def __rsub__(self, v):
2675        return _pywrapcp.IntExpr___rsub__(self, v)
2676
2677    def __mul__(self, *args):
2678        return _pywrapcp.IntExpr___mul__(self, *args)
2679
2680    def __rmul__(self, v):
2681        return _pywrapcp.IntExpr___rmul__(self, v)
2682
2683    def __floordiv__(self, *args):
2684        return _pywrapcp.IntExpr___floordiv__(self, *args)
2685
2686    def __mod__(self, *args):
2687        return _pywrapcp.IntExpr___mod__(self, *args)
2688
2689    def __neg__(self):
2690        return _pywrapcp.IntExpr___neg__(self)
2691
2692    def __abs__(self):
2693        return _pywrapcp.IntExpr___abs__(self)
2694
2695    def Square(self):
2696        return _pywrapcp.IntExpr_Square(self)
2697
2698    def __eq__(self, *args):
2699        return _pywrapcp.IntExpr___eq__(self, *args)
2700
2701    def __ne__(self, *args):
2702        return _pywrapcp.IntExpr___ne__(self, *args)
2703
2704    def __ge__(self, *args):
2705        return _pywrapcp.IntExpr___ge__(self, *args)
2706
2707    def __gt__(self, *args):
2708        return _pywrapcp.IntExpr___gt__(self, *args)
2709
2710    def __le__(self, *args):
2711        return _pywrapcp.IntExpr___le__(self, *args)
2712
2713    def __lt__(self, *args):
2714        return _pywrapcp.IntExpr___lt__(self, *args)
2715
2716    def MapTo(self, vars):
2717        return _pywrapcp.IntExpr_MapTo(self, vars)
2718
2719    def IndexOf(self, *args):
2720        return _pywrapcp.IntExpr_IndexOf(self, *args)
2721
2722    def IsMember(self, values):
2723        return _pywrapcp.IntExpr_IsMember(self, values)
2724
2725    def Member(self, values):
2726        return _pywrapcp.IntExpr_Member(self, values)
2727
2728    def NotMember(self, starts, ends):
2729        return _pywrapcp.IntExpr_NotMember(self, starts, ends)
2730
2731# Register IntExpr in _pywrapcp:
2732_pywrapcp.IntExpr_swigregister(IntExpr)
2733class IntVarIterator(BaseObject):
2734    r"""
2735     The class Iterator has two direct subclasses. HoleIterators
2736     iterates over all holes, that is value removed between the
2737     current min and max of the variable since the last time the
2738     variable was processed in the queue. DomainIterators iterates
2739     over all elements of the variable domain. Both iterators are not
2740     robust to domain changes. Hole iterators can also report values outside
2741     the current min and max of the variable.
2742     HoleIterators should only be called from a demon attached to the
2743     variable that has created this iterator.
2744     IntVar* current_var;
2745     std::unique_ptr<IntVarIterator> it(current_var->MakeHoleIterator(false));
2746     for (const int64_t hole : InitAndGetValues(it)) {
2747    use the hole
2748     }
2749    """
2750
2751    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2752
2753    def __init__(self, *args, **kwargs):
2754        raise AttributeError("No constructor defined - class is abstract")
2755    __repr__ = _swig_repr
2756
2757    def Init(self):
2758        r"""This method must be called before each loop."""
2759        return _pywrapcp.IntVarIterator_Init(self)
2760
2761    def Ok(self):
2762        r"""This method indicates if we can call Value() or not."""
2763        return _pywrapcp.IntVarIterator_Ok(self)
2764
2765    def Value(self):
2766        r"""This method returns the current value of the iterator."""
2767        return _pywrapcp.IntVarIterator_Value(self)
2768
2769    def Next(self):
2770        r"""This method moves the iterator to the next value."""
2771        return _pywrapcp.IntVarIterator_Next(self)
2772
2773    def DebugString(self):
2774        r"""Pretty Print."""
2775        return _pywrapcp.IntVarIterator_DebugString(self)
2776
2777    def __iter__(self):
2778      self.Init()
2779      return self
2780
2781    def next(self):
2782      if self.Ok():
2783        result = self.Value()
2784        self.Next()
2785        return result
2786      else:
2787        raise StopIteration()
2788
2789    def __next__(self):
2790      return self.next()
2791
2792
2793# Register IntVarIterator in _pywrapcp:
2794_pywrapcp.IntVarIterator_swigregister(IntVarIterator)
2795class IntVar(IntExpr):
2796    r"""
2797    The class IntVar is a subset of IntExpr. In addition to the
2798    IntExpr protocol, it offers persistence, removing values from the domains,
2799    and a finer model for events.
2800    """
2801
2802    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2803
2804    def __init__(self, *args, **kwargs):
2805        raise AttributeError("No constructor defined - class is abstract")
2806
2807    def IsVar(self):
2808        return _pywrapcp.IntVar_IsVar(self)
2809
2810    def Var(self):
2811        return _pywrapcp.IntVar_Var(self)
2812
2813    def Value(self):
2814        r"""
2815        This method returns the value of the variable. This method checks
2816        before that the variable is bound.
2817        """
2818        return _pywrapcp.IntVar_Value(self)
2819
2820    def RemoveValue(self, v):
2821        r"""This method removes the value 'v' from the domain of the variable."""
2822        return _pywrapcp.IntVar_RemoveValue(self, v)
2823
2824    def RemoveInterval(self, l, u):
2825        r"""
2826        This method removes the interval 'l' .. 'u' from the domain of
2827        the variable. It assumes that 'l' <= 'u'.
2828        """
2829        return _pywrapcp.IntVar_RemoveInterval(self, l, u)
2830
2831    def RemoveValues(self, values):
2832        r"""This method remove the values from the domain of the variable."""
2833        return _pywrapcp.IntVar_RemoveValues(self, values)
2834
2835    def SetValues(self, values):
2836        r"""This method intersects the current domain with the values in the array."""
2837        return _pywrapcp.IntVar_SetValues(self, values)
2838
2839    def WhenBound(self, *args):
2840        r"""
2841        *Overload 1:*
2842        This method attaches a demon that will be awakened when the
2843        variable is bound.
2844
2845        |
2846
2847        *Overload 2:*
2848        This method attaches a closure that will be awakened when the
2849        variable is bound.
2850        """
2851        return _pywrapcp.IntVar_WhenBound(self, *args)
2852
2853    def WhenDomain(self, *args):
2854        r"""
2855        *Overload 1:*
2856        This method attaches a demon that will watch any domain
2857        modification of the domain of the variable.
2858
2859        |
2860
2861        *Overload 2:*
2862        This method attaches a closure that will watch any domain
2863        modification of the domain of the variable.
2864        """
2865        return _pywrapcp.IntVar_WhenDomain(self, *args)
2866
2867    def Size(self):
2868        r"""This method returns the number of values in the domain of the variable."""
2869        return _pywrapcp.IntVar_Size(self)
2870
2871    def Contains(self, v):
2872        r"""
2873        This method returns whether the value 'v' is in the domain of the
2874        variable.
2875        """
2876        return _pywrapcp.IntVar_Contains(self, v)
2877
2878    def HoleIteratorAux(self, reversible):
2879        r"""
2880        Creates a hole iterator. When 'reversible' is false, the returned
2881        object is created on the normal C++ heap and the solver does NOT
2882        take ownership of the object.
2883        """
2884        return _pywrapcp.IntVar_HoleIteratorAux(self, reversible)
2885
2886    def DomainIteratorAux(self, reversible):
2887        r"""
2888        Creates a domain iterator. When 'reversible' is false, the
2889        returned object is created on the normal C++ heap and the solver
2890        does NOT take ownership of the object.
2891        """
2892        return _pywrapcp.IntVar_DomainIteratorAux(self, reversible)
2893
2894    def OldMin(self):
2895        r"""Returns the previous min."""
2896        return _pywrapcp.IntVar_OldMin(self)
2897
2898    def OldMax(self):
2899        r"""Returns the previous max."""
2900        return _pywrapcp.IntVar_OldMax(self)
2901
2902    def __repr__(self):
2903        return _pywrapcp.IntVar___repr__(self)
2904
2905    def __str__(self):
2906        return _pywrapcp.IntVar___str__(self)
2907
2908    def DomainIterator(self):
2909      return iter(self.DomainIteratorAux(False))
2910
2911    def HoleIterator(self):
2912      return iter(self.HoleIteratorAux(False))
2913
2914
2915# Register IntVar in _pywrapcp:
2916_pywrapcp.IntVar_swigregister(IntVar)
2917class SolutionCollector(SearchMonitor):
2918    r"""
2919    This class is the root class of all solution collectors.
2920    It implements a basic query API to be used independently
2921    of the collector used.
2922    """
2923
2924    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2925
2926    def __init__(self, *args, **kwargs):
2927        raise AttributeError("No constructor defined")
2928    __repr__ = _swig_repr
2929
2930    def DebugString(self):
2931        return _pywrapcp.SolutionCollector_DebugString(self)
2932
2933    def Add(self, *args):
2934        r"""Add API."""
2935        return _pywrapcp.SolutionCollector_Add(self, *args)
2936
2937    def AddObjective(self, objective):
2938        return _pywrapcp.SolutionCollector_AddObjective(self, objective)
2939
2940    def EnterSearch(self):
2941        r"""Beginning of the search."""
2942        return _pywrapcp.SolutionCollector_EnterSearch(self)
2943
2944    def SolutionCount(self):
2945        r"""Returns how many solutions were stored during the search."""
2946        return _pywrapcp.SolutionCollector_SolutionCount(self)
2947
2948    def Solution(self, n):
2949        r"""Returns the nth solution."""
2950        return _pywrapcp.SolutionCollector_Solution(self, n)
2951
2952    def WallTime(self, n):
2953        r"""Returns the wall time in ms for the nth solution."""
2954        return _pywrapcp.SolutionCollector_WallTime(self, n)
2955
2956    def Branches(self, n):
2957        r"""Returns the number of branches when the nth solution was found."""
2958        return _pywrapcp.SolutionCollector_Branches(self, n)
2959
2960    def Failures(self, n):
2961        r"""
2962        Returns the number of failures encountered at the time of the nth
2963        solution.
2964        """
2965        return _pywrapcp.SolutionCollector_Failures(self, n)
2966
2967    def ObjectiveValue(self, n):
2968        r"""Returns the objective value of the nth solution."""
2969        return _pywrapcp.SolutionCollector_ObjectiveValue(self, n)
2970
2971    def Value(self, n, var):
2972        r"""This is a shortcut to get the Value of 'var' in the nth solution."""
2973        return _pywrapcp.SolutionCollector_Value(self, n, var)
2974
2975    def StartValue(self, n, var):
2976        r"""This is a shortcut to get the StartValue of 'var' in the nth solution."""
2977        return _pywrapcp.SolutionCollector_StartValue(self, n, var)
2978
2979    def EndValue(self, n, var):
2980        r"""This is a shortcut to get the EndValue of 'var' in the nth solution."""
2981        return _pywrapcp.SolutionCollector_EndValue(self, n, var)
2982
2983    def DurationValue(self, n, var):
2984        r"""This is a shortcut to get the DurationValue of 'var' in the nth solution."""
2985        return _pywrapcp.SolutionCollector_DurationValue(self, n, var)
2986
2987    def PerformedValue(self, n, var):
2988        r"""This is a shortcut to get the PerformedValue of 'var' in the nth solution."""
2989        return _pywrapcp.SolutionCollector_PerformedValue(self, n, var)
2990
2991    def ForwardSequence(self, n, var):
2992        r"""
2993        This is a shortcut to get the ForwardSequence of 'var' in the
2994        nth solution. The forward sequence is the list of ranked interval
2995        variables starting from the start of the sequence.
2996        """
2997        return _pywrapcp.SolutionCollector_ForwardSequence(self, n, var)
2998
2999    def BackwardSequence(self, n, var):
3000        r"""
3001        This is a shortcut to get the BackwardSequence of 'var' in the
3002        nth solution. The backward sequence is the list of ranked interval
3003        variables starting from the end of the sequence.
3004        """
3005        return _pywrapcp.SolutionCollector_BackwardSequence(self, n, var)
3006
3007    def Unperformed(self, n, var):
3008        r"""
3009        This is a shortcut to get the list of unperformed of 'var' in the
3010        nth solution.
3011        """
3012        return _pywrapcp.SolutionCollector_Unperformed(self, n, var)
3013
3014# Register SolutionCollector in _pywrapcp:
3015_pywrapcp.SolutionCollector_swigregister(SolutionCollector)
3016class OptimizeVar(object):
3017    r"""
3018    This class encapsulates an objective. It requires the direction
3019    (minimize or maximize), the variable to optimize, and the
3020    improvement step.
3021    """
3022
3023    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3024
3025    def __init__(self, *args, **kwargs):
3026        raise AttributeError("No constructor defined")
3027    __repr__ = _swig_repr
3028
3029    def Best(self):
3030        r"""Returns the best value found during search."""
3031        return _pywrapcp.OptimizeVar_Best(self)
3032
3033    def BeginNextDecision(self, db):
3034        r"""Internal methods."""
3035        return _pywrapcp.OptimizeVar_BeginNextDecision(self, db)
3036
3037    def RefuteDecision(self, d):
3038        return _pywrapcp.OptimizeVar_RefuteDecision(self, d)
3039
3040    def AtSolution(self):
3041        return _pywrapcp.OptimizeVar_AtSolution(self)
3042
3043    def AcceptSolution(self):
3044        return _pywrapcp.OptimizeVar_AcceptSolution(self)
3045
3046    def DebugString(self):
3047        return _pywrapcp.OptimizeVar_DebugString(self)
3048    __swig_destroy__ = _pywrapcp.delete_OptimizeVar
3049
3050# Register OptimizeVar in _pywrapcp:
3051_pywrapcp.OptimizeVar_swigregister(OptimizeVar)
3052class SearchLimit(SearchMonitor):
3053    r"""Base class of all search limits."""
3054
3055    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3056
3057    def __init__(self, *args, **kwargs):
3058        raise AttributeError("No constructor defined - class is abstract")
3059    __repr__ = _swig_repr
3060    __swig_destroy__ = _pywrapcp.delete_SearchLimit
3061
3062    def Crossed(self):
3063        r"""Returns true if the limit has been crossed."""
3064        return _pywrapcp.SearchLimit_Crossed(self)
3065
3066    def Check(self):
3067        r"""
3068        This method is called to check the status of the limit. A return
3069        value of true indicates that we have indeed crossed the limit. In
3070        that case, this method will not be called again and the remaining
3071        search will be discarded.
3072        """
3073        return _pywrapcp.SearchLimit_Check(self)
3074
3075    def Init(self):
3076        r"""This method is called when the search limit is initialized."""
3077        return _pywrapcp.SearchLimit_Init(self)
3078
3079    def EnterSearch(self):
3080        r"""Internal methods."""
3081        return _pywrapcp.SearchLimit_EnterSearch(self)
3082
3083    def BeginNextDecision(self, b):
3084        return _pywrapcp.SearchLimit_BeginNextDecision(self, b)
3085
3086    def RefuteDecision(self, d):
3087        return _pywrapcp.SearchLimit_RefuteDecision(self, d)
3088
3089    def DebugString(self):
3090        return _pywrapcp.SearchLimit_DebugString(self)
3091
3092# Register SearchLimit in _pywrapcp:
3093_pywrapcp.SearchLimit_swigregister(SearchLimit)
3094class IntervalVar(PropagationBaseObject):
3095    r"""
3096    Interval variables are often used in scheduling. The main characteristics
3097    of an IntervalVar are the start position, duration, and end
3098    date. All these characteristics can be queried and set, and demons can
3099    be posted on their modifications.
3100
3101    An important aspect is optionality: an IntervalVar can be performed or not.
3102    If unperformed, then it simply does not exist, and its characteristics
3103    cannot be accessed any more. An interval var is automatically marked
3104    as unperformed when it is not consistent anymore (start greater
3105    than end, duration < 0...)
3106    """
3107
3108    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3109
3110    def __init__(self, *args, **kwargs):
3111        raise AttributeError("No constructor defined - class is abstract")
3112
3113    def StartMin(self):
3114        r"""
3115        These methods query, set, and watch the start position of the
3116        interval var.
3117        """
3118        return _pywrapcp.IntervalVar_StartMin(self)
3119
3120    def StartMax(self):
3121        return _pywrapcp.IntervalVar_StartMax(self)
3122
3123    def SetStartMin(self, m):
3124        return _pywrapcp.IntervalVar_SetStartMin(self, m)
3125
3126    def SetStartMax(self, m):
3127        return _pywrapcp.IntervalVar_SetStartMax(self, m)
3128
3129    def SetStartRange(self, mi, ma):
3130        return _pywrapcp.IntervalVar_SetStartRange(self, mi, ma)
3131
3132    def OldStartMin(self):
3133        return _pywrapcp.IntervalVar_OldStartMin(self)
3134
3135    def OldStartMax(self):
3136        return _pywrapcp.IntervalVar_OldStartMax(self)
3137
3138    def WhenStartRange(self, *args):
3139        return _pywrapcp.IntervalVar_WhenStartRange(self, *args)
3140
3141    def WhenStartBound(self, *args):
3142        return _pywrapcp.IntervalVar_WhenStartBound(self, *args)
3143
3144    def DurationMin(self):
3145        r"""These methods query, set, and watch the duration of the interval var."""
3146        return _pywrapcp.IntervalVar_DurationMin(self)
3147
3148    def DurationMax(self):
3149        return _pywrapcp.IntervalVar_DurationMax(self)
3150
3151    def SetDurationMin(self, m):
3152        return _pywrapcp.IntervalVar_SetDurationMin(self, m)
3153
3154    def SetDurationMax(self, m):
3155        return _pywrapcp.IntervalVar_SetDurationMax(self, m)
3156
3157    def SetDurationRange(self, mi, ma):
3158        return _pywrapcp.IntervalVar_SetDurationRange(self, mi, ma)
3159
3160    def OldDurationMin(self):
3161        return _pywrapcp.IntervalVar_OldDurationMin(self)
3162
3163    def OldDurationMax(self):
3164        return _pywrapcp.IntervalVar_OldDurationMax(self)
3165
3166    def WhenDurationRange(self, *args):
3167        return _pywrapcp.IntervalVar_WhenDurationRange(self, *args)
3168
3169    def WhenDurationBound(self, *args):
3170        return _pywrapcp.IntervalVar_WhenDurationBound(self, *args)
3171
3172    def EndMin(self):
3173        r"""These methods query, set, and watch the end position of the interval var."""
3174        return _pywrapcp.IntervalVar_EndMin(self)
3175
3176    def EndMax(self):
3177        return _pywrapcp.IntervalVar_EndMax(self)
3178
3179    def SetEndMin(self, m):
3180        return _pywrapcp.IntervalVar_SetEndMin(self, m)
3181
3182    def SetEndMax(self, m):
3183        return _pywrapcp.IntervalVar_SetEndMax(self, m)
3184
3185    def SetEndRange(self, mi, ma):
3186        return _pywrapcp.IntervalVar_SetEndRange(self, mi, ma)
3187
3188    def OldEndMin(self):
3189        return _pywrapcp.IntervalVar_OldEndMin(self)
3190
3191    def OldEndMax(self):
3192        return _pywrapcp.IntervalVar_OldEndMax(self)
3193
3194    def WhenEndRange(self, *args):
3195        return _pywrapcp.IntervalVar_WhenEndRange(self, *args)
3196
3197    def WhenEndBound(self, *args):
3198        return _pywrapcp.IntervalVar_WhenEndBound(self, *args)
3199
3200    def MustBePerformed(self):
3201        r"""
3202        These methods query, set, and watch the performed status of the
3203        interval var.
3204        """
3205        return _pywrapcp.IntervalVar_MustBePerformed(self)
3206
3207    def MayBePerformed(self):
3208        return _pywrapcp.IntervalVar_MayBePerformed(self)
3209
3210    def CannotBePerformed(self):
3211        return _pywrapcp.IntervalVar_CannotBePerformed(self)
3212
3213    def IsPerformedBound(self):
3214        return _pywrapcp.IntervalVar_IsPerformedBound(self)
3215
3216    def SetPerformed(self, val):
3217        return _pywrapcp.IntervalVar_SetPerformed(self, val)
3218
3219    def WasPerformedBound(self):
3220        return _pywrapcp.IntervalVar_WasPerformedBound(self)
3221
3222    def WhenPerformedBound(self, *args):
3223        return _pywrapcp.IntervalVar_WhenPerformedBound(self, *args)
3224
3225    def WhenAnything(self, *args):
3226        r"""
3227        *Overload 1:*
3228        Attaches a demon awakened when anything about this interval changes.
3229
3230        |
3231
3232        *Overload 2:*
3233        Attaches a closure awakened when anything about this interval changes.
3234        """
3235        return _pywrapcp.IntervalVar_WhenAnything(self, *args)
3236
3237    def StartExpr(self):
3238        r"""
3239        These methods create expressions encapsulating the start, end
3240        and duration of the interval var. Please note that these must not
3241        be used if the interval var is unperformed.
3242        """
3243        return _pywrapcp.IntervalVar_StartExpr(self)
3244
3245    def DurationExpr(self):
3246        return _pywrapcp.IntervalVar_DurationExpr(self)
3247
3248    def EndExpr(self):
3249        return _pywrapcp.IntervalVar_EndExpr(self)
3250
3251    def PerformedExpr(self):
3252        return _pywrapcp.IntervalVar_PerformedExpr(self)
3253
3254    def SafeStartExpr(self, unperformed_value):
3255        r"""
3256        These methods create expressions encapsulating the start, end
3257        and duration of the interval var. If the interval var is
3258        unperformed, they will return the unperformed_value.
3259        """
3260        return _pywrapcp.IntervalVar_SafeStartExpr(self, unperformed_value)
3261
3262    def SafeDurationExpr(self, unperformed_value):
3263        return _pywrapcp.IntervalVar_SafeDurationExpr(self, unperformed_value)
3264
3265    def SafeEndExpr(self, unperformed_value):
3266        return _pywrapcp.IntervalVar_SafeEndExpr(self, unperformed_value)
3267
3268    def EndsAfterEnd(self, other):
3269        return _pywrapcp.IntervalVar_EndsAfterEnd(self, other)
3270
3271    def EndsAfterEndWithDelay(self, other, delay):
3272        return _pywrapcp.IntervalVar_EndsAfterEndWithDelay(self, other, delay)
3273
3274    def EndsAfterStart(self, other):
3275        return _pywrapcp.IntervalVar_EndsAfterStart(self, other)
3276
3277    def EndsAfterStartWithDelay(self, other, delay):
3278        return _pywrapcp.IntervalVar_EndsAfterStartWithDelay(self, other, delay)
3279
3280    def EndsAtEnd(self, other):
3281        return _pywrapcp.IntervalVar_EndsAtEnd(self, other)
3282
3283    def EndsAtEndWithDelay(self, other, delay):
3284        return _pywrapcp.IntervalVar_EndsAtEndWithDelay(self, other, delay)
3285
3286    def EndsAtStart(self, other):
3287        return _pywrapcp.IntervalVar_EndsAtStart(self, other)
3288
3289    def EndsAtStartWithDelay(self, other, delay):
3290        return _pywrapcp.IntervalVar_EndsAtStartWithDelay(self, other, delay)
3291
3292    def StartsAfterEnd(self, other):
3293        return _pywrapcp.IntervalVar_StartsAfterEnd(self, other)
3294
3295    def StartsAfterEndWithDelay(self, other, delay):
3296        return _pywrapcp.IntervalVar_StartsAfterEndWithDelay(self, other, delay)
3297
3298    def StartsAfterStart(self, other):
3299        return _pywrapcp.IntervalVar_StartsAfterStart(self, other)
3300
3301    def StartsAfterStartWithDelay(self, other, delay):
3302        return _pywrapcp.IntervalVar_StartsAfterStartWithDelay(self, other, delay)
3303
3304    def StartsAtEnd(self, other):
3305        return _pywrapcp.IntervalVar_StartsAtEnd(self, other)
3306
3307    def StartsAtEndWithDelay(self, other, delay):
3308        return _pywrapcp.IntervalVar_StartsAtEndWithDelay(self, other, delay)
3309
3310    def StartsAtStart(self, other):
3311        return _pywrapcp.IntervalVar_StartsAtStart(self, other)
3312
3313    def StartsAtStartWithDelay(self, other, delay):
3314        return _pywrapcp.IntervalVar_StartsAtStartWithDelay(self, other, delay)
3315
3316    def StaysInSync(self, other):
3317        return _pywrapcp.IntervalVar_StaysInSync(self, other)
3318
3319    def StaysInSyncWithDelay(self, other, delay):
3320        return _pywrapcp.IntervalVar_StaysInSyncWithDelay(self, other, delay)
3321
3322    def EndsAfter(self, date):
3323        return _pywrapcp.IntervalVar_EndsAfter(self, date)
3324
3325    def EndsAt(self, date):
3326        return _pywrapcp.IntervalVar_EndsAt(self, date)
3327
3328    def EndsBefore(self, date):
3329        return _pywrapcp.IntervalVar_EndsBefore(self, date)
3330
3331    def StartsAfter(self, date):
3332        return _pywrapcp.IntervalVar_StartsAfter(self, date)
3333
3334    def StartsAt(self, date):
3335        return _pywrapcp.IntervalVar_StartsAt(self, date)
3336
3337    def StartsBefore(self, date):
3338        return _pywrapcp.IntervalVar_StartsBefore(self, date)
3339
3340    def CrossesDate(self, date):
3341        return _pywrapcp.IntervalVar_CrossesDate(self, date)
3342
3343    def AvoidsDate(self, date):
3344        return _pywrapcp.IntervalVar_AvoidsDate(self, date)
3345
3346    def __repr__(self):
3347        return _pywrapcp.IntervalVar___repr__(self)
3348
3349    def __str__(self):
3350        return _pywrapcp.IntervalVar___str__(self)
3351
3352# Register IntervalVar in _pywrapcp:
3353_pywrapcp.IntervalVar_swigregister(IntervalVar)
3354class SequenceVar(PropagationBaseObject):
3355    r"""
3356    A sequence variable is a variable whose domain is a set of possible
3357    orderings of the interval variables. It allows ordering of tasks. It
3358    has two sets of methods: ComputePossibleFirstsAndLasts(), which
3359    returns the list of interval variables that can be ranked first or
3360    last; and RankFirst/RankNotFirst/RankLast/RankNotLast, which can be
3361    used to create the search decision.
3362    """
3363
3364    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3365
3366    def __init__(self, *args, **kwargs):
3367        raise AttributeError("No constructor defined")
3368
3369    def DebugString(self):
3370        return _pywrapcp.SequenceVar_DebugString(self)
3371
3372    def RankFirst(self, index):
3373        r"""
3374        Ranks the index_th interval var first of all unranked interval
3375        vars. After that, it will no longer be considered ranked.
3376        """
3377        return _pywrapcp.SequenceVar_RankFirst(self, index)
3378
3379    def RankNotFirst(self, index):
3380        r"""
3381        Indicates that the index_th interval var will not be ranked first
3382        of all currently unranked interval vars.
3383        """
3384        return _pywrapcp.SequenceVar_RankNotFirst(self, index)
3385
3386    def RankLast(self, index):
3387        r"""
3388        Ranks the index_th interval var first of all unranked interval
3389        vars. After that, it will no longer be considered ranked.
3390        """
3391        return _pywrapcp.SequenceVar_RankLast(self, index)
3392
3393    def RankNotLast(self, index):
3394        r"""
3395        Indicates that the index_th interval var will not be ranked first
3396        of all currently unranked interval vars.
3397        """
3398        return _pywrapcp.SequenceVar_RankNotLast(self, index)
3399
3400    def Interval(self, index):
3401        r"""Returns the index_th interval of the sequence."""
3402        return _pywrapcp.SequenceVar_Interval(self, index)
3403
3404    def Next(self, index):
3405        r"""Returns the next of the index_th interval of the sequence."""
3406        return _pywrapcp.SequenceVar_Next(self, index)
3407
3408    def Size(self):
3409        r"""Returns the number of interval vars in the sequence."""
3410        return _pywrapcp.SequenceVar_Size(self)
3411
3412    def __repr__(self):
3413        return _pywrapcp.SequenceVar___repr__(self)
3414
3415    def __str__(self):
3416        return _pywrapcp.SequenceVar___str__(self)
3417
3418# Register SequenceVar in _pywrapcp:
3419_pywrapcp.SequenceVar_swigregister(SequenceVar)
3420class AssignmentElement(object):
3421    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3422
3423    def __init__(self, *args, **kwargs):
3424        raise AttributeError("No constructor defined")
3425    __repr__ = _swig_repr
3426
3427    def Activate(self):
3428        return _pywrapcp.AssignmentElement_Activate(self)
3429
3430    def Deactivate(self):
3431        return _pywrapcp.AssignmentElement_Deactivate(self)
3432
3433    def Activated(self):
3434        return _pywrapcp.AssignmentElement_Activated(self)
3435    __swig_destroy__ = _pywrapcp.delete_AssignmentElement
3436
3437# Register AssignmentElement in _pywrapcp:
3438_pywrapcp.AssignmentElement_swigregister(AssignmentElement)
3439class IntVarElement(AssignmentElement):
3440    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3441
3442    def __init__(self, *args, **kwargs):
3443        raise AttributeError("No constructor defined")
3444    __repr__ = _swig_repr
3445
3446    def Var(self):
3447        return _pywrapcp.IntVarElement_Var(self)
3448
3449    def Min(self):
3450        return _pywrapcp.IntVarElement_Min(self)
3451
3452    def SetMin(self, m):
3453        return _pywrapcp.IntVarElement_SetMin(self, m)
3454
3455    def Max(self):
3456        return _pywrapcp.IntVarElement_Max(self)
3457
3458    def SetMax(self, m):
3459        return _pywrapcp.IntVarElement_SetMax(self, m)
3460
3461    def Value(self):
3462        return _pywrapcp.IntVarElement_Value(self)
3463
3464    def Bound(self):
3465        return _pywrapcp.IntVarElement_Bound(self)
3466
3467    def SetRange(self, l, u):
3468        return _pywrapcp.IntVarElement_SetRange(self, l, u)
3469
3470    def SetValue(self, v):
3471        return _pywrapcp.IntVarElement_SetValue(self, v)
3472
3473    def __eq__(self, element):
3474        return _pywrapcp.IntVarElement___eq__(self, element)
3475
3476    def __ne__(self, element):
3477        return _pywrapcp.IntVarElement___ne__(self, element)
3478    __swig_destroy__ = _pywrapcp.delete_IntVarElement
3479
3480# Register IntVarElement in _pywrapcp:
3481_pywrapcp.IntVarElement_swigregister(IntVarElement)
3482class IntervalVarElement(AssignmentElement):
3483    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3484
3485    def __init__(self, *args, **kwargs):
3486        raise AttributeError("No constructor defined")
3487    __repr__ = _swig_repr
3488
3489    def Var(self):
3490        return _pywrapcp.IntervalVarElement_Var(self)
3491
3492    def StartMin(self):
3493        return _pywrapcp.IntervalVarElement_StartMin(self)
3494
3495    def StartMax(self):
3496        return _pywrapcp.IntervalVarElement_StartMax(self)
3497
3498    def StartValue(self):
3499        return _pywrapcp.IntervalVarElement_StartValue(self)
3500
3501    def DurationMin(self):
3502        return _pywrapcp.IntervalVarElement_DurationMin(self)
3503
3504    def DurationMax(self):
3505        return _pywrapcp.IntervalVarElement_DurationMax(self)
3506
3507    def DurationValue(self):
3508        return _pywrapcp.IntervalVarElement_DurationValue(self)
3509
3510    def EndMin(self):
3511        return _pywrapcp.IntervalVarElement_EndMin(self)
3512
3513    def EndMax(self):
3514        return _pywrapcp.IntervalVarElement_EndMax(self)
3515
3516    def EndValue(self):
3517        return _pywrapcp.IntervalVarElement_EndValue(self)
3518
3519    def PerformedMin(self):
3520        return _pywrapcp.IntervalVarElement_PerformedMin(self)
3521
3522    def PerformedMax(self):
3523        return _pywrapcp.IntervalVarElement_PerformedMax(self)
3524
3525    def PerformedValue(self):
3526        return _pywrapcp.IntervalVarElement_PerformedValue(self)
3527
3528    def SetStartMin(self, m):
3529        return _pywrapcp.IntervalVarElement_SetStartMin(self, m)
3530
3531    def SetStartMax(self, m):
3532        return _pywrapcp.IntervalVarElement_SetStartMax(self, m)
3533
3534    def SetStartRange(self, mi, ma):
3535        return _pywrapcp.IntervalVarElement_SetStartRange(self, mi, ma)
3536
3537    def SetStartValue(self, v):
3538        return _pywrapcp.IntervalVarElement_SetStartValue(self, v)
3539
3540    def SetDurationMin(self, m):
3541        return _pywrapcp.IntervalVarElement_SetDurationMin(self, m)
3542
3543    def SetDurationMax(self, m):
3544        return _pywrapcp.IntervalVarElement_SetDurationMax(self, m)
3545
3546    def SetDurationRange(self, mi, ma):
3547        return _pywrapcp.IntervalVarElement_SetDurationRange(self, mi, ma)
3548
3549    def SetDurationValue(self, v):
3550        return _pywrapcp.IntervalVarElement_SetDurationValue(self, v)
3551
3552    def SetEndMin(self, m):
3553        return _pywrapcp.IntervalVarElement_SetEndMin(self, m)
3554
3555    def SetEndMax(self, m):
3556        return _pywrapcp.IntervalVarElement_SetEndMax(self, m)
3557
3558    def SetEndRange(self, mi, ma):
3559        return _pywrapcp.IntervalVarElement_SetEndRange(self, mi, ma)
3560
3561    def SetEndValue(self, v):
3562        return _pywrapcp.IntervalVarElement_SetEndValue(self, v)
3563
3564    def SetPerformedMin(self, m):
3565        return _pywrapcp.IntervalVarElement_SetPerformedMin(self, m)
3566
3567    def SetPerformedMax(self, m):
3568        return _pywrapcp.IntervalVarElement_SetPerformedMax(self, m)
3569
3570    def SetPerformedRange(self, mi, ma):
3571        return _pywrapcp.IntervalVarElement_SetPerformedRange(self, mi, ma)
3572
3573    def SetPerformedValue(self, v):
3574        return _pywrapcp.IntervalVarElement_SetPerformedValue(self, v)
3575
3576    def __eq__(self, element):
3577        return _pywrapcp.IntervalVarElement___eq__(self, element)
3578
3579    def __ne__(self, element):
3580        return _pywrapcp.IntervalVarElement___ne__(self, element)
3581    __swig_destroy__ = _pywrapcp.delete_IntervalVarElement
3582
3583# Register IntervalVarElement in _pywrapcp:
3584_pywrapcp.IntervalVarElement_swigregister(IntervalVarElement)
3585class SequenceVarElement(AssignmentElement):
3586    r"""
3587    The SequenceVarElement stores a partial representation of ranked
3588    interval variables in the underlying sequence variable.
3589    This representation consists of three vectors:
3590      - the forward sequence. That is the list of interval variables
3591        ranked first in the sequence.  The first element of the backward
3592        sequence is the first interval in the sequence variable.
3593      - the backward sequence. That is the list of interval variables
3594        ranked last in the sequence. The first element of the backward
3595        sequence is the last interval in the sequence variable.
3596      - The list of unperformed interval variables.
3597     Furthermore, if all performed variables are ranked, then by
3598     convention, the forward_sequence will contain all such variables
3599     and the backward_sequence will be empty.
3600    """
3601
3602    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3603
3604    def __init__(self, *args, **kwargs):
3605        raise AttributeError("No constructor defined")
3606    __repr__ = _swig_repr
3607
3608    def Var(self):
3609        return _pywrapcp.SequenceVarElement_Var(self)
3610
3611    def ForwardSequence(self):
3612        return _pywrapcp.SequenceVarElement_ForwardSequence(self)
3613
3614    def BackwardSequence(self):
3615        return _pywrapcp.SequenceVarElement_BackwardSequence(self)
3616
3617    def Unperformed(self):
3618        return _pywrapcp.SequenceVarElement_Unperformed(self)
3619
3620    def SetSequence(self, forward_sequence, backward_sequence, unperformed):
3621        return _pywrapcp.SequenceVarElement_SetSequence(self, forward_sequence, backward_sequence, unperformed)
3622
3623    def SetForwardSequence(self, forward_sequence):
3624        return _pywrapcp.SequenceVarElement_SetForwardSequence(self, forward_sequence)
3625
3626    def SetBackwardSequence(self, backward_sequence):
3627        return _pywrapcp.SequenceVarElement_SetBackwardSequence(self, backward_sequence)
3628
3629    def SetUnperformed(self, unperformed):
3630        return _pywrapcp.SequenceVarElement_SetUnperformed(self, unperformed)
3631
3632    def __eq__(self, element):
3633        return _pywrapcp.SequenceVarElement___eq__(self, element)
3634
3635    def __ne__(self, element):
3636        return _pywrapcp.SequenceVarElement___ne__(self, element)
3637    __swig_destroy__ = _pywrapcp.delete_SequenceVarElement
3638
3639# Register SequenceVarElement in _pywrapcp:
3640_pywrapcp.SequenceVarElement_swigregister(SequenceVarElement)
3641class Assignment(PropagationBaseObject):
3642    r"""
3643    An Assignment is a variable -> domains mapping, used
3644    to report solutions to the user.
3645    """
3646
3647    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3648
3649    def __init__(self, *args, **kwargs):
3650        raise AttributeError("No constructor defined")
3651    __repr__ = _swig_repr
3652
3653    def Clear(self):
3654        return _pywrapcp.Assignment_Clear(self)
3655
3656    def Empty(self):
3657        return _pywrapcp.Assignment_Empty(self)
3658
3659    def Size(self):
3660        return _pywrapcp.Assignment_Size(self)
3661
3662    def NumIntVars(self):
3663        return _pywrapcp.Assignment_NumIntVars(self)
3664
3665    def NumIntervalVars(self):
3666        return _pywrapcp.Assignment_NumIntervalVars(self)
3667
3668    def NumSequenceVars(self):
3669        return _pywrapcp.Assignment_NumSequenceVars(self)
3670
3671    def Store(self):
3672        return _pywrapcp.Assignment_Store(self)
3673
3674    def Restore(self):
3675        return _pywrapcp.Assignment_Restore(self)
3676
3677    def Load(self, *args):
3678        r"""
3679        Loads an assignment from a file; does not add variables to the
3680        assignment (only the variables contained in the assignment are modified).
3681        """
3682        return _pywrapcp.Assignment_Load(self, *args)
3683
3684    def Save(self, *args):
3685        r"""Saves the assignment to a file."""
3686        return _pywrapcp.Assignment_Save(self, *args)
3687
3688    def AddObjective(self, v):
3689        return _pywrapcp.Assignment_AddObjective(self, v)
3690
3691    def Objective(self):
3692        return _pywrapcp.Assignment_Objective(self)
3693
3694    def HasObjective(self):
3695        return _pywrapcp.Assignment_HasObjective(self)
3696
3697    def ObjectiveMin(self):
3698        return _pywrapcp.Assignment_ObjectiveMin(self)
3699
3700    def ObjectiveMax(self):
3701        return _pywrapcp.Assignment_ObjectiveMax(self)
3702
3703    def ObjectiveValue(self):
3704        return _pywrapcp.Assignment_ObjectiveValue(self)
3705
3706    def ObjectiveBound(self):
3707        return _pywrapcp.Assignment_ObjectiveBound(self)
3708
3709    def SetObjectiveMin(self, m):
3710        return _pywrapcp.Assignment_SetObjectiveMin(self, m)
3711
3712    def SetObjectiveMax(self, m):
3713        return _pywrapcp.Assignment_SetObjectiveMax(self, m)
3714
3715    def SetObjectiveValue(self, value):
3716        return _pywrapcp.Assignment_SetObjectiveValue(self, value)
3717
3718    def SetObjectiveRange(self, l, u):
3719        return _pywrapcp.Assignment_SetObjectiveRange(self, l, u)
3720
3721    def Min(self, var):
3722        return _pywrapcp.Assignment_Min(self, var)
3723
3724    def Max(self, var):
3725        return _pywrapcp.Assignment_Max(self, var)
3726
3727    def Value(self, var):
3728        return _pywrapcp.Assignment_Value(self, var)
3729
3730    def Bound(self, var):
3731        return _pywrapcp.Assignment_Bound(self, var)
3732
3733    def SetMin(self, var, m):
3734        return _pywrapcp.Assignment_SetMin(self, var, m)
3735
3736    def SetMax(self, var, m):
3737        return _pywrapcp.Assignment_SetMax(self, var, m)
3738
3739    def SetRange(self, var, l, u):
3740        return _pywrapcp.Assignment_SetRange(self, var, l, u)
3741
3742    def SetValue(self, var, value):
3743        return _pywrapcp.Assignment_SetValue(self, var, value)
3744
3745    def StartMin(self, var):
3746        return _pywrapcp.Assignment_StartMin(self, var)
3747
3748    def StartMax(self, var):
3749        return _pywrapcp.Assignment_StartMax(self, var)
3750
3751    def StartValue(self, var):
3752        return _pywrapcp.Assignment_StartValue(self, var)
3753
3754    def DurationMin(self, var):
3755        return _pywrapcp.Assignment_DurationMin(self, var)
3756
3757    def DurationMax(self, var):
3758        return _pywrapcp.Assignment_DurationMax(self, var)
3759
3760    def DurationValue(self, var):
3761        return _pywrapcp.Assignment_DurationValue(self, var)
3762
3763    def EndMin(self, var):
3764        return _pywrapcp.Assignment_EndMin(self, var)
3765
3766    def EndMax(self, var):
3767        return _pywrapcp.Assignment_EndMax(self, var)
3768
3769    def EndValue(self, var):
3770        return _pywrapcp.Assignment_EndValue(self, var)
3771
3772    def PerformedMin(self, var):
3773        return _pywrapcp.Assignment_PerformedMin(self, var)
3774
3775    def PerformedMax(self, var):
3776        return _pywrapcp.Assignment_PerformedMax(self, var)
3777
3778    def PerformedValue(self, var):
3779        return _pywrapcp.Assignment_PerformedValue(self, var)
3780
3781    def SetStartMin(self, var, m):
3782        return _pywrapcp.Assignment_SetStartMin(self, var, m)
3783
3784    def SetStartMax(self, var, m):
3785        return _pywrapcp.Assignment_SetStartMax(self, var, m)
3786
3787    def SetStartRange(self, var, mi, ma):
3788        return _pywrapcp.Assignment_SetStartRange(self, var, mi, ma)
3789
3790    def SetStartValue(self, var, value):
3791        return _pywrapcp.Assignment_SetStartValue(self, var, value)
3792
3793    def SetDurationMin(self, var, m):
3794        return _pywrapcp.Assignment_SetDurationMin(self, var, m)
3795
3796    def SetDurationMax(self, var, m):
3797        return _pywrapcp.Assignment_SetDurationMax(self, var, m)
3798
3799    def SetDurationRange(self, var, mi, ma):
3800        return _pywrapcp.Assignment_SetDurationRange(self, var, mi, ma)
3801
3802    def SetDurationValue(self, var, value):
3803        return _pywrapcp.Assignment_SetDurationValue(self, var, value)
3804
3805    def SetEndMin(self, var, m):
3806        return _pywrapcp.Assignment_SetEndMin(self, var, m)
3807
3808    def SetEndMax(self, var, m):
3809        return _pywrapcp.Assignment_SetEndMax(self, var, m)
3810
3811    def SetEndRange(self, var, mi, ma):
3812        return _pywrapcp.Assignment_SetEndRange(self, var, mi, ma)
3813
3814    def SetEndValue(self, var, value):
3815        return _pywrapcp.Assignment_SetEndValue(self, var, value)
3816
3817    def SetPerformedMin(self, var, m):
3818        return _pywrapcp.Assignment_SetPerformedMin(self, var, m)
3819
3820    def SetPerformedMax(self, var, m):
3821        return _pywrapcp.Assignment_SetPerformedMax(self, var, m)
3822
3823    def SetPerformedRange(self, var, mi, ma):
3824        return _pywrapcp.Assignment_SetPerformedRange(self, var, mi, ma)
3825
3826    def SetPerformedValue(self, var, value):
3827        return _pywrapcp.Assignment_SetPerformedValue(self, var, value)
3828
3829    def Add(self, *args):
3830        return _pywrapcp.Assignment_Add(self, *args)
3831
3832    def ForwardSequence(self, var):
3833        return _pywrapcp.Assignment_ForwardSequence(self, var)
3834
3835    def BackwardSequence(self, var):
3836        return _pywrapcp.Assignment_BackwardSequence(self, var)
3837
3838    def Unperformed(self, var):
3839        return _pywrapcp.Assignment_Unperformed(self, var)
3840
3841    def SetSequence(self, var, forward_sequence, backward_sequence, unperformed):
3842        return _pywrapcp.Assignment_SetSequence(self, var, forward_sequence, backward_sequence, unperformed)
3843
3844    def SetForwardSequence(self, var, forward_sequence):
3845        return _pywrapcp.Assignment_SetForwardSequence(self, var, forward_sequence)
3846
3847    def SetBackwardSequence(self, var, backward_sequence):
3848        return _pywrapcp.Assignment_SetBackwardSequence(self, var, backward_sequence)
3849
3850    def SetUnperformed(self, var, unperformed):
3851        return _pywrapcp.Assignment_SetUnperformed(self, var, unperformed)
3852
3853    def Activate(self, *args):
3854        return _pywrapcp.Assignment_Activate(self, *args)
3855
3856    def Deactivate(self, *args):
3857        return _pywrapcp.Assignment_Deactivate(self, *args)
3858
3859    def Activated(self, *args):
3860        return _pywrapcp.Assignment_Activated(self, *args)
3861
3862    def DebugString(self):
3863        return _pywrapcp.Assignment_DebugString(self)
3864
3865    def IntVarContainer(self):
3866        return _pywrapcp.Assignment_IntVarContainer(self)
3867
3868    def MutableIntVarContainer(self):
3869        return _pywrapcp.Assignment_MutableIntVarContainer(self)
3870
3871    def IntervalVarContainer(self):
3872        return _pywrapcp.Assignment_IntervalVarContainer(self)
3873
3874    def MutableIntervalVarContainer(self):
3875        return _pywrapcp.Assignment_MutableIntervalVarContainer(self)
3876
3877    def SequenceVarContainer(self):
3878        return _pywrapcp.Assignment_SequenceVarContainer(self)
3879
3880    def MutableSequenceVarContainer(self):
3881        return _pywrapcp.Assignment_MutableSequenceVarContainer(self)
3882
3883    def __eq__(self, assignment):
3884        return _pywrapcp.Assignment___eq__(self, assignment)
3885
3886    def __ne__(self, assignment):
3887        return _pywrapcp.Assignment___ne__(self, assignment)
3888
3889# Register Assignment in _pywrapcp:
3890_pywrapcp.Assignment_swigregister(Assignment)
3891
3892def __lshift__(*args):
3893    return _pywrapcp.__lshift__(*args)
3894class Pack(Constraint):
3895    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3896
3897    def __init__(self, *args, **kwargs):
3898        raise AttributeError("No constructor defined")
3899    __repr__ = _swig_repr
3900
3901    def AddWeightedSumLessOrEqualConstantDimension(self, *args):
3902        r"""
3903        *Overload 1:*
3904        Dimensions are additional constraints than can restrict what is
3905        possible with the pack constraint. It can be used to set capacity
3906        limits, to count objects per bin, to compute unassigned
3907        penalties...
3908        This dimension imposes that for all bins b, the weighted sum
3909        (weights[i]) of all objects i assigned to 'b' is less or equal
3910        'bounds[b]'.
3911
3912        |
3913
3914        *Overload 2:*
3915        This dimension imposes that for all bins b, the weighted sum
3916        (weights->Run(i)) of all objects i assigned to 'b' is less or
3917        equal to 'bounds[b]'. Ownership of the callback is transferred to
3918        the pack constraint.
3919
3920        |
3921
3922        *Overload 3:*
3923        This dimension imposes that for all bins b, the weighted sum
3924        (weights->Run(i, b) of all objects i assigned to 'b' is less or
3925        equal to 'bounds[b]'. Ownership of the callback is transferred to
3926        the pack constraint.
3927        """
3928        return _pywrapcp.Pack_AddWeightedSumLessOrEqualConstantDimension(self, *args)
3929
3930    def AddWeightedSumEqualVarDimension(self, *args):
3931        r"""
3932        *Overload 1:*
3933        This dimension imposes that for all bins b, the weighted sum
3934        (weights[i]) of all objects i assigned to 'b' is equal to loads[b].
3935
3936        |
3937
3938        *Overload 2:*
3939        This dimension imposes that for all bins b, the weighted sum
3940        (weights->Run(i, b)) of all objects i assigned to 'b' is equal to
3941        loads[b].
3942        """
3943        return _pywrapcp.Pack_AddWeightedSumEqualVarDimension(self, *args)
3944
3945    def AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity):
3946        r"""
3947        This dimension imposes:
3948        forall b in bins,
3949           sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b]
3950        where is_assigned(i, b) is true if and only if item i is assigned
3951        to the bin b.
3952
3953        This can be used to model shapes of items by linking variables of
3954        the same item on parallel dimensions with an allowed assignment
3955        constraint.
3956        """
3957        return _pywrapcp.Pack_AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity)
3958
3959    def AddWeightedSumOfAssignedDimension(self, weights, cost_var):
3960        r"""
3961        This dimension enforces that cost_var == sum of weights[i] for
3962        all objects 'i' assigned to a bin.
3963        """
3964        return _pywrapcp.Pack_AddWeightedSumOfAssignedDimension(self, weights, cost_var)
3965
3966    def AddCountUsedBinDimension(self, count_var):
3967        r"""
3968        This dimension links 'count_var' to the actual number of bins used in the
3969        pack.
3970        """
3971        return _pywrapcp.Pack_AddCountUsedBinDimension(self, count_var)
3972
3973    def AddCountAssignedItemsDimension(self, count_var):
3974        r"""
3975        This dimension links 'count_var' to the actual number of items
3976        assigned to a bin in the pack.
3977        """
3978        return _pywrapcp.Pack_AddCountAssignedItemsDimension(self, count_var)
3979
3980    def Post(self):
3981        return _pywrapcp.Pack_Post(self)
3982
3983    def InitialPropagateWrapper(self):
3984        return _pywrapcp.Pack_InitialPropagateWrapper(self)
3985
3986    def DebugString(self):
3987        return _pywrapcp.Pack_DebugString(self)
3988
3989# Register Pack in _pywrapcp:
3990_pywrapcp.Pack_swigregister(Pack)
3991class DisjunctiveConstraint(Constraint):
3992    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3993
3994    def __init__(self, *args, **kwargs):
3995        raise AttributeError("No constructor defined - class is abstract")
3996    __repr__ = _swig_repr
3997
3998    def SequenceVar(self):
3999        r"""Creates a sequence variable from the constraint."""
4000        return _pywrapcp.DisjunctiveConstraint_SequenceVar(self)
4001
4002    def SetTransitionTime(self, transition_time):
4003        r"""
4004        Add a transition time between intervals.  It forces the distance between
4005        the end of interval a and start of interval b that follows it to be at
4006        least transition_time(a, b). This function must always return
4007        a positive or null value.
4008        """
4009        return _pywrapcp.DisjunctiveConstraint_SetTransitionTime(self, transition_time)
4010
4011    def TransitionTime(self, before_index, after_index):
4012        return _pywrapcp.DisjunctiveConstraint_TransitionTime(self, before_index, after_index)
4013
4014# Register DisjunctiveConstraint in _pywrapcp:
4015_pywrapcp.DisjunctiveConstraint_swigregister(DisjunctiveConstraint)
4016class RevInteger(object):
4017    r"""
4018    This class adds reversibility to a POD type.
4019    It contains the stamp optimization. i.e. the SaveValue call is done
4020    only once per node of the search tree.  Please note that actual
4021    stamps always starts at 1, thus an initial value of 0 will always
4022    trigger the first SaveValue.
4023    """
4024
4025    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4026    __repr__ = _swig_repr
4027
4028    def __init__(self, val):
4029        _pywrapcp.RevInteger_swiginit(self, _pywrapcp.new_RevInteger(val))
4030
4031    def Value(self):
4032        return _pywrapcp.RevInteger_Value(self)
4033
4034    def SetValue(self, s, val):
4035        return _pywrapcp.RevInteger_SetValue(self, s, val)
4036    __swig_destroy__ = _pywrapcp.delete_RevInteger
4037
4038# Register RevInteger in _pywrapcp:
4039_pywrapcp.RevInteger_swigregister(RevInteger)
4040class NumericalRevInteger(RevInteger):
4041    r"""Subclass of Rev<T> which adds numerical operations."""
4042
4043    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4044    __repr__ = _swig_repr
4045
4046    def __init__(self, val):
4047        _pywrapcp.NumericalRevInteger_swiginit(self, _pywrapcp.new_NumericalRevInteger(val))
4048
4049    def Add(self, s, to_add):
4050        return _pywrapcp.NumericalRevInteger_Add(self, s, to_add)
4051
4052    def Incr(self, s):
4053        return _pywrapcp.NumericalRevInteger_Incr(self, s)
4054
4055    def Decr(self, s):
4056        return _pywrapcp.NumericalRevInteger_Decr(self, s)
4057    __swig_destroy__ = _pywrapcp.delete_NumericalRevInteger
4058
4059# Register NumericalRevInteger in _pywrapcp:
4060_pywrapcp.NumericalRevInteger_swigregister(NumericalRevInteger)
4061class RevBool(object):
4062    r"""
4063    This class adds reversibility to a POD type.
4064    It contains the stamp optimization. i.e. the SaveValue call is done
4065    only once per node of the search tree.  Please note that actual
4066    stamps always starts at 1, thus an initial value of 0 will always
4067    trigger the first SaveValue.
4068    """
4069
4070    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4071    __repr__ = _swig_repr
4072
4073    def __init__(self, val):
4074        _pywrapcp.RevBool_swiginit(self, _pywrapcp.new_RevBool(val))
4075
4076    def Value(self):
4077        return _pywrapcp.RevBool_Value(self)
4078
4079    def SetValue(self, s, val):
4080        return _pywrapcp.RevBool_SetValue(self, s, val)
4081    __swig_destroy__ = _pywrapcp.delete_RevBool
4082
4083# Register RevBool in _pywrapcp:
4084_pywrapcp.RevBool_swigregister(RevBool)
4085class IntVarContainer(object):
4086    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4087
4088    def __init__(self, *args, **kwargs):
4089        raise AttributeError("No constructor defined")
4090    __repr__ = _swig_repr
4091
4092    def Contains(self, var):
4093        return _pywrapcp.IntVarContainer_Contains(self, var)
4094
4095    def Element(self, index):
4096        return _pywrapcp.IntVarContainer_Element(self, index)
4097
4098    def Size(self):
4099        return _pywrapcp.IntVarContainer_Size(self)
4100
4101    def Store(self):
4102        return _pywrapcp.IntVarContainer_Store(self)
4103
4104    def Restore(self):
4105        return _pywrapcp.IntVarContainer_Restore(self)
4106
4107    def __eq__(self, container):
4108        r"""
4109        Returns true if this and 'container' both represent the same V* -> E map.
4110        Runs in linear time; requires that the == operator on the type E is well
4111        defined.
4112        """
4113        return _pywrapcp.IntVarContainer___eq__(self, container)
4114
4115    def __ne__(self, container):
4116        return _pywrapcp.IntVarContainer___ne__(self, container)
4117    __swig_destroy__ = _pywrapcp.delete_IntVarContainer
4118
4119# Register IntVarContainer in _pywrapcp:
4120_pywrapcp.IntVarContainer_swigregister(IntVarContainer)
4121class IntervalVarContainer(object):
4122    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4123
4124    def __init__(self, *args, **kwargs):
4125        raise AttributeError("No constructor defined")
4126    __repr__ = _swig_repr
4127
4128    def Contains(self, var):
4129        return _pywrapcp.IntervalVarContainer_Contains(self, var)
4130
4131    def Element(self, index):
4132        return _pywrapcp.IntervalVarContainer_Element(self, index)
4133
4134    def Size(self):
4135        return _pywrapcp.IntervalVarContainer_Size(self)
4136
4137    def Store(self):
4138        return _pywrapcp.IntervalVarContainer_Store(self)
4139
4140    def Restore(self):
4141        return _pywrapcp.IntervalVarContainer_Restore(self)
4142
4143    def __eq__(self, container):
4144        r"""
4145        Returns true if this and 'container' both represent the same V* -> E map.
4146        Runs in linear time; requires that the == operator on the type E is well
4147        defined.
4148        """
4149        return _pywrapcp.IntervalVarContainer___eq__(self, container)
4150
4151    def __ne__(self, container):
4152        return _pywrapcp.IntervalVarContainer___ne__(self, container)
4153    __swig_destroy__ = _pywrapcp.delete_IntervalVarContainer
4154
4155# Register IntervalVarContainer in _pywrapcp:
4156_pywrapcp.IntervalVarContainer_swigregister(IntervalVarContainer)
4157class SequenceVarContainer(object):
4158    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4159
4160    def __init__(self, *args, **kwargs):
4161        raise AttributeError("No constructor defined")
4162    __repr__ = _swig_repr
4163
4164    def Contains(self, var):
4165        return _pywrapcp.SequenceVarContainer_Contains(self, var)
4166
4167    def Element(self, index):
4168        return _pywrapcp.SequenceVarContainer_Element(self, index)
4169
4170    def Size(self):
4171        return _pywrapcp.SequenceVarContainer_Size(self)
4172
4173    def Store(self):
4174        return _pywrapcp.SequenceVarContainer_Store(self)
4175
4176    def Restore(self):
4177        return _pywrapcp.SequenceVarContainer_Restore(self)
4178
4179    def __eq__(self, container):
4180        r"""
4181        Returns true if this and 'container' both represent the same V* -> E map.
4182        Runs in linear time; requires that the == operator on the type E is well
4183        defined.
4184        """
4185        return _pywrapcp.SequenceVarContainer___eq__(self, container)
4186
4187    def __ne__(self, container):
4188        return _pywrapcp.SequenceVarContainer___ne__(self, container)
4189    __swig_destroy__ = _pywrapcp.delete_SequenceVarContainer
4190
4191# Register SequenceVarContainer in _pywrapcp:
4192_pywrapcp.SequenceVarContainer_swigregister(SequenceVarContainer)
4193class LocalSearchOperator(BaseObject):
4194    r"""
4195    The base class for all local search operators.
4196
4197    A local search operator is an object that defines the neighborhood of a
4198    solution. In other words, a neighborhood is the set of solutions which can
4199    be reached from a given solution using an operator.
4200
4201    The behavior of the LocalSearchOperator class is similar to iterators.
4202    The operator is synchronized with an assignment (gives the
4203    current values of the variables); this is done in the Start() method.
4204
4205    Then one can iterate over the neighbors using the MakeNextNeighbor method.
4206    This method returns an assignment which represents the incremental changes
4207    to the current solution. It also returns a second assignment representing
4208    the changes to the last solution defined by the neighborhood operator; this
4209    assignment is empty if the neighborhood operator cannot track this
4210    information.
4211    """
4212
4213    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4214
4215    def __init__(self, *args, **kwargs):
4216        raise AttributeError("No constructor defined - class is abstract")
4217    __repr__ = _swig_repr
4218
4219    def NextNeighbor(self, delta, deltadelta):
4220        return _pywrapcp.LocalSearchOperator_NextNeighbor(self, delta, deltadelta)
4221
4222    def Start(self, assignment):
4223        return _pywrapcp.LocalSearchOperator_Start(self, assignment)
4224    def __disown__(self):
4225        self.this.disown()
4226        _pywrapcp.disown_LocalSearchOperator(self)
4227        return weakref.proxy(self)
4228
4229# Register LocalSearchOperator in _pywrapcp:
4230_pywrapcp.LocalSearchOperator_swigregister(LocalSearchOperator)
4231class IntVarLocalSearchOperator(LocalSearchOperator):
4232    r"""
4233    Specialization of LocalSearchOperator built from an array of IntVars
4234    which specifies the scope of the operator.
4235    This class also takes care of storing current variable values in Start(),
4236    keeps track of changes done by the operator and builds the delta.
4237    The Deactivate() method can be used to perform Large Neighborhood Search.
4238    """
4239
4240    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4241    __repr__ = _swig_repr
4242
4243    def __init__(self, vars, keep_inverse_values=False):
4244        if self.__class__ == IntVarLocalSearchOperator:
4245            _self = None
4246        else:
4247            _self = self
4248        _pywrapcp.IntVarLocalSearchOperator_swiginit(self, _pywrapcp.new_IntVarLocalSearchOperator(_self, vars, keep_inverse_values))
4249    __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchOperator
4250
4251    def Start(self, assignment):
4252        r"""
4253        This method should not be overridden. Override OnStart() instead which is
4254        called before exiting this method.
4255        """
4256        return _pywrapcp.IntVarLocalSearchOperator_Start(self, assignment)
4257
4258    def IsIncremental(self):
4259        return _pywrapcp.IntVarLocalSearchOperator_IsIncremental(self)
4260
4261    def Size(self):
4262        return _pywrapcp.IntVarLocalSearchOperator_Size(self)
4263
4264    def Value(self, index):
4265        r"""
4266        Returns the value in the current assignment of the variable of given
4267        index.
4268        """
4269        return _pywrapcp.IntVarLocalSearchOperator_Value(self, index)
4270
4271    def Var(self, index):
4272        r"""Returns the variable of given index."""
4273        return _pywrapcp.IntVarLocalSearchOperator_Var(self, index)
4274
4275    def OldValue(self, index):
4276        return _pywrapcp.IntVarLocalSearchOperator_OldValue(self, index)
4277
4278    def PrevValue(self, index):
4279        return _pywrapcp.IntVarLocalSearchOperator_PrevValue(self, index)
4280
4281    def SetValue(self, index, value):
4282        return _pywrapcp.IntVarLocalSearchOperator_SetValue(self, index, value)
4283
4284    def Activated(self, index):
4285        return _pywrapcp.IntVarLocalSearchOperator_Activated(self, index)
4286
4287    def Activate(self, index):
4288        return _pywrapcp.IntVarLocalSearchOperator_Activate(self, index)
4289
4290    def Deactivate(self, index):
4291        return _pywrapcp.IntVarLocalSearchOperator_Deactivate(self, index)
4292
4293    def AddVars(self, vars):
4294        return _pywrapcp.IntVarLocalSearchOperator_AddVars(self, vars)
4295
4296    def OnStart(self):
4297        r"""
4298        Called by Start() after synchronizing the operator with the current
4299        assignment. Should be overridden instead of Start() to avoid calling
4300        IntVarLocalSearchOperator::Start explicitly.
4301        """
4302        return _pywrapcp.IntVarLocalSearchOperator_OnStart(self)
4303
4304    def NextNeighbor(self, delta, deltadelta):
4305        r"""
4306        OnStart() should really be protected, but then SWIG doesn't see it. So we
4307        make it public, but only subclasses should access to it (to override it).
4308        Redefines MakeNextNeighbor to export a simpler interface. The calls to
4309        ApplyChanges() and RevertChanges() are factored in this method, hiding
4310        both delta and deltadelta from subclasses which only need to override
4311        MakeOneNeighbor().
4312        Therefore this method should not be overridden. Override MakeOneNeighbor()
4313        instead.
4314        """
4315        return _pywrapcp.IntVarLocalSearchOperator_NextNeighbor(self, delta, deltadelta)
4316
4317    def OneNeighbor(self):
4318        r"""
4319        Creates a new neighbor. It returns false when the neighborhood is
4320        completely explored.
4321        MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.
4322        """
4323        return _pywrapcp.IntVarLocalSearchOperator_OneNeighbor(self)
4324    def __disown__(self):
4325        self.this.disown()
4326        _pywrapcp.disown_IntVarLocalSearchOperator(self)
4327        return weakref.proxy(self)
4328
4329# Register IntVarLocalSearchOperator in _pywrapcp:
4330_pywrapcp.IntVarLocalSearchOperator_swigregister(IntVarLocalSearchOperator)
4331class BaseLns(IntVarLocalSearchOperator):
4332    r"""
4333    This is the base class for building an Lns operator. An Lns fragment is a
4334    collection of variables which will be relaxed. Fragments are built with
4335    NextFragment(), which returns false if there are no more fragments to build.
4336    Optionally one can override InitFragments, which is called from
4337    LocalSearchOperator::Start to initialize fragment data.
4338
4339    Here's a sample relaxing one variable at a time:
4340
4341    class OneVarLns : public BaseLns {
4342     public:
4343      OneVarLns(const std::vector<IntVar*>& vars) : BaseLns(vars), index_(0) {}
4344      virtual ~OneVarLns() {}
4345      virtual void InitFragments() { index_ = 0; }
4346      virtual bool NextFragment() {
4347        const int size = Size();
4348        if (index_ < size) {
4349          AppendToFragment(index_);
4350          ++index_;
4351          return true;
4352        } else {
4353          return false;
4354        }
4355      }
4356
4357     private:
4358      int index_;
4359    };
4360    """
4361
4362    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4363    __repr__ = _swig_repr
4364
4365    def __init__(self, vars):
4366        if self.__class__ == BaseLns:
4367            _self = None
4368        else:
4369            _self = self
4370        _pywrapcp.BaseLns_swiginit(self, _pywrapcp.new_BaseLns(_self, vars))
4371    __swig_destroy__ = _pywrapcp.delete_BaseLns
4372
4373    def InitFragments(self):
4374        return _pywrapcp.BaseLns_InitFragments(self)
4375
4376    def NextFragment(self):
4377        return _pywrapcp.BaseLns_NextFragment(self)
4378
4379    def AppendToFragment(self, index):
4380        return _pywrapcp.BaseLns_AppendToFragment(self, index)
4381
4382    def FragmentSize(self):
4383        return _pywrapcp.BaseLns_FragmentSize(self)
4384
4385    def __getitem__(self, index):
4386        return _pywrapcp.BaseLns___getitem__(self, index)
4387
4388    def __len__(self):
4389        return _pywrapcp.BaseLns___len__(self)
4390    def __disown__(self):
4391        self.this.disown()
4392        _pywrapcp.disown_BaseLns(self)
4393        return weakref.proxy(self)
4394
4395# Register BaseLns in _pywrapcp:
4396_pywrapcp.BaseLns_swigregister(BaseLns)
4397class ChangeValue(IntVarLocalSearchOperator):
4398    r"""
4399    Defines operators which change the value of variables;
4400    each neighbor corresponds to *one* modified variable.
4401    Sub-classes have to define ModifyValue which determines what the new
4402    variable value is going to be (given the current value and the variable).
4403    """
4404
4405    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4406    __repr__ = _swig_repr
4407
4408    def __init__(self, vars):
4409        if self.__class__ == ChangeValue:
4410            _self = None
4411        else:
4412            _self = self
4413        _pywrapcp.ChangeValue_swiginit(self, _pywrapcp.new_ChangeValue(_self, vars))
4414    __swig_destroy__ = _pywrapcp.delete_ChangeValue
4415
4416    def ModifyValue(self, index, value):
4417        return _pywrapcp.ChangeValue_ModifyValue(self, index, value)
4418
4419    def OneNeighbor(self):
4420        r"""This method should not be overridden. Override ModifyValue() instead."""
4421        return _pywrapcp.ChangeValue_OneNeighbor(self)
4422    def __disown__(self):
4423        self.this.disown()
4424        _pywrapcp.disown_ChangeValue(self)
4425        return weakref.proxy(self)
4426
4427# Register ChangeValue in _pywrapcp:
4428_pywrapcp.ChangeValue_swigregister(ChangeValue)
4429class LocalSearchFilter(BaseObject):
4430    r"""
4431    Local Search Filters are used for fast neighbor pruning.
4432    Filtering a move is done in several phases:
4433    - in the Relax phase, filters determine which parts of their internals
4434      will be changed by the candidate, and modify intermediary State
4435    - in the Accept phase, filters check that the candidate is feasible,
4436    - if the Accept phase succeeds, the solver may decide to trigger a
4437      Synchronize phase that makes filters change their internal representation
4438      to the last candidate,
4439    - otherwise (Accept fails or the solver does not want to synchronize),
4440      a Revert phase makes filters erase any intermediary State generated by the
4441      Relax and Accept phases.
4442    A given filter has phases called with the following pattern:
4443    (Relax.Accept.Synchronize | Relax.Accept.Revert | Relax.Revert)*.
4444    Filters's Revert() is always called in the reverse order their Accept() was
4445    called, to allow late filters to use state done/undone by early filters'
4446    Accept()/Revert().
4447    """
4448
4449    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4450
4451    def __init__(self, *args, **kwargs):
4452        raise AttributeError("No constructor defined - class is abstract")
4453    __repr__ = _swig_repr
4454
4455    def Accept(self, delta, deltadelta, objective_min, objective_max):
4456        r"""
4457        Accepts a "delta" given the assignment with which the filter has been
4458        synchronized; the delta holds the variables which have been modified and
4459        their new value.
4460        If the filter represents a part of the global objective, its contribution
4461        must be between objective_min and objective_max.
4462        Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1,
4463        for the assignment (a,1), (b,0), the delta (b,1) will be rejected
4464        but the delta (a,0) will be accepted.
4465        TODO(user): Remove arguments when there are no more need for those.
4466        """
4467        return _pywrapcp.LocalSearchFilter_Accept(self, delta, deltadelta, objective_min, objective_max)
4468
4469    def IsIncremental(self):
4470        return _pywrapcp.LocalSearchFilter_IsIncremental(self)
4471
4472    def Synchronize(self, assignment, delta):
4473        r"""
4474        Synchronizes the filter with the current solution, delta being the
4475        difference with the solution passed to the previous call to Synchronize()
4476        or IncrementalSynchronize(). 'delta' can be used to incrementally
4477        synchronizing the filter with the new solution by only considering the
4478        changes in delta.
4479        """
4480        return _pywrapcp.LocalSearchFilter_Synchronize(self, assignment, delta)
4481    __swig_destroy__ = _pywrapcp.delete_LocalSearchFilter
4482
4483# Register LocalSearchFilter in _pywrapcp:
4484_pywrapcp.LocalSearchFilter_swigregister(LocalSearchFilter)
4485class LocalSearchFilterManager(BaseObject):
4486    r"""
4487    Filter manager: when a move is made, filters are executed to decide whether
4488    the solution is feasible and compute parts of the new cost. This class
4489    schedules filter execution and composes costs as a sum.
4490    """
4491
4492    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4493    __repr__ = _swig_repr
4494
4495    def DebugString(self):
4496        return _pywrapcp.LocalSearchFilterManager_DebugString(self)
4497
4498    def __init__(self, *args):
4499        _pywrapcp.LocalSearchFilterManager_swiginit(self, _pywrapcp.new_LocalSearchFilterManager(*args))
4500
4501    def Accept(self, monitor, delta, deltadelta, objective_min, objective_max):
4502        r"""
4503        Returns true iff all filters return true, and the sum of their accepted
4504        objectives is between objective_min and objective_max.
4505        The monitor has its Begin/EndFiltering events triggered.
4506        """
4507        return _pywrapcp.LocalSearchFilterManager_Accept(self, monitor, delta, deltadelta, objective_min, objective_max)
4508
4509    def Synchronize(self, assignment, delta):
4510        r"""Synchronizes all filters to assignment."""
4511        return _pywrapcp.LocalSearchFilterManager_Synchronize(self, assignment, delta)
4512    __swig_destroy__ = _pywrapcp.delete_LocalSearchFilterManager
4513
4514# Register LocalSearchFilterManager in _pywrapcp:
4515_pywrapcp.LocalSearchFilterManager_swigregister(LocalSearchFilterManager)
4516class IntVarLocalSearchFilter(LocalSearchFilter):
4517    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4518    __repr__ = _swig_repr
4519
4520    def __init__(self, vars):
4521        if self.__class__ == IntVarLocalSearchFilter:
4522            _self = None
4523        else:
4524            _self = self
4525        _pywrapcp.IntVarLocalSearchFilter_swiginit(self, _pywrapcp.new_IntVarLocalSearchFilter(_self, vars))
4526    __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchFilter
4527
4528    def Synchronize(self, assignment, delta):
4529        r"""
4530        This method should not be overridden. Override OnSynchronize() instead
4531        which is called before exiting this method.
4532        """
4533        return _pywrapcp.IntVarLocalSearchFilter_Synchronize(self, assignment, delta)
4534
4535    def Size(self):
4536        return _pywrapcp.IntVarLocalSearchFilter_Size(self)
4537
4538    def Value(self, index):
4539        return _pywrapcp.IntVarLocalSearchFilter_Value(self, index)
4540
4541    def IndexFromVar(self, var):
4542        return _pywrapcp.IntVarLocalSearchFilter_IndexFromVar(self, var)
4543    def __disown__(self):
4544        self.this.disown()
4545        _pywrapcp.disown_IntVarLocalSearchFilter(self)
4546        return weakref.proxy(self)
4547
4548# Register IntVarLocalSearchFilter in _pywrapcp:
4549_pywrapcp.IntVarLocalSearchFilter_swigregister(IntVarLocalSearchFilter)
4550class BooleanVar(IntVar):
4551    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4552
4553    def __init__(self, *args, **kwargs):
4554        raise AttributeError("No constructor defined - class is abstract")
4555    __repr__ = _swig_repr
4556
4557    def Min(self):
4558        return _pywrapcp.BooleanVar_Min(self)
4559
4560    def SetMin(self, m):
4561        return _pywrapcp.BooleanVar_SetMin(self, m)
4562
4563    def Max(self):
4564        return _pywrapcp.BooleanVar_Max(self)
4565
4566    def SetMax(self, m):
4567        return _pywrapcp.BooleanVar_SetMax(self, m)
4568
4569    def SetRange(self, mi, ma):
4570        return _pywrapcp.BooleanVar_SetRange(self, mi, ma)
4571
4572    def Bound(self):
4573        return _pywrapcp.BooleanVar_Bound(self)
4574
4575    def Value(self):
4576        return _pywrapcp.BooleanVar_Value(self)
4577
4578    def RemoveValue(self, v):
4579        return _pywrapcp.BooleanVar_RemoveValue(self, v)
4580
4581    def RemoveInterval(self, l, u):
4582        return _pywrapcp.BooleanVar_RemoveInterval(self, l, u)
4583
4584    def WhenBound(self, d):
4585        return _pywrapcp.BooleanVar_WhenBound(self, d)
4586
4587    def WhenRange(self, d):
4588        return _pywrapcp.BooleanVar_WhenRange(self, d)
4589
4590    def WhenDomain(self, d):
4591        return _pywrapcp.BooleanVar_WhenDomain(self, d)
4592
4593    def Size(self):
4594        return _pywrapcp.BooleanVar_Size(self)
4595
4596    def Contains(self, v):
4597        return _pywrapcp.BooleanVar_Contains(self, v)
4598
4599    def HoleIteratorAux(self, reversible):
4600        return _pywrapcp.BooleanVar_HoleIteratorAux(self, reversible)
4601
4602    def DomainIteratorAux(self, reversible):
4603        return _pywrapcp.BooleanVar_DomainIteratorAux(self, reversible)
4604
4605    def DebugString(self):
4606        return _pywrapcp.BooleanVar_DebugString(self)
4607
4608# Register BooleanVar in _pywrapcp:
4609_pywrapcp.BooleanVar_swigregister(BooleanVar)
4610
4611class PyDecision(Decision):
4612  def ApplyWrapper(self, solver):
4613    try:
4614       self.Apply(solver)
4615    except Exception as e:
4616      if 'CP Solver fail' in str(e):
4617        solver.ShouldFail()
4618      else:
4619        raise
4620
4621  def RefuteWrapper(self, solver):
4622    try:
4623       self.Refute(solver)
4624    except Exception as e:
4625      if 'CP Solver fail' in str(e):
4626        solver.ShouldFail()
4627      else:
4628        raise
4629
4630  def DebugString(self):
4631    return "PyDecision"
4632
4633
4634class PyDecisionBuilder(DecisionBuilder):
4635  def NextWrapper(self, solver):
4636    try:
4637      return self.Next(solver)
4638    except Exception as e:
4639      if 'CP Solver fail' in str(e):
4640        return solver.FailDecision()
4641      else:
4642        raise
4643
4644  def DebugString(self):
4645    return "PyDecisionBuilder"
4646
4647
4648class PyDemon(Demon):
4649  def RunWrapper(self, solver):
4650    try:
4651      self.Run(solver)
4652    except Exception as e:
4653      if 'CP Solver fail' in str(e):
4654        solver.ShouldFail()
4655      else:
4656        raise
4657
4658  def DebugString(self):
4659    return "PyDemon"
4660
4661
4662class PyConstraintDemon(PyDemon):
4663  def __init__(self, ct, method, delayed, *args):
4664    super().__init__()
4665    self.__constraint = ct
4666    self.__method = method
4667    self.__delayed = delayed
4668    self.__args = args
4669
4670  def Run(self, solver):
4671    self.__method(self.__constraint, *self.__args)
4672
4673  def Priority(self):
4674    return Solver.DELAYED_PRIORITY if self.__delayed else Solver.NORMAL_PRIORITY
4675
4676  def DebugString(self):
4677    return 'PyConstraintDemon'
4678
4679
4680class PyConstraint(Constraint):
4681  def __init__(self, solver):
4682    super().__init__(solver)
4683    self.__demons = []
4684
4685  def Demon(self, method, *args):
4686    demon = PyConstraintDemon(self, method, False, *args)
4687    self.__demons.append(demon)
4688    return demon
4689
4690  def DelayedDemon(self, method, *args):
4691    demon = PyConstraintDemon(self, method, True, *args)
4692    self.__demons.append(demon)
4693    return demon
4694
4695  def InitialPropagateDemon(self):
4696    return self.solver().ConstraintInitialPropagateCallback(self)
4697
4698  def DelayedInitialPropagateDemon(self):
4699    return self.solver().DelayedConstraintInitialPropagateCallback(self)
4700
4701  def InitialPropagateWrapper(self):
4702    try:
4703      self.InitialPropagate()
4704    except Exception as e:
4705      if 'CP Solver fail' in str(e):
4706        self.solver().ShouldFail()
4707      else:
4708        raise
4709
4710  def DebugString(self):
4711    return "PyConstraint"
4712
4713class RoutingIndexManager(object):
4714    r"""
4715    Manager for any NodeIndex <-> variable index conversion. The routing solver
4716    uses variable indices internally and through its API. These variable indices
4717    are tricky to manage directly because one Node can correspond to a multitude
4718    of variables, depending on the number of times they appear in the model, and
4719    if they're used as start and/or end points. This class aims to simplify
4720    variable index usage, allowing users to use NodeIndex instead.
4721
4722    Usage:
4723
4724      .. code-block:: c++
4725
4726          auto starts_ends = ...;  /// These are NodeIndex.
4727          RoutingIndexManager manager(10, 4, starts_ends);  // 10 nodes, 4 vehicles.
4728          RoutingModel model(manager);
4729
4730    Then, use 'manager.NodeToIndex(node)' whenever model requires a variable
4731    index.
4732
4733    Note: the mapping between node indices and variables indices is subject to
4734    change so no assumption should be made on it. The only guarantee is that
4735    indices range between 0 and n-1, where n = number of vehicles * 2 (for start
4736    and end nodes) + number of non-start or end nodes.
4737    """
4738
4739    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4740    __repr__ = _swig_repr
4741
4742    def __init__(self, *args):
4743        r"""
4744        Creates a NodeIndex to variable index mapping for a problem containing
4745        'num_nodes', 'num_vehicles' and the given starts and ends for each
4746        vehicle. If used, any start/end arrays have to have exactly 'num_vehicles'
4747        elements.
4748        """
4749        _pywrapcp.RoutingIndexManager_swiginit(self, _pywrapcp.new_RoutingIndexManager(*args))
4750
4751    def GetNumberOfNodes(self):
4752        return _pywrapcp.RoutingIndexManager_GetNumberOfNodes(self)
4753
4754    def GetNumberOfVehicles(self):
4755        return _pywrapcp.RoutingIndexManager_GetNumberOfVehicles(self)
4756
4757    def GetNumberOfIndices(self):
4758        return _pywrapcp.RoutingIndexManager_GetNumberOfIndices(self)
4759
4760    def GetStartIndex(self, vehicle):
4761        return _pywrapcp.RoutingIndexManager_GetStartIndex(self, vehicle)
4762
4763    def GetEndIndex(self, vehicle):
4764        return _pywrapcp.RoutingIndexManager_GetEndIndex(self, vehicle)
4765
4766    def NodeToIndex(self, node):
4767        return _pywrapcp.RoutingIndexManager_NodeToIndex(self, node)
4768
4769    def IndexToNode(self, index):
4770        return _pywrapcp.RoutingIndexManager_IndexToNode(self, index)
4771    __swig_destroy__ = _pywrapcp.delete_RoutingIndexManager
4772
4773# Register RoutingIndexManager in _pywrapcp:
4774_pywrapcp.RoutingIndexManager_swigregister(RoutingIndexManager)
4775
4776def DefaultRoutingModelParameters():
4777    return _pywrapcp.DefaultRoutingModelParameters()
4778
4779def DefaultRoutingSearchParameters():
4780    return _pywrapcp.DefaultRoutingSearchParameters()
4781
4782def FindErrorInRoutingSearchParameters(search_parameters):
4783    r"""
4784    Returns an empty std::string if the routing search parameters are valid, and
4785    a non-empty, human readable error description if they're not.
4786    """
4787    return _pywrapcp.FindErrorInRoutingSearchParameters(search_parameters)
4788BOOL_UNSPECIFIED = _pywrapcp.BOOL_UNSPECIFIED
4789BOOL_FALSE = _pywrapcp.BOOL_FALSE
4790BOOL_TRUE = _pywrapcp.BOOL_TRUE
4791class FirstSolutionStrategy(object):
4792    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4793    __repr__ = _swig_repr
4794
4795    def __init__(self):
4796        _pywrapcp.FirstSolutionStrategy_swiginit(self, _pywrapcp.new_FirstSolutionStrategy())
4797    __swig_destroy__ = _pywrapcp.delete_FirstSolutionStrategy
4798
4799# Register FirstSolutionStrategy in _pywrapcp:
4800_pywrapcp.FirstSolutionStrategy_swigregister(FirstSolutionStrategy)
4801class LocalSearchMetaheuristic(object):
4802    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4803    __repr__ = _swig_repr
4804
4805    def __init__(self):
4806        _pywrapcp.LocalSearchMetaheuristic_swiginit(self, _pywrapcp.new_LocalSearchMetaheuristic())
4807    __swig_destroy__ = _pywrapcp.delete_LocalSearchMetaheuristic
4808
4809# Register LocalSearchMetaheuristic in _pywrapcp:
4810_pywrapcp.LocalSearchMetaheuristic_swigregister(LocalSearchMetaheuristic)
4811class RoutingSearchStatus(object):
4812    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4813    __repr__ = _swig_repr
4814
4815    def __init__(self):
4816        _pywrapcp.RoutingSearchStatus_swiginit(self, _pywrapcp.new_RoutingSearchStatus())
4817    __swig_destroy__ = _pywrapcp.delete_RoutingSearchStatus
4818
4819# Register RoutingSearchStatus in _pywrapcp:
4820_pywrapcp.RoutingSearchStatus_swigregister(RoutingSearchStatus)
4821class PathsMetadata(object):
4822    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4823    __repr__ = _swig_repr
4824
4825    def __init__(self, manager):
4826        _pywrapcp.PathsMetadata_swiginit(self, _pywrapcp.new_PathsMetadata(manager))
4827
4828    def IsStart(self, node):
4829        return _pywrapcp.PathsMetadata_IsStart(self, node)
4830
4831    def IsEnd(self, node):
4832        return _pywrapcp.PathsMetadata_IsEnd(self, node)
4833
4834    def GetPath(self, start_or_end_node):
4835        return _pywrapcp.PathsMetadata_GetPath(self, start_or_end_node)
4836
4837    def NumPaths(self):
4838        return _pywrapcp.PathsMetadata_NumPaths(self)
4839
4840    def Paths(self):
4841        return _pywrapcp.PathsMetadata_Paths(self)
4842
4843    def Starts(self):
4844        return _pywrapcp.PathsMetadata_Starts(self)
4845
4846    def Start(self, path):
4847        return _pywrapcp.PathsMetadata_Start(self, path)
4848
4849    def End(self, path):
4850        return _pywrapcp.PathsMetadata_End(self, path)
4851
4852    def Ends(self):
4853        return _pywrapcp.PathsMetadata_Ends(self)
4854    __swig_destroy__ = _pywrapcp.delete_PathsMetadata
4855
4856# Register PathsMetadata in _pywrapcp:
4857_pywrapcp.PathsMetadata_swigregister(PathsMetadata)
4858class RoutingModel(object):
4859    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4860    __repr__ = _swig_repr
4861    PICKUP_AND_DELIVERY_NO_ORDER = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_NO_ORDER
4862    r"""Any precedence is accepted."""
4863    PICKUP_AND_DELIVERY_LIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_LIFO
4864    r"""Deliveries must be performed in reverse order of pickups."""
4865    PICKUP_AND_DELIVERY_FIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_FIFO
4866    r"""Deliveries must be performed in the same order as pickups."""
4867
4868    def __init__(self, *args):
4869        r"""
4870        Constructor taking an index manager. The version which does not take
4871        RoutingModelParameters is equivalent to passing
4872        DefaultRoutingModelParameters().
4873        """
4874        _pywrapcp.RoutingModel_swiginit(self, _pywrapcp.new_RoutingModel(*args))
4875    __swig_destroy__ = _pywrapcp.delete_RoutingModel
4876    kTransitEvaluatorSignUnknown = _pywrapcp.RoutingModel_kTransitEvaluatorSignUnknown
4877    kTransitEvaluatorSignPositiveOrZero = _pywrapcp.RoutingModel_kTransitEvaluatorSignPositiveOrZero
4878    kTransitEvaluatorSignNegativeOrZero = _pywrapcp.RoutingModel_kTransitEvaluatorSignNegativeOrZero
4879
4880    def RegisterUnaryTransitVector(self, values):
4881        r"""
4882        Registers 'callback' and returns its index.
4883        The sign parameter allows to notify the solver that the callback only
4884        return values of the given sign. This can help the solver, but passing
4885        an incorrect sign may crash in non-opt compilation mode, and yield
4886        incorrect results in opt.
4887        """
4888        return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)
4889
4890    def RegisterUnaryTransitCallback(self, *args):
4891        return _pywrapcp.RoutingModel_RegisterUnaryTransitCallback(self, *args)
4892
4893    def RegisterTransitMatrix(self, values):
4894        return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values)
4895
4896    def RegisterTransitCallback(self, *args):
4897        return _pywrapcp.RoutingModel_RegisterTransitCallback(self, *args)
4898
4899    def RegisterCumulDependentTransitCallback(self, callback):
4900        return _pywrapcp.RoutingModel_RegisterCumulDependentTransitCallback(self, callback)
4901
4902    def TransitCallback(self, callback_index):
4903        return _pywrapcp.RoutingModel_TransitCallback(self, callback_index)
4904
4905    def UnaryTransitCallbackOrNull(self, callback_index):
4906        return _pywrapcp.RoutingModel_UnaryTransitCallbackOrNull(self, callback_index)
4907
4908    def CumulDependentTransitCallback(self, callback_index):
4909        return _pywrapcp.RoutingModel_CumulDependentTransitCallback(self, callback_index)
4910
4911    def AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name):
4912        r"""
4913        Model creation
4914        Methods to add dimensions to routes; dimensions represent quantities
4915        accumulated at nodes along the routes. They represent quantities such as
4916        weights or volumes carried along the route, or distance or times.
4917        Quantities at a node are represented by "cumul" variables and the increase
4918        or decrease of quantities between nodes are represented by "transit"
4919        variables. These variables are linked as follows:
4920        if j == next(i), cumul(j) = cumul(i) + transit(i, j) + slack(i)
4921        where slack is a positive slack variable (can represent waiting times for
4922        a time dimension).
4923        Setting the value of fix_start_cumul_to_zero to true will force the
4924        "cumul" variable of the start node of all vehicles to be equal to 0.
4925        Creates a dimension where the transit variable is constrained to be
4926        equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the
4927        slack variable and 'capacity' is the upper bound of the cumul variables.
4928        'name' is the name used to reference the dimension; this name is used to
4929        get cumul and transit variables from the routing model.
4930        Returns false if a dimension with the same name has already been created
4931        (and doesn't create the new dimension).
4932        Takes ownership of the callback 'evaluator'.
4933        """
4934        return _pywrapcp.RoutingModel_AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name)
4935
4936    def AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name):
4937        return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name)
4938
4939    def AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4940        return _pywrapcp.RoutingModel_AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
4941
4942    def AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4943        return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
4944
4945    def AddDimensionWithCumulDependentVehicleTransitAndCapacity(self, fixed_evaluator_indices, cumul_dependent_evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4946        r"""
4947        Creates a dimension where the transit variable on arc i->j is the sum of:
4948        - A "fixed" transit value, obtained from the fixed_evaluator_index for
4949          this vehicle, referencing evaluators in transit_evaluators_, and
4950        - A FloatSlopePiecewiseLinearFunction of the cumul of node i, obtained
4951          from the cumul_dependent_evaluator_index of this vehicle, pointing to
4952          an evaluator in cumul_dependent_transit_evaluators_.
4953        """
4954        return _pywrapcp.RoutingModel_AddDimensionWithCumulDependentVehicleTransitAndCapacity(self, fixed_evaluator_indices, cumul_dependent_evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
4955
4956    def AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name):
4957        r"""
4958        Creates a dimension where the transit variable is constrained to be
4959        equal to 'value'; 'capacity' is the upper bound of the cumul variables.
4960        'name' is the name used to reference the dimension; this name is used to
4961        get cumul and transit variables from the routing model.
4962        Returns a pair consisting of an index to the registered unary transit
4963        callback and a bool denoting whether the dimension has been created.
4964        It is false if a dimension with the same name has already been created
4965        (and doesn't create the new dimension but still register a new callback).
4966        """
4967        return _pywrapcp.RoutingModel_AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name)
4968
4969    def AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name):
4970        return _pywrapcp.RoutingModel_AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name)
4971
4972    def AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4973        r"""
4974        Creates a dimension where the transit variable is constrained to be
4975        equal to 'values[i]' for node i; 'capacity' is the upper bound of
4976        the cumul variables. 'name' is the name used to reference the dimension;
4977        this name is used to get cumul and transit variables from the routing
4978        model.
4979        Returns a pair consisting of an index to the registered unary transit
4980        callback and a bool denoting whether the dimension has been created.
4981        It is false if a dimension with the same name has already been created
4982        (and doesn't create the new dimension but still register a new callback).
4983        """
4984        return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)
4985
4986    def AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4987        r"""
4988        Creates a dimension where the transit variable is constrained to be
4989        equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of
4990        the cumul variables. 'name' is the name used to reference the dimension;
4991        this name is used to get cumul and transit variables from the routing
4992        model.
4993        Returns a pair consisting of an index to the registered transit callback
4994        and a bool denoting whether the dimension has been created.
4995        It is false if a dimension with the same name has already been created
4996        (and doesn't create the new dimension but still register a new callback).
4997        """
4998        return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)
4999
5000    def GetAllDimensionNames(self):
5001        r"""Outputs the names of all dimensions added to the routing engine."""
5002        return _pywrapcp.RoutingModel_GetAllDimensionNames(self)
5003
5004    def GetDimensions(self):
5005        r"""Returns all dimensions of the model."""
5006        return _pywrapcp.RoutingModel_GetDimensions(self)
5007
5008    def GetDimensionsWithSoftOrSpanCosts(self):
5009        r"""Returns dimensions with soft or vehicle span costs."""
5010        return _pywrapcp.RoutingModel_GetDimensionsWithSoftOrSpanCosts(self)
5011
5012    def GetUnaryDimensions(self):
5013        r"""Returns dimensions for which all transit evaluators are unary."""
5014        return _pywrapcp.RoutingModel_GetUnaryDimensions(self)
5015
5016    def GetDimensionsWithGlobalCumulOptimizers(self):
5017        r"""Returns the dimensions which have [global|local]_dimension_optimizers_."""
5018        return _pywrapcp.RoutingModel_GetDimensionsWithGlobalCumulOptimizers(self)
5019
5020    def GetDimensionsWithLocalCumulOptimizers(self):
5021        return _pywrapcp.RoutingModel_GetDimensionsWithLocalCumulOptimizers(self)
5022
5023    def HasGlobalCumulOptimizer(self, dimension):
5024        r"""Returns whether the given dimension has global/local cumul optimizers."""
5025        return _pywrapcp.RoutingModel_HasGlobalCumulOptimizer(self, dimension)
5026
5027    def HasLocalCumulOptimizer(self, dimension):
5028        return _pywrapcp.RoutingModel_HasLocalCumulOptimizer(self, dimension)
5029
5030    def GetMutableGlobalCumulLPOptimizer(self, dimension):
5031        r"""
5032        Returns the global/local dimension cumul optimizer for a given dimension,
5033        or nullptr if there is none.
5034        """
5035        return _pywrapcp.RoutingModel_GetMutableGlobalCumulLPOptimizer(self, dimension)
5036
5037    def GetMutableGlobalCumulMPOptimizer(self, dimension):
5038        return _pywrapcp.RoutingModel_GetMutableGlobalCumulMPOptimizer(self, dimension)
5039
5040    def GetMutableLocalCumulLPOptimizer(self, dimension):
5041        return _pywrapcp.RoutingModel_GetMutableLocalCumulLPOptimizer(self, dimension)
5042
5043    def GetMutableLocalCumulMPOptimizer(self, dimension):
5044        return _pywrapcp.RoutingModel_GetMutableLocalCumulMPOptimizer(self, dimension)
5045
5046    def HasDimension(self, dimension_name):
5047        r"""Returns true if a dimension exists for a given dimension name."""
5048        return _pywrapcp.RoutingModel_HasDimension(self, dimension_name)
5049
5050    def GetDimensionOrDie(self, dimension_name):
5051        r"""Returns a dimension from its name. Dies if the dimension does not exist."""
5052        return _pywrapcp.RoutingModel_GetDimensionOrDie(self, dimension_name)
5053
5054    def GetMutableDimension(self, dimension_name):
5055        r"""
5056        Returns a dimension from its name. Returns nullptr if the dimension does
5057        not exist.
5058        """
5059        return _pywrapcp.RoutingModel_GetMutableDimension(self, dimension_name)
5060
5061    def SetPrimaryConstrainedDimension(self, dimension_name):
5062        r"""
5063        Set the given dimension as "primary constrained". As of August 2013, this
5064        is only used by ArcIsMoreConstrainedThanArc().
5065        "dimension" must be the name of an existing dimension, or be empty, in
5066        which case there will not be a primary dimension after this call.
5067        """
5068        return _pywrapcp.RoutingModel_SetPrimaryConstrainedDimension(self, dimension_name)
5069
5070    def GetPrimaryConstrainedDimension(self):
5071        r"""Get the primary constrained dimension, or an empty string if it is unset."""
5072        return _pywrapcp.RoutingModel_GetPrimaryConstrainedDimension(self)
5073
5074    def GetResourceGroup(self, rg_index):
5075        return _pywrapcp.RoutingModel_GetResourceGroup(self, rg_index)
5076
5077    def GetDimensionResourceGroupIndices(self, dimension):
5078        r"""
5079        Returns the indices of resource groups for this dimension. This method can
5080        only be called after the model has been closed.
5081        """
5082        return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndices(self, dimension)
5083
5084    def GetDimensionResourceGroupIndex(self, dimension):
5085        r"""
5086        Returns the index of the resource group attached to the dimension.
5087        DCHECKS that there's exactly one resource group for this dimension.
5088        """
5089        return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndex(self, dimension)
5090    PENALIZE_ONCE = _pywrapcp.RoutingModel_PENALIZE_ONCE
5091    PENALIZE_PER_INACTIVE = _pywrapcp.RoutingModel_PENALIZE_PER_INACTIVE
5092
5093    def AddDisjunction(self, *args):
5094        r"""
5095        Adds a disjunction constraint on the indices: exactly 'max_cardinality' of
5096        the indices are active. Start and end indices of any vehicle cannot be
5097        part of a disjunction.
5098
5099        If a penalty is given, at most 'max_cardinality' of the indices can be
5100        active, and if less are active, 'penalty' is payed per inactive index if
5101        the penalty cost is set to `PENALIZE_PER_INACTIVE`.
5102        This is equivalent to adding the constraint:
5103            p + Sum(i)active[i] == max_cardinality
5104        where p is an integer variable.
5105        If the penalty cost is set to `PENALIZE_ONCE`, then 'penalty' is payed
5106        once if there are less than `max_cardinality` of the indices active.
5107        This is equivalent to adding the constraint:
5108            p == (Sum(i)active[i] != max_cardinality)
5109        where p is a boolean variable.
5110        The following cost is added to the cost function: p * penalty.
5111        'penalty' must be positive to make the disjunction optional; a negative
5112        penalty will force 'max_cardinality' indices of the disjunction to be
5113        performed, and therefore p == 0.
5114        Note: passing a vector with a single index will model an optional index
5115        with a penalty cost if it is not visited.
5116        """
5117        return _pywrapcp.RoutingModel_AddDisjunction(self, *args)
5118
5119    def GetDisjunctionIndices(self, index):
5120        r"""Returns the indices of the disjunctions to which an index belongs."""
5121        return _pywrapcp.RoutingModel_GetDisjunctionIndices(self, index)
5122
5123    def GetDisjunctionPenalty(self, index):
5124        r"""Returns the penalty of the node disjunction of index 'index'."""
5125        return _pywrapcp.RoutingModel_GetDisjunctionPenalty(self, index)
5126
5127    def GetDisjunctionMaxCardinality(self, index):
5128        r"""
5129        Returns the maximum number of possible active nodes of the node
5130        disjunction of index 'index'.
5131        """
5132        return _pywrapcp.RoutingModel_GetDisjunctionMaxCardinality(self, index)
5133
5134    def GetDisjunctionPenaltyCostBehavior(self, index):
5135        r"""
5136        Returns the 'PenaltyCostBehavior' used by the disjunction of index
5137        'index'.
5138        """
5139        return _pywrapcp.RoutingModel_GetDisjunctionPenaltyCostBehavior(self, index)
5140
5141    def GetNumberOfDisjunctions(self):
5142        r"""Returns the number of node disjunctions in the model."""
5143        return _pywrapcp.RoutingModel_GetNumberOfDisjunctions(self)
5144
5145    def HasMandatoryDisjunctions(self):
5146        r"""
5147        Returns true if the model contains mandatory disjunctions (ones with
5148        kNoPenalty as penalty).
5149        """
5150        return _pywrapcp.RoutingModel_HasMandatoryDisjunctions(self)
5151
5152    def HasMaxCardinalityConstrainedDisjunctions(self):
5153        r"""
5154        Returns true if the model contains at least one disjunction which is
5155        constrained by its max_cardinality.
5156        """
5157        return _pywrapcp.RoutingModel_HasMaxCardinalityConstrainedDisjunctions(self)
5158
5159    def GetPerfectBinaryDisjunctions(self):
5160        r"""
5161        Returns the list of all perfect binary disjunctions, as pairs of variable
5162        indices: a disjunction is "perfect" when its variables do not appear in
5163        any other disjunction. Each pair is sorted (lowest variable index first),
5164        and the output vector is also sorted (lowest pairs first).
5165        """
5166        return _pywrapcp.RoutingModel_GetPerfectBinaryDisjunctions(self)
5167
5168    def IgnoreDisjunctionsAlreadyForcedToZero(self):
5169        r"""
5170        SPECIAL: Makes the solver ignore all the disjunctions whose active
5171        variables are all trivially zero (i.e. Max() == 0), by setting their
5172        max_cardinality to 0.
5173        This can be useful when using the BaseBinaryDisjunctionNeighborhood
5174        operators, in the context of arc-based routing.
5175        """
5176        return _pywrapcp.RoutingModel_IgnoreDisjunctionsAlreadyForcedToZero(self)
5177
5178    def AddSoftSameVehicleConstraint(self, indices, cost):
5179        r"""
5180        Adds a soft constraint to force a set of variable indices to be on the
5181        same vehicle. If all nodes are not on the same vehicle, each extra vehicle
5182        used adds 'cost' to the cost function.
5183        """
5184        return _pywrapcp.RoutingModel_AddSoftSameVehicleConstraint(self, indices, cost)
5185
5186    def SetAllowedVehiclesForIndex(self, vehicles, index):
5187        r"""
5188        Sets the vehicles which can visit a given node. If the node is in a
5189        disjunction, this will not prevent it from being unperformed.
5190        Specifying an empty vector of vehicles has no effect (all vehicles
5191        will be allowed to visit the node).
5192        """
5193        return _pywrapcp.RoutingModel_SetAllowedVehiclesForIndex(self, vehicles, index)
5194
5195    def IsVehicleAllowedForIndex(self, vehicle, index):
5196        r"""Returns true if a vehicle is allowed to visit a given node."""
5197        return _pywrapcp.RoutingModel_IsVehicleAllowedForIndex(self, vehicle, index)
5198
5199    def AddPickupAndDelivery(self, pickup, delivery):
5200        r"""
5201        Notifies that index1 and index2 form a pair of nodes which should belong
5202        to the same route. This methods helps the search find better solutions,
5203        especially in the local search phase.
5204        It should be called each time you have an equality constraint linking
5205        the vehicle variables of two node (including for instance pickup and
5206        delivery problems):
5207            Solver* const solver = routing.solver();
5208            int64_t index1 = manager.NodeToIndex(node1);
5209            int64_t index2 = manager.NodeToIndex(node2);
5210            solver->AddConstraint(solver->MakeEquality(
5211                routing.VehicleVar(index1),
5212                routing.VehicleVar(index2)));
5213            routing.AddPickupAndDelivery(index1, index2);
5214        """
5215        return _pywrapcp.RoutingModel_AddPickupAndDelivery(self, pickup, delivery)
5216
5217    def AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction):
5218        r"""
5219        Same as AddPickupAndDelivery but notifying that the performed node from
5220        the disjunction of index 'pickup_disjunction' is on the same route as the
5221        performed node from the disjunction of index 'delivery_disjunction'.
5222        """
5223        return _pywrapcp.RoutingModel_AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction)
5224
5225    def GetPickupPosition(self, node_index):
5226        r"""Returns the pickup and delivery positions where the node is a pickup."""
5227        return _pywrapcp.RoutingModel_GetPickupPosition(self, node_index)
5228
5229    def GetDeliveryPosition(self, node_index):
5230        r"""Returns the pickup and delivery positions where the node is a delivery."""
5231        return _pywrapcp.RoutingModel_GetDeliveryPosition(self, node_index)
5232
5233    def IsPickup(self, node_index):
5234        r"""Returns whether the node is a pickup (resp. delivery)."""
5235        return _pywrapcp.RoutingModel_IsPickup(self, node_index)
5236
5237    def IsDelivery(self, node_index):
5238        return _pywrapcp.RoutingModel_IsDelivery(self, node_index)
5239
5240    def SetPickupAndDeliveryPolicyOfAllVehicles(self, policy):
5241        r"""
5242        Sets the Pickup and delivery policy of all vehicles. It is equivalent to
5243        calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.
5244        """
5245        return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfAllVehicles(self, policy)
5246
5247    def SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle):
5248        return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle)
5249
5250    def GetPickupAndDeliveryPolicyOfVehicle(self, vehicle):
5251        return _pywrapcp.RoutingModel_GetPickupAndDeliveryPolicyOfVehicle(self, vehicle)
5252
5253    def GetNumOfSingletonNodes(self):
5254        r"""
5255        Returns the number of non-start/end nodes which do not appear in a
5256        pickup/delivery pair.
5257        """
5258        return _pywrapcp.RoutingModel_GetNumOfSingletonNodes(self)
5259
5260    def GetFirstMatchingPickupDeliverySibling(self, node, is_match):
5261        return _pywrapcp.RoutingModel_GetFirstMatchingPickupDeliverySibling(self, node, is_match)
5262    TYPE_ADDED_TO_VEHICLE = _pywrapcp.RoutingModel_TYPE_ADDED_TO_VEHICLE
5263    r"""When visited, the number of types 'T' on the vehicle increases by one."""
5264    ADDED_TYPE_REMOVED_FROM_VEHICLE = _pywrapcp.RoutingModel_ADDED_TYPE_REMOVED_FROM_VEHICLE
5265    r"""
5266    When visited, one instance of type 'T' previously added to the route
5267    (TYPE_ADDED_TO_VEHICLE), if any, is removed from the vehicle.
5268    If the type was not previously added to the route or all added instances
5269    have already been removed, this visit has no effect on the types.
5270    """
5271    TYPE_ON_VEHICLE_UP_TO_VISIT = _pywrapcp.RoutingModel_TYPE_ON_VEHICLE_UP_TO_VISIT
5272    r"""
5273    With the following policy, the visit enforces that type 'T' is
5274    considered on the route from its start until this node is visited.
5275    """
5276    TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = _pywrapcp.RoutingModel_TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
5277    r"""
5278    The visit doesn't have an impact on the number of types 'T' on the
5279    route, as it's (virtually) added and removed directly.
5280    This policy can be used for visits which are part of an incompatibility
5281    or requirement set without affecting the type count on the route.
5282    """
5283
5284    def SetVisitType(self, index, type, type_policy):
5285        return _pywrapcp.RoutingModel_SetVisitType(self, index, type, type_policy)
5286
5287    def GetVisitType(self, index):
5288        return _pywrapcp.RoutingModel_GetVisitType(self, index)
5289
5290    def GetSingleNodesOfType(self, type):
5291        return _pywrapcp.RoutingModel_GetSingleNodesOfType(self, type)
5292
5293    def GetPairIndicesOfType(self, type):
5294        return _pywrapcp.RoutingModel_GetPairIndicesOfType(self, type)
5295
5296    def GetVisitTypePolicy(self, index):
5297        return _pywrapcp.RoutingModel_GetVisitTypePolicy(self, index)
5298
5299    def GetNumberOfVisitTypes(self):
5300        return _pywrapcp.RoutingModel_GetNumberOfVisitTypes(self)
5301
5302    def AddHardTypeIncompatibility(self, type1, type2):
5303        r"""
5304        Incompatibilities:
5305        Two nodes with "hard" incompatible types cannot share the same route at
5306        all, while with a "temporal" incompatibility they can't be on the same
5307        route at the same time.
5308        NOTE: To avoid unnecessary memory reallocations, it is recommended to only
5309        add incompatibilities once all the existing types have been set with
5310        SetVisitType().
5311        """
5312        return _pywrapcp.RoutingModel_AddHardTypeIncompatibility(self, type1, type2)
5313
5314    def AddTemporalTypeIncompatibility(self, type1, type2):
5315        return _pywrapcp.RoutingModel_AddTemporalTypeIncompatibility(self, type1, type2)
5316
5317    def GetHardTypeIncompatibilitiesOfType(self, type):
5318        r"""Returns visit types incompatible with a given type."""
5319        return _pywrapcp.RoutingModel_GetHardTypeIncompatibilitiesOfType(self, type)
5320
5321    def GetTemporalTypeIncompatibilitiesOfType(self, type):
5322        return _pywrapcp.RoutingModel_GetTemporalTypeIncompatibilitiesOfType(self, type)
5323
5324    def HasHardTypeIncompatibilities(self):
5325        r"""
5326        Returns true iff any hard (resp. temporal) type incompatibilities have
5327        been added to the model.
5328        """
5329        return _pywrapcp.RoutingModel_HasHardTypeIncompatibilities(self)
5330
5331    def HasTemporalTypeIncompatibilities(self):
5332        return _pywrapcp.RoutingModel_HasTemporalTypeIncompatibilities(self)
5333
5334    def AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives):
5335        r"""
5336        Requirements:
5337        NOTE: As of 2019-04, cycles in the requirement graph are not supported,
5338        and lead to the dependent nodes being skipped if possible (otherwise
5339        the model is considered infeasible).
5340        The following functions specify that "dependent_type" requires at least
5341        one of the types in "required_type_alternatives".
5342
5343        For same-vehicle requirements, a node of dependent type type_D requires at
5344        least one node of type type_R among the required alternatives on the same
5345        route.
5346        NOTE: To avoid unnecessary memory reallocations, it is recommended to only
5347        add requirements once all the existing types have been set with
5348        SetVisitType().
5349        """
5350        return _pywrapcp.RoutingModel_AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives)
5351
5352    def AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives):
5353        r"""
5354        If type_D depends on type_R when adding type_D, any node_D of type_D and
5355        VisitTypePolicy TYPE_ADDED_TO_VEHICLE or
5356        TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its
5357        vehicle at the time node_D is visited.
5358        """
5359        return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives)
5360
5361    def AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives):
5362        r"""
5363        The following requirements apply when visiting dependent nodes that remove
5364        their type from the route, i.e. type_R must be on the vehicle when type_D
5365        of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE,
5366        TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is
5367        visited.
5368        """
5369        return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives)
5370
5371    def GetSameVehicleRequiredTypeAlternativesOfType(self, type):
5372        r"""
5373        Returns the set of same-vehicle requirement alternatives for the given
5374        type.
5375        """
5376        return _pywrapcp.RoutingModel_GetSameVehicleRequiredTypeAlternativesOfType(self, type)
5377
5378    def GetRequiredTypeAlternativesWhenAddingType(self, type):
5379        r"""Returns the set of requirement alternatives when adding the given type."""
5380        return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenAddingType(self, type)
5381
5382    def GetRequiredTypeAlternativesWhenRemovingType(self, type):
5383        r"""Returns the set of requirement alternatives when removing the given type."""
5384        return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenRemovingType(self, type)
5385
5386    def HasSameVehicleTypeRequirements(self):
5387        r"""
5388        Returns true iff any same-route (resp. temporal) type requirements have
5389        been added to the model.
5390        """
5391        return _pywrapcp.RoutingModel_HasSameVehicleTypeRequirements(self)
5392
5393    def HasTemporalTypeRequirements(self):
5394        return _pywrapcp.RoutingModel_HasTemporalTypeRequirements(self)
5395
5396    def HasTypeRegulations(self):
5397        r"""
5398        Returns true iff the model has any incompatibilities or requirements set
5399        on node types.
5400        """
5401        return _pywrapcp.RoutingModel_HasTypeRegulations(self)
5402
5403    def UnperformedPenalty(self, var_index):
5404        r"""
5405        Get the "unperformed" penalty of a node. This is only well defined if the
5406        node is only part of a single Disjunction, and that disjunction has a
5407        penalty. For forced active nodes returns max int64_t. In all other cases,
5408        this returns 0.
5409        """
5410        return _pywrapcp.RoutingModel_UnperformedPenalty(self, var_index)
5411
5412    def UnperformedPenaltyOrValue(self, default_value, var_index):
5413        r"""
5414        Same as above except that it returns default_value instead of 0 when
5415        penalty is not well defined (default value is passed as first argument to
5416        simplify the usage of the method in a callback).
5417        """
5418        return _pywrapcp.RoutingModel_UnperformedPenaltyOrValue(self, default_value, var_index)
5419
5420    def GetDepot(self):
5421        r"""
5422        Returns the variable index of the first starting or ending node of all
5423        routes. If all routes start  and end at the same node (single depot), this
5424        is the node returned.
5425        """
5426        return _pywrapcp.RoutingModel_GetDepot(self)
5427
5428    def SetMaximumNumberOfActiveVehicles(self, max_active_vehicles):
5429        r"""
5430        Constrains the maximum number of active vehicles, aka the number of
5431        vehicles which do not have an empty route. For instance, this can be used
5432        to limit the number of routes in the case where there are fewer drivers
5433        than vehicles and that the fleet of vehicle is heterogeneous.
5434        """
5435        return _pywrapcp.RoutingModel_SetMaximumNumberOfActiveVehicles(self, max_active_vehicles)
5436
5437    def GetMaximumNumberOfActiveVehicles(self):
5438        r"""Returns the maximum number of active vehicles."""
5439        return _pywrapcp.RoutingModel_GetMaximumNumberOfActiveVehicles(self)
5440
5441    def SetArcCostEvaluatorOfAllVehicles(self, evaluator_index):
5442        r"""
5443        Sets the cost function of the model such that the cost of a segment of a
5444        route between node 'from' and 'to' is evaluator(from, to), whatever the
5445        route or vehicle performing the route.
5446        """
5447        return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfAllVehicles(self, evaluator_index)
5448
5449    def SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle):
5450        r"""Sets the cost function for a given vehicle route."""
5451        return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle)
5452
5453    def SetFixedCostOfAllVehicles(self, cost):
5454        r"""
5455        Sets the fixed cost of all vehicle routes. It is equivalent to calling
5456        SetFixedCostOfVehicle on all vehicle routes.
5457        """
5458        return _pywrapcp.RoutingModel_SetFixedCostOfAllVehicles(self, cost)
5459
5460    def SetFixedCostOfVehicle(self, cost, vehicle):
5461        r"""Sets the fixed cost of one vehicle route."""
5462        return _pywrapcp.RoutingModel_SetFixedCostOfVehicle(self, cost, vehicle)
5463
5464    def GetFixedCostOfVehicle(self, vehicle):
5465        r"""
5466        Returns the route fixed cost taken into account if the route of the
5467        vehicle is not empty, aka there's at least one node on the route other
5468        than the first and last nodes.
5469        """
5470        return _pywrapcp.RoutingModel_GetFixedCostOfVehicle(self, vehicle)
5471
5472    def SetPathEnergyCostOfVehicle(self, force, distance, cost_per_unit, vehicle):
5473        return _pywrapcp.RoutingModel_SetPathEnergyCostOfVehicle(self, force, distance, cost_per_unit, vehicle)
5474
5475    def SetPathEnergyCostsOfVehicle(self, force, distance, threshold, cost_per_unit_below_threshold, cost_per_unit_above_threshold, vehicle):
5476        return _pywrapcp.RoutingModel_SetPathEnergyCostsOfVehicle(self, force, distance, threshold, cost_per_unit_below_threshold, cost_per_unit_above_threshold, vehicle)
5477
5478    def SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor):
5479        r"""
5480        The following methods set the linear and quadratic cost factors of
5481        vehicles (must be positive values). The default value of these parameters
5482        is zero for all vehicles.
5483
5484        When set, the cost_ of the model will contain terms aiming at reducing the
5485        number of vehicles used in the model, by adding the following to the
5486        objective for every vehicle v:
5487        INDICATOR(v used in the model) *
5488          [linear_cost_factor_of_vehicle_[v]
5489           - quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)]
5490        i.e. for every used vehicle, we add the linear factor as fixed cost, and
5491        subtract the square of the route length multiplied by the quadratic
5492        factor. This second term aims at making the routes as dense as possible.
5493
5494        Sets the linear and quadratic cost factor of all vehicles.
5495        """
5496        return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor)
5497
5498    def SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle):
5499        r"""Sets the linear and quadratic cost factor of the given vehicle."""
5500        return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle)
5501
5502    def GetAmortizedLinearCostFactorOfVehicles(self):
5503        return _pywrapcp.RoutingModel_GetAmortizedLinearCostFactorOfVehicles(self)
5504
5505    def GetAmortizedQuadraticCostFactorOfVehicles(self):
5506        return _pywrapcp.RoutingModel_GetAmortizedQuadraticCostFactorOfVehicles(self)
5507
5508    def AddRouteConstraint(self, route_evaluator, costs_are_homogeneous_across_vehicles=False):
5509        return _pywrapcp.RoutingModel_AddRouteConstraint(self, route_evaluator, costs_are_homogeneous_across_vehicles)
5510
5511    def GetRouteCost(self, route):
5512        return _pywrapcp.RoutingModel_GetRouteCost(self, route)
5513
5514    def SetVehicleUsedWhenEmpty(self, is_used, vehicle):
5515        return _pywrapcp.RoutingModel_SetVehicleUsedWhenEmpty(self, is_used, vehicle)
5516
5517    def IsVehicleUsedWhenEmpty(self, vehicle):
5518        return _pywrapcp.RoutingModel_IsVehicleUsedWhenEmpty(self, vehicle)
5519
5520    def SetFirstSolutionEvaluator(self, evaluator):
5521        r"""
5522        Gets/sets the evaluator used during the search. Only relevant when
5523        RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY.
5524        Takes ownership of evaluator.
5525        """
5526        return _pywrapcp.RoutingModel_SetFirstSolutionEvaluator(self, evaluator)
5527
5528    def SetFirstSolutionHint(self, hint):
5529        r"""
5530        Adds a hint to be used by first solution strategies. The hint assignment
5531        must outlive the search.
5532        As of 2024-12, only used by LOCAL_CHEAPEST_INSERTION and
5533        LOCAL_CHEAPEST_COST_INSERTION.
5534        """
5535        return _pywrapcp.RoutingModel_SetFirstSolutionHint(self, hint)
5536
5537    def GetFirstSolutionHint(self):
5538        r"""Returns the current hint assignment."""
5539        return _pywrapcp.RoutingModel_GetFirstSolutionHint(self)
5540
5541    def AddLocalSearchOperator(self, ls_operator):
5542        r"""
5543        Adds a local search operator to the set of operators used to solve the
5544        vehicle routing problem.
5545        """
5546        return _pywrapcp.RoutingModel_AddLocalSearchOperator(self, ls_operator)
5547
5548    def AddSearchMonitor(self, monitor):
5549        r"""Adds a search monitor to the search used to solve the routing model."""
5550        return _pywrapcp.RoutingModel_AddSearchMonitor(self, monitor)
5551
5552    def AddEnterSearchCallback(self, callback):
5553        return _pywrapcp.RoutingModel_AddEnterSearchCallback(self, callback)
5554
5555    def AddAtSolutionCallback(self, callback, track_unchecked_neighbors=False):
5556        r"""
5557        Adds a callback called each time a solution is found during the search.
5558        This is a shortcut to creating a monitor to call the callback on
5559        AtSolution() and adding it with AddSearchMonitor.
5560        If track_unchecked_neighbors is true, the callback will also be called on
5561        AcceptUncheckedNeighbor() events, which is useful to grab solutions
5562        obtained when solver_parameters.check_solution_period > 1 (aka fastLS).
5563        """
5564        return _pywrapcp.RoutingModel_AddAtSolutionCallback(self, callback, track_unchecked_neighbors)
5565
5566    def AddRestoreDimensionValuesResetCallback(self, callback):
5567        return _pywrapcp.RoutingModel_AddRestoreDimensionValuesResetCallback(self, callback)
5568
5569    def AddVariableMinimizedByFinalizer(self, var):
5570        r"""
5571        Adds a variable to minimize in the solution finalizer. The solution
5572        finalizer is called each time a solution is found during the search and
5573        allows to instantiate secondary variables (such as dimension cumul
5574        variables).
5575        """
5576        return _pywrapcp.RoutingModel_AddVariableMinimizedByFinalizer(self, var)
5577
5578    def AddVariableMaximizedByFinalizer(self, var):
5579        r"""
5580        Adds a variable to maximize in the solution finalizer (see above for
5581        information on the solution finalizer).
5582        """
5583        return _pywrapcp.RoutingModel_AddVariableMaximizedByFinalizer(self, var)
5584
5585    def AddWeightedVariableMinimizedByFinalizer(self, var, cost):
5586        r"""
5587        Adds a variable to minimize in the solution finalizer, with a weighted
5588        priority: the higher the more priority it has.
5589        """
5590        return _pywrapcp.RoutingModel_AddWeightedVariableMinimizedByFinalizer(self, var, cost)
5591
5592    def AddWeightedVariableMaximizedByFinalizer(self, var, cost):
5593        r"""
5594        Adds a variable to maximize in the solution finalizer, with a weighted
5595        priority: the higher the more priority it has.
5596        """
5597        return _pywrapcp.RoutingModel_AddWeightedVariableMaximizedByFinalizer(self, var, cost)
5598
5599    def AddVariableTargetToFinalizer(self, var, target):
5600        r"""
5601        Add a variable to set the closest possible to the target value in the
5602        solution finalizer.
5603        """
5604        return _pywrapcp.RoutingModel_AddVariableTargetToFinalizer(self, var, target)
5605
5606    def AddWeightedVariableTargetToFinalizer(self, var, target, cost):
5607        r"""
5608        Same as above with a weighted priority: the higher the cost, the more
5609        priority it has to be set close to the target value.
5610        """
5611        return _pywrapcp.RoutingModel_AddWeightedVariableTargetToFinalizer(self, var, target, cost)
5612
5613    def CloseModel(self):
5614        r"""
5615        Closes the current routing model; after this method is called, no
5616        modification to the model can be done, but RoutesToAssignment becomes
5617        available. Note that CloseModel() is automatically called by Solve() and
5618        other methods that produce solution.
5619        This is equivalent to calling
5620        CloseModelWithParameters(DefaultRoutingSearchParameters()).
5621        """
5622        return _pywrapcp.RoutingModel_CloseModel(self)
5623
5624    def CloseModelWithParameters(self, search_parameters):
5625        r"""
5626        Same as above taking search parameters (as of 10/2015 some the parameters
5627        have to be set when closing the model).
5628        """
5629        return _pywrapcp.RoutingModel_CloseModelWithParameters(self, search_parameters)
5630
5631    def Solve(self, assignment=None):
5632        r"""
5633        Solves the current routing model; closes the current model.
5634        This is equivalent to calling
5635        SolveWithParameters(DefaultRoutingSearchParameters())
5636        or
5637        SolveFromAssignmentWithParameters(assignment,
5638                                          DefaultRoutingSearchParameters()).
5639        """
5640        return _pywrapcp.RoutingModel_Solve(self, assignment)
5641
5642    def SolveWithParameters(self, search_parameters, solutions=None):
5643        r"""
5644        Solves the current routing model with the given parameters. If 'solutions'
5645        is specified, it will contain the k best solutions found during the search
5646        (from worst to best, including the one returned by this method), where k
5647        corresponds to the 'number_of_solutions_to_collect' in
5648        'search_parameters'. Note that the Assignment returned by the method and
5649        the ones in solutions are owned by the underlying solver and should not be
5650        deleted.
5651        """
5652        return _pywrapcp.RoutingModel_SolveWithParameters(self, search_parameters, solutions)
5653
5654    def SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions=None):
5655        r"""
5656        Same as above, except that if assignment is not null, it will be used as
5657        the initial solution.
5658        """
5659        return _pywrapcp.RoutingModel_SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions)
5660
5661    def FastSolveFromAssignmentWithParameters(self, assignment, search_parameters, check_solution_in_cp, touched=None):
5662        r"""
5663        Improves a given assignment using unchecked local search.
5664        If check_solution_in_cp is true the final solution will be checked with
5665        the CP solver.
5666        As of 11/2023, only works with greedy descent.
5667        """
5668        return _pywrapcp.RoutingModel_FastSolveFromAssignmentWithParameters(self, assignment, search_parameters, check_solution_in_cp, touched)
5669
5670    def SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions=None):
5671        r"""
5672        Same as above but will try all assignments in order as first solutions
5673        until one succeeds.
5674        """
5675        return _pywrapcp.RoutingModel_SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions)
5676
5677    def SolveWithIteratedLocalSearch(self, search_parameters):
5678        r"""
5679        Solves the current routing model by using an Iterated Local Search
5680        approach.
5681        """
5682        return _pywrapcp.RoutingModel_SolveWithIteratedLocalSearch(self, search_parameters)
5683
5684    def SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment):
5685        r"""
5686        Given a "source_model" and its "source_assignment", resets
5687        "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_
5688        if costs aren't homogeneous across vehicles) of "this" model, with the
5689        values set according to those in "other_assignment".
5690        The objective_element of target_assignment is set to this->cost_.
5691        """
5692        return _pywrapcp.RoutingModel_SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment)
5693
5694    def ComputeLowerBound(self):
5695        r"""
5696        Computes a lower bound to the routing problem solving a linear assignment
5697        problem. The routing model must be closed before calling this method.
5698        Note that problems with node disjunction constraints (including optional
5699        nodes) and non-homogenous costs are not supported (the method returns 0 in
5700        these cases).
5701        """
5702        return _pywrapcp.RoutingModel_ComputeLowerBound(self)
5703
5704    def objective_lower_bound(self):
5705        r"""
5706        Returns the current lower bound found by internal solvers during the
5707        search.
5708        """
5709        return _pywrapcp.RoutingModel_objective_lower_bound(self)
5710
5711    def status(self):
5712        r"""Returns the current status of the routing model."""
5713        return _pywrapcp.RoutingModel_status(self)
5714
5715    def enable_deep_serialization(self):
5716        r"""Returns the value of the internal enable_deep_serialization_ parameter."""
5717        return _pywrapcp.RoutingModel_enable_deep_serialization(self)
5718
5719    def ApplyLocks(self, locks):
5720        r"""
5721        Applies a lock chain to the next search. 'locks' represents an ordered
5722        vector of nodes representing a partial route which will be fixed during
5723        the next search; it will constrain next variables such that:
5724        next[locks[i]] == locks[i+1].
5725
5726        Returns the next variable at the end of the locked chain; this variable is
5727        not locked. An assignment containing the locks can be obtained by calling
5728        PreAssignment().
5729        """
5730        return _pywrapcp.RoutingModel_ApplyLocks(self, locks)
5731
5732    def ApplyLocksToAllVehicles(self, locks, close_routes):
5733        r"""
5734        Applies lock chains to all vehicles to the next search, such that locks[p]
5735        is the lock chain for route p. Returns false if the locks do not contain
5736        valid routes; expects that the routes do not contain the depots,
5737        i.e. there are empty vectors in place of empty routes.
5738        If close_routes is set to true, adds the end nodes to the route of each
5739        vehicle and deactivates other nodes.
5740        An assignment containing the locks can be obtained by calling
5741        PreAssignment().
5742        """
5743        return _pywrapcp.RoutingModel_ApplyLocksToAllVehicles(self, locks, close_routes)
5744
5745    def PreAssignment(self):
5746        r"""
5747        Returns an assignment used to fix some of the variables of the problem.
5748        In practice, this assignment locks partial routes of the problem. This
5749        can be used in the context of locking the parts of the routes which have
5750        already been driven in online routing problems.
5751        """
5752        return _pywrapcp.RoutingModel_PreAssignment(self)
5753
5754    def MutablePreAssignment(self):
5755        return _pywrapcp.RoutingModel_MutablePreAssignment(self)
5756
5757    def WriteAssignment(self, file_name):
5758        r"""
5759        Writes the current solution to a file containing an AssignmentProto.
5760        Returns false if the file cannot be opened or if there is no current
5761        solution.
5762        """
5763        return _pywrapcp.RoutingModel_WriteAssignment(self, file_name)
5764
5765    def ReadAssignment(self, file_name):
5766        r"""
5767        Reads an assignment from a file and returns the current solution.
5768        Returns nullptr if the file cannot be opened or if the assignment is not
5769        valid.
5770        """
5771        return _pywrapcp.RoutingModel_ReadAssignment(self, file_name)
5772
5773    def RestoreAssignment(self, solution):
5774        r"""
5775        Restores an assignment as a solution in the routing model and returns the
5776        new solution. Returns nullptr if the assignment is not valid.
5777        """
5778        return _pywrapcp.RoutingModel_RestoreAssignment(self, solution)
5779
5780    def ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices):
5781        r"""
5782        Restores the routes as the current solution. Returns nullptr if the
5783        solution cannot be restored (routes do not contain a valid solution). Note
5784        that calling this method will run the solver to assign values to the
5785        dimension variables; this may take considerable amount of time, especially
5786        when using dimensions with slack.
5787        """
5788        return _pywrapcp.RoutingModel_ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices)
5789
5790    def RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment):
5791        r"""
5792        Fills an assignment from a specification of the routes of the
5793        vehicles. The routes are specified as lists of variable indices that
5794        appear on the routes of the vehicles. The indices of the outer vector in
5795        'routes' correspond to vehicles IDs, the inner vector contains the
5796        variable indices on the routes for the given vehicle. The inner vectors
5797        must not contain the start and end indices, as these are determined by the
5798        routing model.  Sets the value of NextVars in the assignment, adding the
5799        variables to the assignment if necessary. The method does not touch other
5800        variables in the assignment. The method can only be called after the model
5801        is closed.  With ignore_inactive_indices set to false, this method will
5802        fail (return nullptr) in case some of the route contain indices that are
5803        deactivated in the model; when set to true, these indices will be
5804        skipped.  Returns true if routes were successfully
5805        loaded. However, such assignment still might not be a valid
5806        solution to the routing problem due to more complex constraints;
5807        it is advisible to call solver()->CheckSolution() afterwards.
5808        """
5809        return _pywrapcp.RoutingModel_RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment)
5810
5811    def AssignmentToRoutes(self, assignment, routes):
5812        r"""
5813        Converts the solution in the given assignment to routes for all vehicles.
5814        Expects that assignment contains a valid solution (i.e. routes for all
5815        vehicles end with an end index for that vehicle).
5816        """
5817        return _pywrapcp.RoutingModel_AssignmentToRoutes(self, assignment, routes)
5818
5819    def CompactAssignment(self, assignment):
5820        r"""
5821        Converts the solution in the given assignment to routes for all vehicles.
5822        If the returned vector is route_indices, route_indices[i][j] is the index
5823        for jth location visited on route i. Note that contrary to
5824        AssignmentToRoutes, the vectors do include start and end locations.
5825        Returns a compacted version of the given assignment, in which all vehicles
5826        with id lower or equal to some N have non-empty routes, and all vehicles
5827        with id greater than N have empty routes. Does not take ownership of the
5828        returned object.
5829        If found, the cost of the compact assignment is the same as in the
5830        original assignment and it preserves the values of 'active' variables.
5831        Returns nullptr if a compact assignment was not found.
5832        This method only works in homogenous mode, and it only swaps equivalent
5833        vehicles (vehicles with the same start and end nodes). When creating the
5834        compact assignment, the empty plan is replaced by the route assigned to
5835        the compatible vehicle with the highest id. Note that with more complex
5836        constraints on vehicle variables, this method might fail even if a compact
5837        solution exists.
5838        This method changes the vehicle and dimension variables as necessary.
5839        While compacting the solution, only basic checks on vehicle variables are
5840        performed; if one of these checks fails no attempts to repair it are made
5841        (instead, the method returns nullptr).
5842        """
5843        return _pywrapcp.RoutingModel_CompactAssignment(self, assignment)
5844
5845    def CompactAndCheckAssignment(self, assignment):
5846        r"""
5847        Same as CompactAssignment() but also checks the validity of the final
5848        compact solution; if it is not valid, no attempts to repair it are made
5849        (instead, the method returns nullptr).
5850        """
5851        return _pywrapcp.RoutingModel_CompactAndCheckAssignment(self, assignment)
5852
5853    def AddToAssignment(self, var):
5854        r"""Adds an extra variable to the vehicle routing assignment."""
5855        return _pywrapcp.RoutingModel_AddToAssignment(self, var)
5856
5857    def AddIntervalToAssignment(self, interval):
5858        return _pywrapcp.RoutingModel_AddIntervalToAssignment(self, interval)
5859
5860    def PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached=None):
5861        r"""
5862        For every dimension in the model with an optimizer in
5863        local/global_dimension_optimizers_, this method tries to pack the cumul
5864        values of the dimension, such that:
5865        - The cumul costs (span costs, soft lower and upper bound costs, etc) are
5866          minimized.
5867        - The cumuls of the ends of the routes are minimized for this given
5868          minimal cumul cost.
5869        - Given these minimal end cumuls, the route start cumuls are maximized.
5870        Returns the assignment resulting from allocating these packed cumuls with
5871        the solver, and nullptr if these cumuls could not be set by the solver.
5872        """
5873        return _pywrapcp.RoutingModel_PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached)
5874
5875    def GetOrCreateNodeNeighborsByCostClass(self, *args):
5876        r"""
5877        *Overload 1:*
5878        Returns neighbors of all nodes for every cost class. The result is cached
5879        and is computed once. The number of neighbors considered is based on a
5880        ratio of non-vehicle nodes, specified by neighbors_ratio, with a minimum
5881        of min-neighbors node considered.
5882
5883        |
5884
5885        *Overload 2:*
5886        Returns parameters.num_neighbors neighbors of all nodes for every cost
5887        class. The result is cached and is computed once.
5888        """
5889        return _pywrapcp.RoutingModel_GetOrCreateNodeNeighborsByCostClass(self, *args)
5890
5891    def AddLocalSearchFilter(self, filter):
5892        r"""
5893        Adds a custom local search filter to the list of filters used to speed up
5894        local search by pruning unfeasible variable assignments.
5895        Calling this method after the routing model has been closed (CloseModel()
5896        or Solve() has been called) has no effect.
5897        The routing model does not take ownership of the filter.
5898        """
5899        return _pywrapcp.RoutingModel_AddLocalSearchFilter(self, filter)
5900
5901    def Start(self, vehicle):
5902        r"""
5903        Model inspection.
5904        Returns the variable index of the starting node of a vehicle route.
5905        """
5906        return _pywrapcp.RoutingModel_Start(self, vehicle)
5907
5908    def End(self, vehicle):
5909        r"""Returns the variable index of the ending node of a vehicle route."""
5910        return _pywrapcp.RoutingModel_End(self, vehicle)
5911
5912    def IsStart(self, index):
5913        r"""Returns true if 'index' represents the first node of a route."""
5914        return _pywrapcp.RoutingModel_IsStart(self, index)
5915
5916    def IsEnd(self, index):
5917        r"""Returns true if 'index' represents the last node of a route."""
5918        return _pywrapcp.RoutingModel_IsEnd(self, index)
5919
5920    def VehicleIndex(self, index):
5921        r"""
5922        Returns the vehicle of the given start/end index, and -1 if the given
5923        index is not a vehicle start/end.
5924        """
5925        return _pywrapcp.RoutingModel_VehicleIndex(self, index)
5926
5927    def Next(self, assignment, index):
5928        r"""
5929        Assignment inspection
5930        Returns the variable index of the node directly after the node
5931        corresponding to 'index' in 'assignment'.
5932        """
5933        return _pywrapcp.RoutingModel_Next(self, assignment, index)
5934
5935    def IsVehicleUsed(self, assignment, vehicle):
5936        r"""Returns true if the route of 'vehicle' is non empty in 'assignment'."""
5937        return _pywrapcp.RoutingModel_IsVehicleUsed(self, assignment, vehicle)
5938
5939    def NextVar(self, index):
5940        r"""
5941        Returns the next variable of the node corresponding to index. Note that
5942        NextVar(index) == index is equivalent to ActiveVar(index) == 0.
5943        """
5944        return _pywrapcp.RoutingModel_NextVar(self, index)
5945
5946    def ActiveVar(self, index):
5947        r"""Returns the active variable of the node corresponding to index."""
5948        return _pywrapcp.RoutingModel_ActiveVar(self, index)
5949
5950    def ActiveVehicleVar(self, vehicle):
5951        r"""
5952        Returns the active variable of the vehicle. It will be equal to 1 iff the
5953        route of the vehicle is not empty, 0 otherwise.
5954        """
5955        return _pywrapcp.RoutingModel_ActiveVehicleVar(self, vehicle)
5956
5957    def VehicleRouteConsideredVar(self, vehicle):
5958        r"""
5959        Returns the variable specifying whether or not the given vehicle route is
5960        considered for costs and constraints. It will be equal to 1 iff the route
5961        of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.
5962        """
5963        return _pywrapcp.RoutingModel_VehicleRouteConsideredVar(self, vehicle)
5964
5965    def VehicleVar(self, index):
5966        r"""
5967        Returns the vehicle variable of the node corresponding to index. Note that
5968        VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.
5969        """
5970        return _pywrapcp.RoutingModel_VehicleVar(self, index)
5971
5972    def ResourceVar(self, vehicle, resource_group):
5973        r"""
5974        Returns the resource variable for the given vehicle index in the given
5975        resource group. If a vehicle doesn't require a resource from the
5976        corresponding resource group, then ResourceVar(v, r_g) == -1.
5977        """
5978        return _pywrapcp.RoutingModel_ResourceVar(self, vehicle, resource_group)
5979
5980    def CostVar(self):
5981        r"""Returns the global cost variable which is being minimized."""
5982        return _pywrapcp.RoutingModel_CostVar(self)
5983
5984    def GetArcCostForVehicle(self, from_index, to_index, vehicle):
5985        r"""
5986        Returns the cost of the transit arc between two nodes for a given vehicle.
5987        Input are variable indices of node. This returns 0 if vehicle < 0.
5988        """
5989        return _pywrapcp.RoutingModel_GetArcCostForVehicle(self, from_index, to_index, vehicle)
5990
5991    def CostsAreHomogeneousAcrossVehicles(self):
5992        r"""Whether costs are homogeneous across all vehicles."""
5993        return _pywrapcp.RoutingModel_CostsAreHomogeneousAcrossVehicles(self)
5994
5995    def GetHomogeneousCost(self, from_index, to_index):
5996        r"""
5997        Returns the cost of the segment between two nodes supposing all vehicle
5998        costs are the same (returns the cost for the first vehicle otherwise).
5999        """
6000        return _pywrapcp.RoutingModel_GetHomogeneousCost(self, from_index, to_index)
6001
6002    def GetArcCostForFirstSolution(self, from_index, to_index):
6003        r"""
6004        Returns the cost of the arc in the context of the first solution strategy.
6005        This is typically a simplification of the actual cost; see the .cc.
6006        """
6007        return _pywrapcp.RoutingModel_GetArcCostForFirstSolution(self, from_index, to_index)
6008
6009    def GetArcCostForClass(self, from_index, to_index, cost_class_index):
6010        r"""
6011        Returns the cost of the segment between two nodes for a given cost
6012        class. Input are variable indices of nodes and the cost class.
6013        Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the
6014        returned cost won't necessarily be zero: only some of the components
6015        of the cost that depend on the cost class will be omited. See the code
6016        for details.
6017        """
6018        return _pywrapcp.RoutingModel_GetArcCostForClass(self, from_index, to_index, cost_class_index)
6019
6020    def GetCostClassIndexOfVehicle(self, vehicle):
6021        r"""Get the cost class index of the given vehicle."""
6022        return _pywrapcp.RoutingModel_GetCostClassIndexOfVehicle(self, vehicle)
6023
6024    def HasVehicleWithCostClassIndex(self, cost_class_index):
6025        r"""
6026        Returns true iff the model contains a vehicle with the given
6027        cost_class_index.
6028        """
6029        return _pywrapcp.RoutingModel_HasVehicleWithCostClassIndex(self, cost_class_index)
6030
6031    def GetCostClassesCount(self):
6032        r"""Returns the number of different cost classes in the model."""
6033        return _pywrapcp.RoutingModel_GetCostClassesCount(self)
6034
6035    def GetNonZeroCostClassesCount(self):
6036        r"""Ditto, minus the 'always zero', built-in cost class."""
6037        return _pywrapcp.RoutingModel_GetNonZeroCostClassesCount(self)
6038
6039    def GetVehicleClassIndexOfVehicle(self, vehicle):
6040        return _pywrapcp.RoutingModel_GetVehicleClassIndexOfVehicle(self, vehicle)
6041
6042    def GetVehicleOfClass(self, vehicle_class):
6043        r"""
6044        Returns a vehicle of the given vehicle class, and -1 if there are no
6045        vehicles for this class.
6046        """
6047        return _pywrapcp.RoutingModel_GetVehicleOfClass(self, vehicle_class)
6048
6049    def GetVehicleClassesCount(self):
6050        r"""Returns the number of different vehicle classes in the model."""
6051        return _pywrapcp.RoutingModel_GetVehicleClassesCount(self)
6052
6053    def GetSameVehicleIndicesOfIndex(self, node):
6054        r"""Returns variable indices of nodes constrained to be on the same route."""
6055        return _pywrapcp.RoutingModel_GetSameVehicleIndicesOfIndex(self, node)
6056
6057    def GetSameActivityIndicesOfIndex(self, node):
6058        r"""Returns variable indices of nodes constrained to have the same activity."""
6059        return _pywrapcp.RoutingModel_GetSameActivityIndicesOfIndex(self, node)
6060
6061    def GetSameActivityGroupOfIndex(self, node):
6062        r"""Returns the same activity group of the node."""
6063        return _pywrapcp.RoutingModel_GetSameActivityGroupOfIndex(self, node)
6064
6065    def GetSameActivityGroupsCount(self):
6066        r"""Returns the number of same activity groups."""
6067        return _pywrapcp.RoutingModel_GetSameActivityGroupsCount(self)
6068
6069    def GetSameActivityIndicesOfGroup(self, group):
6070        r"""Returns variable indices of nodes in the same activity group."""
6071        return _pywrapcp.RoutingModel_GetSameActivityIndicesOfGroup(self, group)
6072
6073    def GetVehicleTypeContainer(self):
6074        return _pywrapcp.RoutingModel_GetVehicleTypeContainer(self)
6075
6076    def ArcIsMoreConstrainedThanArc(self, _from, to1, to2):
6077        r"""
6078        Returns whether the arc from->to1 is more constrained than from->to2,
6079        taking into account, in order:
6080        - whether the destination node isn't an end node
6081        - whether the destination node is mandatory
6082        - whether the destination node is bound to the same vehicle as the source
6083        - the "primary constrained" dimension (see SetPrimaryConstrainedDimension)
6084        It then breaks ties using, in order:
6085        - the arc cost (taking unperformed penalties into account)
6086        - the size of the vehicle vars of "to1" and "to2" (lowest size wins)
6087        - the value: the lowest value of the indices to1 and to2 wins.
6088        See the .cc for details.
6089        The more constrained arc is typically preferable when building a
6090        first solution. This method is intended to be used as a callback for the
6091        BestValueByComparisonSelector value selector.
6092        Args:
6093          from: the variable index of the source node
6094          to1: the variable index of the first candidate destination node.
6095          to2: the variable index of the second candidate destination node.
6096        """
6097        return _pywrapcp.RoutingModel_ArcIsMoreConstrainedThanArc(self, _from, to1, to2)
6098
6099    def DebugOutputAssignment(self, solution_assignment, dimension_to_print):
6100        r"""
6101        Print some debugging information about an assignment, including the
6102        feasible intervals of the CumulVar for dimension "dimension_to_print"
6103        at each step of the routes.
6104        If "dimension_to_print" is omitted, all dimensions will be printed.
6105        """
6106        return _pywrapcp.RoutingModel_DebugOutputAssignment(self, solution_assignment, dimension_to_print)
6107
6108    def CheckIfAssignmentIsFeasible(self, assignment, call_at_solution_monitors):
6109        r"""
6110        Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair
6111        containing the minimum and maximum of the CumulVar of the jth node on
6112        route i.
6113        - cumul_bounds[i][j].first is the minimum.
6114        - cumul_bounds[i][j].second is the maximum.
6115        Checks if an assignment is feasible.
6116        """
6117        return _pywrapcp.RoutingModel_CheckIfAssignmentIsFeasible(self, assignment, call_at_solution_monitors)
6118
6119    def solver(self):
6120        r"""
6121        Returns the underlying constraint solver. Can be used to add extra
6122        constraints and/or modify search algorithms.
6123        """
6124        return _pywrapcp.RoutingModel_solver(self)
6125
6126    def CheckLimit(self, *args):
6127        r"""
6128        Returns true if the search limit has been crossed with the given time
6129        offset.
6130        """
6131        return _pywrapcp.RoutingModel_CheckLimit(self, *args)
6132
6133    def RemainingTime(self):
6134        r"""Returns the time left in the search limit."""
6135        return _pywrapcp.RoutingModel_RemainingTime(self)
6136
6137    def UpdateTimeLimit(self, time_limit):
6138        r"""Updates the time limit of the search limit."""
6139        return _pywrapcp.RoutingModel_UpdateTimeLimit(self, time_limit)
6140
6141    def TimeBuffer(self):
6142        r"""Returns the time buffer to safely return a solution."""
6143        return _pywrapcp.RoutingModel_TimeBuffer(self)
6144
6145    def GetMutableCPSatInterrupt(self):
6146        r"""Returns the atomic<bool> to stop the CP-SAT solver."""
6147        return _pywrapcp.RoutingModel_GetMutableCPSatInterrupt(self)
6148
6149    def GetMutableCPInterrupt(self):
6150        r"""Returns the atomic<bool> to stop the CP solver."""
6151        return _pywrapcp.RoutingModel_GetMutableCPInterrupt(self)
6152
6153    def CancelSearch(self):
6154        r"""Cancels the current search."""
6155        return _pywrapcp.RoutingModel_CancelSearch(self)
6156
6157    def nodes(self):
6158        r"""
6159        Sizes and indices
6160        Returns the number of nodes in the model.
6161        """
6162        return _pywrapcp.RoutingModel_nodes(self)
6163
6164    def vehicles(self):
6165        r"""Returns the number of vehicle routes in the model."""
6166        return _pywrapcp.RoutingModel_vehicles(self)
6167
6168    def Size(self):
6169        r"""Returns the number of next variables in the model."""
6170        return _pywrapcp.RoutingModel_Size(self)
6171
6172    def GetNumberOfDecisionsInFirstSolution(self, search_parameters):
6173        r"""
6174        Returns statistics on first solution search, number of decisions sent to
6175        filters, number of decisions rejected by filters.
6176        """
6177        return _pywrapcp.RoutingModel_GetNumberOfDecisionsInFirstSolution(self, search_parameters)
6178
6179    def GetNumberOfRejectsInFirstSolution(self, search_parameters):
6180        return _pywrapcp.RoutingModel_GetNumberOfRejectsInFirstSolution(self, search_parameters)
6181
6182    def GetAutomaticFirstSolutionStrategy(self):
6183        r"""Returns the automatic first solution strategy selected."""
6184        return _pywrapcp.RoutingModel_GetAutomaticFirstSolutionStrategy(self)
6185
6186    def IsMatchingModel(self):
6187        r"""Returns true if a vehicle/node matching problem is detected."""
6188        return _pywrapcp.RoutingModel_IsMatchingModel(self)
6189
6190    def AreRoutesInterdependent(self, parameters):
6191        r"""
6192        Returns true if routes are interdependent. This means that any
6193        modification to a route might impact another.
6194        """
6195        return _pywrapcp.RoutingModel_AreRoutesInterdependent(self, parameters)
6196
6197    def MakeGuidedSlackFinalizer(self, dimension, initializer):
6198        r"""
6199        The next few members are in the public section only for testing purposes.
6200
6201        MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a
6202        dimension using a callback to choose which values to start with.
6203        The finalizer works only when all next variables in the model have
6204        been fixed. It has the following two characteristics:
6205        1. It follows the routes defined by the nexts variables when choosing a
6206           variable to make a decision on.
6207        2. When it comes to choose a value for the slack of node i, the decision
6208           builder first calls the callback with argument i, and supposingly the
6209           returned value is x it creates decisions slack[i] = x, slack[i] = x +
6210           1, slack[i] = x - 1, slack[i] = x + 2, etc.
6211        """
6212        return _pywrapcp.RoutingModel_MakeGuidedSlackFinalizer(self, dimension, initializer)
6213
6214    def MakeSelfDependentDimensionFinalizer(self, dimension):
6215        r"""
6216        MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a
6217        self-dependent dimension. It makes an extensive use of the caches of the
6218        state dependent transits.
6219        In detail, MakeSelfDependentDimensionFinalizer returns a composition of a
6220        local search decision builder with a greedy descent operator for the cumul
6221        of the start of each route and a guided slack finalizer. Provided there
6222        are no time windows and the maximum slacks are large enough, once the
6223        cumul of the start of route is fixed, the guided finalizer can find
6224        optimal values of the slacks for the rest of the route in time
6225        proportional to the length of the route. Therefore the composed finalizer
6226        generally works in time O(log(t)*n*m), where t is the latest possible
6227        departute time, n is the number of nodes in the network and m is the
6228        number of vehicles.
6229        """
6230        return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension)
6231
6232    def GetPathsMetadata(self):
6233        return _pywrapcp.RoutingModel_GetPathsMetadata(self)
6234
6235    def GetVehiclesOfSameClass(self, start_end_index):
6236        r"""
6237        Returns indices of the vehicles which are in the same vehicle class as the
6238        vehicle starting or ending at start_end_index.
6239        """
6240        return _pywrapcp.RoutingModel_GetVehiclesOfSameClass(self, start_end_index)
6241
6242    def GetSameVehicleClassArcs(self, from_index, to_index):
6243        r"""
6244        Returns all arcs which are equivalent to the {from_index, to_index} arc
6245        wrt vehicle classes. Arcs will be returned only if from_index is the
6246        start of a vehicle or if to_index is the end of a vehicle. The returned
6247        arcs will then be starting or ending at start or end nodes of vehicles in
6248        the same vehicle class. The input arc is included in the returned vector.
6249        """
6250        return _pywrapcp.RoutingModel_GetSameVehicleClassArcs(self, from_index, to_index)
6251
6252# Register RoutingModel in _pywrapcp:
6253_pywrapcp.RoutingModel_swigregister(RoutingModel)
6254cvar = _pywrapcp.cvar
6255RoutingModel.kNoPenalty = _pywrapcp.cvar.RoutingModel_kNoPenalty
6256RoutingModel.kNoDisjunction = _pywrapcp.cvar.RoutingModel_kNoDisjunction
6257RoutingModel.kNoDimension = _pywrapcp.cvar.RoutingModel_kNoDimension
6258
6259class RoutingModelVisitor(BaseObject):
6260    r"""Routing model visitor."""
6261
6262    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6263    __repr__ = _swig_repr
6264
6265    def __init__(self):
6266        _pywrapcp.RoutingModelVisitor_swiginit(self, _pywrapcp.new_RoutingModelVisitor())
6267    __swig_destroy__ = _pywrapcp.delete_RoutingModelVisitor
6268
6269# Register RoutingModelVisitor in _pywrapcp:
6270_pywrapcp.RoutingModelVisitor_swigregister(RoutingModelVisitor)
6271RoutingModelVisitor.kLightElement = _pywrapcp.cvar.RoutingModelVisitor_kLightElement
6272RoutingModelVisitor.kLightElement2 = _pywrapcp.cvar.RoutingModelVisitor_kLightElement2
6273RoutingModelVisitor.kRemoveValues = _pywrapcp.cvar.RoutingModelVisitor_kRemoveValues
6274
6275class GlobalVehicleBreaksConstraint(Constraint):
6276    r"""
6277    GlobalVehicleBreaksConstraint ensures breaks constraints are enforced on
6278    all vehicles in the dimension passed to its constructor.
6279    It is intended to be used for dimensions representing time.
6280    A break constraint ensures break intervals fit on the route of a vehicle.
6281    For a given vehicle, it forces break intervals to be disjoint from visit
6282    intervals, where visit intervals start at CumulVar(node) and last for
6283    node_visit_transit[node]. Moreover, it ensures that there is enough time
6284    between two consecutive nodes of a route to do transit and vehicle breaks,
6285    i.e. if Next(nodeA) = nodeB, CumulVar(nodeA) = tA and CumulVar(nodeB) = tB,
6286    then SlackVar(nodeA) >= sum_{breaks [tA, tB)} duration(break).
6287    """
6288
6289    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6290    __repr__ = _swig_repr
6291
6292    def __init__(self, dimension):
6293        _pywrapcp.GlobalVehicleBreaksConstraint_swiginit(self, _pywrapcp.new_GlobalVehicleBreaksConstraint(dimension))
6294
6295    def DebugString(self):
6296        return _pywrapcp.GlobalVehicleBreaksConstraint_DebugString(self)
6297
6298    def Post(self):
6299        return _pywrapcp.GlobalVehicleBreaksConstraint_Post(self)
6300
6301    def InitialPropagateWrapper(self):
6302        return _pywrapcp.GlobalVehicleBreaksConstraint_InitialPropagateWrapper(self)
6303    __swig_destroy__ = _pywrapcp.delete_GlobalVehicleBreaksConstraint
6304
6305# Register GlobalVehicleBreaksConstraint in _pywrapcp:
6306_pywrapcp.GlobalVehicleBreaksConstraint_swigregister(GlobalVehicleBreaksConstraint)
6307class TypeRegulationsChecker(object):
6308    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6309
6310    def __init__(self, *args, **kwargs):
6311        raise AttributeError("No constructor defined - class is abstract")
6312    __repr__ = _swig_repr
6313    __swig_destroy__ = _pywrapcp.delete_TypeRegulationsChecker
6314
6315    def CheckVehicle(self, vehicle, next_accessor):
6316        return _pywrapcp.TypeRegulationsChecker_CheckVehicle(self, vehicle, next_accessor)
6317
6318# Register TypeRegulationsChecker in _pywrapcp:
6319_pywrapcp.TypeRegulationsChecker_swigregister(TypeRegulationsChecker)
6320class TypeIncompatibilityChecker(TypeRegulationsChecker):
6321    r"""Checker for type incompatibilities."""
6322
6323    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6324    __repr__ = _swig_repr
6325
6326    def __init__(self, model, check_hard_incompatibilities):
6327        _pywrapcp.TypeIncompatibilityChecker_swiginit(self, _pywrapcp.new_TypeIncompatibilityChecker(model, check_hard_incompatibilities))
6328    __swig_destroy__ = _pywrapcp.delete_TypeIncompatibilityChecker
6329
6330# Register TypeIncompatibilityChecker in _pywrapcp:
6331_pywrapcp.TypeIncompatibilityChecker_swigregister(TypeIncompatibilityChecker)
6332class TypeRequirementChecker(TypeRegulationsChecker):
6333    r"""Checker for type requirements."""
6334
6335    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6336    __repr__ = _swig_repr
6337
6338    def __init__(self, model):
6339        _pywrapcp.TypeRequirementChecker_swiginit(self, _pywrapcp.new_TypeRequirementChecker(model))
6340    __swig_destroy__ = _pywrapcp.delete_TypeRequirementChecker
6341
6342# Register TypeRequirementChecker in _pywrapcp:
6343_pywrapcp.TypeRequirementChecker_swigregister(TypeRequirementChecker)
6344class TypeRegulationsConstraint(Constraint):
6345    r"""
6346    The following constraint ensures that incompatibilities and requirements
6347    between types are respected.
6348
6349    It verifies both "hard" and "temporal" incompatibilities.
6350    Two nodes with hard incompatible types cannot be served by the same vehicle
6351    at all, while with a temporal incompatibility they can't be on the same
6352    route at the same time.
6353    The VisitTypePolicy of a node determines how visiting it impacts the type
6354    count on the route.
6355
6356    For example, for
6357    - three temporally incompatible types T1 T2 and T3
6358    - 2 pairs of nodes a1/r1 and a2/r2 of type T1 and T2 respectively, with
6359        - a1 and a2 of VisitTypePolicy TYPE_ADDED_TO_VEHICLE
6360        - r1 and r2 of policy ADDED_TYPE_REMOVED_FROM_VEHICLE
6361    - 3 nodes A, UV and AR of type T3, respectively with type policies
6362      TYPE_ADDED_TO_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT and
6363      TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
6364    the configurations
6365    UV --> a1 --> r1 --> a2 --> r2,   a1 --> r1 --> a2 --> r2 --> A and
6366    a1 --> r1 --> AR --> a2 --> r2 are acceptable, whereas the configurations
6367    a1 --> a2 --> r1 --> ..., or A --> a1 --> r1 --> ..., or
6368    a1 --> r1 --> UV --> ... are not feasible.
6369
6370    It also verifies same-vehicle and temporal type requirements.
6371    A node of type T_d with a same-vehicle requirement for type T_r needs to be
6372    served by the same vehicle as a node of type T_r.
6373    Temporal requirements, on the other hand, can take effect either when the
6374    dependent type is being added to the route or when it's removed from it,
6375    which is determined by the dependent node's VisitTypePolicy.
6376    In the above example:
6377    - If T3 is required on the same vehicle as T1, A, AR or UV must be on the
6378      same vehicle as a1.
6379    - If T2 is required when adding T1, a2 must be visited *before* a1, and if
6380      r2 is also visited on the route, it must be *after* a1, i.e. T2 must be on
6381      the vehicle when a1 is visited:
6382      ... --> a2 --> ... --> a1 --> ... --> r2 --> ...
6383    - If T3 is required when removing T1, T3 needs to be on the vehicle when
6384      r1 is visited:
6385      ... --> A --> ... --> r1 --> ...   OR   ... --> r1 --> ... --> UV --> ...
6386    """
6387
6388    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6389    __repr__ = _swig_repr
6390
6391    def __init__(self, model):
6392        _pywrapcp.TypeRegulationsConstraint_swiginit(self, _pywrapcp.new_TypeRegulationsConstraint(model))
6393
6394    def Post(self):
6395        return _pywrapcp.TypeRegulationsConstraint_Post(self)
6396
6397    def InitialPropagateWrapper(self):
6398        return _pywrapcp.TypeRegulationsConstraint_InitialPropagateWrapper(self)
6399    __swig_destroy__ = _pywrapcp.delete_TypeRegulationsConstraint
6400
6401# Register TypeRegulationsConstraint in _pywrapcp:
6402_pywrapcp.TypeRegulationsConstraint_swigregister(TypeRegulationsConstraint)
6403class BoundCost(object):
6404    r"""
6405    A structure meant to store soft bounds and associated violation constants.
6406    It is 'Simple' because it has one BoundCost per element,
6407    in contrast to 'Multiple'. Design notes:
6408    - it is meant to store model information to be shared through pointers,
6409      so it disallows copy and assign to avoid accidental duplication.
6410    - it keeps soft bounds as an array of structs to help cache,
6411      because code that uses such bounds typically use both bound and cost.
6412    - soft bounds are named pairs, prevents some mistakes.
6413    - using operator[] to access elements is not interesting,
6414      because the structure will be accessed through pointers, moreover having
6415      to type bound_cost reminds the user of the order if they do a copy
6416      assignment of the element.
6417    """
6418
6419    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6420    __repr__ = _swig_repr
6421    bound = property(_pywrapcp.BoundCost_bound_get, _pywrapcp.BoundCost_bound_set)
6422    cost = property(_pywrapcp.BoundCost_cost_get, _pywrapcp.BoundCost_cost_set)
6423
6424    def __init__(self, *args):
6425        _pywrapcp.BoundCost_swiginit(self, _pywrapcp.new_BoundCost(*args))
6426    __swig_destroy__ = _pywrapcp.delete_BoundCost
6427
6428# Register BoundCost in _pywrapcp:
6429_pywrapcp.BoundCost_swigregister(BoundCost)
6430class SimpleBoundCosts(object):
6431    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6432    __repr__ = _swig_repr
6433
6434    def __init__(self, num_bounds, default_bound_cost):
6435        _pywrapcp.SimpleBoundCosts_swiginit(self, _pywrapcp.new_SimpleBoundCosts(num_bounds, default_bound_cost))
6436
6437    def bound_cost(self, element):
6438        return _pywrapcp.SimpleBoundCosts_bound_cost(self, element)
6439
6440    def size(self):
6441        return _pywrapcp.SimpleBoundCosts_size(self)
6442    __swig_destroy__ = _pywrapcp.delete_SimpleBoundCosts
6443
6444# Register SimpleBoundCosts in _pywrapcp:
6445_pywrapcp.SimpleBoundCosts_swigregister(SimpleBoundCosts)
6446class RoutingDimension(object):
6447    r"""
6448    Dimensions represent quantities accumulated at nodes along the routes. They
6449    represent quantities such as weights or volumes carried along the route, or
6450    distance or times.
6451
6452    Quantities at a node are represented by "cumul" variables and the increase
6453    or decrease of quantities between nodes are represented by "transit"
6454    variables. These variables are linked as follows:
6455
6456    if j == next(i),
6457    cumuls(j) = cumuls(i) + transits(i) + slacks(i) +
6458                state_dependent_transits(i)
6459
6460    where slack is a positive slack variable (can represent waiting times for
6461    a time dimension), and state_dependent_transits is a non-purely functional
6462    version of transits_. Favour transits over state_dependent_transits when
6463    possible, because purely functional callbacks allow more optimisations and
6464    make the model faster and easier to solve.
6465    for a given vehicle, it is passed as an external vector, it would be better
6466    to have this information here.
6467    """
6468
6469    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6470
6471    def __init__(self, *args, **kwargs):
6472        raise AttributeError("No constructor defined")
6473    __repr__ = _swig_repr
6474    __swig_destroy__ = _pywrapcp.delete_RoutingDimension
6475
6476    def model(self):
6477        r"""Returns the model on which the dimension was created."""
6478        return _pywrapcp.RoutingDimension_model(self)
6479
6480    def GetTransitValue(self, from_index, to_index, vehicle):
6481        r"""
6482        Returns the transition value for a given pair of nodes (as var index);
6483        this value is the one taken by the corresponding transit variable when
6484        the 'next' variable for 'from_index' is bound to 'to_index'.
6485        """
6486        return _pywrapcp.RoutingDimension_GetTransitValue(self, from_index, to_index, vehicle)
6487
6488    def GetTransitValueFromClass(self, from_index, to_index, vehicle_class):
6489        r"""
6490        Same as above but taking a vehicle class of the dimension instead of a
6491        vehicle (the class of a vehicle can be obtained with vehicle_to_class()).
6492        """
6493        return _pywrapcp.RoutingDimension_GetTransitValueFromClass(self, from_index, to_index, vehicle_class)
6494
6495    def CumulVar(self, index):
6496        r"""
6497        Get the cumul, transit and slack variables for the given node (given as
6498        int64_t var index).
6499        """
6500        return _pywrapcp.RoutingDimension_CumulVar(self, index)
6501
6502    def TransitVar(self, index):
6503        return _pywrapcp.RoutingDimension_TransitVar(self, index)
6504
6505    def FixedTransitVar(self, index):
6506        return _pywrapcp.RoutingDimension_FixedTransitVar(self, index)
6507
6508    def SlackVar(self, index):
6509        return _pywrapcp.RoutingDimension_SlackVar(self, index)
6510
6511    def SetCumulVarRange(self, index, min, max):
6512        r"""
6513        Some functions to allow users to use the interface without knowing about
6514        the underlying CP model.
6515        Restricts the range of the cumul variable associated to index.
6516        """
6517        return _pywrapcp.RoutingDimension_SetCumulVarRange(self, index, min, max)
6518
6519    def GetCumulVarMin(self, index):
6520        r"""Gets the current minimum of the cumul variable associated to index."""
6521        return _pywrapcp.RoutingDimension_GetCumulVarMin(self, index)
6522
6523    def GetCumulVarMax(self, index):
6524        r"""Gets the current maximum of the cumul variable associated to index."""
6525        return _pywrapcp.RoutingDimension_GetCumulVarMax(self, index)
6526
6527    def SetSpanUpperBoundForVehicle(self, upper_bound, vehicle):
6528        r"""
6529        Sets an upper bound on the dimension span on a given vehicle. This is the
6530        preferred way to limit the "length" of the route of a vehicle according to
6531        a dimension.
6532        """
6533        return _pywrapcp.RoutingDimension_SetSpanUpperBoundForVehicle(self, upper_bound, vehicle)
6534
6535    def SetSpanCostCoefficientForVehicle(self, coefficient, vehicle):
6536        r"""
6537        Sets a cost proportional to the dimension span on a given vehicle,
6538        or on all vehicles at once. "coefficient" must be nonnegative.
6539        This is handy to model costs proportional to idle time when the dimension
6540        represents time.
6541        The cost for a vehicle is
6542          span_cost = coefficient * (dimension end value - dimension start value).
6543        """
6544        return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForVehicle(self, coefficient, vehicle)
6545
6546    def SetSpanCostCoefficientForAllVehicles(self, coefficient):
6547        return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForAllVehicles(self, coefficient)
6548
6549    def SetSlackCostCoefficientForVehicle(self, coefficient, vehicle):
6550        r"""
6551        Sets a cost proportional to the dimension total slack on a given vehicle,
6552        or on all vehicles at once. "coefficient" must be nonnegative.
6553        This is handy to model costs only proportional to idle time when the
6554        dimension represents time.
6555        The cost for a vehicle is
6556          slack_cost = coefficient *
6557                (dimension end value - dimension start value - total_transit).
6558        """
6559        return _pywrapcp.RoutingDimension_SetSlackCostCoefficientForVehicle(self, coefficient, vehicle)
6560
6561    def SetSlackCostCoefficientForAllVehicles(self, coefficient):
6562        return _pywrapcp.RoutingDimension_SetSlackCostCoefficientForAllVehicles(self, coefficient)
6563
6564    def SetGlobalSpanCostCoefficient(self, coefficient):
6565        r"""
6566        Sets a cost proportional to the *global* dimension span, that is the
6567        difference between the largest value of route end cumul variables and
6568        the smallest value of route start cumul variables.
6569        In other words:
6570        global_span_cost =
6571          coefficient * (Max(dimension end value) - Min(dimension start value)).
6572        """
6573        return _pywrapcp.RoutingDimension_SetGlobalSpanCostCoefficient(self, coefficient)
6574
6575    def SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient):
6576        r"""
6577        Sets a soft upper bound to the cumul variable of a given variable index.
6578        If the value of the cumul variable is greater than the bound, a cost
6579        proportional to the difference between this value and the bound is added
6580        to the cost function of the model:
6581          cumulVar <= upper_bound -> cost = 0
6582           cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound)
6583        This is also handy to model tardiness costs when the dimension represents
6584        time.
6585        """
6586        return _pywrapcp.RoutingDimension_SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient)
6587
6588    def HasCumulVarSoftUpperBound(self, index):
6589        r"""
6590        Returns true if a soft upper bound has been set for a given variable
6591        index.
6592        """
6593        return _pywrapcp.RoutingDimension_HasCumulVarSoftUpperBound(self, index)
6594
6595    def GetCumulVarSoftUpperBound(self, index):
6596        r"""
6597        Returns the soft upper bound of a cumul variable for a given variable
6598        index. The "hard" upper bound of the variable is returned if no soft upper
6599        bound has been set.
6600        """
6601        return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBound(self, index)
6602
6603    def GetCumulVarSoftUpperBoundCoefficient(self, index):
6604        r"""
6605        Returns the cost coefficient of the soft upper bound of a cumul variable
6606        for a given variable index. If no soft upper bound has been set, 0 is
6607        returned.
6608        """
6609        return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBoundCoefficient(self, index)
6610
6611    def SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient):
6612        r"""
6613        Sets a soft lower bound to the cumul variable of a given variable index.
6614        If the value of the cumul variable is less than the bound, a cost
6615        proportional to the difference between this value and the bound is added
6616        to the cost function of the model:
6617          cumulVar > lower_bound -> cost = 0
6618          cumulVar <= lower_bound -> cost = coefficient * (lower_bound -
6619                      cumulVar).
6620        This is also handy to model earliness costs when the dimension represents
6621        time.
6622        """
6623        return _pywrapcp.RoutingDimension_SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient)
6624
6625    def HasCumulVarSoftLowerBound(self, index):
6626        r"""
6627        Returns true if a soft lower bound has been set for a given variable
6628        index.
6629        """
6630        return _pywrapcp.RoutingDimension_HasCumulVarSoftLowerBound(self, index)
6631
6632    def GetCumulVarSoftLowerBound(self, index):
6633        r"""
6634        Returns the soft lower bound of a cumul variable for a given variable
6635        index. The "hard" lower bound of the variable is returned if no soft lower
6636        bound has been set.
6637        """
6638        return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBound(self, index)
6639
6640    def GetCumulVarSoftLowerBoundCoefficient(self, index):
6641        r"""
6642        Returns the cost coefficient of the soft lower bound of a cumul variable
6643        for a given variable index. If no soft lower bound has been set, 0 is
6644        returned.
6645        """
6646        return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBoundCoefficient(self, index)
6647
6648    def SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits):
6649        r"""
6650        Sets the breaks for a given vehicle. Breaks are represented by
6651        IntervalVars. They may interrupt transits between nodes and increase
6652        the value of corresponding slack variables.
6653        A break may take place before the start of a vehicle, after the end of
6654        a vehicle, or during a travel i -> j.
6655
6656        In that case, the interval [break.Start(), break.End()) must be a subset
6657        of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In
6658        other words, a break may not overlap any node n's visit, given by
6659        [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)).
6660        This formula considers post_travel(_, start) and pre_travel(end, _) to be
6661        0; pre_travel will never be called on any (_, start) and post_travel will
6662        never we called on any (end, _). If pre_travel_evaluator or
6663        post_travel_evaluator is -1, it will be taken as a function that always
6664        returns 0.
6665        Deprecated, sets pre_travel(i, j) = node_visit_transit[i].
6666        """
6667        return _pywrapcp.RoutingDimension_SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits)
6668
6669    def SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle):
6670        r"""
6671        With breaks supposed to be consecutive, this forces the distance between
6672        breaks of size at least minimum_break_duration to be at most distance.
6673        This supposes that the time until route start and after route end are
6674        infinite breaks.
6675        """
6676        return _pywrapcp.RoutingDimension_SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle)
6677
6678    def InitializeBreaks(self):
6679        r"""
6680        Sets up vehicle_break_intervals_, vehicle_break_distance_duration_,
6681        pre_travel_evaluators and post_travel_evaluators.
6682        """
6683        return _pywrapcp.RoutingDimension_InitializeBreaks(self)
6684
6685    def HasBreakConstraints(self):
6686        r"""Returns true if any break interval or break distance was defined."""
6687        return _pywrapcp.RoutingDimension_HasBreakConstraints(self)
6688
6689    def GetPreTravelEvaluatorOfVehicle(self, vehicle):
6690        return _pywrapcp.RoutingDimension_GetPreTravelEvaluatorOfVehicle(self, vehicle)
6691
6692    def GetPostTravelEvaluatorOfVehicle(self, vehicle):
6693        return _pywrapcp.RoutingDimension_GetPostTravelEvaluatorOfVehicle(self, vehicle)
6694
6695    def base_dimension(self):
6696        r"""Returns the parent in the dependency tree if any or nullptr otherwise."""
6697        return _pywrapcp.RoutingDimension_base_dimension(self)
6698
6699    def ShortestTransitionSlack(self, node):
6700        r"""
6701        It makes sense to use the function only for self-dependent dimension.
6702        For such dimensions the value of the slack of a node determines the
6703        transition cost of the next transit. Provided that
6704          1. cumul[node] is fixed,
6705          2. next[node] and next[next[node]] (if exists) are fixed,
6706        the value of slack[node] for which cumul[next[node]] + transit[next[node]]
6707        is minimized can be found in O(1) using this function.
6708        """
6709        return _pywrapcp.RoutingDimension_ShortestTransitionSlack(self, node)
6710
6711    def name(self):
6712        r"""Returns the name of the dimension."""
6713        return _pywrapcp.RoutingDimension_name(self)
6714
6715    def SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index):
6716        return _pywrapcp.RoutingDimension_SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index)
6717
6718    def HasPickupToDeliveryLimits(self):
6719        return _pywrapcp.RoutingDimension_HasPickupToDeliveryLimits(self)
6720
6721    def AddNodePrecedence(self, first_node, second_node, offset):
6722        return _pywrapcp.RoutingDimension_AddNodePrecedence(self, first_node, second_node, offset)
6723
6724    def GetSpanUpperBoundForVehicle(self, vehicle):
6725        return _pywrapcp.RoutingDimension_GetSpanUpperBoundForVehicle(self, vehicle)
6726
6727    def GetSpanCostCoefficientForVehicle(self, vehicle):
6728        return _pywrapcp.RoutingDimension_GetSpanCostCoefficientForVehicle(self, vehicle)
6729
6730    def GetSlackCostCoefficientForVehicle(self, vehicle):
6731        return _pywrapcp.RoutingDimension_GetSlackCostCoefficientForVehicle(self, vehicle)
6732
6733    def global_span_cost_coefficient(self):
6734        return _pywrapcp.RoutingDimension_global_span_cost_coefficient(self)
6735
6736    def GetGlobalOptimizerOffset(self):
6737        return _pywrapcp.RoutingDimension_GetGlobalOptimizerOffset(self)
6738
6739    def GetLocalOptimizerOffsetForVehicle(self, vehicle):
6740        return _pywrapcp.RoutingDimension_GetLocalOptimizerOffsetForVehicle(self, vehicle)
6741
6742    def SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6743        r"""
6744        If the span of vehicle on this dimension is larger than bound,
6745        the cost will be increased by cost * (span - bound).
6746        """
6747        return _pywrapcp.RoutingDimension_SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)
6748
6749    def HasSoftSpanUpperBounds(self):
6750        return _pywrapcp.RoutingDimension_HasSoftSpanUpperBounds(self)
6751
6752    def GetSoftSpanUpperBoundForVehicle(self, vehicle):
6753        return _pywrapcp.RoutingDimension_GetSoftSpanUpperBoundForVehicle(self, vehicle)
6754
6755    def SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6756        r"""
6757        If the span of vehicle on this dimension is larger than bound,
6758        the cost will be increased by cost * (span - bound)^2.
6759        """
6760        return _pywrapcp.RoutingDimension_SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)
6761
6762    def HasQuadraticCostSoftSpanUpperBounds(self):
6763        return _pywrapcp.RoutingDimension_HasQuadraticCostSoftSpanUpperBounds(self)
6764
6765    def GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle):
6766        return _pywrapcp.RoutingDimension_GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle)
6767
6768# Register RoutingDimension in _pywrapcp:
6769_pywrapcp.RoutingDimension_swigregister(RoutingDimension)
6770
6771def SolveModelWithSat(model, search_parameters, initial_solution, solution):
6772    r"""
6773    Attempts to solve the model using the cp-sat solver. As of 5/2019, will
6774    solve the TSP corresponding to the model if it has a single vehicle.
6775    Therefore the resulting solution might not actually be feasible. Will return
6776    false if a solution could not be found.
6777    """
6778    return _pywrapcp.SolveModelWithSat(model, search_parameters, initial_solution, solution)
class DefaultPhaseParameters:
 64class DefaultPhaseParameters(object):
 65    r"""
 66    This struct holds all parameters for the default search.
 67    DefaultPhaseParameters is only used by Solver::MakeDefaultPhase methods.
 68    Note this is for advanced users only.
 69    """
 70
 71    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 72    __repr__ = _swig_repr
 73    CHOOSE_MAX_SUM_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_SUM_IMPACT
 74    CHOOSE_MAX_AVERAGE_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_AVERAGE_IMPACT
 75    CHOOSE_MAX_VALUE_IMPACT = _pywrapcp.DefaultPhaseParameters_CHOOSE_MAX_VALUE_IMPACT
 76    SELECT_MIN_IMPACT = _pywrapcp.DefaultPhaseParameters_SELECT_MIN_IMPACT
 77    SELECT_MAX_IMPACT = _pywrapcp.DefaultPhaseParameters_SELECT_MAX_IMPACT
 78    NONE = _pywrapcp.DefaultPhaseParameters_NONE
 79    NORMAL = _pywrapcp.DefaultPhaseParameters_NORMAL
 80    VERBOSE = _pywrapcp.DefaultPhaseParameters_VERBOSE
 81    var_selection_schema = property(_pywrapcp.DefaultPhaseParameters_var_selection_schema_get, _pywrapcp.DefaultPhaseParameters_var_selection_schema_set, doc=r"""
 82    This parameter describes how the next variable to instantiate
 83    will be chosen.
 84    """)
 85    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.""")
 86    initialization_splits = property(_pywrapcp.DefaultPhaseParameters_initialization_splits_get, _pywrapcp.DefaultPhaseParameters_initialization_splits_set, doc=r"""
 87    Maximum number of intervals that the initialization of impacts will scan
 88    per variable.
 89    """)
 90    run_all_heuristics = property(_pywrapcp.DefaultPhaseParameters_run_all_heuristics_get, _pywrapcp.DefaultPhaseParameters_run_all_heuristics_set, doc=r"""
 91    The default phase will run heuristics periodically. This parameter
 92    indicates if we should run all heuristics, or a randomly selected
 93    one.
 94    """)
 95    heuristic_period = property(_pywrapcp.DefaultPhaseParameters_heuristic_period_get, _pywrapcp.DefaultPhaseParameters_heuristic_period_set, doc=r"""
 96    The distance in nodes between each run of the heuristics. A
 97    negative or null value will mean that we will not run heuristics
 98    at all.
 99    """)
100    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.""")
101    persistent_impact = property(_pywrapcp.DefaultPhaseParameters_persistent_impact_get, _pywrapcp.DefaultPhaseParameters_persistent_impact_set, doc=r"""
102    Whether to keep the impact from the first search for other searches,
103    or to recompute the impact for each new search.
104    """)
105    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.""")
106    display_level = property(_pywrapcp.DefaultPhaseParameters_display_level_get, _pywrapcp.DefaultPhaseParameters_display_level_set, doc=r"""
107    This represents the amount of information displayed by the default search.
108    NONE means no display, VERBOSE means extra information.
109    """)
110    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.""")
111
112    def __init__(self):
113        _pywrapcp.DefaultPhaseParameters_swiginit(self, _pywrapcp.new_DefaultPhaseParameters())
114    __swig_destroy__ = _pywrapcp.delete_DefaultPhaseParameters

This struct holds all parameters for the default search. DefaultPhaseParameters is only used by Solver::MakeDefaultPhase methods. Note this is for advanced users only.

thisown
71    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

CHOOSE_MAX_SUM_IMPACT = 0
CHOOSE_MAX_AVERAGE_IMPACT = 1
CHOOSE_MAX_VALUE_IMPACT = 2
SELECT_MIN_IMPACT = 0
SELECT_MAX_IMPACT = 1
NONE = 0
NORMAL = 1
VERBOSE = 2
var_selection_schema

This parameter describes how the next variable to instantiate will be chosen.

value_selection_schema

This parameter describes which value to select for a given var.

initialization_splits

Maximum number of intervals that the initialization of impacts will scan per variable.

run_all_heuristics

The default phase will run heuristics periodically. This parameter indicates if we should run all heuristics, or a randomly selected one.

heuristic_period

The distance in nodes between each run of the heuristics. A negative or null value will mean that we will not run heuristics at all.

heuristic_num_failures_limit

The failure limit for each heuristic that we run.

persistent_impact

Whether to keep the impact from the first search for other searches, or to recompute the impact for each new search.

random_seed

Seed used to initialize the random part in some heuristics.

display_level

This represents the amount of information displayed by the default search. NONE means no display, VERBOSE means extra information.

decision_builder

When defined, this overrides the default impact based decision builder.

class Solver:
 118class Solver(object):
 119    r"""
 120    Solver Class
 121
 122    A solver represents the main computation engine. It implements the entire
 123    range of Constraint Programming protocols:
 124      - Reversibility
 125      - Propagation
 126      - Search
 127
 128    Usually, Constraint Programming code consists of
 129      - the creation of the Solver,
 130      - the creation of the decision variables of the model,
 131      - the creation of the constraints of the model and their addition to the
 132        solver() through the AddConstraint() method,
 133      - the creation of the main DecisionBuilder class,
 134      - the launch of the solve() method with the decision builder.
 135
 136    For the time being, Solver is neither MT_SAFE nor MT_HOT.
 137    """
 138
 139    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 140    __repr__ = _swig_repr
 141    INT_VAR_DEFAULT = _pywrapcp.Solver_INT_VAR_DEFAULT
 142    r"""The default behavior is CHOOSE_FIRST_UNBOUND."""
 143    INT_VAR_SIMPLE = _pywrapcp.Solver_INT_VAR_SIMPLE
 144    r"""The simple selection is CHOOSE_FIRST_UNBOUND."""
 145    CHOOSE_FIRST_UNBOUND = _pywrapcp.Solver_CHOOSE_FIRST_UNBOUND
 146    r"""
 147    Select the first unbound variable.
 148    Variables are considered in the order of the vector of IntVars used
 149    to create the selector.
 150    """
 151    CHOOSE_RANDOM = _pywrapcp.Solver_CHOOSE_RANDOM
 152    r"""Randomly select one of the remaining unbound variables."""
 153    CHOOSE_MIN_SIZE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MIN
 154    r"""
 155    Among unbound variables, select the variable with the smallest size,
 156    i.e., the smallest number of possible values.
 157    In case of a tie, the selected variables is the one with the lowest min
 158    value.
 159    In case of a tie, the first one is selected, first being defined by the
 160    order in the vector of IntVars used to create the selector.
 161    """
 162    CHOOSE_MIN_SIZE_HIGHEST_MIN = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MIN
 163    r"""
 164    Among unbound variables, select the variable with the smallest size,
 165    i.e., the smallest number of possible values.
 166    In case of a tie, the selected variable is the one with the highest min
 167    value.
 168    In case of a tie, the first one is selected, first being defined by the
 169    order in the vector of IntVars used to create the selector.
 170    """
 171    CHOOSE_MIN_SIZE_LOWEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_LOWEST_MAX
 172    r"""
 173    Among unbound variables, select the variable with the smallest size,
 174    i.e., the smallest number of possible values.
 175    In case of a tie, the selected variables is the one with the lowest max
 176    value.
 177    In case of a tie, the first one is selected, first being defined by the
 178    order in the vector of IntVars used to create the selector.
 179    """
 180    CHOOSE_MIN_SIZE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_MIN_SIZE_HIGHEST_MAX
 181    r"""
 182    Among unbound variables, select the variable with the smallest size,
 183    i.e., the smallest number of possible values.
 184    In case of a tie, the selected variable is the one with the highest max
 185    value.
 186    In case of a tie, the first one is selected, first being defined by the
 187    order in the vector of IntVars used to create the selector.
 188    """
 189    CHOOSE_LOWEST_MIN = _pywrapcp.Solver_CHOOSE_LOWEST_MIN
 190    r"""
 191    Among unbound variables, select the variable with the smallest minimal
 192    value.
 193    In case of a tie, the first one is selected, "first" defined by the
 194    order in the vector of IntVars used to create the selector.
 195    """
 196    CHOOSE_HIGHEST_MAX = _pywrapcp.Solver_CHOOSE_HIGHEST_MAX
 197    r"""
 198    Among unbound variables, select the variable with the highest maximal
 199    value.
 200    In case of a tie, the first one is selected, first being defined by the
 201    order in the vector of IntVars used to create the selector.
 202    """
 203    CHOOSE_MIN_SIZE = _pywrapcp.Solver_CHOOSE_MIN_SIZE
 204    r"""
 205    Among unbound variables, select the variable with the smallest size.
 206    In case of a tie, the first one is selected, first being defined by the
 207    order in the vector of IntVars used to create the selector.
 208    """
 209    CHOOSE_MAX_SIZE = _pywrapcp.Solver_CHOOSE_MAX_SIZE
 210    r"""
 211    Among unbound variables, select the variable with the highest size.
 212    In case of a tie, the first one is selected, first being defined by the
 213    order in the vector of IntVars used to create the selector.
 214    """
 215    CHOOSE_MAX_REGRET_ON_MIN = _pywrapcp.Solver_CHOOSE_MAX_REGRET_ON_MIN
 216    r"""
 217    Among unbound variables, select the variable with the largest
 218    gap between the first and the second values of the domain.
 219    """
 220    CHOOSE_PATH = _pywrapcp.Solver_CHOOSE_PATH
 221    r"""
 222    Selects the next unbound variable on a path, the path being defined by
 223    the variables: var[i] corresponds to the index of the next of i.
 224    """
 225    INT_VALUE_DEFAULT = _pywrapcp.Solver_INT_VALUE_DEFAULT
 226    r"""The default behavior is ASSIGN_MIN_VALUE."""
 227    INT_VALUE_SIMPLE = _pywrapcp.Solver_INT_VALUE_SIMPLE
 228    r"""The simple selection is ASSIGN_MIN_VALUE."""
 229    ASSIGN_MIN_VALUE = _pywrapcp.Solver_ASSIGN_MIN_VALUE
 230    r"""Selects the min value of the selected variable."""
 231    ASSIGN_MAX_VALUE = _pywrapcp.Solver_ASSIGN_MAX_VALUE
 232    r"""Selects the max value of the selected variable."""
 233    ASSIGN_RANDOM_VALUE = _pywrapcp.Solver_ASSIGN_RANDOM_VALUE
 234    r"""Selects randomly one of the possible values of the selected variable."""
 235    ASSIGN_CENTER_VALUE = _pywrapcp.Solver_ASSIGN_CENTER_VALUE
 236    r"""
 237    Selects the first possible value which is the closest to the center
 238    of the domain of the selected variable.
 239    The center is defined as (min + max) / 2.
 240    """
 241    SPLIT_LOWER_HALF = _pywrapcp.Solver_SPLIT_LOWER_HALF
 242    r"""
 243    Split the domain in two around the center, and choose the lower
 244    part first.
 245    """
 246    SPLIT_UPPER_HALF = _pywrapcp.Solver_SPLIT_UPPER_HALF
 247    r"""
 248    Split the domain in two around the center, and choose the lower
 249    part first.
 250    """
 251    SEQUENCE_DEFAULT = _pywrapcp.Solver_SEQUENCE_DEFAULT
 252    SEQUENCE_SIMPLE = _pywrapcp.Solver_SEQUENCE_SIMPLE
 253    CHOOSE_MIN_SLACK_RANK_FORWARD = _pywrapcp.Solver_CHOOSE_MIN_SLACK_RANK_FORWARD
 254    CHOOSE_RANDOM_RANK_FORWARD = _pywrapcp.Solver_CHOOSE_RANDOM_RANK_FORWARD
 255    INTERVAL_DEFAULT = _pywrapcp.Solver_INTERVAL_DEFAULT
 256    r"""The default is INTERVAL_SET_TIMES_FORWARD."""
 257    INTERVAL_SIMPLE = _pywrapcp.Solver_INTERVAL_SIMPLE
 258    r"""The simple is INTERVAL_SET_TIMES_FORWARD."""
 259    INTERVAL_SET_TIMES_FORWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_FORWARD
 260    r"""
 261    Selects the variable with the lowest starting time of all variables,
 262    and fixes its starting time to this lowest value.
 263    """
 264    INTERVAL_SET_TIMES_BACKWARD = _pywrapcp.Solver_INTERVAL_SET_TIMES_BACKWARD
 265    r"""
 266    Selects the variable with the highest ending time of all variables,
 267    and fixes the ending time to this highest values.
 268    """
 269    TWOOPT = _pywrapcp.Solver_TWOOPT
 270    r"""
 271    Operator which reverses a sub-chain of a path. It is called TwoOpt
 272    because it breaks two arcs on the path; resulting paths are called
 273    two-optimal.
 274    Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5
 275    (where (1, 5) are first and last nodes of the path and can therefore not
 276    be moved):
 277      1 -> [3 -> 2] -> 4  -> 5
 278      1 -> [4 -> 3  -> 2] -> 5
 279      1 ->  2 -> [4 -> 3] -> 5
 280    """
 281    OROPT = _pywrapcp.Solver_OROPT
 282    r"""
 283    Relocate: OROPT and RELOCATE.
 284    Operator which moves a sub-chain of a path to another position; the
 285    specified chain length is the fixed length of the chains being moved.
 286    When this length is 1, the operator simply moves a node to another
 287    position.
 288    Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5, for a chain
 289    length of 2 (where (1, 5) are first and last nodes of the path and can
 290    therefore not be moved):
 291      1 ->  4 -> [2 -> 3] -> 5
 292      1 -> [3 -> 4] -> 2  -> 5
 293
 294    Using Relocate with chain lengths of 1, 2 and 3 together is equivalent
 295    to the OrOpt operator on a path. The OrOpt operator is a limited
 296     version of 3Opt (breaks 3 arcs on a path).
 297    """
 298    RELOCATE = _pywrapcp.Solver_RELOCATE
 299    r"""Relocate neighborhood with length of 1 (see OROPT comment)."""
 300    EXCHANGE = _pywrapcp.Solver_EXCHANGE
 301    r"""
 302    Operator which exchanges the positions of two nodes.
 303    Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5
 304    (where (1, 5) are first and last nodes of the path and can therefore not
 305    be moved):
 306      1 -> [3] -> [2] ->  4  -> 5
 307      1 -> [4] ->  3  -> [2] -> 5
 308      1 ->  2  -> [4] -> [3] -> 5
 309    """
 310    CROSS = _pywrapcp.Solver_CROSS
 311    r"""
 312    Operator which cross exchanges the starting chains of 2 paths, including
 313    exchanging the whole paths.
 314    First and last nodes are not moved.
 315    Possible neighbors for the paths 1 -> 2 -> 3 -> 4 -> 5 and 6 -> 7 -> 8
 316    (where (1, 5) and (6, 8) are first and last nodes of the paths and can
 317    therefore not be moved):
 318      1 -> [7] -> 3 -> 4 -> 5  6 -> [2] -> 8
 319      1 -> [7] -> 4 -> 5       6 -> [2 -> 3] -> 8
 320      1 -> [7] -> 5            6 -> [2 -> 3 -> 4] -> 8
 321    """
 322    MAKEACTIVE = _pywrapcp.Solver_MAKEACTIVE
 323    r"""
 324    Operator which inserts an inactive node into a path.
 325    Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
 326    (where 1 and 4 are first and last nodes of the path) are:
 327      1 -> [5] ->  2  ->  3  -> 4
 328      1 ->  2  -> [5] ->  3  -> 4
 329      1 ->  2  ->  3  -> [5] -> 4
 330    """
 331    MAKEINACTIVE = _pywrapcp.Solver_MAKEINACTIVE
 332    r"""
 333    Operator which makes path nodes inactive.
 334    Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are
 335    first and last nodes of the path) are:
 336      1 -> 3 -> 4 with 2 inactive
 337      1 -> 2 -> 4 with 3 inactive
 338    """
 339    MAKECHAININACTIVE = _pywrapcp.Solver_MAKECHAININACTIVE
 340    r"""
 341    Operator which makes a "chain" of path nodes inactive.
 342    Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are
 343    first and last nodes of the path) are:
 344      1 -> 3 -> 4 with 2 inactive
 345      1 -> 2 -> 4 with 3 inactive
 346      1 -> 4 with 2 and 3 inactive
 347    """
 348    SWAPACTIVE = _pywrapcp.Solver_SWAPACTIVE
 349    r"""
 350    Operator which replaces an active node by an inactive one.
 351    Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
 352    (where 1 and 4 are first and last nodes of the path) are:
 353      1 -> [5] ->  3  -> 4 with 2 inactive
 354      1 ->  2  -> [5] -> 4 with 3 inactive
 355    """
 356    EXTENDEDSWAPACTIVE = _pywrapcp.Solver_EXTENDEDSWAPACTIVE
 357    r"""
 358    Operator which makes an inactive node active and an active one inactive.
 359    It is similar to SwapActiveOperator except that it tries to insert the
 360    inactive node in all possible positions instead of just the position of
 361    the node made inactive.
 362    Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
 363    (where 1 and 4 are first and last nodes of the path) are:
 364      1 -> [5] ->  3  -> 4 with 2 inactive
 365      1 ->  3  -> [5] -> 4 with 2 inactive
 366      1 -> [5] ->  2  -> 4 with 3 inactive
 367      1 ->  2  -> [5] -> 4 with 3 inactive
 368    """
 369    PATHLNS = _pywrapcp.Solver_PATHLNS
 370    r"""
 371    Operator which relaxes two sub-chains of three consecutive arcs each.
 372    Each sub-chain is defined by a start node and the next three arcs. Those
 373    six arcs are relaxed to build a new neighbor.
 374    PATHLNS explores all possible pairs of starting nodes and so defines
 375    n^2 neighbors, n being the number of nodes.
 376    Note that the two sub-chains can be part of the same path; they even may
 377    overlap.
 378    """
 379    FULLPATHLNS = _pywrapcp.Solver_FULLPATHLNS
 380    r"""
 381    Operator which relaxes one entire path and all inactive nodes, thus
 382    defining num_paths neighbors.
 383    """
 384    UNACTIVELNS = _pywrapcp.Solver_UNACTIVELNS
 385    r"""
 386    Operator which relaxes all inactive nodes and one sub-chain of six
 387    consecutive arcs. That way the path can be improved by inserting
 388    inactive nodes or swapping arcs.
 389    """
 390    INCREMENT = _pywrapcp.Solver_INCREMENT
 391    r"""
 392    Operator which defines one neighbor per variable. Each neighbor tries to
 393    increment by one the value of the corresponding variable. When a new
 394    solution is found the neighborhood is rebuilt from scratch, i.e., tries
 395    to increment values in the variable order.
 396    Consider for instance variables x and y. x is incremented one by one to
 397    its max, and when it is not possible to increment x anymore, y is
 398    incremented once. If this is a solution, then next neighbor tries to
 399    increment x.
 400    """
 401    DECREMENT = _pywrapcp.Solver_DECREMENT
 402    r"""
 403    Operator which defines a neighborhood to decrement values.
 404    The behavior is the same as INCREMENT, except values are decremented
 405    instead of incremented.
 406    """
 407    SIMPLELNS = _pywrapcp.Solver_SIMPLELNS
 408    r"""
 409    Operator which defines one neighbor per variable. Each neighbor relaxes
 410    one variable.
 411    When a new solution is found the neighborhood is rebuilt from scratch.
 412    Consider for instance variables x and y. First x is relaxed and the
 413    solver is looking for the best possible solution (with only x relaxed).
 414    Then y is relaxed, and the solver is looking for a new solution.
 415    If a new solution is found, then the next variable to be relaxed is x.
 416    """
 417    GE = _pywrapcp.Solver_GE
 418    r"""Move is accepted when the current objective value >= objective.Min."""
 419    LE = _pywrapcp.Solver_LE
 420    r"""Move is accepted when the current objective value <= objective.Max."""
 421    EQ = _pywrapcp.Solver_EQ
 422    r"""
 423    Move is accepted when the current objective value is in the interval
 424    objective.Min .. objective.Max.
 425    """
 426    DELAYED_PRIORITY = _pywrapcp.Solver_DELAYED_PRIORITY
 427    r"""
 428    DELAYED_PRIORITY is the lowest priority: Demons will be processed after
 429    VAR_PRIORITY and NORMAL_PRIORITY demons.
 430    """
 431    VAR_PRIORITY = _pywrapcp.Solver_VAR_PRIORITY
 432    r"""VAR_PRIORITY is between DELAYED_PRIORITY and NORMAL_PRIORITY."""
 433    NORMAL_PRIORITY = _pywrapcp.Solver_NORMAL_PRIORITY
 434    r"""NORMAL_PRIORITY is the highest priority: Demons will be processed first."""
 435
 436    def __init__(self, *args):
 437        r"""Solver API"""
 438        _pywrapcp.Solver_swiginit(self, _pywrapcp.new_Solver(*args))
 439
 440        self.__python_constraints = []
 441
 442
 443
 444    __swig_destroy__ = _pywrapcp.delete_Solver
 445
 446    def Parameters(self):
 447        r"""Stored Parameters."""
 448        return _pywrapcp.Solver_Parameters(self)
 449
 450    @staticmethod
 451    def DefaultSolverParameters():
 452        r"""Create a ConstraintSolverParameters proto with all the default values."""
 453        return _pywrapcp.Solver_DefaultSolverParameters()
 454
 455    def AddConstraint(self, c):
 456        r"""
 457        Adds the constraint 'c' to the model.
 458
 459        After calling this method, and until there is a backtrack that undoes the
 460        addition, any assignment of variables to values must satisfy the given
 461        constraint in order to be considered feasible. There are two fairly
 462        different use cases:
 463
 464        - the most common use case is modeling: the given constraint is really
 465        part of the problem that the user is trying to solve. In this use case,
 466        AddConstraint is called outside of search (i.e., with state() ==
 467        OUTSIDE_SEARCH). Most users should only use AddConstraint in this
 468        way. In this case, the constraint will belong to the model forever: it
 469        cannot be removed by backtracking.
 470
 471        - a rarer use case is that 'c' is not a real constraint of the model. It
 472        may be a constraint generated by a branching decision (a constraint whose
 473        goal is to restrict the search space), a symmetry breaking constraint (a
 474        constraint that does restrict the search space, but in a way that cannot
 475        have an impact on the quality of the solutions in the subtree), or an
 476        inferred constraint that, while having no semantic value to the model (it
 477        does not restrict the set of solutions), is worth having because we
 478        believe it may strengthen the propagation. In these cases, it happens
 479        that the constraint is added during the search (i.e., with state() ==
 480        IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is
 481        added during a search, it applies only to the subtree of the search tree
 482        rooted at the current node, and will be automatically removed by
 483        backtracking.
 484
 485        This method does not take ownership of the constraint. If the constraint
 486        has been created by any factory method (Solver::MakeXXX), it will
 487        automatically be deleted. However, power users who implement their own
 488        constraints should do: solver.AddConstraint(solver.RevAlloc(new
 489        MyConstraint(...));
 490        """
 491        return _pywrapcp.Solver_AddConstraint(self, c)
 492
 493    def Solve(self, *args):
 494        r"""
 495         Solves the problem using the given DecisionBuilder and returns true if a
 496         solution was found and accepted.
 497
 498         These methods are the ones most users should use to search for a solution.
 499         Note that the definition of 'solution' is subtle. A solution here is
 500         defined as a leaf of the search tree with respect to the given decision
 501         builder for which there is no failure. What this means is that, contrary
 502         to intuition, a solution may not have all variables of the model bound.
 503         It is the responsibility of the decision builder to keep returning
 504         decisions until all variables are indeed bound. The most extreme
 505         counterexample is calling Solve with a trivial decision builder whose
 506         Next() method always returns nullptr. In this case, Solve immediately
 507         returns 'true', since not assigning any variable to any value is a
 508         solution, unless the root node propagation discovers that the model is
 509         infeasible.
 510
 511         This function must be called either from outside of search,
 512         or from within the Next() method of a decision builder.
 513
 514         Solve will terminate whenever any of the following event arise:
 515        A search monitor asks the solver to terminate the search by calling
 516           solver()->FinishCurrentSearch().
 517        A solution is found that is accepted by all search monitors, and none of
 518           the search monitors decides to search for another one.
 519
 520         Upon search termination, there will be a series of backtracks all the way
 521         to the top level. This means that a user cannot expect to inspect the
 522         solution by querying variables after a call to Solve(): all the
 523         information will be lost. In order to do something with the solution, the
 524         user must either:
 525
 526        Use a search monitor that can process such a leaf. See, in particular,
 527             the SolutionCollector class.
 528        Do not use Solve. Instead, use the more fine-grained approach using
 529             methods NewSearch(...), NextSolution(), and EndSearch().
 530
 531         :type db: :py:class:`DecisionBuilder`
 532         :param db: The decision builder that will generate the search tree.
 533         :type monitors: std::vector< operations_research::SearchMonitor * >
 534         :param monitors: A vector of search monitors that will be notified of
 535             various events during the search. In their reaction to these events, such
 536             monitors may influence the search.
 537        """
 538        return _pywrapcp.Solver_Solve(self, *args)
 539
 540    def NewSearch(self, *args):
 541        r"""
 542         Decomposed search.
 543         The code for a top level search should look like
 544         solver->NewSearch(db);
 545         while (solver->NextSolution()) {
 546        .. use the current solution
 547         }
 548         solver()->EndSearch();
 549        """
 550        return _pywrapcp.Solver_NewSearch(self, *args)
 551
 552    def NextSolution(self):
 553        return _pywrapcp.Solver_NextSolution(self)
 554
 555    def RestartSearch(self):
 556        return _pywrapcp.Solver_RestartSearch(self)
 557
 558    def EndSearch(self):
 559        return _pywrapcp.Solver_EndSearch(self)
 560
 561    def SolveAndCommit(self, *args):
 562        r"""
 563        SolveAndCommit using a decision builder and up to three
 564          search monitors, usually one for the objective, one for the limits
 565          and one to collect solutions.
 566
 567        The difference between a SolveAndCommit() and a Solve() method
 568        call is the fact that SolveAndCommit will not backtrack all
 569        modifications at the end of the search. This method is only
 570        usable during the Next() method of a decision builder.
 571        """
 572        return _pywrapcp.Solver_SolveAndCommit(self, *args)
 573
 574    def CheckAssignment(self, solution):
 575        r"""Checks whether the given assignment satisfies all relevant constraints."""
 576        return _pywrapcp.Solver_CheckAssignment(self, solution)
 577
 578    def CheckConstraint(self, ct):
 579        r"""
 580        Checks whether adding this constraint will lead to an immediate
 581        failure. It will return false if the model is already inconsistent, or if
 582        adding the constraint makes it inconsistent.
 583        """
 584        return _pywrapcp.Solver_CheckConstraint(self, ct)
 585
 586    def Fail(self):
 587        r"""Abandon the current branch in the search tree. A backtrack will follow."""
 588        return _pywrapcp.Solver_Fail(self)
 589
 590    @staticmethod
 591    def MemoryUsage():
 592        r"""Current memory usage in bytes"""
 593        return _pywrapcp.Solver_MemoryUsage()
 594
 595    def WallTime(self):
 596        r"""
 597        DEPRECATED: Use Now() instead.
 598        Time elapsed, in ms since the creation of the solver.
 599        """
 600        return _pywrapcp.Solver_WallTime(self)
 601
 602    def Branches(self):
 603        r"""The number of branches explored since the creation of the solver."""
 604        return _pywrapcp.Solver_Branches(self)
 605
 606    def Solutions(self):
 607        r"""The number of solutions found since the start of the search."""
 608        return _pywrapcp.Solver_Solutions(self)
 609
 610    def Failures(self):
 611        r"""The number of failures encountered since the creation of the solver."""
 612        return _pywrapcp.Solver_Failures(self)
 613
 614    def AcceptedNeighbors(self):
 615        r"""The number of accepted neighbors."""
 616        return _pywrapcp.Solver_AcceptedNeighbors(self)
 617
 618    def Stamp(self):
 619        r"""
 620        The stamp indicates how many moves in the search tree we have performed.
 621        It is useful to detect if we need to update same lazy structures.
 622        """
 623        return _pywrapcp.Solver_Stamp(self)
 624
 625    def FailStamp(self):
 626        r"""The fail_stamp() is incremented after each backtrack."""
 627        return _pywrapcp.Solver_FailStamp(self)
 628
 629    def IntVar(self, *args):
 630        r"""
 631        *Overload 1:*
 632        MakeIntVar will create the best range based int var for the bounds given.
 633
 634        |
 635
 636        *Overload 2:*
 637        MakeIntVar will create a variable with the given sparse domain.
 638
 639        |
 640
 641        *Overload 3:*
 642        MakeIntVar will create a variable with the given sparse domain.
 643
 644        |
 645
 646        *Overload 4:*
 647        MakeIntVar will create the best range based int var for the bounds given.
 648
 649        |
 650
 651        *Overload 5:*
 652        MakeIntVar will create a variable with the given sparse domain.
 653
 654        |
 655
 656        *Overload 6:*
 657        MakeIntVar will create a variable with the given sparse domain.
 658        """
 659        return _pywrapcp.Solver_IntVar(self, *args)
 660
 661    def BoolVar(self, *args):
 662        r"""
 663        *Overload 1:*
 664        MakeBoolVar will create a variable with a {0, 1} domain.
 665
 666        |
 667
 668        *Overload 2:*
 669        MakeBoolVar will create a variable with a {0, 1} domain.
 670        """
 671        return _pywrapcp.Solver_BoolVar(self, *args)
 672
 673    def IntConst(self, *args):
 674        r"""
 675        *Overload 1:*
 676        IntConst will create a constant expression.
 677
 678        |
 679
 680        *Overload 2:*
 681        IntConst will create a constant expression.
 682        """
 683        return _pywrapcp.Solver_IntConst(self, *args)
 684
 685    def Sum(self, vars):
 686        r"""sum of all vars."""
 687        return _pywrapcp.Solver_Sum(self, vars)
 688
 689    def ScalProd(self, *args):
 690        r"""
 691        *Overload 1:*
 692        scalar product
 693
 694        |
 695
 696        *Overload 2:*
 697        scalar product
 698        """
 699        return _pywrapcp.Solver_ScalProd(self, *args)
 700
 701    def MonotonicElement(self, values, increasing, index):
 702        r"""
 703        Function based element. The constraint takes ownership of the
 704        callback.  The callback must be monotonic. It must be able to
 705        cope with any possible value in the domain of 'index'
 706        (potentially negative ones too). Furtermore, monotonicity is not
 707        checked. Thus giving a non-monotonic function, or specifying an
 708        incorrect increasing parameter will result in undefined behavior.
 709        """
 710        return _pywrapcp.Solver_MonotonicElement(self, values, increasing, index)
 711
 712    def Element(self, *args):
 713        r"""
 714        *Overload 1:*
 715        values[index]
 716
 717        |
 718
 719        *Overload 2:*
 720        values[index]
 721
 722        |
 723
 724        *Overload 3:*
 725        Function-based element. The constraint takes ownership of the
 726        callback. The callback must be able to cope with any possible
 727        value in the domain of 'index' (potentially negative ones too).
 728
 729        |
 730
 731        *Overload 4:*
 732        2D version of function-based element expression, values(expr1, expr2).
 733
 734        |
 735
 736        *Overload 5:*
 737        vars[expr]
 738        """
 739        return _pywrapcp.Solver_Element(self, *args)
 740
 741    def IndexExpression(self, vars, value):
 742        r"""
 743        Returns the expression expr such that vars[expr] == value.
 744        It assumes that vars are all different.
 745        """
 746        return _pywrapcp.Solver_IndexExpression(self, vars, value)
 747
 748    def Min(self, *args):
 749        r"""
 750        *Overload 1:*
 751        std::min(vars)
 752
 753        |
 754
 755        *Overload 2:*
 756        std::min (left, right)
 757
 758        |
 759
 760        *Overload 3:*
 761        std::min(expr, value)
 762
 763        |
 764
 765        *Overload 4:*
 766        std::min(expr, value)
 767        """
 768        return _pywrapcp.Solver_Min(self, *args)
 769
 770    def Max(self, *args):
 771        r"""
 772        *Overload 1:*
 773        std::max(vars)
 774
 775        |
 776
 777        *Overload 2:*
 778        std::max(left, right)
 779
 780        |
 781
 782        *Overload 3:*
 783        std::max(expr, value)
 784
 785        |
 786
 787        *Overload 4:*
 788        std::max(expr, value)
 789        """
 790        return _pywrapcp.Solver_Max(self, *args)
 791
 792    def ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost):
 793        r"""Convex piecewise function."""
 794        return _pywrapcp.Solver_ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost)
 795
 796    def SemiContinuousExpr(self, expr, fixed_charge, step):
 797        r"""
 798        Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b)
 799        a >= 0 and b >= 0
 800        """
 801        return _pywrapcp.Solver_SemiContinuousExpr(self, expr, fixed_charge, step)
 802
 803    def ConditionalExpression(self, condition, expr, unperformed_value):
 804        r"""Conditional Expr condition ? expr : unperformed_value"""
 805        return _pywrapcp.Solver_ConditionalExpression(self, condition, expr, unperformed_value)
 806
 807    def TrueConstraint(self):
 808        r"""This constraint always succeeds."""
 809        return _pywrapcp.Solver_TrueConstraint(self)
 810
 811    def FalseConstraint(self, *args):
 812        r"""This constraint always fails."""
 813        return _pywrapcp.Solver_FalseConstraint(self, *args)
 814
 815    def IsEqualCstCt(self, var, value, boolvar):
 816        r"""boolvar == (var == value)"""
 817        return _pywrapcp.Solver_IsEqualCstCt(self, var, value, boolvar)
 818
 819    def IsEqualCstVar(self, var, value):
 820        r"""status var of (var == value)"""
 821        return _pywrapcp.Solver_IsEqualCstVar(self, var, value)
 822
 823    def IsEqualCt(self, v1, v2, b):
 824        r"""b == (v1 == v2)"""
 825        return _pywrapcp.Solver_IsEqualCt(self, v1, v2, b)
 826
 827    def IsEqualVar(self, v1, v2):
 828        r"""status var of (v1 == v2)"""
 829        return _pywrapcp.Solver_IsEqualVar(self, v1, v2)
 830
 831    def IsDifferentCstCt(self, var, value, boolvar):
 832        r"""boolvar == (var != value)"""
 833        return _pywrapcp.Solver_IsDifferentCstCt(self, var, value, boolvar)
 834
 835    def IsDifferentCstVar(self, var, value):
 836        r"""status var of (var != value)"""
 837        return _pywrapcp.Solver_IsDifferentCstVar(self, var, value)
 838
 839    def IsDifferentVar(self, v1, v2):
 840        r"""status var of (v1 != v2)"""
 841        return _pywrapcp.Solver_IsDifferentVar(self, v1, v2)
 842
 843    def IsDifferentCt(self, v1, v2, b):
 844        r"""b == (v1 != v2)"""
 845        return _pywrapcp.Solver_IsDifferentCt(self, v1, v2, b)
 846
 847    def IsLessOrEqualCstCt(self, var, value, boolvar):
 848        r"""boolvar == (var <= value)"""
 849        return _pywrapcp.Solver_IsLessOrEqualCstCt(self, var, value, boolvar)
 850
 851    def IsLessOrEqualCstVar(self, var, value):
 852        r"""status var of (var <= value)"""
 853        return _pywrapcp.Solver_IsLessOrEqualCstVar(self, var, value)
 854
 855    def IsLessOrEqualVar(self, left, right):
 856        r"""status var of (left <= right)"""
 857        return _pywrapcp.Solver_IsLessOrEqualVar(self, left, right)
 858
 859    def IsLessOrEqualCt(self, left, right, b):
 860        r"""b == (left <= right)"""
 861        return _pywrapcp.Solver_IsLessOrEqualCt(self, left, right, b)
 862
 863    def IsGreaterOrEqualCstCt(self, var, value, boolvar):
 864        r"""boolvar == (var >= value)"""
 865        return _pywrapcp.Solver_IsGreaterOrEqualCstCt(self, var, value, boolvar)
 866
 867    def IsGreaterOrEqualCstVar(self, var, value):
 868        r"""status var of (var >= value)"""
 869        return _pywrapcp.Solver_IsGreaterOrEqualCstVar(self, var, value)
 870
 871    def IsGreaterOrEqualVar(self, left, right):
 872        r"""status var of (left >= right)"""
 873        return _pywrapcp.Solver_IsGreaterOrEqualVar(self, left, right)
 874
 875    def IsGreaterOrEqualCt(self, left, right, b):
 876        r"""b == (left >= right)"""
 877        return _pywrapcp.Solver_IsGreaterOrEqualCt(self, left, right, b)
 878
 879    def IsGreaterCstCt(self, v, c, b):
 880        r"""b == (v > c)"""
 881        return _pywrapcp.Solver_IsGreaterCstCt(self, v, c, b)
 882
 883    def IsGreaterCstVar(self, var, value):
 884        r"""status var of (var > value)"""
 885        return _pywrapcp.Solver_IsGreaterCstVar(self, var, value)
 886
 887    def IsGreaterVar(self, left, right):
 888        r"""status var of (left > right)"""
 889        return _pywrapcp.Solver_IsGreaterVar(self, left, right)
 890
 891    def IsGreaterCt(self, left, right, b):
 892        r"""b == (left > right)"""
 893        return _pywrapcp.Solver_IsGreaterCt(self, left, right, b)
 894
 895    def IsLessCstCt(self, v, c, b):
 896        r"""b == (v < c)"""
 897        return _pywrapcp.Solver_IsLessCstCt(self, v, c, b)
 898
 899    def IsLessCstVar(self, var, value):
 900        r"""status var of (var < value)"""
 901        return _pywrapcp.Solver_IsLessCstVar(self, var, value)
 902
 903    def IsLessVar(self, left, right):
 904        r"""status var of (left < right)"""
 905        return _pywrapcp.Solver_IsLessVar(self, left, right)
 906
 907    def IsLessCt(self, left, right, b):
 908        r"""b == (left < right)"""
 909        return _pywrapcp.Solver_IsLessCt(self, left, right, b)
 910
 911    def SumLessOrEqual(self, vars, cst):
 912        r"""Variation on arrays."""
 913        return _pywrapcp.Solver_SumLessOrEqual(self, vars, cst)
 914
 915    def SumGreaterOrEqual(self, vars, cst):
 916        return _pywrapcp.Solver_SumGreaterOrEqual(self, vars, cst)
 917
 918    def SumEquality(self, *args):
 919        return _pywrapcp.Solver_SumEquality(self, *args)
 920
 921    def ScalProdEquality(self, *args):
 922        return _pywrapcp.Solver_ScalProdEquality(self, *args)
 923
 924    def ScalProdGreaterOrEqual(self, *args):
 925        return _pywrapcp.Solver_ScalProdGreaterOrEqual(self, *args)
 926
 927    def ScalProdLessOrEqual(self, *args):
 928        return _pywrapcp.Solver_ScalProdLessOrEqual(self, *args)
 929
 930    def MinEquality(self, vars, min_var):
 931        return _pywrapcp.Solver_MinEquality(self, vars, min_var)
 932
 933    def MaxEquality(self, vars, max_var):
 934        return _pywrapcp.Solver_MaxEquality(self, vars, max_var)
 935
 936    def ElementEquality(self, *args):
 937        return _pywrapcp.Solver_ElementEquality(self, *args)
 938
 939    def AbsEquality(self, var, abs_var):
 940        r"""Creates the constraint abs(var) == abs_var."""
 941        return _pywrapcp.Solver_AbsEquality(self, var, abs_var)
 942
 943    def IndexOfConstraint(self, vars, index, target):
 944        r"""
 945        This constraint is a special case of the element constraint with
 946        an array of integer variables, where the variables are all
 947        different and the index variable is constrained such that
 948        vars[index] == target.
 949        """
 950        return _pywrapcp.Solver_IndexOfConstraint(self, vars, index, target)
 951
 952    def ConstraintInitialPropagateCallback(self, ct):
 953        r"""
 954        This method is a specialized case of the MakeConstraintDemon
 955        method to call the InitiatePropagate of the constraint 'ct'.
 956        """
 957        return _pywrapcp.Solver_ConstraintInitialPropagateCallback(self, ct)
 958
 959    def DelayedConstraintInitialPropagateCallback(self, ct):
 960        r"""
 961        This method is a specialized case of the MakeConstraintDemon
 962        method to call the InitiatePropagate of the constraint 'ct' with
 963        low priority.
 964        """
 965        return _pywrapcp.Solver_DelayedConstraintInitialPropagateCallback(self, ct)
 966
 967    def ClosureDemon(self, closure):
 968        r"""Creates a demon from a closure."""
 969        return _pywrapcp.Solver_ClosureDemon(self, closure)
 970
 971    def BetweenCt(self, expr, l, u):
 972        r"""(l <= expr <= u)"""
 973        return _pywrapcp.Solver_BetweenCt(self, expr, l, u)
 974
 975    def IsBetweenCt(self, expr, l, u, b):
 976        r"""b == (l <= expr <= u)"""
 977        return _pywrapcp.Solver_IsBetweenCt(self, expr, l, u, b)
 978
 979    def IsBetweenVar(self, v, l, u):
 980        return _pywrapcp.Solver_IsBetweenVar(self, v, l, u)
 981
 982    def MemberCt(self, *args):
 983        r"""
 984        expr in set. Propagation is lazy, i.e. this constraint does not
 985        creates holes in the domain of the variable.
 986        """
 987        return _pywrapcp.Solver_MemberCt(self, *args)
 988
 989    def NotMemberCt(self, *args):
 990        r"""
 991        *Overload 1:*
 992        expr not in set.
 993
 994        |
 995
 996        *Overload 2:*
 997        expr should not be in the list of forbidden intervals [start[i]..end[i]].
 998
 999        |
1000
1001        *Overload 3:*
1002        expr should not be in the list of forbidden intervals [start[i]..end[i]].
1003        """
1004        return _pywrapcp.Solver_NotMemberCt(self, *args)
1005
1006    def IsMemberCt(self, *args):
1007        r"""boolvar == (expr in set)"""
1008        return _pywrapcp.Solver_IsMemberCt(self, *args)
1009
1010    def IsMemberVar(self, *args):
1011        return _pywrapcp.Solver_IsMemberVar(self, *args)
1012
1013    def Count(self, *args):
1014        r"""
1015        *Overload 1:*
1016        |{i | vars[i] == value}| == max_count
1017
1018        |
1019
1020        *Overload 2:*
1021        |{i | vars[i] == value}| == max_count
1022        """
1023        return _pywrapcp.Solver_Count(self, *args)
1024
1025    def Distribute(self, *args):
1026        r"""
1027        *Overload 1:*
1028        Aggregated version of count:  |{i | v[i] == values[j]}| == cards[j]
1029
1030        |
1031
1032        *Overload 2:*
1033        Aggregated version of count:  |{i | v[i] == values[j]}| == cards[j]
1034
1035        |
1036
1037        *Overload 3:*
1038        Aggregated version of count:  |{i | v[i] == j}| == cards[j]
1039
1040        |
1041
1042        *Overload 4:*
1043        Aggregated version of count with bounded cardinalities:
1044        forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max
1045
1046        |
1047
1048        *Overload 5:*
1049        Aggregated version of count with bounded cardinalities:
1050        forall j in 0 .. card_size - 1:
1051           card_min[j] <= |{i | v[i] == j}| <= card_max[j]
1052
1053        |
1054
1055        *Overload 6:*
1056        Aggregated version of count with bounded cardinalities:
1057        forall j in 0 .. card_size - 1:
1058           card_min[j] <= |{i | v[i] == j}| <= card_max[j]
1059
1060        |
1061
1062        *Overload 7:*
1063        Aggregated version of count with bounded cardinalities:
1064        forall j in 0 .. card_size - 1:
1065           card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
1066
1067        |
1068
1069        *Overload 8:*
1070        Aggregated version of count with bounded cardinalities:
1071        forall j in 0 .. card_size - 1:
1072           card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
1073        """
1074        return _pywrapcp.Solver_Distribute(self, *args)
1075
1076    def Deviation(self, vars, deviation_var, total_sum):
1077        r"""
1078        Deviation constraint:
1079        sum_i |n * vars[i] - total_sum| <= deviation_var and
1080        sum_i vars[i] == total_sum
1081        n = #vars
1082        """
1083        return _pywrapcp.Solver_Deviation(self, vars, deviation_var, total_sum)
1084
1085    def AllDifferent(self, *args):
1086        r"""
1087        *Overload 1:*
1088        All variables are pairwise different. This corresponds to the
1089        stronger version of the propagation algorithm.
1090
1091        |
1092
1093        *Overload 2:*
1094        All variables are pairwise different.  If 'stronger_propagation'
1095        is true, stronger, and potentially slower propagation will
1096        occur. This API will be deprecated in the future.
1097        """
1098        return _pywrapcp.Solver_AllDifferent(self, *args)
1099
1100    def AllDifferentExcept(self, vars, escape_value):
1101        r"""
1102        All variables are pairwise different, unless they are assigned to
1103        the escape value.
1104        """
1105        return _pywrapcp.Solver_AllDifferentExcept(self, vars, escape_value)
1106
1107    def SortingConstraint(self, vars, sorted):
1108        r"""
1109        Creates a constraint binding the arrays of variables "vars" and
1110        "sorted_vars": sorted_vars[0] must be equal to the minimum of all
1111        variables in vars, and so on: the value of sorted_vars[i] must be
1112        equal to the i-th value of variables invars.
1113
1114        This constraint propagates in both directions: from "vars" to
1115        "sorted_vars" and vice-versa.
1116
1117        Behind the scenes, this constraint maintains that:
1118          - sorted is always increasing.
1119          - whatever the values of vars, there exists a permutation that
1120            injects its values into the sorted variables.
1121
1122        For more info, please have a look at:
1123          https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf
1124        """
1125        return _pywrapcp.Solver_SortingConstraint(self, vars, sorted)
1126
1127    def LexicalLess(self, left, right):
1128        r"""
1129        Creates a constraint that enforces that left is lexicographically less
1130        than right.
1131        """
1132        return _pywrapcp.Solver_LexicalLess(self, left, right)
1133
1134    def LexicalLessOrEqual(self, left, right):
1135        r"""
1136        Creates a constraint that enforces that left is lexicographically less
1137        than or equal to right.
1138        """
1139        return _pywrapcp.Solver_LexicalLessOrEqual(self, left, right)
1140
1141    def InversePermutationConstraint(self, left, right):
1142        r"""
1143        Creates a constraint that enforces that 'left' and 'right' both
1144        represent permutations of [0..left.size()-1], and that 'right' is
1145        the inverse permutation of 'left', i.e. for all i in
1146        [0..left.size()-1], right[left[i]] = i.
1147        """
1148        return _pywrapcp.Solver_InversePermutationConstraint(self, left, right)
1149
1150    def NullIntersect(self, first_vars, second_vars):
1151        r"""
1152        Creates a constraint that states that all variables in the first
1153        vector are different from all variables in the second
1154        group. Thus the set of values in the first vector does not
1155        intersect with the set of values in the second vector.
1156        """
1157        return _pywrapcp.Solver_NullIntersect(self, first_vars, second_vars)
1158
1159    def NullIntersectExcept(self, first_vars, second_vars, escape_value):
1160        r"""
1161        Creates a constraint that states that all variables in the first
1162        vector are different from all variables from the second group,
1163        unless they are assigned to the escape value. Thus the set of
1164        values in the first vector minus the escape value does not
1165        intersect with the set of values in the second vector.
1166        """
1167        return _pywrapcp.Solver_NullIntersectExcept(self, first_vars, second_vars, escape_value)
1168
1169    def Circuit(self, nexts):
1170        r"""Force the "nexts" variable to create a complete Hamiltonian path."""
1171        return _pywrapcp.Solver_Circuit(self, nexts)
1172
1173    def SubCircuit(self, nexts):
1174        r"""
1175        Force the "nexts" variable to create a complete Hamiltonian path
1176        for those that do not loop upon themselves.
1177        """
1178        return _pywrapcp.Solver_SubCircuit(self, nexts)
1179
1180    def DelayedPathCumul(self, nexts, active, cumuls, transits):
1181        r"""
1182        Delayed version of the same constraint: propagation on the nexts variables
1183        is delayed until all constraints have propagated.
1184        """
1185        return _pywrapcp.Solver_DelayedPathCumul(self, nexts, active, cumuls, transits)
1186
1187    def PathCumul(self, *args):
1188        r"""
1189        *Overload 1:*
1190        Creates a constraint which accumulates values along a path such that:
1191        cumuls[next[i]] = cumuls[i] + transits[i].
1192        Active variables indicate if the corresponding next variable is active;
1193        this could be useful to model unperformed nodes in a routing problem.
1194
1195        |
1196
1197        *Overload 2:*
1198        Creates a constraint which accumulates values along a path such that:
1199        cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]).
1200        Active variables indicate if the corresponding next variable is active;
1201        this could be useful to model unperformed nodes in a routing problem.
1202        Ownership of transit_evaluator is taken and it must be a repeatable
1203        callback.
1204
1205        |
1206
1207        *Overload 3:*
1208        Creates a constraint which accumulates values along a path such that:
1209        cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i].
1210        Active variables indicate if the corresponding next variable is active;
1211        this could be useful to model unperformed nodes in a routing problem.
1212        Ownership of transit_evaluator is taken and it must be a repeatable
1213        callback.
1214        """
1215        return _pywrapcp.Solver_PathCumul(self, *args)
1216
1217    def AllowedAssignments(self, *args):
1218        r"""
1219        *Overload 1:*
1220        This method creates a constraint where the graph of the relation
1221        between the variables is given in extension. There are 'arity'
1222        variables involved in the relation and the graph is given by a
1223        integer tuple set.
1224
1225        |
1226
1227        *Overload 2:*
1228        Compatibility layer for Python API.
1229        """
1230        return _pywrapcp.Solver_AllowedAssignments(self, *args)
1231
1232    def TransitionConstraint(self, *args):
1233        r"""
1234        *Overload 1:*
1235        This constraint create a finite automaton that will check the
1236        sequence of variables vars. It uses a transition table called
1237        'transition_table'. Each transition is a triple
1238           (current_state, variable_value, new_state).
1239        The initial state is given, and the set of accepted states is decribed
1240        by 'final_states'. These states are hidden inside the constraint.
1241        Only the transitions (i.e. the variables) are visible.
1242
1243        |
1244
1245        *Overload 2:*
1246        This constraint create a finite automaton that will check the
1247        sequence of variables vars. It uses a transition table called
1248        'transition_table'. Each transition is a triple
1249           (current_state, variable_value, new_state).
1250        The initial state is given, and the set of accepted states is decribed
1251        by 'final_states'. These states are hidden inside the constraint.
1252        Only the transitions (i.e. the variables) are visible.
1253        """
1254        return _pywrapcp.Solver_TransitionConstraint(self, *args)
1255
1256    def NonOverlappingBoxesConstraint(self, *args):
1257        r"""
1258        This constraint states that all the boxes must not overlap.
1259        The coordinates of box i are:
1260          (x_vars[i], y_vars[i]),
1261          (x_vars[i], y_vars[i] + y_size[i]),
1262          (x_vars[i] + x_size[i], y_vars[i]),
1263          (x_vars[i] + x_size[i], y_vars[i] + y_size[i]).
1264        The sizes must be non-negative. Boxes with a zero dimension can be
1265        pushed like any box.
1266        """
1267        return _pywrapcp.Solver_NonOverlappingBoxesConstraint(self, *args)
1268
1269    def Pack(self, vars, number_of_bins):
1270        r"""
1271        This constraint packs all variables onto 'number_of_bins'
1272        variables.  For any given variable, a value of 'number_of_bins'
1273        indicates that the variable is not assigned to any bin.
1274        Dimensions, i.e., cumulative constraints on this packing, can be
1275        added directly from the pack class.
1276        """
1277        return _pywrapcp.Solver_Pack(self, vars, number_of_bins)
1278
1279    def FixedDurationIntervalVar(self, *args):
1280        r"""
1281        *Overload 1:*
1282        Creates an interval var with a fixed duration. The duration must
1283        be greater than 0. If optional is true, then the interval can be
1284        performed or unperformed. If optional is false, then the interval
1285        is always performed.
1286
1287        |
1288
1289        *Overload 2:*
1290        Creates a performed interval var with a fixed duration. The duration must
1291        be greater than 0.
1292
1293        |
1294
1295        *Overload 3:*
1296        Creates an interval var with a fixed duration, and performed_variable.
1297        The duration must be greater than 0.
1298        """
1299        return _pywrapcp.Solver_FixedDurationIntervalVar(self, *args)
1300
1301    def FixedInterval(self, start, duration, name):
1302        r"""Creates a fixed and performed interval."""
1303        return _pywrapcp.Solver_FixedInterval(self, start, duration, name)
1304
1305    def IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name):
1306        r"""
1307        Creates an interval var by specifying the bounds on start,
1308        duration, and end.
1309        """
1310        return _pywrapcp.Solver_IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name)
1311
1312    def MirrorInterval(self, interval_var):
1313        r"""
1314        Creates an interval var that is the mirror image of the given one, that
1315        is, the interval var obtained by reversing the axis.
1316        """
1317        return _pywrapcp.Solver_MirrorInterval(self, interval_var)
1318
1319    def FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1320        r"""
1321        Creates an interval var with a fixed duration whose start is
1322        synchronized with the start of another interval, with a given
1323        offset. The performed status is also in sync with the performed
1324        status of the given interval variable.
1325        """
1326        return _pywrapcp.Solver_FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset)
1327
1328    def FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1329        r"""
1330        Creates an interval var with a fixed duration whose start is
1331        synchronized with the end of another interval, with a given
1332        offset. The performed status is also in sync with the performed
1333        status of the given interval variable.
1334        """
1335        return _pywrapcp.Solver_FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset)
1336
1337    def FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1338        r"""
1339        Creates an interval var with a fixed duration whose end is
1340        synchronized with the start of another interval, with a given
1341        offset. The performed status is also in sync with the performed
1342        status of the given interval variable.
1343        """
1344        return _pywrapcp.Solver_FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset)
1345
1346    def FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1347        r"""
1348        Creates an interval var with a fixed duration whose end is
1349        synchronized with the end of another interval, with a given
1350        offset. The performed status is also in sync with the performed
1351        status of the given interval variable.
1352        """
1353        return _pywrapcp.Solver_FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset)
1354
1355    def IntervalRelaxedMin(self, interval_var):
1356        r"""
1357         Creates and returns an interval variable that wraps around the given one,
1358         relaxing the min start and end. Relaxing means making unbounded when
1359         optional. If the variable is non-optional, this method returns
1360         interval_var.
1361
1362         More precisely, such an interval variable behaves as follows:
1363        When the underlying must be performed, the returned interval variable
1364             behaves exactly as the underlying;
1365        When the underlying may or may not be performed, the returned interval
1366             variable behaves like the underlying, except that it is unbounded on
1367             the min side;
1368        When the underlying cannot be performed, the returned interval variable
1369             is of duration 0 and must be performed in an interval unbounded on
1370             both sides.
1371
1372         This is very useful to implement propagators that may only modify
1373         the start max or end max.
1374        """
1375        return _pywrapcp.Solver_IntervalRelaxedMin(self, interval_var)
1376
1377    def IntervalRelaxedMax(self, interval_var):
1378        r"""
1379         Creates and returns an interval variable that wraps around the given one,
1380         relaxing the max start and end. Relaxing means making unbounded when
1381         optional. If the variable is non optional, this method returns
1382         interval_var.
1383
1384         More precisely, such an interval variable behaves as follows:
1385        When the underlying must be performed, the returned interval variable
1386             behaves exactly as the underlying;
1387        When the underlying may or may not be performed, the returned interval
1388             variable behaves like the underlying, except that it is unbounded on
1389             the max side;
1390        When the underlying cannot be performed, the returned interval variable
1391             is of duration 0 and must be performed in an interval unbounded on
1392             both sides.
1393
1394         This is very useful for implementing propagators that may only modify
1395         the start min or end min.
1396        """
1397        return _pywrapcp.Solver_IntervalRelaxedMax(self, interval_var)
1398
1399    def TemporalDisjunction(self, *args):
1400        r"""
1401        *Overload 1:*
1402        This constraint implements a temporal disjunction between two
1403        interval vars t1 and t2. 'alt' indicates which alternative was
1404        chosen (alt == 0 is equivalent to t1 before t2).
1405
1406        |
1407
1408        *Overload 2:*
1409        This constraint implements a temporal disjunction between two
1410        interval vars.
1411        """
1412        return _pywrapcp.Solver_TemporalDisjunction(self, *args)
1413
1414    def DisjunctiveConstraint(self, intervals, name):
1415        r"""
1416        This constraint forces all interval vars into an non-overlapping
1417        sequence. Intervals with zero duration can be scheduled anywhere.
1418        """
1419        return _pywrapcp.Solver_DisjunctiveConstraint(self, intervals, name)
1420
1421    def Cumulative(self, *args):
1422        r"""
1423        *Overload 1:*
1424        This constraint forces that, for any integer t, the sum of the demands
1425        corresponding to an interval containing t does not exceed the given
1426        capacity.
1427
1428        Intervals and demands should be vectors of equal size.
1429
1430        Demands should only contain non-negative values. Zero values are
1431        supported, and the corresponding intervals are filtered out, as they
1432        neither impact nor are impacted by this constraint.
1433
1434        |
1435
1436        *Overload 2:*
1437        This constraint forces that, for any integer t, the sum of the demands
1438        corresponding to an interval containing t does not exceed the given
1439        capacity.
1440
1441        Intervals and demands should be vectors of equal size.
1442
1443        Demands should only contain non-negative values. Zero values are
1444        supported, and the corresponding intervals are filtered out, as they
1445        neither impact nor are impacted by this constraint.
1446
1447        |
1448
1449        *Overload 3:*
1450        This constraint forces that, for any integer t, the sum of the demands
1451        corresponding to an interval containing t does not exceed the given
1452        capacity.
1453
1454        Intervals and demands should be vectors of equal size.
1455
1456        Demands should only contain non-negative values. Zero values are
1457        supported, and the corresponding intervals are filtered out, as they
1458        neither impact nor are impacted by this constraint.
1459
1460        |
1461
1462        *Overload 4:*
1463        This constraint enforces that, for any integer t, the sum of the demands
1464        corresponding to an interval containing t does not exceed the given
1465        capacity.
1466
1467        Intervals and demands should be vectors of equal size.
1468
1469        Demands should only contain non-negative values. Zero values are
1470        supported, and the corresponding intervals are filtered out, as they
1471        neither impact nor are impacted by this constraint.
1472
1473        |
1474
1475        *Overload 5:*
1476        This constraint enforces that, for any integer t, the sum of demands
1477        corresponding to an interval containing t does not exceed the given
1478        capacity.
1479
1480        Intervals and demands should be vectors of equal size.
1481
1482        Demands should be positive.
1483
1484        |
1485
1486        *Overload 6:*
1487        This constraint enforces that, for any integer t, the sum of demands
1488        corresponding to an interval containing t does not exceed the given
1489        capacity.
1490
1491        Intervals and demands should be vectors of equal size.
1492
1493        Demands should be positive.
1494        """
1495        return _pywrapcp.Solver_Cumulative(self, *args)
1496
1497    def Cover(self, vars, target_var):
1498        r"""
1499        This constraint states that the target_var is the convex hull of
1500        the intervals. If none of the interval variables is performed,
1501        then the target var is unperformed too. Also, if the target
1502        variable is unperformed, then all the intervals variables are
1503        unperformed too.
1504        """
1505        return _pywrapcp.Solver_Cover(self, vars, target_var)
1506
1507    def Assignment(self, *args):
1508        r"""
1509        *Overload 1:*
1510        This method creates an empty assignment.
1511
1512        |
1513
1514        *Overload 2:*
1515        This method creates an assignment which is a copy of 'a'.
1516        """
1517        return _pywrapcp.Solver_Assignment(self, *args)
1518
1519    def FirstSolutionCollector(self, *args):
1520        r"""
1521        *Overload 1:*
1522        Collect the first solution of the search.
1523
1524        |
1525
1526        *Overload 2:*
1527        Collect the first solution of the search. The variables will need to
1528        be added later.
1529        """
1530        return _pywrapcp.Solver_FirstSolutionCollector(self, *args)
1531
1532    def LastSolutionCollector(self, *args):
1533        r"""
1534        *Overload 1:*
1535        Collect the last solution of the search.
1536
1537        |
1538
1539        *Overload 2:*
1540        Collect the last solution of the search. The variables will need to
1541        be added later.
1542        """
1543        return _pywrapcp.Solver_LastSolutionCollector(self, *args)
1544
1545    def BestValueSolutionCollector(self, *args):
1546        r"""
1547        *Overload 1:*
1548        Collect the solution corresponding to the optimal value of the objective
1549        of 'assignment'; if 'assignment' does not have an objective no solution is
1550        collected. This collector only collects one solution corresponding to the
1551        best objective value (the first one found).
1552
1553        |
1554
1555        *Overload 2:*
1556        Collect the solution corresponding to the optimal value of the
1557        objective of the internal assignment; if this assignment does not have an
1558        objective no solution is collected. This collector only collects one
1559        solution corresponding to the best objective value (the first one found).
1560        The variables and objective(s) will need to be added later.
1561        """
1562        return _pywrapcp.Solver_BestValueSolutionCollector(self, *args)
1563
1564    def AllSolutionCollector(self, *args):
1565        r"""
1566        *Overload 1:*
1567        Collect all solutions of the search.
1568
1569        |
1570
1571        *Overload 2:*
1572        Collect all solutions of the search. The variables will need to
1573        be added later.
1574        """
1575        return _pywrapcp.Solver_AllSolutionCollector(self, *args)
1576
1577    def Minimize(self, v, step):
1578        r"""Creates a minimization objective."""
1579        return _pywrapcp.Solver_Minimize(self, v, step)
1580
1581    def Maximize(self, v, step):
1582        r"""Creates a maximization objective."""
1583        return _pywrapcp.Solver_Maximize(self, v, step)
1584
1585    def Optimize(self, maximize, v, step):
1586        r"""Creates a objective with a given sense (true = maximization)."""
1587        return _pywrapcp.Solver_Optimize(self, maximize, v, step)
1588
1589    def WeightedMinimize(self, *args):
1590        r"""
1591        *Overload 1:*
1592        Creates a minimization weighted objective. The actual objective is
1593        scalar_prod(sub_objectives, weights).
1594
1595        |
1596
1597        *Overload 2:*
1598        Creates a minimization weighted objective. The actual objective is
1599        scalar_prod(sub_objectives, weights).
1600        """
1601        return _pywrapcp.Solver_WeightedMinimize(self, *args)
1602
1603    def WeightedMaximize(self, *args):
1604        r"""
1605        *Overload 1:*
1606        Creates a maximization weigthed objective.
1607
1608        |
1609
1610        *Overload 2:*
1611        Creates a maximization weigthed objective.
1612        """
1613        return _pywrapcp.Solver_WeightedMaximize(self, *args)
1614
1615    def WeightedOptimize(self, *args):
1616        r"""
1617        *Overload 1:*
1618        Creates a weighted objective with a given sense (true = maximization).
1619
1620        |
1621
1622        *Overload 2:*
1623        Creates a weighted objective with a given sense (true = maximization).
1624        """
1625        return _pywrapcp.Solver_WeightedOptimize(self, *args)
1626
1627    def TabuSearch(self, maximize, objective, step, vars, keep_tenure, forbid_tenure, tabu_factor):
1628        r"""
1629        MetaHeuristics which try to get the search out of local optima.
1630        Creates a Tabu Search monitor.
1631        In the context of local search the behavior is similar to MakeOptimize(),
1632        creating an objective in a given sense. The behavior differs once a local
1633        optimum is reached: thereafter solutions which degrade the value of the
1634        objective are allowed if they are not "tabu". A solution is "tabu" if it
1635        doesn't respect the following rules:
1636        - improving the best solution found so far
1637        - variables in the "keep" list must keep their value, variables in the
1638        "forbid" list must not take the value they have in the list.
1639        Variables with new values enter the tabu lists after each new solution
1640        found and leave the lists after a given number of iterations (called
1641        tenure). Only the variables passed to the method can enter the lists.
1642        The tabu criterion is softened by the tabu factor which gives the number
1643        of "tabu" violations which is tolerated; a factor of 1 means no violations
1644        allowed; a factor of 0 means all violations are allowed.
1645        """
1646        return _pywrapcp.Solver_TabuSearch(self, maximize, objective, step, vars, keep_tenure, forbid_tenure, tabu_factor)
1647
1648    def SimulatedAnnealing(self, maximize, v, step, initial_temperature):
1649        r"""Creates a Simulated Annealing monitor."""
1650        return _pywrapcp.Solver_SimulatedAnnealing(self, maximize, v, step, initial_temperature)
1651
1652    def LubyRestart(self, scale_factor):
1653        r"""
1654        This search monitor will restart the search periodically.
1655        At the iteration n, it will restart after scale_factor * Luby(n) failures
1656        where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).
1657        """
1658        return _pywrapcp.Solver_LubyRestart(self, scale_factor)
1659
1660    def ConstantRestart(self, frequency):
1661        r"""
1662        This search monitor will restart the search periodically after 'frequency'
1663        failures.
1664        """
1665        return _pywrapcp.Solver_ConstantRestart(self, frequency)
1666
1667    def TimeLimit(self, *args):
1668        r"""Creates a search limit that constrains the running time."""
1669        return _pywrapcp.Solver_TimeLimit(self, *args)
1670
1671    def BranchesLimit(self, branches):
1672        r"""
1673        Creates a search limit that constrains the number of branches
1674        explored in the search tree.
1675        """
1676        return _pywrapcp.Solver_BranchesLimit(self, branches)
1677
1678    def FailuresLimit(self, failures):
1679        r"""
1680        Creates a search limit that constrains the number of failures
1681        that can happen when exploring the search tree.
1682        """
1683        return _pywrapcp.Solver_FailuresLimit(self, failures)
1684
1685    def SolutionsLimit(self, solutions):
1686        r"""
1687        Creates a search limit that constrains the number of solutions found
1688        during the search.
1689        """
1690        return _pywrapcp.Solver_SolutionsLimit(self, solutions)
1691
1692    def Limit(self, *args):
1693        r"""
1694        *Overload 1:*
1695        Limits the search with the 'time', 'branches', 'failures' and
1696        'solutions' limits. 'smart_time_check' reduces the calls to the wall
1697
1698        |
1699
1700        *Overload 2:*
1701        Creates a search limit from its protobuf description
1702
1703        |
1704
1705        *Overload 3:*
1706        Creates a search limit that is reached when either of the underlying limit
1707        is reached. That is, the returned limit is more stringent than both
1708        argument limits.
1709        """
1710        return _pywrapcp.Solver_Limit(self, *args)
1711
1712    def CustomLimit(self, limiter):
1713        r"""
1714        Callback-based search limit. Search stops when limiter returns true; if
1715        this happens at a leaf the corresponding solution will be rejected.
1716        """
1717        return _pywrapcp.Solver_CustomLimit(self, limiter)
1718
1719    def SearchLog(self, *args):
1720        r"""
1721        *Overload 1:*
1722         The SearchMonitors below will display a periodic search log
1723         on LOG(INFO) every branch_period branches explored.
1724
1725        |
1726
1727        *Overload 2:*
1728         At each solution, this monitor also display the var value.
1729
1730        |
1731
1732        *Overload 3:*
1733         At each solution, this monitor will also display result of
1734        ``display_callback``.
1735
1736        |
1737
1738        *Overload 4:*
1739         At each solution, this monitor will display the 'var' value and the
1740         result of ``display_callback``.
1741
1742        |
1743
1744        *Overload 5:*
1745         At each solution, this monitor will display the 'vars' values and the
1746         result of ``display_callback``.
1747
1748        |
1749
1750        *Overload 6:*
1751         OptimizeVar Search Logs
1752         At each solution, this monitor will also display the 'opt_var' value.
1753
1754        |
1755
1756        *Overload 7:*
1757         Creates a search monitor that will also print the result of the
1758         display callback.
1759        """
1760        return _pywrapcp.Solver_SearchLog(self, *args)
1761
1762    def SearchTrace(self, prefix):
1763        r"""
1764        Creates a search monitor that will trace precisely the behavior of the
1765        search. Use this only for low level debugging.
1766        """
1767        return _pywrapcp.Solver_SearchTrace(self, prefix)
1768
1769    def PrintModelVisitor(self):
1770        r"""Prints the model."""
1771        return _pywrapcp.Solver_PrintModelVisitor(self)
1772
1773    def StatisticsModelVisitor(self):
1774        r"""Displays some nice statistics on the model."""
1775        return _pywrapcp.Solver_StatisticsModelVisitor(self)
1776
1777    def AssignVariableValue(self, var, val):
1778        r"""Decisions."""
1779        return _pywrapcp.Solver_AssignVariableValue(self, var, val)
1780
1781    def VariableLessOrEqualValue(self, var, value):
1782        return _pywrapcp.Solver_VariableLessOrEqualValue(self, var, value)
1783
1784    def VariableGreaterOrEqualValue(self, var, value):
1785        return _pywrapcp.Solver_VariableGreaterOrEqualValue(self, var, value)
1786
1787    def SplitVariableDomain(self, var, val, start_with_lower_half):
1788        return _pywrapcp.Solver_SplitVariableDomain(self, var, val, start_with_lower_half)
1789
1790    def AssignVariableValueOrFail(self, var, value):
1791        return _pywrapcp.Solver_AssignVariableValueOrFail(self, var, value)
1792
1793    def AssignVariablesValues(self, vars, values):
1794        return _pywrapcp.Solver_AssignVariablesValues(self, vars, values)
1795
1796    def FailDecision(self):
1797        return _pywrapcp.Solver_FailDecision(self)
1798
1799    def Decision(self, apply, refute):
1800        return _pywrapcp.Solver_Decision(self, apply, refute)
1801
1802    def Compose(self, dbs):
1803        return _pywrapcp.Solver_Compose(self, dbs)
1804
1805    def Try(self, dbs):
1806        return _pywrapcp.Solver_Try(self, dbs)
1807
1808    def DefaultPhase(self, *args):
1809        return _pywrapcp.Solver_DefaultPhase(self, *args)
1810
1811    def ScheduleOrPostpone(self, var, est, marker):
1812        r"""
1813        Returns a decision that tries to schedule a task at a given time.
1814        On the Apply branch, it will set that interval var as performed and set
1815        its start to 'est'. On the Refute branch, it will just update the
1816        'marker' to 'est' + 1. This decision is used in the
1817        INTERVAL_SET_TIMES_FORWARD strategy.
1818        """
1819        return _pywrapcp.Solver_ScheduleOrPostpone(self, var, est, marker)
1820
1821    def ScheduleOrExpedite(self, var, est, marker):
1822        r"""
1823        Returns a decision that tries to schedule a task at a given time.
1824        On the Apply branch, it will set that interval var as performed and set
1825        its end to 'est'. On the Refute branch, it will just update the
1826        'marker' to 'est' - 1. This decision is used in the
1827        INTERVAL_SET_TIMES_BACKWARD strategy.
1828        """
1829        return _pywrapcp.Solver_ScheduleOrExpedite(self, var, est, marker)
1830
1831    def RankFirstInterval(self, sequence, index):
1832        r"""
1833        Returns a decision that tries to rank first the ith interval var
1834        in the sequence variable.
1835        """
1836        return _pywrapcp.Solver_RankFirstInterval(self, sequence, index)
1837
1838    def RankLastInterval(self, sequence, index):
1839        r"""
1840        Returns a decision that tries to rank last the ith interval var
1841        in the sequence variable.
1842        """
1843        return _pywrapcp.Solver_RankLastInterval(self, sequence, index)
1844
1845    def Phase(self, *args):
1846        r"""
1847        *Overload 1:*
1848        Phases on IntVar arrays.
1849        for all other functions that have several homonyms in this .h).
1850
1851        |
1852
1853        *Overload 2:*
1854        Scheduling phases.
1855        """
1856        return _pywrapcp.Solver_Phase(self, *args)
1857
1858    def DecisionBuilderFromAssignment(self, assignment, db, vars):
1859        r"""
1860        Returns a decision builder for which the left-most leaf corresponds
1861        to assignment, the rest of the tree being explored using 'db'.
1862        """
1863        return _pywrapcp.Solver_DecisionBuilderFromAssignment(self, assignment, db, vars)
1864
1865    def ConstraintAdder(self, ct):
1866        r"""
1867        Returns a decision builder that will add the given constraint to
1868        the model.
1869        """
1870        return _pywrapcp.Solver_ConstraintAdder(self, ct)
1871
1872    def SolveOnce(self, db, monitors):
1873        return _pywrapcp.Solver_SolveOnce(self, db, monitors)
1874
1875    def NestedOptimize(self, *args):
1876        r"""
1877        NestedOptimize will collapse a search tree described by a
1878        decision builder 'db' and a set of monitors and wrap it into a
1879        single point. If there are no solutions to this nested tree, then
1880        NestedOptimize will fail. If there are solutions, it will find
1881        the best as described by the mandatory objective in the solution
1882        as well as the optimization direction, instantiate all variables
1883        to this solution, and return nullptr.
1884        """
1885        return _pywrapcp.Solver_NestedOptimize(self, *args)
1886
1887    def RestoreAssignment(self, assignment):
1888        r"""
1889        Returns a DecisionBuilder which restores an Assignment
1890        (calls void Assignment::Restore())
1891        """
1892        return _pywrapcp.Solver_RestoreAssignment(self, assignment)
1893
1894    def StoreAssignment(self, assignment):
1895        r"""
1896        Returns a DecisionBuilder which stores an Assignment
1897        (calls void Assignment::Store())
1898        """
1899        return _pywrapcp.Solver_StoreAssignment(self, assignment)
1900
1901    def Operator(self, *args):
1902        r"""Local Search Operators."""
1903        return _pywrapcp.Solver_Operator(self, *args)
1904
1905    def RandomLnsOperator(self, *args):
1906        r"""
1907        Creates a large neighborhood search operator which creates fragments (set
1908        of relaxed variables) with up to number_of_variables random variables
1909        (sampling with replacement is performed meaning that at most
1910        number_of_variables variables are selected). Warning: this operator will
1911        always return neighbors; using it without a search limit will result in a
1912        non-ending search.
1913        Optionally a random seed can be specified.
1914        """
1915        return _pywrapcp.Solver_RandomLnsOperator(self, *args)
1916
1917    def MoveTowardTargetOperator(self, *args):
1918        r"""
1919        *Overload 1:*
1920        Creates a local search operator that tries to move the assignment of some
1921        variables toward a target. The target is given as an Assignment. This
1922        operator generates neighbors in which the only difference compared to the
1923        current state is that one variable that belongs to the target assignment
1924        is set to its target value.
1925
1926        |
1927
1928        *Overload 2:*
1929        Creates a local search operator that tries to move the assignment of some
1930        variables toward a target. The target is given either as two vectors: a
1931        vector of variables and a vector of associated target values. The two
1932        vectors should be of the same length. This operator generates neighbors in
1933        which the only difference compared to the current state is that one
1934        variable that belongs to the given vector is set to its target value.
1935        """
1936        return _pywrapcp.Solver_MoveTowardTargetOperator(self, *args)
1937
1938    def ConcatenateOperators(self, *args):
1939        r"""
1940        Creates a local search operator which concatenates a vector of operators.
1941        Each operator from the vector is called sequentially. By default, when a
1942        neighbor is found the neighborhood exploration restarts from the last
1943        active operator (the one which produced the neighbor).
1944        This can be overridden by setting restart to true to force the exploration
1945        to start from the first operator in the vector.
1946
1947        The default behavior can also be overridden using an evaluation callback
1948        to set the order in which the operators are explored (the callback is
1949        called in LocalSearchOperator::Start()). The first argument of the
1950        callback is the index of the operator which produced the last move, the
1951        second argument is the index of the operator to be evaluated. Ownership of
1952        the callback is taken by ConcatenateOperators.
1953
1954        Example:
1955
1956         const int kPriorities = {10, 100, 10, 0};
1957         int64_t Evaluate(int active_operator, int current_operator) {
1958           return kPriorities[current_operator];
1959         }
1960
1961         LocalSearchOperator* concat =
1962           solver.ConcatenateOperators(operators,
1963                                       NewPermanentCallback(&Evaluate));
1964
1965        The elements of the vector operators will be sorted by increasing priority
1966        and explored in that order (tie-breaks are handled by keeping the relative
1967        operator order in the vector). This would result in the following order:
1968        operators[3], operators[0], operators[2], operators[1].
1969        """
1970        return _pywrapcp.Solver_ConcatenateOperators(self, *args)
1971
1972    def RandomConcatenateOperators(self, *args):
1973        r"""
1974        *Overload 1:*
1975        Randomized version of local search concatenator; calls a random operator
1976        at each call to MakeNextNeighbor().
1977
1978        |
1979
1980        *Overload 2:*
1981        Randomized version of local search concatenator; calls a random operator
1982        at each call to MakeNextNeighbor(). The provided seed is used to
1983        initialize the random number generator.
1984        """
1985        return _pywrapcp.Solver_RandomConcatenateOperators(self, *args)
1986
1987    def NeighborhoodLimit(self, op, limit):
1988        r"""
1989        Creates a local search operator that wraps another local search
1990        operator and limits the number of neighbors explored (i.e., calls
1991        to MakeNextNeighbor from the current solution (between two calls
1992        to Start()). When this limit is reached, MakeNextNeighbor()
1993        returns false. The counter is cleared when Start() is called.
1994        """
1995        return _pywrapcp.Solver_NeighborhoodLimit(self, op, limit)
1996
1997    def LocalSearchPhase(self, *args):
1998        r"""
1999        *Overload 1:*
2000        Local Search decision builders factories.
2001        Local search is used to improve a given solution. This initial solution
2002        can be specified either by an Assignment or by a DecisionBulder, and the
2003        corresponding variables, the initial solution being the first solution
2004        found by the DecisionBuilder.
2005        The LocalSearchPhaseParameters parameter holds the actual definition of
2006        the local search phase:
2007        - a local search operator used to explore the neighborhood of the current
2008          solution,
2009        - a decision builder to instantiate unbound variables once a neighbor has
2010          been defined; in the case of LNS-based operators instantiates fragment
2011          variables; search monitors can be added to this sub-search by wrapping
2012          the decision builder with MakeSolveOnce.
2013        - a search limit specifying how long local search looks for neighbors
2014          before accepting one; the last neighbor is always taken and in the case
2015          of a greedy search, this corresponds to the best local neighbor;
2016          first-accept (which is the default behavior) can be modeled using a
2017          solution found limit of 1,
2018        - a vector of local search filters used to speed up the search by pruning
2019          unfeasible neighbors.
2020        Metaheuristics can be added by defining specialized search monitors;
2021        currently down/up-hill climbing is available through OptimizeVar, as well
2022        as Guided Local Search, Tabu Search and Simulated Annealing.
2023
2024        |
2025
2026        *Overload 2:*
2027        Variant with a sub_decison_builder specific to the first solution.
2028        """
2029        return _pywrapcp.Solver_LocalSearchPhase(self, *args)
2030
2031    def LocalSearchPhaseParameters(self, *args):
2032        r"""Local Search Phase Parameters"""
2033        return _pywrapcp.Solver_LocalSearchPhaseParameters(self, *args)
2034
2035    def TopProgressPercent(self):
2036        r"""
2037        Returns a percentage representing the propress of the search before
2038        reaching the limits of the top-level search (can be called from a nested
2039        solve).
2040        """
2041        return _pywrapcp.Solver_TopProgressPercent(self)
2042
2043    def SearchDepth(self):
2044        r"""
2045        Gets the search depth of the current active search. Returns -1 if
2046        there is no active search opened.
2047        """
2048        return _pywrapcp.Solver_SearchDepth(self)
2049
2050    def SearchLeftDepth(self):
2051        r"""
2052        Gets the search left depth of the current active search. Returns -1 if
2053        there is no active search opened.
2054        """
2055        return _pywrapcp.Solver_SearchLeftDepth(self)
2056
2057    def SolveDepth(self):
2058        r"""
2059        Gets the number of nested searches. It returns 0 outside search,
2060        1 during the top level search, 2 or more in case of nested searches.
2061        """
2062        return _pywrapcp.Solver_SolveDepth(self)
2063
2064    def Rand64(self, size):
2065        r"""Returns a random value between 0 and 'size' - 1;"""
2066        return _pywrapcp.Solver_Rand64(self, size)
2067
2068    def Rand32(self, size):
2069        r"""Returns a random value between 0 and 'size' - 1;"""
2070        return _pywrapcp.Solver_Rand32(self, size)
2071
2072    def ReSeed(self, seed):
2073        r"""Reseed the solver random generator."""
2074        return _pywrapcp.Solver_ReSeed(self, seed)
2075
2076    def LocalSearchProfile(self):
2077        r"""Returns local search profiling information in a human readable format."""
2078        return _pywrapcp.Solver_LocalSearchProfile(self)
2079
2080    def Constraints(self):
2081        r"""
2082        Counts the number of constraints that have been added
2083        to the solver before the search.
2084        """
2085        return _pywrapcp.Solver_Constraints(self)
2086
2087    def Accept(self, visitor):
2088        r"""Accepts the given model visitor."""
2089        return _pywrapcp.Solver_Accept(self, visitor)
2090
2091    def FinishCurrentSearch(self):
2092        r"""Tells the solver to kill or restart the current search."""
2093        return _pywrapcp.Solver_FinishCurrentSearch(self)
2094
2095    def RestartCurrentSearch(self):
2096        return _pywrapcp.Solver_RestartCurrentSearch(self)
2097
2098    def ShouldFail(self):
2099        r"""
2100        These methods are only useful for the SWIG wrappers, which need a way
2101        to externally cause the Solver to fail.
2102        """
2103        return _pywrapcp.Solver_ShouldFail(self)
2104
2105    def __str__(self):
2106        return _pywrapcp.Solver___str__(self)
2107
2108    def Add(self, ct):
2109      if isinstance(ct, PyConstraint):
2110        self.__python_constraints.append(ct)
2111      self.AddConstraint(ct)
2112
2113
2114    def TreeNoCycle(self, nexts, active, callback=0):
2115        return _pywrapcp.Solver_TreeNoCycle(self, nexts, active, callback)
2116
2117    def SearchLogWithCallback(self, period, callback):
2118        return _pywrapcp.Solver_SearchLogWithCallback(self, period, callback)
2119
2120    def ElementFunction(self, values, index):
2121        return _pywrapcp.Solver_ElementFunction(self, values, index)
2122
2123    def VarEvalValStrPhase(self, vars, var_evaluator, val_str):
2124        return _pywrapcp.Solver_VarEvalValStrPhase(self, vars, var_evaluator, val_str)
2125
2126    def VarStrValEvalPhase(self, vars, var_str, val_eval):
2127        return _pywrapcp.Solver_VarStrValEvalPhase(self, vars, var_str, val_eval)
2128
2129    def VarEvalValEvalPhase(self, vars, var_eval, val_eval):
2130        return _pywrapcp.Solver_VarEvalValEvalPhase(self, vars, var_eval, val_eval)
2131
2132    def VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker):
2133        return _pywrapcp.Solver_VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker)
2134
2135    def VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker):
2136        return _pywrapcp.Solver_VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker)
2137
2138    def EvalEvalStrPhase(self, vars, evaluator, str):
2139        return _pywrapcp.Solver_EvalEvalStrPhase(self, vars, evaluator, str)
2140
2141    def EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str):
2142        return _pywrapcp.Solver_EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str)
2143
2144    def GuidedLocalSearch(self, maximize, objective, objective_function, step, vars, penalty_factor):
2145        return _pywrapcp.Solver_GuidedLocalSearch(self, maximize, objective, objective_function, step, vars, penalty_factor)
2146
2147    def SumObjectiveFilter(self, vars, values, filter_enum):
2148        return _pywrapcp.Solver_SumObjectiveFilter(self, vars, values, filter_enum)

Solver Class

A solver represents the main computation engine. It implements the entire range of Constraint Programming protocols:

  • Reversibility
  • Propagation
  • Search

Usually, Constraint Programming code consists of

  • the creation of the Solver,
  • the creation of the decision variables of the model,
  • the creation of the constraints of the model and their addition to the solver() through the AddConstraint() method,
  • the creation of the main DecisionBuilder class,
  • the launch of the solve() method with the decision builder.

For the time being, Solver is neither MT_SAFE nor MT_HOT.

Solver(*args)
436    def __init__(self, *args):
437        r"""Solver API"""
438        _pywrapcp.Solver_swiginit(self, _pywrapcp.new_Solver(*args))
439
440        self.__python_constraints = []

Solver API

thisown
139    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

INT_VAR_DEFAULT = 0

The default behavior is CHOOSE_FIRST_UNBOUND.

INT_VAR_SIMPLE = 1

The simple selection is CHOOSE_FIRST_UNBOUND.

CHOOSE_FIRST_UNBOUND = 2

Select the first unbound variable. Variables are considered in the order of the vector of IntVars used to create the selector.

CHOOSE_RANDOM = 3

Randomly select one of the remaining unbound variables.

CHOOSE_MIN_SIZE_LOWEST_MIN = 4

Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variables is the one with the lowest min value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_MIN_SIZE_HIGHEST_MIN = 5

Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variable is the one with the highest min value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_MIN_SIZE_LOWEST_MAX = 6

Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variables is the one with the lowest max value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_MIN_SIZE_HIGHEST_MAX = 7

Among unbound variables, select the variable with the smallest size, i.e., the smallest number of possible values. In case of a tie, the selected variable is the one with the highest max value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_LOWEST_MIN = 8

Among unbound variables, select the variable with the smallest minimal value. In case of a tie, the first one is selected, "first" defined by the order in the vector of IntVars used to create the selector.

CHOOSE_HIGHEST_MAX = 9

Among unbound variables, select the variable with the highest maximal value. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_MIN_SIZE = 10

Among unbound variables, select the variable with the smallest size. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_MAX_SIZE = 11

Among unbound variables, select the variable with the highest size. In case of a tie, the first one is selected, first being defined by the order in the vector of IntVars used to create the selector.

CHOOSE_MAX_REGRET_ON_MIN = 12

Among unbound variables, select the variable with the largest gap between the first and the second values of the domain.

CHOOSE_PATH = 13

Selects the next unbound variable on a path, the path being defined by the variables: var[i] corresponds to the index of the next of i.

INT_VALUE_DEFAULT = 0

The default behavior is ASSIGN_MIN_VALUE.

INT_VALUE_SIMPLE = 1

The simple selection is ASSIGN_MIN_VALUE.

ASSIGN_MIN_VALUE = 2

Selects the min value of the selected variable.

ASSIGN_MAX_VALUE = 3

Selects the max value of the selected variable.

ASSIGN_RANDOM_VALUE = 4

Selects randomly one of the possible values of the selected variable.

ASSIGN_CENTER_VALUE = 5

Selects the first possible value which is the closest to the center of the domain of the selected variable. The center is defined as (min + max) / 2.

SPLIT_LOWER_HALF = 6

Split the domain in two around the center, and choose the lower part first.

SPLIT_UPPER_HALF = 7

Split the domain in two around the center, and choose the lower part first.

SEQUENCE_DEFAULT = 0
SEQUENCE_SIMPLE = 1
CHOOSE_MIN_SLACK_RANK_FORWARD = 2
CHOOSE_RANDOM_RANK_FORWARD = 3
INTERVAL_DEFAULT = 0

The default is INTERVAL_SET_TIMES_FORWARD.

INTERVAL_SIMPLE = 1

The simple is INTERVAL_SET_TIMES_FORWARD.

INTERVAL_SET_TIMES_FORWARD = 2

Selects the variable with the lowest starting time of all variables, and fixes its starting time to this lowest value.

INTERVAL_SET_TIMES_BACKWARD = 3

Selects the variable with the highest ending time of all variables, and fixes the ending time to this highest values.

TWOOPT = 0

Operator which reverses a sub-chain of a path. It is called TwoOpt because it breaks two arcs on the path; resulting paths are called two-optimal. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> [3 -> 2] -> 4 -> 5 1 -> [4 -> 3 -> 2] -> 5 1 -> 2 -> [4 -> 3] -> 5

OROPT = 1

Relocate: OROPT and RELOCATE. Operator which moves a sub-chain of a path to another position; the specified chain length is the fixed length of the chains being moved. When this length is 1, the operator simply moves a node to another position. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5, for a chain length of 2 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> 4 -> [2 -> 3] -> 5 1 -> [3 -> 4] -> 2 -> 5

Using Relocate with chain lengths of 1, 2 and 3 together is equivalent to the OrOpt operator on a path. The OrOpt operator is a limited version of 3Opt (breaks 3 arcs on a path).

RELOCATE = 2

Relocate neighborhood with length of 1 (see OROPT comment).

EXCHANGE = 3

Operator which exchanges the positions of two nodes. Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5 (where (1, 5) are first and last nodes of the path and can therefore not be moved): 1 -> [3] -> [2] -> 4 -> 5 1 -> [4] -> 3 -> [2] -> 5 1 -> 2 -> [4] -> [3] -> 5

CROSS = 4

Operator which cross exchanges the starting chains of 2 paths, including exchanging the whole paths. First and last nodes are not moved. Possible neighbors for the paths 1 -> 2 -> 3 -> 4 -> 5 and 6 -> 7 -> 8 (where (1, 5) and (6, 8) are first and last nodes of the paths and can therefore not be moved): 1 -> [7] -> 3 -> 4 -> 5 6 -> [2] -> 8 1 -> [7] -> 4 -> 5 6 -> [2 -> 3] -> 8 1 -> [7] -> 5 6 -> [2 -> 3 -> 4] -> 8

MAKEACTIVE = 5

Operator which inserts an inactive node into a path. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 2 -> 3 -> 4 1 -> 2 -> [5] -> 3 -> 4 1 -> 2 -> 3 -> [5] -> 4

MAKEINACTIVE = 6

Operator which makes path nodes inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are first and last nodes of the path) are: 1 -> 3 -> 4 with 2 inactive 1 -> 2 -> 4 with 3 inactive

MAKECHAININACTIVE = 7

Operator which makes a "chain" of path nodes inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are first and last nodes of the path) are: 1 -> 3 -> 4 with 2 inactive 1 -> 2 -> 4 with 3 inactive 1 -> 4 with 2 and 3 inactive

SWAPACTIVE = 8

Operator which replaces an active node by an inactive one. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 3 -> 4 with 2 inactive 1 -> 2 -> [5] -> 4 with 3 inactive

EXTENDEDSWAPACTIVE = 10

Operator which makes an inactive node active and an active one inactive. It is similar to SwapActiveOperator except that it tries to insert the inactive node in all possible positions instead of just the position of the node made inactive. Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive (where 1 and 4 are first and last nodes of the path) are: 1 -> [5] -> 3 -> 4 with 2 inactive 1 -> 3 -> [5] -> 4 with 2 inactive 1 -> [5] -> 2 -> 4 with 3 inactive 1 -> 2 -> [5] -> 4 with 3 inactive

PATHLNS = 11

Operator which relaxes two sub-chains of three consecutive arcs each. Each sub-chain is defined by a start node and the next three arcs. Those six arcs are relaxed to build a new neighbor. PATHLNS explores all possible pairs of starting nodes and so defines n^2 neighbors, n being the number of nodes. Note that the two sub-chains can be part of the same path; they even may overlap.

FULLPATHLNS = 12

Operator which relaxes one entire path and all inactive nodes, thus defining num_paths neighbors.

UNACTIVELNS = 13

Operator which relaxes all inactive nodes and one sub-chain of six consecutive arcs. That way the path can be improved by inserting inactive nodes or swapping arcs.

INCREMENT = 14

Operator which defines one neighbor per variable. Each neighbor tries to increment by one the value of the corresponding variable. When a new solution is found the neighborhood is rebuilt from scratch, i.e., tries to increment values in the variable order. Consider for instance variables x and y. x is incremented one by one to its max, and when it is not possible to increment x anymore, y is incremented once. If this is a solution, then next neighbor tries to increment x.

DECREMENT = 15

Operator which defines a neighborhood to decrement values. The behavior is the same as INCREMENT, except values are decremented instead of incremented.

SIMPLELNS = 16

Operator which defines one neighbor per variable. Each neighbor relaxes one variable. When a new solution is found the neighborhood is rebuilt from scratch. Consider for instance variables x and y. First x is relaxed and the solver is looking for the best possible solution (with only x relaxed). Then y is relaxed, and the solver is looking for a new solution. If a new solution is found, then the next variable to be relaxed is x.

GE = 0

Move is accepted when the current objective value >= objective.Min.

LE = 1

Move is accepted when the current objective value <= objective.Max.

EQ = 2

Move is accepted when the current objective value is in the interval objective.Min .. objective.Max.

DELAYED_PRIORITY = 0

DELAYED_PRIORITY is the lowest priority: Demons will be processed after VAR_PRIORITY and NORMAL_PRIORITY demons.

VAR_PRIORITY = 1

VAR_PRIORITY is between DELAYED_PRIORITY and NORMAL_PRIORITY.

NORMAL_PRIORITY = 2

NORMAL_PRIORITY is the highest priority: Demons will be processed first.

def Parameters(self):
446    def Parameters(self):
447        r"""Stored Parameters."""
448        return _pywrapcp.Solver_Parameters(self)

Stored Parameters.

@staticmethod
def DefaultSolverParameters():
450    @staticmethod
451    def DefaultSolverParameters():
452        r"""Create a ConstraintSolverParameters proto with all the default values."""
453        return _pywrapcp.Solver_DefaultSolverParameters()

Create a ConstraintSolverParameters proto with all the default values.

def AddConstraint(self, c):
455    def AddConstraint(self, c):
456        r"""
457        Adds the constraint 'c' to the model.
458
459        After calling this method, and until there is a backtrack that undoes the
460        addition, any assignment of variables to values must satisfy the given
461        constraint in order to be considered feasible. There are two fairly
462        different use cases:
463
464        - the most common use case is modeling: the given constraint is really
465        part of the problem that the user is trying to solve. In this use case,
466        AddConstraint is called outside of search (i.e., with state() ==
467        OUTSIDE_SEARCH). Most users should only use AddConstraint in this
468        way. In this case, the constraint will belong to the model forever: it
469        cannot be removed by backtracking.
470
471        - a rarer use case is that 'c' is not a real constraint of the model. It
472        may be a constraint generated by a branching decision (a constraint whose
473        goal is to restrict the search space), a symmetry breaking constraint (a
474        constraint that does restrict the search space, but in a way that cannot
475        have an impact on the quality of the solutions in the subtree), or an
476        inferred constraint that, while having no semantic value to the model (it
477        does not restrict the set of solutions), is worth having because we
478        believe it may strengthen the propagation. In these cases, it happens
479        that the constraint is added during the search (i.e., with state() ==
480        IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is
481        added during a search, it applies only to the subtree of the search tree
482        rooted at the current node, and will be automatically removed by
483        backtracking.
484
485        This method does not take ownership of the constraint. If the constraint
486        has been created by any factory method (Solver::MakeXXX), it will
487        automatically be deleted. However, power users who implement their own
488        constraints should do: solver.AddConstraint(solver.RevAlloc(new
489        MyConstraint(...));
490        """
491        return _pywrapcp.Solver_AddConstraint(self, c)

Adds the constraint 'c' to the model.

After calling this method, and until there is a backtrack that undoes the addition, any assignment of variables to values must satisfy the given constraint in order to be considered feasible. There are two fairly different use cases:

  • the most common use case is modeling: the given constraint is really part of the problem that the user is trying to solve. In this use case, AddConstraint is called outside of search (i.e., with state() == OUTSIDE_SEARCH). Most users should only use AddConstraint in this way. In this case, the constraint will belong to the model forever: it cannot be removed by backtracking.

  • a rarer use case is that 'c' is not a real constraint of the model. It may be a constraint generated by a branching decision (a constraint whose goal is to restrict the search space), a symmetry breaking constraint (a constraint that does restrict the search space, but in a way that cannot have an impact on the quality of the solutions in the subtree), or an inferred constraint that, while having no semantic value to the model (it does not restrict the set of solutions), is worth having because we believe it may strengthen the propagation. In these cases, it happens that the constraint is added during the search (i.e., with state() == IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is added during a search, it applies only to the subtree of the search tree rooted at the current node, and will be automatically removed by backtracking.

This method does not take ownership of the constraint. If the constraint has been created by any factory method (Solver::MakeXXX), it will automatically be deleted. However, power users who implement their own constraints should do: solver.AddConstraint(solver.RevAlloc(new MyConstraint(...));

def Solve(self, *args):
493    def Solve(self, *args):
494        r"""
495         Solves the problem using the given DecisionBuilder and returns true if a
496         solution was found and accepted.
497
498         These methods are the ones most users should use to search for a solution.
499         Note that the definition of 'solution' is subtle. A solution here is
500         defined as a leaf of the search tree with respect to the given decision
501         builder for which there is no failure. What this means is that, contrary
502         to intuition, a solution may not have all variables of the model bound.
503         It is the responsibility of the decision builder to keep returning
504         decisions until all variables are indeed bound. The most extreme
505         counterexample is calling Solve with a trivial decision builder whose
506         Next() method always returns nullptr. In this case, Solve immediately
507         returns 'true', since not assigning any variable to any value is a
508         solution, unless the root node propagation discovers that the model is
509         infeasible.
510
511         This function must be called either from outside of search,
512         or from within the Next() method of a decision builder.
513
514         Solve will terminate whenever any of the following event arise:
515        A search monitor asks the solver to terminate the search by calling
516           solver()->FinishCurrentSearch().
517        A solution is found that is accepted by all search monitors, and none of
518           the search monitors decides to search for another one.
519
520         Upon search termination, there will be a series of backtracks all the way
521         to the top level. This means that a user cannot expect to inspect the
522         solution by querying variables after a call to Solve(): all the
523         information will be lost. In order to do something with the solution, the
524         user must either:
525
526        Use a search monitor that can process such a leaf. See, in particular,
527             the SolutionCollector class.
528        Do not use Solve. Instead, use the more fine-grained approach using
529             methods NewSearch(...), NextSolution(), and EndSearch().
530
531         :type db: :py:class:`DecisionBuilder`
532         :param db: The decision builder that will generate the search tree.
533         :type monitors: std::vector< operations_research::SearchMonitor * >
534         :param monitors: A vector of search monitors that will be notified of
535             various events during the search. In their reaction to these events, such
536             monitors may influence the search.
537        """
538        return _pywrapcp.Solver_Solve(self, *args)

Solves the problem using the given DecisionBuilder and returns true if a solution was found and accepted.

These methods are the ones most users should use to search for a solution. Note that the definition of 'solution' is subtle. A solution here is defined as a leaf of the search tree with respect to the given decision builder for which there is no failure. What this means is that, contrary to intuition, a solution may not have all variables of the model bound. It is the responsibility of the decision builder to keep returning decisions until all variables are indeed bound. The most extreme counterexample is calling Solve with a trivial decision builder whose Next() method always returns nullptr. In this case, Solve immediately returns 'true', since not assigning any variable to any value is a solution, unless the root node propagation discovers that the model is infeasible.

This function must be called either from outside of search, or from within the Next() method of a decision builder.

Solve will terminate whenever any of the following event arise: A search monitor asks the solver to terminate the search by calling solver()->FinishCurrentSearch(). A solution is found that is accepted by all search monitors, and none of the search monitors decides to search for another one.

Upon search termination, there will be a series of backtracks all the way to the top level. This means that a user cannot expect to inspect the solution by querying variables after a call to Solve(): all the information will be lost. In order to do something with the solution, the user must either:

Use a search monitor that can process such a leaf. See, in particular, the SolutionCollector class. Do not use Solve. Instead, use the more fine-grained approach using methods NewSearch(...), NextSolution(), and EndSearch().

:type db: DecisionBuilder :param db: The decision builder that will generate the search tree. :type monitors: std::vector< operations_research::SearchMonitor * > :param monitors: A vector of search monitors that will be notified of various events during the search. In their reaction to these events, such monitors may influence the search.

def NewSearch(self, *args):
540    def NewSearch(self, *args):
541        r"""
542         Decomposed search.
543         The code for a top level search should look like
544         solver->NewSearch(db);
545         while (solver->NextSolution()) {
546        .. use the current solution
547         }
548         solver()->EndSearch();
549        """
550        return _pywrapcp.Solver_NewSearch(self, *args)

Decomposed search. The code for a top level search should look like solver->NewSearch(db); while (solver->NextSolution()) { .. use the current solution } solver()->EndSearch();

def NextSolution(self):
552    def NextSolution(self):
553        return _pywrapcp.Solver_NextSolution(self)
def RestartSearch(self):
555    def RestartSearch(self):
556        return _pywrapcp.Solver_RestartSearch(self)
def EndSearch(self):
558    def EndSearch(self):
559        return _pywrapcp.Solver_EndSearch(self)
def SolveAndCommit(self, *args):
561    def SolveAndCommit(self, *args):
562        r"""
563        SolveAndCommit using a decision builder and up to three
564          search monitors, usually one for the objective, one for the limits
565          and one to collect solutions.
566
567        The difference between a SolveAndCommit() and a Solve() method
568        call is the fact that SolveAndCommit will not backtrack all
569        modifications at the end of the search. This method is only
570        usable during the Next() method of a decision builder.
571        """
572        return _pywrapcp.Solver_SolveAndCommit(self, *args)

SolveAndCommit using a decision builder and up to three search monitors, usually one for the objective, one for the limits and one to collect solutions.

The difference between a SolveAndCommit() and a Solve() method call is the fact that SolveAndCommit will not backtrack all modifications at the end of the search. This method is only usable during the Next() method of a decision builder.

def CheckAssignment(self, solution):
574    def CheckAssignment(self, solution):
575        r"""Checks whether the given assignment satisfies all relevant constraints."""
576        return _pywrapcp.Solver_CheckAssignment(self, solution)

Checks whether the given assignment satisfies all relevant constraints.

def CheckConstraint(self, ct):
578    def CheckConstraint(self, ct):
579        r"""
580        Checks whether adding this constraint will lead to an immediate
581        failure. It will return false if the model is already inconsistent, or if
582        adding the constraint makes it inconsistent.
583        """
584        return _pywrapcp.Solver_CheckConstraint(self, ct)

Checks whether adding this constraint will lead to an immediate failure. It will return false if the model is already inconsistent, or if adding the constraint makes it inconsistent.

def Fail(self):
586    def Fail(self):
587        r"""Abandon the current branch in the search tree. A backtrack will follow."""
588        return _pywrapcp.Solver_Fail(self)

Abandon the current branch in the search tree. A backtrack will follow.

@staticmethod
def MemoryUsage():
590    @staticmethod
591    def MemoryUsage():
592        r"""Current memory usage in bytes"""
593        return _pywrapcp.Solver_MemoryUsage()

Current memory usage in bytes

def WallTime(self):
595    def WallTime(self):
596        r"""
597        DEPRECATED: Use Now() instead.
598        Time elapsed, in ms since the creation of the solver.
599        """
600        return _pywrapcp.Solver_WallTime(self)

DEPRECATED: Use Now() instead. Time elapsed, in ms since the creation of the solver.

def Branches(self):
602    def Branches(self):
603        r"""The number of branches explored since the creation of the solver."""
604        return _pywrapcp.Solver_Branches(self)

The number of branches explored since the creation of the solver.

def Solutions(self):
606    def Solutions(self):
607        r"""The number of solutions found since the start of the search."""
608        return _pywrapcp.Solver_Solutions(self)

The number of solutions found since the start of the search.

def Failures(self):
610    def Failures(self):
611        r"""The number of failures encountered since the creation of the solver."""
612        return _pywrapcp.Solver_Failures(self)

The number of failures encountered since the creation of the solver.

def AcceptedNeighbors(self):
614    def AcceptedNeighbors(self):
615        r"""The number of accepted neighbors."""
616        return _pywrapcp.Solver_AcceptedNeighbors(self)

The number of accepted neighbors.

def Stamp(self):
618    def Stamp(self):
619        r"""
620        The stamp indicates how many moves in the search tree we have performed.
621        It is useful to detect if we need to update same lazy structures.
622        """
623        return _pywrapcp.Solver_Stamp(self)

The stamp indicates how many moves in the search tree we have performed. It is useful to detect if we need to update same lazy structures.

def FailStamp(self):
625    def FailStamp(self):
626        r"""The fail_stamp() is incremented after each backtrack."""
627        return _pywrapcp.Solver_FailStamp(self)

The fail_stamp() is incremented after each backtrack.

def IntVar(self, *args):
629    def IntVar(self, *args):
630        r"""
631        *Overload 1:*
632        MakeIntVar will create the best range based int var for the bounds given.
633
634        |
635
636        *Overload 2:*
637        MakeIntVar will create a variable with the given sparse domain.
638
639        |
640
641        *Overload 3:*
642        MakeIntVar will create a variable with the given sparse domain.
643
644        |
645
646        *Overload 4:*
647        MakeIntVar will create the best range based int var for the bounds given.
648
649        |
650
651        *Overload 5:*
652        MakeIntVar will create a variable with the given sparse domain.
653
654        |
655
656        *Overload 6:*
657        MakeIntVar will create a variable with the given sparse domain.
658        """
659        return _pywrapcp.Solver_IntVar(self, *args)

Overload 1: MakeIntVar will create the best range based int var for the bounds given.

|

Overload 2: MakeIntVar will create a variable with the given sparse domain.

|

Overload 3: MakeIntVar will create a variable with the given sparse domain.

|

Overload 4: MakeIntVar will create the best range based int var for the bounds given.

|

Overload 5: MakeIntVar will create a variable with the given sparse domain.

|

Overload 6: MakeIntVar will create a variable with the given sparse domain.

def BoolVar(self, *args):
661    def BoolVar(self, *args):
662        r"""
663        *Overload 1:*
664        MakeBoolVar will create a variable with a {0, 1} domain.
665
666        |
667
668        *Overload 2:*
669        MakeBoolVar will create a variable with a {0, 1} domain.
670        """
671        return _pywrapcp.Solver_BoolVar(self, *args)

Overload 1: MakeBoolVar will create a variable with a {0, 1} domain.

|

Overload 2: MakeBoolVar will create a variable with a {0, 1} domain.

def IntConst(self, *args):
673    def IntConst(self, *args):
674        r"""
675        *Overload 1:*
676        IntConst will create a constant expression.
677
678        |
679
680        *Overload 2:*
681        IntConst will create a constant expression.
682        """
683        return _pywrapcp.Solver_IntConst(self, *args)

Overload 1: IntConst will create a constant expression.

|

Overload 2: IntConst will create a constant expression.

def Sum(self, vars):
685    def Sum(self, vars):
686        r"""sum of all vars."""
687        return _pywrapcp.Solver_Sum(self, vars)

sum of all vars.

def ScalProd(self, *args):
689    def ScalProd(self, *args):
690        r"""
691        *Overload 1:*
692        scalar product
693
694        |
695
696        *Overload 2:*
697        scalar product
698        """
699        return _pywrapcp.Solver_ScalProd(self, *args)

Overload 1: scalar product

|

Overload 2: scalar product

def MonotonicElement(self, values, increasing, index):
701    def MonotonicElement(self, values, increasing, index):
702        r"""
703        Function based element. The constraint takes ownership of the
704        callback.  The callback must be monotonic. It must be able to
705        cope with any possible value in the domain of 'index'
706        (potentially negative ones too). Furtermore, monotonicity is not
707        checked. Thus giving a non-monotonic function, or specifying an
708        incorrect increasing parameter will result in undefined behavior.
709        """
710        return _pywrapcp.Solver_MonotonicElement(self, values, increasing, index)

Function based element. The constraint takes ownership of the callback. The callback must be monotonic. It must be able to cope with any possible value in the domain of 'index' (potentially negative ones too). Furtermore, monotonicity is not checked. Thus giving a non-monotonic function, or specifying an incorrect increasing parameter will result in undefined behavior.

def Element(self, *args):
712    def Element(self, *args):
713        r"""
714        *Overload 1:*
715        values[index]
716
717        |
718
719        *Overload 2:*
720        values[index]
721
722        |
723
724        *Overload 3:*
725        Function-based element. The constraint takes ownership of the
726        callback. The callback must be able to cope with any possible
727        value in the domain of 'index' (potentially negative ones too).
728
729        |
730
731        *Overload 4:*
732        2D version of function-based element expression, values(expr1, expr2).
733
734        |
735
736        *Overload 5:*
737        vars[expr]
738        """
739        return _pywrapcp.Solver_Element(self, *args)

Overload 1: values[index]

|

Overload 2: values[index]

|

Overload 3: Function-based element. The constraint takes ownership of the callback. The callback must be able to cope with any possible value in the domain of 'index' (potentially negative ones too).

|

Overload 4: 2D version of function-based element expression, values(expr1, expr2).

|

Overload 5: vars[expr]

def IndexExpression(self, vars, value):
741    def IndexExpression(self, vars, value):
742        r"""
743        Returns the expression expr such that vars[expr] == value.
744        It assumes that vars are all different.
745        """
746        return _pywrapcp.Solver_IndexExpression(self, vars, value)

Returns the expression expr such that vars[expr] == value. It assumes that vars are all different.

def Min(self, *args):
748    def Min(self, *args):
749        r"""
750        *Overload 1:*
751        std::min(vars)
752
753        |
754
755        *Overload 2:*
756        std::min (left, right)
757
758        |
759
760        *Overload 3:*
761        std::min(expr, value)
762
763        |
764
765        *Overload 4:*
766        std::min(expr, value)
767        """
768        return _pywrapcp.Solver_Min(self, *args)

Overload 1: std::min(vars)

|

Overload 2: std::min (left, right)

|

Overload 3: std::min(expr, value)

|

Overload 4: std::min(expr, value)

def Max(self, *args):
770    def Max(self, *args):
771        r"""
772        *Overload 1:*
773        std::max(vars)
774
775        |
776
777        *Overload 2:*
778        std::max(left, right)
779
780        |
781
782        *Overload 3:*
783        std::max(expr, value)
784
785        |
786
787        *Overload 4:*
788        std::max(expr, value)
789        """
790        return _pywrapcp.Solver_Max(self, *args)

Overload 1: std::max(vars)

|

Overload 2: std::max(left, right)

|

Overload 3: std::max(expr, value)

|

Overload 4: std::max(expr, value)

def ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost):
792    def ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost):
793        r"""Convex piecewise function."""
794        return _pywrapcp.Solver_ConvexPiecewiseExpr(self, expr, early_cost, early_date, late_date, late_cost)

Convex piecewise function.

def SemiContinuousExpr(self, expr, fixed_charge, step):
796    def SemiContinuousExpr(self, expr, fixed_charge, step):
797        r"""
798        Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b)
799        a >= 0 and b >= 0
800        """
801        return _pywrapcp.Solver_SemiContinuousExpr(self, expr, fixed_charge, step)

Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b) a >= 0 and b >= 0

def ConditionalExpression(self, condition, expr, unperformed_value):
803    def ConditionalExpression(self, condition, expr, unperformed_value):
804        r"""Conditional Expr condition ? expr : unperformed_value"""
805        return _pywrapcp.Solver_ConditionalExpression(self, condition, expr, unperformed_value)

Conditional Expr condition ? expr : unperformed_value

def TrueConstraint(self):
807    def TrueConstraint(self):
808        r"""This constraint always succeeds."""
809        return _pywrapcp.Solver_TrueConstraint(self)

This constraint always succeeds.

def FalseConstraint(self, *args):
811    def FalseConstraint(self, *args):
812        r"""This constraint always fails."""
813        return _pywrapcp.Solver_FalseConstraint(self, *args)

This constraint always fails.

def IsEqualCstCt(self, var, value, boolvar):
815    def IsEqualCstCt(self, var, value, boolvar):
816        r"""boolvar == (var == value)"""
817        return _pywrapcp.Solver_IsEqualCstCt(self, var, value, boolvar)

boolvar == (var == value)

def IsEqualCstVar(self, var, value):
819    def IsEqualCstVar(self, var, value):
820        r"""status var of (var == value)"""
821        return _pywrapcp.Solver_IsEqualCstVar(self, var, value)

status var of (var == value)

def IsEqualCt(self, v1, v2, b):
823    def IsEqualCt(self, v1, v2, b):
824        r"""b == (v1 == v2)"""
825        return _pywrapcp.Solver_IsEqualCt(self, v1, v2, b)

b == (v1 == v2)

def IsEqualVar(self, v1, v2):
827    def IsEqualVar(self, v1, v2):
828        r"""status var of (v1 == v2)"""
829        return _pywrapcp.Solver_IsEqualVar(self, v1, v2)

status var of (v1 == v2)

def IsDifferentCstCt(self, var, value, boolvar):
831    def IsDifferentCstCt(self, var, value, boolvar):
832        r"""boolvar == (var != value)"""
833        return _pywrapcp.Solver_IsDifferentCstCt(self, var, value, boolvar)

boolvar == (var != value)

def IsDifferentCstVar(self, var, value):
835    def IsDifferentCstVar(self, var, value):
836        r"""status var of (var != value)"""
837        return _pywrapcp.Solver_IsDifferentCstVar(self, var, value)

status var of (var != value)

def IsDifferentVar(self, v1, v2):
839    def IsDifferentVar(self, v1, v2):
840        r"""status var of (v1 != v2)"""
841        return _pywrapcp.Solver_IsDifferentVar(self, v1, v2)

status var of (v1 != v2)

def IsDifferentCt(self, v1, v2, b):
843    def IsDifferentCt(self, v1, v2, b):
844        r"""b == (v1 != v2)"""
845        return _pywrapcp.Solver_IsDifferentCt(self, v1, v2, b)

b == (v1 != v2)

def IsLessOrEqualCstCt(self, var, value, boolvar):
847    def IsLessOrEqualCstCt(self, var, value, boolvar):
848        r"""boolvar == (var <= value)"""
849        return _pywrapcp.Solver_IsLessOrEqualCstCt(self, var, value, boolvar)

boolvar == (var <= value)

def IsLessOrEqualCstVar(self, var, value):
851    def IsLessOrEqualCstVar(self, var, value):
852        r"""status var of (var <= value)"""
853        return _pywrapcp.Solver_IsLessOrEqualCstVar(self, var, value)

status var of (var <= value)

def IsLessOrEqualVar(self, left, right):
855    def IsLessOrEqualVar(self, left, right):
856        r"""status var of (left <= right)"""
857        return _pywrapcp.Solver_IsLessOrEqualVar(self, left, right)

status var of (left <= right)

def IsLessOrEqualCt(self, left, right, b):
859    def IsLessOrEqualCt(self, left, right, b):
860        r"""b == (left <= right)"""
861        return _pywrapcp.Solver_IsLessOrEqualCt(self, left, right, b)

b == (left <= right)

def IsGreaterOrEqualCstCt(self, var, value, boolvar):
863    def IsGreaterOrEqualCstCt(self, var, value, boolvar):
864        r"""boolvar == (var >= value)"""
865        return _pywrapcp.Solver_IsGreaterOrEqualCstCt(self, var, value, boolvar)

boolvar == (var >= value)

def IsGreaterOrEqualCstVar(self, var, value):
867    def IsGreaterOrEqualCstVar(self, var, value):
868        r"""status var of (var >= value)"""
869        return _pywrapcp.Solver_IsGreaterOrEqualCstVar(self, var, value)

status var of (var >= value)

def IsGreaterOrEqualVar(self, left, right):
871    def IsGreaterOrEqualVar(self, left, right):
872        r"""status var of (left >= right)"""
873        return _pywrapcp.Solver_IsGreaterOrEqualVar(self, left, right)

status var of (left >= right)

def IsGreaterOrEqualCt(self, left, right, b):
875    def IsGreaterOrEqualCt(self, left, right, b):
876        r"""b == (left >= right)"""
877        return _pywrapcp.Solver_IsGreaterOrEqualCt(self, left, right, b)

b == (left >= right)

def IsGreaterCstCt(self, v, c, b):
879    def IsGreaterCstCt(self, v, c, b):
880        r"""b == (v > c)"""
881        return _pywrapcp.Solver_IsGreaterCstCt(self, v, c, b)

b == (v > c)

def IsGreaterCstVar(self, var, value):
883    def IsGreaterCstVar(self, var, value):
884        r"""status var of (var > value)"""
885        return _pywrapcp.Solver_IsGreaterCstVar(self, var, value)

status var of (var > value)

def IsGreaterVar(self, left, right):
887    def IsGreaterVar(self, left, right):
888        r"""status var of (left > right)"""
889        return _pywrapcp.Solver_IsGreaterVar(self, left, right)

status var of (left > right)

def IsGreaterCt(self, left, right, b):
891    def IsGreaterCt(self, left, right, b):
892        r"""b == (left > right)"""
893        return _pywrapcp.Solver_IsGreaterCt(self, left, right, b)

b == (left > right)

def IsLessCstCt(self, v, c, b):
895    def IsLessCstCt(self, v, c, b):
896        r"""b == (v < c)"""
897        return _pywrapcp.Solver_IsLessCstCt(self, v, c, b)

b == (v < c)

def IsLessCstVar(self, var, value):
899    def IsLessCstVar(self, var, value):
900        r"""status var of (var < value)"""
901        return _pywrapcp.Solver_IsLessCstVar(self, var, value)

status var of (var < value)

def IsLessVar(self, left, right):
903    def IsLessVar(self, left, right):
904        r"""status var of (left < right)"""
905        return _pywrapcp.Solver_IsLessVar(self, left, right)

status var of (left < right)

def IsLessCt(self, left, right, b):
907    def IsLessCt(self, left, right, b):
908        r"""b == (left < right)"""
909        return _pywrapcp.Solver_IsLessCt(self, left, right, b)

b == (left < right)

def SumLessOrEqual(self, vars, cst):
911    def SumLessOrEqual(self, vars, cst):
912        r"""Variation on arrays."""
913        return _pywrapcp.Solver_SumLessOrEqual(self, vars, cst)

Variation on arrays.

def SumGreaterOrEqual(self, vars, cst):
915    def SumGreaterOrEqual(self, vars, cst):
916        return _pywrapcp.Solver_SumGreaterOrEqual(self, vars, cst)
def SumEquality(self, *args):
918    def SumEquality(self, *args):
919        return _pywrapcp.Solver_SumEquality(self, *args)
def ScalProdEquality(self, *args):
921    def ScalProdEquality(self, *args):
922        return _pywrapcp.Solver_ScalProdEquality(self, *args)
def ScalProdGreaterOrEqual(self, *args):
924    def ScalProdGreaterOrEqual(self, *args):
925        return _pywrapcp.Solver_ScalProdGreaterOrEqual(self, *args)
def ScalProdLessOrEqual(self, *args):
927    def ScalProdLessOrEqual(self, *args):
928        return _pywrapcp.Solver_ScalProdLessOrEqual(self, *args)
def MinEquality(self, vars, min_var):
930    def MinEquality(self, vars, min_var):
931        return _pywrapcp.Solver_MinEquality(self, vars, min_var)
def MaxEquality(self, vars, max_var):
933    def MaxEquality(self, vars, max_var):
934        return _pywrapcp.Solver_MaxEquality(self, vars, max_var)
def ElementEquality(self, *args):
936    def ElementEquality(self, *args):
937        return _pywrapcp.Solver_ElementEquality(self, *args)
def AbsEquality(self, var, abs_var):
939    def AbsEquality(self, var, abs_var):
940        r"""Creates the constraint abs(var) == abs_var."""
941        return _pywrapcp.Solver_AbsEquality(self, var, abs_var)

Creates the constraint abs(var) == abs_var.

def IndexOfConstraint(self, vars, index, target):
943    def IndexOfConstraint(self, vars, index, target):
944        r"""
945        This constraint is a special case of the element constraint with
946        an array of integer variables, where the variables are all
947        different and the index variable is constrained such that
948        vars[index] == target.
949        """
950        return _pywrapcp.Solver_IndexOfConstraint(self, vars, index, target)

This constraint is a special case of the element constraint with an array of integer variables, where the variables are all different and the index variable is constrained such that vars[index] == target.

def ConstraintInitialPropagateCallback(self, ct):
952    def ConstraintInitialPropagateCallback(self, ct):
953        r"""
954        This method is a specialized case of the MakeConstraintDemon
955        method to call the InitiatePropagate of the constraint 'ct'.
956        """
957        return _pywrapcp.Solver_ConstraintInitialPropagateCallback(self, ct)

This method is a specialized case of the MakeConstraintDemon method to call the InitiatePropagate of the constraint 'ct'.

def DelayedConstraintInitialPropagateCallback(self, ct):
959    def DelayedConstraintInitialPropagateCallback(self, ct):
960        r"""
961        This method is a specialized case of the MakeConstraintDemon
962        method to call the InitiatePropagate of the constraint 'ct' with
963        low priority.
964        """
965        return _pywrapcp.Solver_DelayedConstraintInitialPropagateCallback(self, ct)

This method is a specialized case of the MakeConstraintDemon method to call the InitiatePropagate of the constraint 'ct' with low priority.

def ClosureDemon(self, closure):
967    def ClosureDemon(self, closure):
968        r"""Creates a demon from a closure."""
969        return _pywrapcp.Solver_ClosureDemon(self, closure)

Creates a demon from a closure.

def BetweenCt(self, expr, l, u):
971    def BetweenCt(self, expr, l, u):
972        r"""(l <= expr <= u)"""
973        return _pywrapcp.Solver_BetweenCt(self, expr, l, u)

(l <= expr <= u)

def IsBetweenCt(self, expr, l, u, b):
975    def IsBetweenCt(self, expr, l, u, b):
976        r"""b == (l <= expr <= u)"""
977        return _pywrapcp.Solver_IsBetweenCt(self, expr, l, u, b)

b == (l <= expr <= u)

def IsBetweenVar(self, v, l, u):
979    def IsBetweenVar(self, v, l, u):
980        return _pywrapcp.Solver_IsBetweenVar(self, v, l, u)
def MemberCt(self, *args):
982    def MemberCt(self, *args):
983        r"""
984        expr in set. Propagation is lazy, i.e. this constraint does not
985        creates holes in the domain of the variable.
986        """
987        return _pywrapcp.Solver_MemberCt(self, *args)

expr in set. Propagation is lazy, i.e. this constraint does not creates holes in the domain of the variable.

def NotMemberCt(self, *args):
 989    def NotMemberCt(self, *args):
 990        r"""
 991        *Overload 1:*
 992        expr not in set.
 993
 994        |
 995
 996        *Overload 2:*
 997        expr should not be in the list of forbidden intervals [start[i]..end[i]].
 998
 999        |
1000
1001        *Overload 3:*
1002        expr should not be in the list of forbidden intervals [start[i]..end[i]].
1003        """
1004        return _pywrapcp.Solver_NotMemberCt(self, *args)

Overload 1: expr not in set.

|

Overload 2: expr should not be in the list of forbidden intervals [start[i]..end[i]].

|

Overload 3: expr should not be in the list of forbidden intervals [start[i]..end[i]].

def IsMemberCt(self, *args):
1006    def IsMemberCt(self, *args):
1007        r"""boolvar == (expr in set)"""
1008        return _pywrapcp.Solver_IsMemberCt(self, *args)

boolvar == (expr in set)

def IsMemberVar(self, *args):
1010    def IsMemberVar(self, *args):
1011        return _pywrapcp.Solver_IsMemberVar(self, *args)
def Count(self, *args):
1013    def Count(self, *args):
1014        r"""
1015        *Overload 1:*
1016        |{i | vars[i] == value}| == max_count
1017
1018        |
1019
1020        *Overload 2:*
1021        |{i | vars[i] == value}| == max_count
1022        """
1023        return _pywrapcp.Solver_Count(self, *args)

Overload 1: |{i | vars[i] == value}| == max_count

|

Overload 2: |{i | vars[i] == value}| == max_count

def Distribute(self, *args):
1025    def Distribute(self, *args):
1026        r"""
1027        *Overload 1:*
1028        Aggregated version of count:  |{i | v[i] == values[j]}| == cards[j]
1029
1030        |
1031
1032        *Overload 2:*
1033        Aggregated version of count:  |{i | v[i] == values[j]}| == cards[j]
1034
1035        |
1036
1037        *Overload 3:*
1038        Aggregated version of count:  |{i | v[i] == j}| == cards[j]
1039
1040        |
1041
1042        *Overload 4:*
1043        Aggregated version of count with bounded cardinalities:
1044        forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max
1045
1046        |
1047
1048        *Overload 5:*
1049        Aggregated version of count with bounded cardinalities:
1050        forall j in 0 .. card_size - 1:
1051           card_min[j] <= |{i | v[i] == j}| <= card_max[j]
1052
1053        |
1054
1055        *Overload 6:*
1056        Aggregated version of count with bounded cardinalities:
1057        forall j in 0 .. card_size - 1:
1058           card_min[j] <= |{i | v[i] == j}| <= card_max[j]
1059
1060        |
1061
1062        *Overload 7:*
1063        Aggregated version of count with bounded cardinalities:
1064        forall j in 0 .. card_size - 1:
1065           card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
1066
1067        |
1068
1069        *Overload 8:*
1070        Aggregated version of count with bounded cardinalities:
1071        forall j in 0 .. card_size - 1:
1072           card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
1073        """
1074        return _pywrapcp.Solver_Distribute(self, *args)

Overload 1: Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]

|

Overload 2: Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]

|

Overload 3: Aggregated version of count: |{i | v[i] == j}| == cards[j]

|

Overload 4: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max

|

Overload 5: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == j}| <= card_max[j]

|

Overload 6: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == j}| <= card_max[j]

|

Overload 7: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]

|

Overload 8: Aggregated version of count with bounded cardinalities: forall j in 0 .. card_size - 1: card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]

def Deviation(self, vars, deviation_var, total_sum):
1076    def Deviation(self, vars, deviation_var, total_sum):
1077        r"""
1078        Deviation constraint:
1079        sum_i |n * vars[i] - total_sum| <= deviation_var and
1080        sum_i vars[i] == total_sum
1081        n = #vars
1082        """
1083        return _pywrapcp.Solver_Deviation(self, vars, deviation_var, total_sum)

Deviation constraint: sum_i |n * vars[i] - total_sum| <= deviation_var and sum_i vars[i] == total_sum n = #vars

def AllDifferent(self, *args):
1085    def AllDifferent(self, *args):
1086        r"""
1087        *Overload 1:*
1088        All variables are pairwise different. This corresponds to the
1089        stronger version of the propagation algorithm.
1090
1091        |
1092
1093        *Overload 2:*
1094        All variables are pairwise different.  If 'stronger_propagation'
1095        is true, stronger, and potentially slower propagation will
1096        occur. This API will be deprecated in the future.
1097        """
1098        return _pywrapcp.Solver_AllDifferent(self, *args)

Overload 1: All variables are pairwise different. This corresponds to the stronger version of the propagation algorithm.

|

Overload 2: All variables are pairwise different. If 'stronger_propagation' is true, stronger, and potentially slower propagation will occur. This API will be deprecated in the future.

def AllDifferentExcept(self, vars, escape_value):
1100    def AllDifferentExcept(self, vars, escape_value):
1101        r"""
1102        All variables are pairwise different, unless they are assigned to
1103        the escape value.
1104        """
1105        return _pywrapcp.Solver_AllDifferentExcept(self, vars, escape_value)

All variables are pairwise different, unless they are assigned to the escape value.

def SortingConstraint(self, vars, sorted):
1107    def SortingConstraint(self, vars, sorted):
1108        r"""
1109        Creates a constraint binding the arrays of variables "vars" and
1110        "sorted_vars": sorted_vars[0] must be equal to the minimum of all
1111        variables in vars, and so on: the value of sorted_vars[i] must be
1112        equal to the i-th value of variables invars.
1113
1114        This constraint propagates in both directions: from "vars" to
1115        "sorted_vars" and vice-versa.
1116
1117        Behind the scenes, this constraint maintains that:
1118          - sorted is always increasing.
1119          - whatever the values of vars, there exists a permutation that
1120            injects its values into the sorted variables.
1121
1122        For more info, please have a look at:
1123          https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf
1124        """
1125        return _pywrapcp.Solver_SortingConstraint(self, vars, sorted)

Creates a constraint binding the arrays of variables "vars" and "sorted_vars": sorted_vars[0] must be equal to the minimum of all variables in vars, and so on: the value of sorted_vars[i] must be equal to the i-th value of variables invars.

This constraint propagates in both directions: from "vars" to "sorted_vars" and vice-versa.

Behind the scenes, this constraint maintains that:

  • sorted is always increasing.
  • whatever the values of vars, there exists a permutation that injects its values into the sorted variables.

For more info, please have a look at: https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf

def LexicalLess(self, left, right):
1127    def LexicalLess(self, left, right):
1128        r"""
1129        Creates a constraint that enforces that left is lexicographically less
1130        than right.
1131        """
1132        return _pywrapcp.Solver_LexicalLess(self, left, right)

Creates a constraint that enforces that left is lexicographically less than right.

def LexicalLessOrEqual(self, left, right):
1134    def LexicalLessOrEqual(self, left, right):
1135        r"""
1136        Creates a constraint that enforces that left is lexicographically less
1137        than or equal to right.
1138        """
1139        return _pywrapcp.Solver_LexicalLessOrEqual(self, left, right)

Creates a constraint that enforces that left is lexicographically less than or equal to right.

def InversePermutationConstraint(self, left, right):
1141    def InversePermutationConstraint(self, left, right):
1142        r"""
1143        Creates a constraint that enforces that 'left' and 'right' both
1144        represent permutations of [0..left.size()-1], and that 'right' is
1145        the inverse permutation of 'left', i.e. for all i in
1146        [0..left.size()-1], right[left[i]] = i.
1147        """
1148        return _pywrapcp.Solver_InversePermutationConstraint(self, left, right)

Creates a constraint that enforces that 'left' and 'right' both represent permutations of [0..left.size()-1], and that 'right' is the inverse permutation of 'left', i.e. for all i in [0..left.size()-1], right[left[i]] = i.

def NullIntersect(self, first_vars, second_vars):
1150    def NullIntersect(self, first_vars, second_vars):
1151        r"""
1152        Creates a constraint that states that all variables in the first
1153        vector are different from all variables in the second
1154        group. Thus the set of values in the first vector does not
1155        intersect with the set of values in the second vector.
1156        """
1157        return _pywrapcp.Solver_NullIntersect(self, first_vars, second_vars)

Creates a constraint that states that all variables in the first vector are different from all variables in the second group. Thus the set of values in the first vector does not intersect with the set of values in the second vector.

def NullIntersectExcept(self, first_vars, second_vars, escape_value):
1159    def NullIntersectExcept(self, first_vars, second_vars, escape_value):
1160        r"""
1161        Creates a constraint that states that all variables in the first
1162        vector are different from all variables from the second group,
1163        unless they are assigned to the escape value. Thus the set of
1164        values in the first vector minus the escape value does not
1165        intersect with the set of values in the second vector.
1166        """
1167        return _pywrapcp.Solver_NullIntersectExcept(self, first_vars, second_vars, escape_value)

Creates a constraint that states that all variables in the first vector are different from all variables from the second group, unless they are assigned to the escape value. Thus the set of values in the first vector minus the escape value does not intersect with the set of values in the second vector.

def Circuit(self, nexts):
1169    def Circuit(self, nexts):
1170        r"""Force the "nexts" variable to create a complete Hamiltonian path."""
1171        return _pywrapcp.Solver_Circuit(self, nexts)

Force the "nexts" variable to create a complete Hamiltonian path.

def SubCircuit(self, nexts):
1173    def SubCircuit(self, nexts):
1174        r"""
1175        Force the "nexts" variable to create a complete Hamiltonian path
1176        for those that do not loop upon themselves.
1177        """
1178        return _pywrapcp.Solver_SubCircuit(self, nexts)

Force the "nexts" variable to create a complete Hamiltonian path for those that do not loop upon themselves.

def DelayedPathCumul(self, nexts, active, cumuls, transits):
1180    def DelayedPathCumul(self, nexts, active, cumuls, transits):
1181        r"""
1182        Delayed version of the same constraint: propagation on the nexts variables
1183        is delayed until all constraints have propagated.
1184        """
1185        return _pywrapcp.Solver_DelayedPathCumul(self, nexts, active, cumuls, transits)

Delayed version of the same constraint: propagation on the nexts variables is delayed until all constraints have propagated.

def PathCumul(self, *args):
1187    def PathCumul(self, *args):
1188        r"""
1189        *Overload 1:*
1190        Creates a constraint which accumulates values along a path such that:
1191        cumuls[next[i]] = cumuls[i] + transits[i].
1192        Active variables indicate if the corresponding next variable is active;
1193        this could be useful to model unperformed nodes in a routing problem.
1194
1195        |
1196
1197        *Overload 2:*
1198        Creates a constraint which accumulates values along a path such that:
1199        cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]).
1200        Active variables indicate if the corresponding next variable is active;
1201        this could be useful to model unperformed nodes in a routing problem.
1202        Ownership of transit_evaluator is taken and it must be a repeatable
1203        callback.
1204
1205        |
1206
1207        *Overload 3:*
1208        Creates a constraint which accumulates values along a path such that:
1209        cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i].
1210        Active variables indicate if the corresponding next variable is active;
1211        this could be useful to model unperformed nodes in a routing problem.
1212        Ownership of transit_evaluator is taken and it must be a repeatable
1213        callback.
1214        """
1215        return _pywrapcp.Solver_PathCumul(self, *args)

Overload 1: Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transits[i]. Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem.

|

Overload 2: Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]). Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. Ownership of transit_evaluator is taken and it must be a repeatable callback.

|

Overload 3: Creates a constraint which accumulates values along a path such that: cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i]. Active variables indicate if the corresponding next variable is active; this could be useful to model unperformed nodes in a routing problem. Ownership of transit_evaluator is taken and it must be a repeatable callback.

def AllowedAssignments(self, *args):
1217    def AllowedAssignments(self, *args):
1218        r"""
1219        *Overload 1:*
1220        This method creates a constraint where the graph of the relation
1221        between the variables is given in extension. There are 'arity'
1222        variables involved in the relation and the graph is given by a
1223        integer tuple set.
1224
1225        |
1226
1227        *Overload 2:*
1228        Compatibility layer for Python API.
1229        """
1230        return _pywrapcp.Solver_AllowedAssignments(self, *args)

Overload 1: This method creates a constraint where the graph of the relation between the variables is given in extension. There are 'arity' variables involved in the relation and the graph is given by a integer tuple set.

|

Overload 2: Compatibility layer for Python API.

def TransitionConstraint(self, *args):
1232    def TransitionConstraint(self, *args):
1233        r"""
1234        *Overload 1:*
1235        This constraint create a finite automaton that will check the
1236        sequence of variables vars. It uses a transition table called
1237        'transition_table'. Each transition is a triple
1238           (current_state, variable_value, new_state).
1239        The initial state is given, and the set of accepted states is decribed
1240        by 'final_states'. These states are hidden inside the constraint.
1241        Only the transitions (i.e. the variables) are visible.
1242
1243        |
1244
1245        *Overload 2:*
1246        This constraint create a finite automaton that will check the
1247        sequence of variables vars. It uses a transition table called
1248        'transition_table'. Each transition is a triple
1249           (current_state, variable_value, new_state).
1250        The initial state is given, and the set of accepted states is decribed
1251        by 'final_states'. These states are hidden inside the constraint.
1252        Only the transitions (i.e. the variables) are visible.
1253        """
1254        return _pywrapcp.Solver_TransitionConstraint(self, *args)

Overload 1: This constraint create a finite automaton that will check the sequence of variables vars. It uses a transition table called 'transition_table'. Each transition is a triple (current_state, variable_value, new_state). The initial state is given, and the set of accepted states is decribed by 'final_states'. These states are hidden inside the constraint. Only the transitions (i.e. the variables) are visible.

|

Overload 2: This constraint create a finite automaton that will check the sequence of variables vars. It uses a transition table called 'transition_table'. Each transition is a triple (current_state, variable_value, new_state). The initial state is given, and the set of accepted states is decribed by 'final_states'. These states are hidden inside the constraint. Only the transitions (i.e. the variables) are visible.

def NonOverlappingBoxesConstraint(self, *args):
1256    def NonOverlappingBoxesConstraint(self, *args):
1257        r"""
1258        This constraint states that all the boxes must not overlap.
1259        The coordinates of box i are:
1260          (x_vars[i], y_vars[i]),
1261          (x_vars[i], y_vars[i] + y_size[i]),
1262          (x_vars[i] + x_size[i], y_vars[i]),
1263          (x_vars[i] + x_size[i], y_vars[i] + y_size[i]).
1264        The sizes must be non-negative. Boxes with a zero dimension can be
1265        pushed like any box.
1266        """
1267        return _pywrapcp.Solver_NonOverlappingBoxesConstraint(self, *args)

This constraint states that all the boxes must not overlap.

The coordinates of box i are:

(x_vars[i], y_vars[i]), (x_vars[i], y_vars[i] + y_size[i]), (x_vars[i] + x_size[i], y_vars[i]), (x_vars[i] + x_size[i], y_vars[i] + y_size[i]).

The sizes must be non-negative. Boxes with a zero dimension can be pushed like any box.

def Pack(self, vars, number_of_bins):
1269    def Pack(self, vars, number_of_bins):
1270        r"""
1271        This constraint packs all variables onto 'number_of_bins'
1272        variables.  For any given variable, a value of 'number_of_bins'
1273        indicates that the variable is not assigned to any bin.
1274        Dimensions, i.e., cumulative constraints on this packing, can be
1275        added directly from the pack class.
1276        """
1277        return _pywrapcp.Solver_Pack(self, vars, number_of_bins)

This constraint packs all variables onto 'number_of_bins' variables. For any given variable, a value of 'number_of_bins' indicates that the variable is not assigned to any bin. Dimensions, i.e., cumulative constraints on this packing, can be added directly from the pack class.

def FixedDurationIntervalVar(self, *args):
1279    def FixedDurationIntervalVar(self, *args):
1280        r"""
1281        *Overload 1:*
1282        Creates an interval var with a fixed duration. The duration must
1283        be greater than 0. If optional is true, then the interval can be
1284        performed or unperformed. If optional is false, then the interval
1285        is always performed.
1286
1287        |
1288
1289        *Overload 2:*
1290        Creates a performed interval var with a fixed duration. The duration must
1291        be greater than 0.
1292
1293        |
1294
1295        *Overload 3:*
1296        Creates an interval var with a fixed duration, and performed_variable.
1297        The duration must be greater than 0.
1298        """
1299        return _pywrapcp.Solver_FixedDurationIntervalVar(self, *args)

Overload 1: Creates an interval var with a fixed duration. The duration must be greater than 0. If optional is true, then the interval can be performed or unperformed. If optional is false, then the interval is always performed.

|

Overload 2: Creates a performed interval var with a fixed duration. The duration must be greater than 0.

|

Overload 3: Creates an interval var with a fixed duration, and performed_variable. The duration must be greater than 0.

def FixedInterval(self, start, duration, name):
1301    def FixedInterval(self, start, duration, name):
1302        r"""Creates a fixed and performed interval."""
1303        return _pywrapcp.Solver_FixedInterval(self, start, duration, name)

Creates a fixed and performed interval.

def IntervalVar( self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name):
1305    def IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name):
1306        r"""
1307        Creates an interval var by specifying the bounds on start,
1308        duration, and end.
1309        """
1310        return _pywrapcp.Solver_IntervalVar(self, start_min, start_max, duration_min, duration_max, end_min, end_max, optional, name)

Creates an interval var by specifying the bounds on start, duration, and end.

def MirrorInterval(self, interval_var):
1312    def MirrorInterval(self, interval_var):
1313        r"""
1314        Creates an interval var that is the mirror image of the given one, that
1315        is, the interval var obtained by reversing the axis.
1316        """
1317        return _pywrapcp.Solver_MirrorInterval(self, interval_var)

Creates an interval var that is the mirror image of the given one, that is, the interval var obtained by reversing the axis.

def FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1319    def FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1320        r"""
1321        Creates an interval var with a fixed duration whose start is
1322        synchronized with the start of another interval, with a given
1323        offset. The performed status is also in sync with the performed
1324        status of the given interval variable.
1325        """
1326        return _pywrapcp.Solver_FixedDurationStartSyncedOnStartIntervalVar(self, interval_var, duration, offset)

Creates an interval var with a fixed duration whose start is synchronized with the start of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.

def FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1328    def FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1329        r"""
1330        Creates an interval var with a fixed duration whose start is
1331        synchronized with the end of another interval, with a given
1332        offset. The performed status is also in sync with the performed
1333        status of the given interval variable.
1334        """
1335        return _pywrapcp.Solver_FixedDurationStartSyncedOnEndIntervalVar(self, interval_var, duration, offset)

Creates an interval var with a fixed duration whose start is synchronized with the end of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.

def FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1337    def FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset):
1338        r"""
1339        Creates an interval var with a fixed duration whose end is
1340        synchronized with the start of another interval, with a given
1341        offset. The performed status is also in sync with the performed
1342        status of the given interval variable.
1343        """
1344        return _pywrapcp.Solver_FixedDurationEndSyncedOnStartIntervalVar(self, interval_var, duration, offset)

Creates an interval var with a fixed duration whose end is synchronized with the start of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.

def FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1346    def FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset):
1347        r"""
1348        Creates an interval var with a fixed duration whose end is
1349        synchronized with the end of another interval, with a given
1350        offset. The performed status is also in sync with the performed
1351        status of the given interval variable.
1352        """
1353        return _pywrapcp.Solver_FixedDurationEndSyncedOnEndIntervalVar(self, interval_var, duration, offset)

Creates an interval var with a fixed duration whose end is synchronized with the end of another interval, with a given offset. The performed status is also in sync with the performed status of the given interval variable.

def IntervalRelaxedMin(self, interval_var):
1355    def IntervalRelaxedMin(self, interval_var):
1356        r"""
1357         Creates and returns an interval variable that wraps around the given one,
1358         relaxing the min start and end. Relaxing means making unbounded when
1359         optional. If the variable is non-optional, this method returns
1360         interval_var.
1361
1362         More precisely, such an interval variable behaves as follows:
1363        When the underlying must be performed, the returned interval variable
1364             behaves exactly as the underlying;
1365        When the underlying may or may not be performed, the returned interval
1366             variable behaves like the underlying, except that it is unbounded on
1367             the min side;
1368        When the underlying cannot be performed, the returned interval variable
1369             is of duration 0 and must be performed in an interval unbounded on
1370             both sides.
1371
1372         This is very useful to implement propagators that may only modify
1373         the start max or end max.
1374        """
1375        return _pywrapcp.Solver_IntervalRelaxedMin(self, interval_var)

Creates and returns an interval variable that wraps around the given one, relaxing the min start and end. Relaxing means making unbounded when optional. If the variable is non-optional, this method returns interval_var.

More precisely, such an interval variable behaves as follows: When the underlying must be performed, the returned interval variable behaves exactly as the underlying; When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the min side; When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides.

This is very useful to implement propagators that may only modify the start max or end max.

def IntervalRelaxedMax(self, interval_var):
1377    def IntervalRelaxedMax(self, interval_var):
1378        r"""
1379         Creates and returns an interval variable that wraps around the given one,
1380         relaxing the max start and end. Relaxing means making unbounded when
1381         optional. If the variable is non optional, this method returns
1382         interval_var.
1383
1384         More precisely, such an interval variable behaves as follows:
1385        When the underlying must be performed, the returned interval variable
1386             behaves exactly as the underlying;
1387        When the underlying may or may not be performed, the returned interval
1388             variable behaves like the underlying, except that it is unbounded on
1389             the max side;
1390        When the underlying cannot be performed, the returned interval variable
1391             is of duration 0 and must be performed in an interval unbounded on
1392             both sides.
1393
1394         This is very useful for implementing propagators that may only modify
1395         the start min or end min.
1396        """
1397        return _pywrapcp.Solver_IntervalRelaxedMax(self, interval_var)

Creates and returns an interval variable that wraps around the given one, relaxing the max start and end. Relaxing means making unbounded when optional. If the variable is non optional, this method returns interval_var.

More precisely, such an interval variable behaves as follows: When the underlying must be performed, the returned interval variable behaves exactly as the underlying; When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the max side; When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides.

This is very useful for implementing propagators that may only modify the start min or end min.

def TemporalDisjunction(self, *args):
1399    def TemporalDisjunction(self, *args):
1400        r"""
1401        *Overload 1:*
1402        This constraint implements a temporal disjunction between two
1403        interval vars t1 and t2. 'alt' indicates which alternative was
1404        chosen (alt == 0 is equivalent to t1 before t2).
1405
1406        |
1407
1408        *Overload 2:*
1409        This constraint implements a temporal disjunction between two
1410        interval vars.
1411        """
1412        return _pywrapcp.Solver_TemporalDisjunction(self, *args)

Overload 1: This constraint implements a temporal disjunction between two interval vars t1 and t2. 'alt' indicates which alternative was chosen (alt == 0 is equivalent to t1 before t2).

|

Overload 2: This constraint implements a temporal disjunction between two interval vars.

def DisjunctiveConstraint(self, intervals, name):
1414    def DisjunctiveConstraint(self, intervals, name):
1415        r"""
1416        This constraint forces all interval vars into an non-overlapping
1417        sequence. Intervals with zero duration can be scheduled anywhere.
1418        """
1419        return _pywrapcp.Solver_DisjunctiveConstraint(self, intervals, name)

This constraint forces all interval vars into an non-overlapping sequence. Intervals with zero duration can be scheduled anywhere.

def Cumulative(self, *args):
1421    def Cumulative(self, *args):
1422        r"""
1423        *Overload 1:*
1424        This constraint forces that, for any integer t, the sum of the demands
1425        corresponding to an interval containing t does not exceed the given
1426        capacity.
1427
1428        Intervals and demands should be vectors of equal size.
1429
1430        Demands should only contain non-negative values. Zero values are
1431        supported, and the corresponding intervals are filtered out, as they
1432        neither impact nor are impacted by this constraint.
1433
1434        |
1435
1436        *Overload 2:*
1437        This constraint forces that, for any integer t, the sum of the demands
1438        corresponding to an interval containing t does not exceed the given
1439        capacity.
1440
1441        Intervals and demands should be vectors of equal size.
1442
1443        Demands should only contain non-negative values. Zero values are
1444        supported, and the corresponding intervals are filtered out, as they
1445        neither impact nor are impacted by this constraint.
1446
1447        |
1448
1449        *Overload 3:*
1450        This constraint forces that, for any integer t, the sum of the demands
1451        corresponding to an interval containing t does not exceed the given
1452        capacity.
1453
1454        Intervals and demands should be vectors of equal size.
1455
1456        Demands should only contain non-negative values. Zero values are
1457        supported, and the corresponding intervals are filtered out, as they
1458        neither impact nor are impacted by this constraint.
1459
1460        |
1461
1462        *Overload 4:*
1463        This constraint enforces that, for any integer t, the sum of the demands
1464        corresponding to an interval containing t does not exceed the given
1465        capacity.
1466
1467        Intervals and demands should be vectors of equal size.
1468
1469        Demands should only contain non-negative values. Zero values are
1470        supported, and the corresponding intervals are filtered out, as they
1471        neither impact nor are impacted by this constraint.
1472
1473        |
1474
1475        *Overload 5:*
1476        This constraint enforces that, for any integer t, the sum of demands
1477        corresponding to an interval containing t does not exceed the given
1478        capacity.
1479
1480        Intervals and demands should be vectors of equal size.
1481
1482        Demands should be positive.
1483
1484        |
1485
1486        *Overload 6:*
1487        This constraint enforces that, for any integer t, the sum of demands
1488        corresponding to an interval containing t does not exceed the given
1489        capacity.
1490
1491        Intervals and demands should be vectors of equal size.
1492
1493        Demands should be positive.
1494        """
1495        return _pywrapcp.Solver_Cumulative(self, *args)

Overload 1: This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity.

Intervals and demands should be vectors of equal size.

Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint.

|

Overload 2: This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity.

Intervals and demands should be vectors of equal size.

Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint.

|

Overload 3: This constraint forces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity.

Intervals and demands should be vectors of equal size.

Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint.

|

Overload 4: This constraint enforces that, for any integer t, the sum of the demands corresponding to an interval containing t does not exceed the given capacity.

Intervals and demands should be vectors of equal size.

Demands should only contain non-negative values. Zero values are supported, and the corresponding intervals are filtered out, as they neither impact nor are impacted by this constraint.

|

Overload 5: This constraint enforces that, for any integer t, the sum of demands corresponding to an interval containing t does not exceed the given capacity.

Intervals and demands should be vectors of equal size.

Demands should be positive.

|

Overload 6: This constraint enforces that, for any integer t, the sum of demands corresponding to an interval containing t does not exceed the given capacity.

Intervals and demands should be vectors of equal size.

Demands should be positive.

def Cover(self, vars, target_var):
1497    def Cover(self, vars, target_var):
1498        r"""
1499        This constraint states that the target_var is the convex hull of
1500        the intervals. If none of the interval variables is performed,
1501        then the target var is unperformed too. Also, if the target
1502        variable is unperformed, then all the intervals variables are
1503        unperformed too.
1504        """
1505        return _pywrapcp.Solver_Cover(self, vars, target_var)

This constraint states that the target_var is the convex hull of the intervals. If none of the interval variables is performed, then the target var is unperformed too. Also, if the target variable is unperformed, then all the intervals variables are unperformed too.

def Assignment(self, *args):
1507    def Assignment(self, *args):
1508        r"""
1509        *Overload 1:*
1510        This method creates an empty assignment.
1511
1512        |
1513
1514        *Overload 2:*
1515        This method creates an assignment which is a copy of 'a'.
1516        """
1517        return _pywrapcp.Solver_Assignment(self, *args)

Overload 1: This method creates an empty assignment.

|

Overload 2: This method creates an assignment which is a copy of 'a'.

def FirstSolutionCollector(self, *args):
1519    def FirstSolutionCollector(self, *args):
1520        r"""
1521        *Overload 1:*
1522        Collect the first solution of the search.
1523
1524        |
1525
1526        *Overload 2:*
1527        Collect the first solution of the search. The variables will need to
1528        be added later.
1529        """
1530        return _pywrapcp.Solver_FirstSolutionCollector(self, *args)

Overload 1: Collect the first solution of the search.

|

Overload 2: Collect the first solution of the search. The variables will need to be added later.

def LastSolutionCollector(self, *args):
1532    def LastSolutionCollector(self, *args):
1533        r"""
1534        *Overload 1:*
1535        Collect the last solution of the search.
1536
1537        |
1538
1539        *Overload 2:*
1540        Collect the last solution of the search. The variables will need to
1541        be added later.
1542        """
1543        return _pywrapcp.Solver_LastSolutionCollector(self, *args)

Overload 1: Collect the last solution of the search.

|

Overload 2: Collect the last solution of the search. The variables will need to be added later.

def BestValueSolutionCollector(self, *args):
1545    def BestValueSolutionCollector(self, *args):
1546        r"""
1547        *Overload 1:*
1548        Collect the solution corresponding to the optimal value of the objective
1549        of 'assignment'; if 'assignment' does not have an objective no solution is
1550        collected. This collector only collects one solution corresponding to the
1551        best objective value (the first one found).
1552
1553        |
1554
1555        *Overload 2:*
1556        Collect the solution corresponding to the optimal value of the
1557        objective of the internal assignment; if this assignment does not have an
1558        objective no solution is collected. This collector only collects one
1559        solution corresponding to the best objective value (the first one found).
1560        The variables and objective(s) will need to be added later.
1561        """
1562        return _pywrapcp.Solver_BestValueSolutionCollector(self, *args)

Overload 1: Collect the solution corresponding to the optimal value of the objective of 'assignment'; if 'assignment' does not have an objective no solution is collected. This collector only collects one solution corresponding to the best objective value (the first one found).

|

Overload 2: Collect the solution corresponding to the optimal value of the objective of the internal assignment; if this assignment does not have an objective no solution is collected. This collector only collects one solution corresponding to the best objective value (the first one found). The variables and objective(s) will need to be added later.

def AllSolutionCollector(self, *args):
1564    def AllSolutionCollector(self, *args):
1565        r"""
1566        *Overload 1:*
1567        Collect all solutions of the search.
1568
1569        |
1570
1571        *Overload 2:*
1572        Collect all solutions of the search. The variables will need to
1573        be added later.
1574        """
1575        return _pywrapcp.Solver_AllSolutionCollector(self, *args)

Overload 1: Collect all solutions of the search.

|

Overload 2: Collect all solutions of the search. The variables will need to be added later.

def Minimize(self, v, step):
1577    def Minimize(self, v, step):
1578        r"""Creates a minimization objective."""
1579        return _pywrapcp.Solver_Minimize(self, v, step)

Creates a minimization objective.

def Maximize(self, v, step):
1581    def Maximize(self, v, step):
1582        r"""Creates a maximization objective."""
1583        return _pywrapcp.Solver_Maximize(self, v, step)

Creates a maximization objective.

def Optimize(self, maximize, v, step):
1585    def Optimize(self, maximize, v, step):
1586        r"""Creates a objective with a given sense (true = maximization)."""
1587        return _pywrapcp.Solver_Optimize(self, maximize, v, step)

Creates a objective with a given sense (true = maximization).

def WeightedMinimize(self, *args):
1589    def WeightedMinimize(self, *args):
1590        r"""
1591        *Overload 1:*
1592        Creates a minimization weighted objective. The actual objective is
1593        scalar_prod(sub_objectives, weights).
1594
1595        |
1596
1597        *Overload 2:*
1598        Creates a minimization weighted objective. The actual objective is
1599        scalar_prod(sub_objectives, weights).
1600        """
1601        return _pywrapcp.Solver_WeightedMinimize(self, *args)

Overload 1: Creates a minimization weighted objective. The actual objective is scalar_prod(sub_objectives, weights).

|

Overload 2: Creates a minimization weighted objective. The actual objective is scalar_prod(sub_objectives, weights).

def WeightedMaximize(self, *args):
1603    def WeightedMaximize(self, *args):
1604        r"""
1605        *Overload 1:*
1606        Creates a maximization weigthed objective.
1607
1608        |
1609
1610        *Overload 2:*
1611        Creates a maximization weigthed objective.
1612        """
1613        return _pywrapcp.Solver_WeightedMaximize(self, *args)

Overload 1: Creates a maximization weigthed objective.

|

Overload 2: Creates a maximization weigthed objective.

def WeightedOptimize(self, *args):
1615    def WeightedOptimize(self, *args):
1616        r"""
1617        *Overload 1:*
1618        Creates a weighted objective with a given sense (true = maximization).
1619
1620        |
1621
1622        *Overload 2:*
1623        Creates a weighted objective with a given sense (true = maximization).
1624        """
1625        return _pywrapcp.Solver_WeightedOptimize(self, *args)

Overload 1: Creates a weighted objective with a given sense (true = maximization).

|

Overload 2: Creates a weighted objective with a given sense (true = maximization).

def TabuSearch( self, maximize, objective, step, vars, keep_tenure, forbid_tenure, tabu_factor):
1627    def TabuSearch(self, maximize, objective, step, vars, keep_tenure, forbid_tenure, tabu_factor):
1628        r"""
1629        MetaHeuristics which try to get the search out of local optima.
1630        Creates a Tabu Search monitor.
1631        In the context of local search the behavior is similar to MakeOptimize(),
1632        creating an objective in a given sense. The behavior differs once a local
1633        optimum is reached: thereafter solutions which degrade the value of the
1634        objective are allowed if they are not "tabu". A solution is "tabu" if it
1635        doesn't respect the following rules:
1636        - improving the best solution found so far
1637        - variables in the "keep" list must keep their value, variables in the
1638        "forbid" list must not take the value they have in the list.
1639        Variables with new values enter the tabu lists after each new solution
1640        found and leave the lists after a given number of iterations (called
1641        tenure). Only the variables passed to the method can enter the lists.
1642        The tabu criterion is softened by the tabu factor which gives the number
1643        of "tabu" violations which is tolerated; a factor of 1 means no violations
1644        allowed; a factor of 0 means all violations are allowed.
1645        """
1646        return _pywrapcp.Solver_TabuSearch(self, maximize, objective, step, vars, keep_tenure, forbid_tenure, tabu_factor)

MetaHeuristics which try to get the search out of local optima. Creates a Tabu Search monitor. In the context of local search the behavior is similar to MakeOptimize(), creating an objective in a given sense. The behavior differs once a local optimum is reached: thereafter solutions which degrade the value of the objective are allowed if they are not "tabu". A solution is "tabu" if it doesn't respect the following rules:

  • improving the best solution found so far
  • variables in the "keep" list must keep their value, variables in the "forbid" list must not take the value they have in the list. Variables with new values enter the tabu lists after each new solution found and leave the lists after a given number of iterations (called tenure). Only the variables passed to the method can enter the lists. The tabu criterion is softened by the tabu factor which gives the number of "tabu" violations which is tolerated; a factor of 1 means no violations allowed; a factor of 0 means all violations are allowed.
def SimulatedAnnealing(self, maximize, v, step, initial_temperature):
1648    def SimulatedAnnealing(self, maximize, v, step, initial_temperature):
1649        r"""Creates a Simulated Annealing monitor."""
1650        return _pywrapcp.Solver_SimulatedAnnealing(self, maximize, v, step, initial_temperature)

Creates a Simulated Annealing monitor.

def LubyRestart(self, scale_factor):
1652    def LubyRestart(self, scale_factor):
1653        r"""
1654        This search monitor will restart the search periodically.
1655        At the iteration n, it will restart after scale_factor * Luby(n) failures
1656        where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).
1657        """
1658        return _pywrapcp.Solver_LubyRestart(self, scale_factor)

This search monitor will restart the search periodically. At the iteration n, it will restart after scale_factor * Luby(n) failures where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).

def ConstantRestart(self, frequency):
1660    def ConstantRestart(self, frequency):
1661        r"""
1662        This search monitor will restart the search periodically after 'frequency'
1663        failures.
1664        """
1665        return _pywrapcp.Solver_ConstantRestart(self, frequency)

This search monitor will restart the search periodically after 'frequency' failures.

def TimeLimit(self, *args):
1667    def TimeLimit(self, *args):
1668        r"""Creates a search limit that constrains the running time."""
1669        return _pywrapcp.Solver_TimeLimit(self, *args)

Creates a search limit that constrains the running time.

def BranchesLimit(self, branches):
1671    def BranchesLimit(self, branches):
1672        r"""
1673        Creates a search limit that constrains the number of branches
1674        explored in the search tree.
1675        """
1676        return _pywrapcp.Solver_BranchesLimit(self, branches)

Creates a search limit that constrains the number of branches explored in the search tree.

def FailuresLimit(self, failures):
1678    def FailuresLimit(self, failures):
1679        r"""
1680        Creates a search limit that constrains the number of failures
1681        that can happen when exploring the search tree.
1682        """
1683        return _pywrapcp.Solver_FailuresLimit(self, failures)

Creates a search limit that constrains the number of failures that can happen when exploring the search tree.

def SolutionsLimit(self, solutions):
1685    def SolutionsLimit(self, solutions):
1686        r"""
1687        Creates a search limit that constrains the number of solutions found
1688        during the search.
1689        """
1690        return _pywrapcp.Solver_SolutionsLimit(self, solutions)

Creates a search limit that constrains the number of solutions found during the search.

def Limit(self, *args):
1692    def Limit(self, *args):
1693        r"""
1694        *Overload 1:*
1695        Limits the search with the 'time', 'branches', 'failures' and
1696        'solutions' limits. 'smart_time_check' reduces the calls to the wall
1697
1698        |
1699
1700        *Overload 2:*
1701        Creates a search limit from its protobuf description
1702
1703        |
1704
1705        *Overload 3:*
1706        Creates a search limit that is reached when either of the underlying limit
1707        is reached. That is, the returned limit is more stringent than both
1708        argument limits.
1709        """
1710        return _pywrapcp.Solver_Limit(self, *args)

Overload 1: Limits the search with the 'time', 'branches', 'failures' and 'solutions' limits. 'smart_time_check' reduces the calls to the wall

|

Overload 2: Creates a search limit from its protobuf description

|

Overload 3: Creates a search limit that is reached when either of the underlying limit is reached. That is, the returned limit is more stringent than both argument limits.

def CustomLimit(self, limiter):
1712    def CustomLimit(self, limiter):
1713        r"""
1714        Callback-based search limit. Search stops when limiter returns true; if
1715        this happens at a leaf the corresponding solution will be rejected.
1716        """
1717        return _pywrapcp.Solver_CustomLimit(self, limiter)

Callback-based search limit. Search stops when limiter returns true; if this happens at a leaf the corresponding solution will be rejected.

def SearchLog(self, *args):
1719    def SearchLog(self, *args):
1720        r"""
1721        *Overload 1:*
1722         The SearchMonitors below will display a periodic search log
1723         on LOG(INFO) every branch_period branches explored.
1724
1725        |
1726
1727        *Overload 2:*
1728         At each solution, this monitor also display the var value.
1729
1730        |
1731
1732        *Overload 3:*
1733         At each solution, this monitor will also display result of
1734        ``display_callback``.
1735
1736        |
1737
1738        *Overload 4:*
1739         At each solution, this monitor will display the 'var' value and the
1740         result of ``display_callback``.
1741
1742        |
1743
1744        *Overload 5:*
1745         At each solution, this monitor will display the 'vars' values and the
1746         result of ``display_callback``.
1747
1748        |
1749
1750        *Overload 6:*
1751         OptimizeVar Search Logs
1752         At each solution, this monitor will also display the 'opt_var' value.
1753
1754        |
1755
1756        *Overload 7:*
1757         Creates a search monitor that will also print the result of the
1758         display callback.
1759        """
1760        return _pywrapcp.Solver_SearchLog(self, *args)

Overload 1: The SearchMonitors below will display a periodic search log on LOG(INFO) every branch_period branches explored.

|

Overload 2: At each solution, this monitor also display the var value.

|

Overload 3: At each solution, this monitor will also display result of display_callback.

|

Overload 4: At each solution, this monitor will display the 'var' value and the result of display_callback.

|

Overload 5: At each solution, this monitor will display the 'vars' values and the result of display_callback.

|

Overload 6: OptimizeVar Search Logs At each solution, this monitor will also display the 'opt_var' value.

|

Overload 7: Creates a search monitor that will also print the result of the display callback.

def SearchTrace(self, prefix):
1762    def SearchTrace(self, prefix):
1763        r"""
1764        Creates a search monitor that will trace precisely the behavior of the
1765        search. Use this only for low level debugging.
1766        """
1767        return _pywrapcp.Solver_SearchTrace(self, prefix)

Creates a search monitor that will trace precisely the behavior of the search. Use this only for low level debugging.

def PrintModelVisitor(self):
1769    def PrintModelVisitor(self):
1770        r"""Prints the model."""
1771        return _pywrapcp.Solver_PrintModelVisitor(self)

Prints the model.

def StatisticsModelVisitor(self):
1773    def StatisticsModelVisitor(self):
1774        r"""Displays some nice statistics on the model."""
1775        return _pywrapcp.Solver_StatisticsModelVisitor(self)

Displays some nice statistics on the model.

def AssignVariableValue(self, var, val):
1777    def AssignVariableValue(self, var, val):
1778        r"""Decisions."""
1779        return _pywrapcp.Solver_AssignVariableValue(self, var, val)

Decisions.

def VariableLessOrEqualValue(self, var, value):
1781    def VariableLessOrEqualValue(self, var, value):
1782        return _pywrapcp.Solver_VariableLessOrEqualValue(self, var, value)
def VariableGreaterOrEqualValue(self, var, value):
1784    def VariableGreaterOrEqualValue(self, var, value):
1785        return _pywrapcp.Solver_VariableGreaterOrEqualValue(self, var, value)
def SplitVariableDomain(self, var, val, start_with_lower_half):
1787    def SplitVariableDomain(self, var, val, start_with_lower_half):
1788        return _pywrapcp.Solver_SplitVariableDomain(self, var, val, start_with_lower_half)
def AssignVariableValueOrFail(self, var, value):
1790    def AssignVariableValueOrFail(self, var, value):
1791        return _pywrapcp.Solver_AssignVariableValueOrFail(self, var, value)
def AssignVariablesValues(self, vars, values):
1793    def AssignVariablesValues(self, vars, values):
1794        return _pywrapcp.Solver_AssignVariablesValues(self, vars, values)
def FailDecision(self):
1796    def FailDecision(self):
1797        return _pywrapcp.Solver_FailDecision(self)
def Decision(self, apply, refute):
1799    def Decision(self, apply, refute):
1800        return _pywrapcp.Solver_Decision(self, apply, refute)
def Compose(self, dbs):
1802    def Compose(self, dbs):
1803        return _pywrapcp.Solver_Compose(self, dbs)
def Try(self, dbs):
1805    def Try(self, dbs):
1806        return _pywrapcp.Solver_Try(self, dbs)
def DefaultPhase(self, *args):
1808    def DefaultPhase(self, *args):
1809        return _pywrapcp.Solver_DefaultPhase(self, *args)
def ScheduleOrPostpone(self, var, est, marker):
1811    def ScheduleOrPostpone(self, var, est, marker):
1812        r"""
1813        Returns a decision that tries to schedule a task at a given time.
1814        On the Apply branch, it will set that interval var as performed and set
1815        its start to 'est'. On the Refute branch, it will just update the
1816        'marker' to 'est' + 1. This decision is used in the
1817        INTERVAL_SET_TIMES_FORWARD strategy.
1818        """
1819        return _pywrapcp.Solver_ScheduleOrPostpone(self, var, est, marker)

Returns a decision that tries to schedule a task at a given time. On the Apply branch, it will set that interval var as performed and set its start to 'est'. On the Refute branch, it will just update the 'marker' to 'est' + 1. This decision is used in the INTERVAL_SET_TIMES_FORWARD strategy.

def ScheduleOrExpedite(self, var, est, marker):
1821    def ScheduleOrExpedite(self, var, est, marker):
1822        r"""
1823        Returns a decision that tries to schedule a task at a given time.
1824        On the Apply branch, it will set that interval var as performed and set
1825        its end to 'est'. On the Refute branch, it will just update the
1826        'marker' to 'est' - 1. This decision is used in the
1827        INTERVAL_SET_TIMES_BACKWARD strategy.
1828        """
1829        return _pywrapcp.Solver_ScheduleOrExpedite(self, var, est, marker)

Returns a decision that tries to schedule a task at a given time. On the Apply branch, it will set that interval var as performed and set its end to 'est'. On the Refute branch, it will just update the 'marker' to 'est' - 1. This decision is used in the INTERVAL_SET_TIMES_BACKWARD strategy.

def RankFirstInterval(self, sequence, index):
1831    def RankFirstInterval(self, sequence, index):
1832        r"""
1833        Returns a decision that tries to rank first the ith interval var
1834        in the sequence variable.
1835        """
1836        return _pywrapcp.Solver_RankFirstInterval(self, sequence, index)

Returns a decision that tries to rank first the ith interval var in the sequence variable.

def RankLastInterval(self, sequence, index):
1838    def RankLastInterval(self, sequence, index):
1839        r"""
1840        Returns a decision that tries to rank last the ith interval var
1841        in the sequence variable.
1842        """
1843        return _pywrapcp.Solver_RankLastInterval(self, sequence, index)

Returns a decision that tries to rank last the ith interval var in the sequence variable.

def Phase(self, *args):
1845    def Phase(self, *args):
1846        r"""
1847        *Overload 1:*
1848        Phases on IntVar arrays.
1849        for all other functions that have several homonyms in this .h).
1850
1851        |
1852
1853        *Overload 2:*
1854        Scheduling phases.
1855        """
1856        return _pywrapcp.Solver_Phase(self, *args)

Overload 1: Phases on IntVar arrays. for all other functions that have several homonyms in this .h).

|

Overload 2: Scheduling phases.

def DecisionBuilderFromAssignment(self, assignment, db, vars):
1858    def DecisionBuilderFromAssignment(self, assignment, db, vars):
1859        r"""
1860        Returns a decision builder for which the left-most leaf corresponds
1861        to assignment, the rest of the tree being explored using 'db'.
1862        """
1863        return _pywrapcp.Solver_DecisionBuilderFromAssignment(self, assignment, db, vars)

Returns a decision builder for which the left-most leaf corresponds to assignment, the rest of the tree being explored using 'db'.

def ConstraintAdder(self, ct):
1865    def ConstraintAdder(self, ct):
1866        r"""
1867        Returns a decision builder that will add the given constraint to
1868        the model.
1869        """
1870        return _pywrapcp.Solver_ConstraintAdder(self, ct)

Returns a decision builder that will add the given constraint to the model.

def SolveOnce(self, db, monitors):
1872    def SolveOnce(self, db, monitors):
1873        return _pywrapcp.Solver_SolveOnce(self, db, monitors)
def NestedOptimize(self, *args):
1875    def NestedOptimize(self, *args):
1876        r"""
1877        NestedOptimize will collapse a search tree described by a
1878        decision builder 'db' and a set of monitors and wrap it into a
1879        single point. If there are no solutions to this nested tree, then
1880        NestedOptimize will fail. If there are solutions, it will find
1881        the best as described by the mandatory objective in the solution
1882        as well as the optimization direction, instantiate all variables
1883        to this solution, and return nullptr.
1884        """
1885        return _pywrapcp.Solver_NestedOptimize(self, *args)

NestedOptimize will collapse a search tree described by a decision builder 'db' and a set of monitors and wrap it into a single point. If there are no solutions to this nested tree, then NestedOptimize will fail. If there are solutions, it will find the best as described by the mandatory objective in the solution as well as the optimization direction, instantiate all variables to this solution, and return nullptr.

def RestoreAssignment(self, assignment):
1887    def RestoreAssignment(self, assignment):
1888        r"""
1889        Returns a DecisionBuilder which restores an Assignment
1890        (calls void Assignment::Restore())
1891        """
1892        return _pywrapcp.Solver_RestoreAssignment(self, assignment)

Returns a DecisionBuilder which restores an Assignment (calls void Assignment::Restore())

def StoreAssignment(self, assignment):
1894    def StoreAssignment(self, assignment):
1895        r"""
1896        Returns a DecisionBuilder which stores an Assignment
1897        (calls void Assignment::Store())
1898        """
1899        return _pywrapcp.Solver_StoreAssignment(self, assignment)

Returns a DecisionBuilder which stores an Assignment (calls void Assignment::Store())

def Operator(self, *args):
1901    def Operator(self, *args):
1902        r"""Local Search Operators."""
1903        return _pywrapcp.Solver_Operator(self, *args)

Local Search Operators.

def RandomLnsOperator(self, *args):
1905    def RandomLnsOperator(self, *args):
1906        r"""
1907        Creates a large neighborhood search operator which creates fragments (set
1908        of relaxed variables) with up to number_of_variables random variables
1909        (sampling with replacement is performed meaning that at most
1910        number_of_variables variables are selected). Warning: this operator will
1911        always return neighbors; using it without a search limit will result in a
1912        non-ending search.
1913        Optionally a random seed can be specified.
1914        """
1915        return _pywrapcp.Solver_RandomLnsOperator(self, *args)

Creates a large neighborhood search operator which creates fragments (set of relaxed variables) with up to number_of_variables random variables (sampling with replacement is performed meaning that at most number_of_variables variables are selected). Warning: this operator will always return neighbors; using it without a search limit will result in a non-ending search. Optionally a random seed can be specified.

def MoveTowardTargetOperator(self, *args):
1917    def MoveTowardTargetOperator(self, *args):
1918        r"""
1919        *Overload 1:*
1920        Creates a local search operator that tries to move the assignment of some
1921        variables toward a target. The target is given as an Assignment. This
1922        operator generates neighbors in which the only difference compared to the
1923        current state is that one variable that belongs to the target assignment
1924        is set to its target value.
1925
1926        |
1927
1928        *Overload 2:*
1929        Creates a local search operator that tries to move the assignment of some
1930        variables toward a target. The target is given either as two vectors: a
1931        vector of variables and a vector of associated target values. The two
1932        vectors should be of the same length. This operator generates neighbors in
1933        which the only difference compared to the current state is that one
1934        variable that belongs to the given vector is set to its target value.
1935        """
1936        return _pywrapcp.Solver_MoveTowardTargetOperator(self, *args)

Overload 1: Creates a local search operator that tries to move the assignment of some variables toward a target. The target is given as an Assignment. This operator generates neighbors in which the only difference compared to the current state is that one variable that belongs to the target assignment is set to its target value.

|

Overload 2: Creates a local search operator that tries to move the assignment of some variables toward a target. The target is given either as two vectors: a vector of variables and a vector of associated target values. The two vectors should be of the same length. This operator generates neighbors in which the only difference compared to the current state is that one variable that belongs to the given vector is set to its target value.

def ConcatenateOperators(self, *args):
1938    def ConcatenateOperators(self, *args):
1939        r"""
1940        Creates a local search operator which concatenates a vector of operators.
1941        Each operator from the vector is called sequentially. By default, when a
1942        neighbor is found the neighborhood exploration restarts from the last
1943        active operator (the one which produced the neighbor).
1944        This can be overridden by setting restart to true to force the exploration
1945        to start from the first operator in the vector.
1946
1947        The default behavior can also be overridden using an evaluation callback
1948        to set the order in which the operators are explored (the callback is
1949        called in LocalSearchOperator::Start()). The first argument of the
1950        callback is the index of the operator which produced the last move, the
1951        second argument is the index of the operator to be evaluated. Ownership of
1952        the callback is taken by ConcatenateOperators.
1953
1954        Example:
1955
1956         const int kPriorities = {10, 100, 10, 0};
1957         int64_t Evaluate(int active_operator, int current_operator) {
1958           return kPriorities[current_operator];
1959         }
1960
1961         LocalSearchOperator* concat =
1962           solver.ConcatenateOperators(operators,
1963                                       NewPermanentCallback(&Evaluate));
1964
1965        The elements of the vector operators will be sorted by increasing priority
1966        and explored in that order (tie-breaks are handled by keeping the relative
1967        operator order in the vector). This would result in the following order:
1968        operators[3], operators[0], operators[2], operators[1].
1969        """
1970        return _pywrapcp.Solver_ConcatenateOperators(self, *args)

Creates a local search operator which concatenates a vector of operators. Each operator from the vector is called sequentially. By default, when a neighbor is found the neighborhood exploration restarts from the last active operator (the one which produced the neighbor). This can be overridden by setting restart to true to force the exploration to start from the first operator in the vector.

The default behavior can also be overridden using an evaluation callback to set the order in which the operators are explored (the callback is called in LocalSearchOperator::Start()). The first argument of the callback is the index of the operator which produced the last move, the second argument is the index of the operator to be evaluated. Ownership of the callback is taken by ConcatenateOperators.

Example:

const int kPriorities = {10, 100, 10, 0}; int64_t Evaluate(int active_operator, int current_operator) { return kPriorities[current_operator]; }

LocalSearchOperator* concat = solver.ConcatenateOperators(operators, NewPermanentCallback(&Evaluate));

The elements of the vector operators will be sorted by increasing priority and explored in that order (tie-breaks are handled by keeping the relative operator order in the vector). This would result in the following order: operators[3], operators[0], operators[2], operators[1].

def RandomConcatenateOperators(self, *args):
1972    def RandomConcatenateOperators(self, *args):
1973        r"""
1974        *Overload 1:*
1975        Randomized version of local search concatenator; calls a random operator
1976        at each call to MakeNextNeighbor().
1977
1978        |
1979
1980        *Overload 2:*
1981        Randomized version of local search concatenator; calls a random operator
1982        at each call to MakeNextNeighbor(). The provided seed is used to
1983        initialize the random number generator.
1984        """
1985        return _pywrapcp.Solver_RandomConcatenateOperators(self, *args)

Overload 1: Randomized version of local search concatenator; calls a random operator at each call to MakeNextNeighbor().

|

Overload 2: Randomized version of local search concatenator; calls a random operator at each call to MakeNextNeighbor(). The provided seed is used to initialize the random number generator.

def NeighborhoodLimit(self, op, limit):
1987    def NeighborhoodLimit(self, op, limit):
1988        r"""
1989        Creates a local search operator that wraps another local search
1990        operator and limits the number of neighbors explored (i.e., calls
1991        to MakeNextNeighbor from the current solution (between two calls
1992        to Start()). When this limit is reached, MakeNextNeighbor()
1993        returns false. The counter is cleared when Start() is called.
1994        """
1995        return _pywrapcp.Solver_NeighborhoodLimit(self, op, limit)

Creates a local search operator that wraps another local search operator and limits the number of neighbors explored (i.e., calls to MakeNextNeighbor from the current solution (between two calls to Start()). When this limit is reached, MakeNextNeighbor() returns false. The counter is cleared when Start() is called.

def LocalSearchPhase(self, *args):
1997    def LocalSearchPhase(self, *args):
1998        r"""
1999        *Overload 1:*
2000        Local Search decision builders factories.
2001        Local search is used to improve a given solution. This initial solution
2002        can be specified either by an Assignment or by a DecisionBulder, and the
2003        corresponding variables, the initial solution being the first solution
2004        found by the DecisionBuilder.
2005        The LocalSearchPhaseParameters parameter holds the actual definition of
2006        the local search phase:
2007        - a local search operator used to explore the neighborhood of the current
2008          solution,
2009        - a decision builder to instantiate unbound variables once a neighbor has
2010          been defined; in the case of LNS-based operators instantiates fragment
2011          variables; search monitors can be added to this sub-search by wrapping
2012          the decision builder with MakeSolveOnce.
2013        - a search limit specifying how long local search looks for neighbors
2014          before accepting one; the last neighbor is always taken and in the case
2015          of a greedy search, this corresponds to the best local neighbor;
2016          first-accept (which is the default behavior) can be modeled using a
2017          solution found limit of 1,
2018        - a vector of local search filters used to speed up the search by pruning
2019          unfeasible neighbors.
2020        Metaheuristics can be added by defining specialized search monitors;
2021        currently down/up-hill climbing is available through OptimizeVar, as well
2022        as Guided Local Search, Tabu Search and Simulated Annealing.
2023
2024        |
2025
2026        *Overload 2:*
2027        Variant with a sub_decison_builder specific to the first solution.
2028        """
2029        return _pywrapcp.Solver_LocalSearchPhase(self, *args)

Overload 1: Local Search decision builders factories. Local search is used to improve a given solution. This initial solution can be specified either by an Assignment or by a DecisionBulder, and the corresponding variables, the initial solution being the first solution found by the DecisionBuilder. The LocalSearchPhaseParameters parameter holds the actual definition of the local search phase:

  • a local search operator used to explore the neighborhood of the current solution,
  • a decision builder to instantiate unbound variables once a neighbor has been defined; in the case of LNS-based operators instantiates fragment variables; search monitors can be added to this sub-search by wrapping the decision builder with MakeSolveOnce.
  • a search limit specifying how long local search looks for neighbors before accepting one; the last neighbor is always taken and in the case of a greedy search, this corresponds to the best local neighbor; first-accept (which is the default behavior) can be modeled using a solution found limit of 1,
  • a vector of local search filters used to speed up the search by pruning unfeasible neighbors. Metaheuristics can be added by defining specialized search monitors; currently down/up-hill climbing is available through OptimizeVar, as well as Guided Local Search, Tabu Search and Simulated Annealing.

|

Overload 2: Variant with a sub_decison_builder specific to the first solution.

def LocalSearchPhaseParameters(self, *args):
2031    def LocalSearchPhaseParameters(self, *args):
2032        r"""Local Search Phase Parameters"""
2033        return _pywrapcp.Solver_LocalSearchPhaseParameters(self, *args)

Local Search Phase Parameters

def TopProgressPercent(self):
2035    def TopProgressPercent(self):
2036        r"""
2037        Returns a percentage representing the propress of the search before
2038        reaching the limits of the top-level search (can be called from a nested
2039        solve).
2040        """
2041        return _pywrapcp.Solver_TopProgressPercent(self)

Returns a percentage representing the propress of the search before reaching the limits of the top-level search (can be called from a nested solve).

def SearchDepth(self):
2043    def SearchDepth(self):
2044        r"""
2045        Gets the search depth of the current active search. Returns -1 if
2046        there is no active search opened.
2047        """
2048        return _pywrapcp.Solver_SearchDepth(self)

Gets the search depth of the current active search. Returns -1 if there is no active search opened.

def SearchLeftDepth(self):
2050    def SearchLeftDepth(self):
2051        r"""
2052        Gets the search left depth of the current active search. Returns -1 if
2053        there is no active search opened.
2054        """
2055        return _pywrapcp.Solver_SearchLeftDepth(self)

Gets the search left depth of the current active search. Returns -1 if there is no active search opened.

def SolveDepth(self):
2057    def SolveDepth(self):
2058        r"""
2059        Gets the number of nested searches. It returns 0 outside search,
2060        1 during the top level search, 2 or more in case of nested searches.
2061        """
2062        return _pywrapcp.Solver_SolveDepth(self)

Gets the number of nested searches. It returns 0 outside search, 1 during the top level search, 2 or more in case of nested searches.

def Rand64(self, size):
2064    def Rand64(self, size):
2065        r"""Returns a random value between 0 and 'size' - 1;"""
2066        return _pywrapcp.Solver_Rand64(self, size)

Returns a random value between 0 and 'size' - 1;

def Rand32(self, size):
2068    def Rand32(self, size):
2069        r"""Returns a random value between 0 and 'size' - 1;"""
2070        return _pywrapcp.Solver_Rand32(self, size)

Returns a random value between 0 and 'size' - 1;

def ReSeed(self, seed):
2072    def ReSeed(self, seed):
2073        r"""Reseed the solver random generator."""
2074        return _pywrapcp.Solver_ReSeed(self, seed)

Reseed the solver random generator.

def LocalSearchProfile(self):
2076    def LocalSearchProfile(self):
2077        r"""Returns local search profiling information in a human readable format."""
2078        return _pywrapcp.Solver_LocalSearchProfile(self)

Returns local search profiling information in a human readable format.

def Constraints(self):
2080    def Constraints(self):
2081        r"""
2082        Counts the number of constraints that have been added
2083        to the solver before the search.
2084        """
2085        return _pywrapcp.Solver_Constraints(self)

Counts the number of constraints that have been added to the solver before the search.

def Accept(self, visitor):
2087    def Accept(self, visitor):
2088        r"""Accepts the given model visitor."""
2089        return _pywrapcp.Solver_Accept(self, visitor)

Accepts the given model visitor.

def FinishCurrentSearch(self):
2091    def FinishCurrentSearch(self):
2092        r"""Tells the solver to kill or restart the current search."""
2093        return _pywrapcp.Solver_FinishCurrentSearch(self)

Tells the solver to kill or restart the current search.

def RestartCurrentSearch(self):
2095    def RestartCurrentSearch(self):
2096        return _pywrapcp.Solver_RestartCurrentSearch(self)
def ShouldFail(self):
2098    def ShouldFail(self):
2099        r"""
2100        These methods are only useful for the SWIG wrappers, which need a way
2101        to externally cause the Solver to fail.
2102        """
2103        return _pywrapcp.Solver_ShouldFail(self)

These methods are only useful for the SWIG wrappers, which need a way to externally cause the Solver to fail.

def Add(self, ct):
2108    def Add(self, ct):
2109      if isinstance(ct, PyConstraint):
2110        self.__python_constraints.append(ct)
2111      self.AddConstraint(ct)
def TreeNoCycle(self, nexts, active, callback=0):
2114    def TreeNoCycle(self, nexts, active, callback=0):
2115        return _pywrapcp.Solver_TreeNoCycle(self, nexts, active, callback)
def SearchLogWithCallback(self, period, callback):
2117    def SearchLogWithCallback(self, period, callback):
2118        return _pywrapcp.Solver_SearchLogWithCallback(self, period, callback)
def ElementFunction(self, values, index):
2120    def ElementFunction(self, values, index):
2121        return _pywrapcp.Solver_ElementFunction(self, values, index)
def VarEvalValStrPhase(self, vars, var_evaluator, val_str):
2123    def VarEvalValStrPhase(self, vars, var_evaluator, val_str):
2124        return _pywrapcp.Solver_VarEvalValStrPhase(self, vars, var_evaluator, val_str)
def VarStrValEvalPhase(self, vars, var_str, val_eval):
2126    def VarStrValEvalPhase(self, vars, var_str, val_eval):
2127        return _pywrapcp.Solver_VarStrValEvalPhase(self, vars, var_str, val_eval)
def VarEvalValEvalPhase(self, vars, var_eval, val_eval):
2129    def VarEvalValEvalPhase(self, vars, var_eval, val_eval):
2130        return _pywrapcp.Solver_VarEvalValEvalPhase(self, vars, var_eval, val_eval)
def VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker):
2132    def VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker):
2133        return _pywrapcp.Solver_VarStrValEvalTieBreakPhase(self, vars, var_str, val_eval, tie_breaker)
def VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker):
2135    def VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker):
2136        return _pywrapcp.Solver_VarEvalValEvalTieBreakPhase(self, vars, var_eval, val_eval, tie_breaker)
def EvalEvalStrPhase(self, vars, evaluator, str):
2138    def EvalEvalStrPhase(self, vars, evaluator, str):
2139        return _pywrapcp.Solver_EvalEvalStrPhase(self, vars, evaluator, str)
def EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str):
2141    def EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str):
2142        return _pywrapcp.Solver_EvalEvalStrTieBreakPhase(self, vars, evaluator, tie_breaker, str)
def GuidedLocalSearch( self, maximize, objective, objective_function, step, vars, penalty_factor):
2144    def GuidedLocalSearch(self, maximize, objective, objective_function, step, vars, penalty_factor):
2145        return _pywrapcp.Solver_GuidedLocalSearch(self, maximize, objective, objective_function, step, vars, penalty_factor)
def SumObjectiveFilter(self, vars, values, filter_enum):
2147    def SumObjectiveFilter(self, vars, values, filter_enum):
2148        return _pywrapcp.Solver_SumObjectiveFilter(self, vars, values, filter_enum)
class BaseObject:
2152class BaseObject(object):
2153    r"""
2154    A BaseObject is the root of all reversibly allocated objects.
2155    A DebugString method and the associated << operator are implemented
2156    as a convenience.
2157    """
2158
2159    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2160
2161    def __init__(self):
2162        if self.__class__ == BaseObject:
2163            _self = None
2164        else:
2165            _self = self
2166        _pywrapcp.BaseObject_swiginit(self, _pywrapcp.new_BaseObject(_self, ))
2167    __swig_destroy__ = _pywrapcp.delete_BaseObject
2168
2169    def DebugString(self):
2170        return _pywrapcp.BaseObject_DebugString(self)
2171
2172    def __str__(self):
2173        return _pywrapcp.BaseObject___str__(self)
2174
2175    def __repr__(self):
2176        return _pywrapcp.BaseObject___repr__(self)
2177    def __disown__(self):
2178        self.this.disown()
2179        _pywrapcp.disown_BaseObject(self)
2180        return weakref.proxy(self)

A BaseObject is the root of all reversibly allocated objects. A DebugString method and the associated << operator are implemented as a convenience.

thisown
2159    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def DebugString(self):
2169    def DebugString(self):
2170        return _pywrapcp.BaseObject_DebugString(self)
class PropagationBaseObject(BaseObject):
2184class PropagationBaseObject(BaseObject):
2185    r"""
2186    NOLINT
2187    The PropagationBaseObject is a subclass of BaseObject that is also
2188    friend to the Solver class. It allows accessing methods useful when
2189    writing new constraints or new expressions.
2190    """
2191
2192    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2193    __repr__ = _swig_repr
2194
2195    def __init__(self, s):
2196        if self.__class__ == PropagationBaseObject:
2197            _self = None
2198        else:
2199            _self = self
2200        _pywrapcp.PropagationBaseObject_swiginit(self, _pywrapcp.new_PropagationBaseObject(_self, s))
2201    __swig_destroy__ = _pywrapcp.delete_PropagationBaseObject
2202
2203    def DebugString(self):
2204        return _pywrapcp.PropagationBaseObject_DebugString(self)
2205
2206    def solver(self):
2207        return _pywrapcp.PropagationBaseObject_solver(self)
2208
2209    def Name(self):
2210        r"""Object naming."""
2211        return _pywrapcp.PropagationBaseObject_Name(self)
2212    def __disown__(self):
2213        self.this.disown()
2214        _pywrapcp.disown_PropagationBaseObject(self)
2215        return weakref.proxy(self)

NOLINT The PropagationBaseObject is a subclass of BaseObject that is also friend to the Solver class. It allows accessing methods useful when writing new constraints or new expressions.

PropagationBaseObject(s)
2195    def __init__(self, s):
2196        if self.__class__ == PropagationBaseObject:
2197            _self = None
2198        else:
2199            _self = self
2200        _pywrapcp.PropagationBaseObject_swiginit(self, _pywrapcp.new_PropagationBaseObject(_self, s))
thisown
2192    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def DebugString(self):
2203    def DebugString(self):
2204        return _pywrapcp.PropagationBaseObject_DebugString(self)
def solver(self):
2206    def solver(self):
2207        return _pywrapcp.PropagationBaseObject_solver(self)
def Name(self):
2209    def Name(self):
2210        r"""Object naming."""
2211        return _pywrapcp.PropagationBaseObject_Name(self)

Object naming.

class Decision(BaseObject):
2219class Decision(BaseObject):
2220    r"""
2221    A Decision represents a choice point in the search tree. The two main
2222    methods are Apply() to go left, or Refute() to go right.
2223    """
2224
2225    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2226
2227    def __init__(self):
2228        if self.__class__ == Decision:
2229            _self = None
2230        else:
2231            _self = self
2232        _pywrapcp.Decision_swiginit(self, _pywrapcp.new_Decision(_self, ))
2233    __swig_destroy__ = _pywrapcp.delete_Decision
2234
2235    def ApplyWrapper(self, s):
2236        r"""Apply will be called first when the decision is executed."""
2237        return _pywrapcp.Decision_ApplyWrapper(self, s)
2238
2239    def RefuteWrapper(self, s):
2240        r"""Refute will be called after a backtrack."""
2241        return _pywrapcp.Decision_RefuteWrapper(self, s)
2242
2243    def DebugString(self):
2244        return _pywrapcp.Decision_DebugString(self)
2245
2246    def __repr__(self):
2247        return _pywrapcp.Decision___repr__(self)
2248
2249    def __str__(self):
2250        return _pywrapcp.Decision___str__(self)
2251    def __disown__(self):
2252        self.this.disown()
2253        _pywrapcp.disown_Decision(self)
2254        return weakref.proxy(self)

A Decision represents a choice point in the search tree. The two main methods are Apply() to go left, or Refute() to go right.

thisown
2225    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def ApplyWrapper(self, s):
2235    def ApplyWrapper(self, s):
2236        r"""Apply will be called first when the decision is executed."""
2237        return _pywrapcp.Decision_ApplyWrapper(self, s)

Apply will be called first when the decision is executed.

def RefuteWrapper(self, s):
2239    def RefuteWrapper(self, s):
2240        r"""Refute will be called after a backtrack."""
2241        return _pywrapcp.Decision_RefuteWrapper(self, s)

Refute will be called after a backtrack.

def DebugString(self):
2243    def DebugString(self):
2244        return _pywrapcp.Decision_DebugString(self)
class DecisionBuilder(BaseObject):
2258class DecisionBuilder(BaseObject):
2259    r"""
2260    A DecisionBuilder is responsible for creating the search tree. The
2261    important method is Next(), which returns the next decision to execute.
2262    """
2263
2264    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2265
2266    def __init__(self):
2267        if self.__class__ == DecisionBuilder:
2268            _self = None
2269        else:
2270            _self = self
2271        _pywrapcp.DecisionBuilder_swiginit(self, _pywrapcp.new_DecisionBuilder(_self, ))
2272    __swig_destroy__ = _pywrapcp.delete_DecisionBuilder
2273
2274    def NextWrapper(self, s):
2275        r"""
2276        This is the main method of the decision builder class. It must
2277        return a decision (an instance of the class Decision). If it
2278        returns nullptr, this means that the decision builder has finished
2279        its work.
2280        """
2281        return _pywrapcp.DecisionBuilder_NextWrapper(self, s)
2282
2283    def DebugString(self):
2284        return _pywrapcp.DecisionBuilder_DebugString(self)
2285
2286    def __repr__(self):
2287        return _pywrapcp.DecisionBuilder___repr__(self)
2288
2289    def __str__(self):
2290        return _pywrapcp.DecisionBuilder___str__(self)
2291    def __disown__(self):
2292        self.this.disown()
2293        _pywrapcp.disown_DecisionBuilder(self)
2294        return weakref.proxy(self)

A DecisionBuilder is responsible for creating the search tree. The important method is Next(), which returns the next decision to execute.

thisown
2264    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def NextWrapper(self, s):
2274    def NextWrapper(self, s):
2275        r"""
2276        This is the main method of the decision builder class. It must
2277        return a decision (an instance of the class Decision). If it
2278        returns nullptr, this means that the decision builder has finished
2279        its work.
2280        """
2281        return _pywrapcp.DecisionBuilder_NextWrapper(self, s)

This is the main method of the decision builder class. It must return a decision (an instance of the class Decision). If it returns nullptr, this means that the decision builder has finished its work.

def DebugString(self):
2283    def DebugString(self):
2284        return _pywrapcp.DecisionBuilder_DebugString(self)
class Demon(BaseObject):
2298class Demon(BaseObject):
2299    r"""
2300    A Demon is the base element of a propagation queue. It is the main
2301      object responsible for implementing the actual propagation
2302      of the constraint and pruning the inconsistent values in the domains
2303      of the variables. The main concept is that demons are listeners that are
2304      attached to the variables and listen to their modifications.
2305    There are two methods:
2306     - Run() is the actual method called when the demon is processed.
2307     - priority() returns its priority. Standard priorities are slow, normal
2308       or fast. "immediate" is reserved for variables and is treated separately.
2309    """
2310
2311    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2312    __repr__ = _swig_repr
2313
2314    def __init__(self):
2315        r"""
2316        This indicates the priority of a demon. Immediate demons are treated
2317        separately and corresponds to variables.
2318        """
2319        if self.__class__ == Demon:
2320            _self = None
2321        else:
2322            _self = self
2323        _pywrapcp.Demon_swiginit(self, _pywrapcp.new_Demon(_self, ))
2324    __swig_destroy__ = _pywrapcp.delete_Demon
2325
2326    def RunWrapper(self, s):
2327        r"""This is the main callback of the demon."""
2328        return _pywrapcp.Demon_RunWrapper(self, s)
2329
2330    def Priority(self):
2331        r"""
2332        This method returns the priority of the demon. Usually a demon is
2333        fast, slow or normal. Immediate demons are reserved for internal
2334        use to maintain variables.
2335        """
2336        return _pywrapcp.Demon_Priority(self)
2337
2338    def DebugString(self):
2339        return _pywrapcp.Demon_DebugString(self)
2340
2341    def Inhibit(self, s):
2342        r"""
2343        This method inhibits the demon in the search tree below the
2344        current position.
2345        """
2346        return _pywrapcp.Demon_Inhibit(self, s)
2347
2348    def Desinhibit(self, s):
2349        r"""This method un-inhibits the demon that was previously inhibited."""
2350        return _pywrapcp.Demon_Desinhibit(self, s)
2351    def __disown__(self):
2352        self.this.disown()
2353        _pywrapcp.disown_Demon(self)
2354        return weakref.proxy(self)

A Demon is the base element of a propagation queue. It is the main object responsible for implementing the actual propagation of the constraint and pruning the inconsistent values in the domains of the variables. The main concept is that demons are listeners that are attached to the variables and listen to their modifications.

There are two methods:
  • Run() is the actual method called when the demon is processed.
  • priority() returns its priority. Standard priorities are slow, normal or fast. "immediate" is reserved for variables and is treated separately.
Demon()
2314    def __init__(self):
2315        r"""
2316        This indicates the priority of a demon. Immediate demons are treated
2317        separately and corresponds to variables.
2318        """
2319        if self.__class__ == Demon:
2320            _self = None
2321        else:
2322            _self = self
2323        _pywrapcp.Demon_swiginit(self, _pywrapcp.new_Demon(_self, ))

This indicates the priority of a demon. Immediate demons are treated separately and corresponds to variables.

thisown
2311    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def RunWrapper(self, s):
2326    def RunWrapper(self, s):
2327        r"""This is the main callback of the demon."""
2328        return _pywrapcp.Demon_RunWrapper(self, s)

This is the main callback of the demon.

def Priority(self):
2330    def Priority(self):
2331        r"""
2332        This method returns the priority of the demon. Usually a demon is
2333        fast, slow or normal. Immediate demons are reserved for internal
2334        use to maintain variables.
2335        """
2336        return _pywrapcp.Demon_Priority(self)

This method returns the priority of the demon. Usually a demon is fast, slow or normal. Immediate demons are reserved for internal use to maintain variables.

def DebugString(self):
2338    def DebugString(self):
2339        return _pywrapcp.Demon_DebugString(self)
def Inhibit(self, s):
2341    def Inhibit(self, s):
2342        r"""
2343        This method inhibits the demon in the search tree below the
2344        current position.
2345        """
2346        return _pywrapcp.Demon_Inhibit(self, s)

This method inhibits the demon in the search tree below the current position.

def Desinhibit(self, s):
2348    def Desinhibit(self, s):
2349        r"""This method un-inhibits the demon that was previously inhibited."""
2350        return _pywrapcp.Demon_Desinhibit(self, s)

This method un-inhibits the demon that was previously inhibited.

class Constraint(PropagationBaseObject):
2358class Constraint(PropagationBaseObject):
2359    r"""
2360    A constraint is the main modeling object. It provides two methods:
2361      - Post() is responsible for creating the demons and attaching them to
2362        immediate demons().
2363      - InitialPropagate() is called once just after Post and performs
2364        the initial propagation. The subsequent propagations will be performed
2365        by the demons Posted during the post() method.
2366    """
2367
2368    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2369
2370    def __init__(self, solver):
2371        if self.__class__ == Constraint:
2372            _self = None
2373        else:
2374            _self = self
2375        _pywrapcp.Constraint_swiginit(self, _pywrapcp.new_Constraint(_self, solver))
2376    __swig_destroy__ = _pywrapcp.delete_Constraint
2377
2378    def Post(self):
2379        r"""
2380        This method is called when the constraint is processed by the
2381        solver. Its main usage is to attach demons to variables.
2382        """
2383        return _pywrapcp.Constraint_Post(self)
2384
2385    def InitialPropagateWrapper(self):
2386        r"""
2387        This method performs the initial propagation of the
2388        constraint. It is called just after the post.
2389        """
2390        return _pywrapcp.Constraint_InitialPropagateWrapper(self)
2391
2392    def DebugString(self):
2393        return _pywrapcp.Constraint_DebugString(self)
2394
2395    def Var(self):
2396        r"""
2397        Creates a Boolean variable representing the status of the constraint
2398        (false = constraint is violated, true = constraint is satisfied). It
2399        returns nullptr if the constraint does not support this API.
2400        """
2401        return _pywrapcp.Constraint_Var(self)
2402
2403    def __repr__(self):
2404        return _pywrapcp.Constraint___repr__(self)
2405
2406    def __str__(self):
2407        return _pywrapcp.Constraint___str__(self)
2408
2409    def __add__(self, *args):
2410        return _pywrapcp.Constraint___add__(self, *args)
2411
2412    def __radd__(self, v):
2413        return _pywrapcp.Constraint___radd__(self, v)
2414
2415    def __sub__(self, *args):
2416        return _pywrapcp.Constraint___sub__(self, *args)
2417
2418    def __rsub__(self, v):
2419        return _pywrapcp.Constraint___rsub__(self, v)
2420
2421    def __mul__(self, *args):
2422        return _pywrapcp.Constraint___mul__(self, *args)
2423
2424    def __rmul__(self, v):
2425        return _pywrapcp.Constraint___rmul__(self, v)
2426
2427    def __floordiv__(self, v):
2428        return _pywrapcp.Constraint___floordiv__(self, v)
2429
2430    def __neg__(self):
2431        return _pywrapcp.Constraint___neg__(self)
2432
2433    def __abs__(self):
2434        return _pywrapcp.Constraint___abs__(self)
2435
2436    def Square(self):
2437        return _pywrapcp.Constraint_Square(self)
2438
2439    def __eq__(self, *args):
2440        return _pywrapcp.Constraint___eq__(self, *args)
2441
2442    def __ne__(self, *args):
2443        return _pywrapcp.Constraint___ne__(self, *args)
2444
2445    def __ge__(self, *args):
2446        return _pywrapcp.Constraint___ge__(self, *args)
2447
2448    def __gt__(self, *args):
2449        return _pywrapcp.Constraint___gt__(self, *args)
2450
2451    def __le__(self, *args):
2452        return _pywrapcp.Constraint___le__(self, *args)
2453
2454    def __lt__(self, *args):
2455        return _pywrapcp.Constraint___lt__(self, *args)
2456
2457    def MapTo(self, vars):
2458        return _pywrapcp.Constraint_MapTo(self, vars)
2459
2460    def IndexOf(self, *args):
2461        return _pywrapcp.Constraint_IndexOf(self, *args)
2462    def __disown__(self):
2463        self.this.disown()
2464        _pywrapcp.disown_Constraint(self)
2465        return weakref.proxy(self)

A constraint is the main modeling object. It provides two methods:

  • Post() is responsible for creating the demons and attaching them to immediate demons().
  • InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
Constraint(solver)
2370    def __init__(self, solver):
2371        if self.__class__ == Constraint:
2372            _self = None
2373        else:
2374            _self = self
2375        _pywrapcp.Constraint_swiginit(self, _pywrapcp.new_Constraint(_self, solver))
thisown
2368    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Post(self):
2378    def Post(self):
2379        r"""
2380        This method is called when the constraint is processed by the
2381        solver. Its main usage is to attach demons to variables.
2382        """
2383        return _pywrapcp.Constraint_Post(self)

This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.

def InitialPropagateWrapper(self):
2385    def InitialPropagateWrapper(self):
2386        r"""
2387        This method performs the initial propagation of the
2388        constraint. It is called just after the post.
2389        """
2390        return _pywrapcp.Constraint_InitialPropagateWrapper(self)

This method performs the initial propagation of the constraint. It is called just after the post.

def DebugString(self):
2392    def DebugString(self):
2393        return _pywrapcp.Constraint_DebugString(self)
def Var(self):
2395    def Var(self):
2396        r"""
2397        Creates a Boolean variable representing the status of the constraint
2398        (false = constraint is violated, true = constraint is satisfied). It
2399        returns nullptr if the constraint does not support this API.
2400        """
2401        return _pywrapcp.Constraint_Var(self)

Creates a Boolean variable representing the status of the constraint (false = constraint is violated, true = constraint is satisfied). It returns nullptr if the constraint does not support this API.

def Square(self):
2436    def Square(self):
2437        return _pywrapcp.Constraint_Square(self)
def MapTo(self, vars):
2457    def MapTo(self, vars):
2458        return _pywrapcp.Constraint_MapTo(self, vars)
def IndexOf(self, *args):
2460    def IndexOf(self, *args):
2461        return _pywrapcp.Constraint_IndexOf(self, *args)
Inherited Members
PropagationBaseObject
solver
Name
class SearchMonitor(BaseObject):
2469class SearchMonitor(BaseObject):
2470    r"""A search monitor is a simple set of callbacks to monitor all search events"""
2471
2472    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2473    kNoProgress = _pywrapcp.SearchMonitor_kNoProgress
2474
2475    def __init__(self, s):
2476        if self.__class__ == SearchMonitor:
2477            _self = None
2478        else:
2479            _self = self
2480        _pywrapcp.SearchMonitor_swiginit(self, _pywrapcp.new_SearchMonitor(_self, s))
2481    __swig_destroy__ = _pywrapcp.delete_SearchMonitor
2482
2483    def EnterSearch(self):
2484        r"""Beginning of the search."""
2485        return _pywrapcp.SearchMonitor_EnterSearch(self)
2486
2487    def RestartSearch(self):
2488        r"""Restart the search."""
2489        return _pywrapcp.SearchMonitor_RestartSearch(self)
2490
2491    def ExitSearch(self):
2492        r"""End of the search."""
2493        return _pywrapcp.SearchMonitor_ExitSearch(self)
2494
2495    def BeginNextDecision(self, b):
2496        r"""Before calling DecisionBuilder::Next."""
2497        return _pywrapcp.SearchMonitor_BeginNextDecision(self, b)
2498
2499    def EndNextDecision(self, b, d):
2500        r"""After calling DecisionBuilder::Next, along with the returned decision."""
2501        return _pywrapcp.SearchMonitor_EndNextDecision(self, b, d)
2502
2503    def ApplyDecision(self, d):
2504        r"""Before applying the decision."""
2505        return _pywrapcp.SearchMonitor_ApplyDecision(self, d)
2506
2507    def RefuteDecision(self, d):
2508        r"""Before refuting the decision."""
2509        return _pywrapcp.SearchMonitor_RefuteDecision(self, d)
2510
2511    def AfterDecision(self, d, apply):
2512        r"""
2513        Just after refuting or applying the decision, apply is true after Apply.
2514        This is called only if the Apply() or Refute() methods have not failed.
2515        """
2516        return _pywrapcp.SearchMonitor_AfterDecision(self, d, apply)
2517
2518    def BeginFail(self):
2519        r"""Just when the failure occurs."""
2520        return _pywrapcp.SearchMonitor_BeginFail(self)
2521
2522    def EndFail(self):
2523        r"""After completing the backtrack."""
2524        return _pywrapcp.SearchMonitor_EndFail(self)
2525
2526    def BeginInitialPropagation(self):
2527        r"""Before the initial propagation."""
2528        return _pywrapcp.SearchMonitor_BeginInitialPropagation(self)
2529
2530    def EndInitialPropagation(self):
2531        r"""After the initial propagation."""
2532        return _pywrapcp.SearchMonitor_EndInitialPropagation(self)
2533
2534    def AcceptSolution(self):
2535        r"""
2536        This method is called when a solution is found. It asserts whether the
2537        solution is valid. A value of false indicates that the solution
2538        should be discarded.
2539        """
2540        return _pywrapcp.SearchMonitor_AcceptSolution(self)
2541
2542    def AtSolution(self):
2543        r"""
2544        This method is called when a valid solution is found. If the
2545        return value is true, then search will resume after. If the result
2546        is false, then search will stop there.
2547        """
2548        return _pywrapcp.SearchMonitor_AtSolution(self)
2549
2550    def NoMoreSolutions(self):
2551        r"""When the search tree is finished."""
2552        return _pywrapcp.SearchMonitor_NoMoreSolutions(self)
2553
2554    def LocalOptimum(self):
2555        r"""
2556        When a local optimum is reached. If 'true' is returned, the last solution
2557        is discarded and the search proceeds with the next one.
2558        """
2559        return _pywrapcp.SearchMonitor_LocalOptimum(self)
2560
2561    def AcceptDelta(self, delta, deltadelta):
2562        
2563        return _pywrapcp.SearchMonitor_AcceptDelta(self, delta, deltadelta)
2564
2565    def AcceptNeighbor(self):
2566        r"""After accepting a neighbor during local search."""
2567        return _pywrapcp.SearchMonitor_AcceptNeighbor(self)
2568
2569    def ProgressPercent(self):
2570        r"""
2571        Returns a percentage representing the propress of the search before
2572        reaching limits.
2573        """
2574        return _pywrapcp.SearchMonitor_ProgressPercent(self)
2575
2576    def solver(self):
2577        return _pywrapcp.SearchMonitor_solver(self)
2578
2579    def __repr__(self):
2580        return _pywrapcp.SearchMonitor___repr__(self)
2581
2582    def __str__(self):
2583        return _pywrapcp.SearchMonitor___str__(self)
2584    def __disown__(self):
2585        self.this.disown()
2586        _pywrapcp.disown_SearchMonitor(self)
2587        return weakref.proxy(self)

A search monitor is a simple set of callbacks to monitor all search events

SearchMonitor(s)
2475    def __init__(self, s):
2476        if self.__class__ == SearchMonitor:
2477            _self = None
2478        else:
2479            _self = self
2480        _pywrapcp.SearchMonitor_swiginit(self, _pywrapcp.new_SearchMonitor(_self, s))
thisown
2472    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

kNoProgress = -1
def EnterSearch(self):
2483    def EnterSearch(self):
2484        r"""Beginning of the search."""
2485        return _pywrapcp.SearchMonitor_EnterSearch(self)

Beginning of the search.

def RestartSearch(self):
2487    def RestartSearch(self):
2488        r"""Restart the search."""
2489        return _pywrapcp.SearchMonitor_RestartSearch(self)

Restart the search.

def ExitSearch(self):
2491    def ExitSearch(self):
2492        r"""End of the search."""
2493        return _pywrapcp.SearchMonitor_ExitSearch(self)

End of the search.

def BeginNextDecision(self, b):
2495    def BeginNextDecision(self, b):
2496        r"""Before calling DecisionBuilder::Next."""
2497        return _pywrapcp.SearchMonitor_BeginNextDecision(self, b)

Before calling DecisionBuilder::Next.

def EndNextDecision(self, b, d):
2499    def EndNextDecision(self, b, d):
2500        r"""After calling DecisionBuilder::Next, along with the returned decision."""
2501        return _pywrapcp.SearchMonitor_EndNextDecision(self, b, d)

After calling DecisionBuilder::Next, along with the returned decision.

def ApplyDecision(self, d):
2503    def ApplyDecision(self, d):
2504        r"""Before applying the decision."""
2505        return _pywrapcp.SearchMonitor_ApplyDecision(self, d)

Before applying the decision.

def RefuteDecision(self, d):
2507    def RefuteDecision(self, d):
2508        r"""Before refuting the decision."""
2509        return _pywrapcp.SearchMonitor_RefuteDecision(self, d)

Before refuting the decision.

def AfterDecision(self, d, apply):
2511    def AfterDecision(self, d, apply):
2512        r"""
2513        Just after refuting or applying the decision, apply is true after Apply.
2514        This is called only if the Apply() or Refute() methods have not failed.
2515        """
2516        return _pywrapcp.SearchMonitor_AfterDecision(self, d, apply)

Just after refuting or applying the decision, apply is true after Apply. This is called only if the Apply() or Refute() methods have not failed.

def BeginFail(self):
2518    def BeginFail(self):
2519        r"""Just when the failure occurs."""
2520        return _pywrapcp.SearchMonitor_BeginFail(self)

Just when the failure occurs.

def EndFail(self):
2522    def EndFail(self):
2523        r"""After completing the backtrack."""
2524        return _pywrapcp.SearchMonitor_EndFail(self)

After completing the backtrack.

def BeginInitialPropagation(self):
2526    def BeginInitialPropagation(self):
2527        r"""Before the initial propagation."""
2528        return _pywrapcp.SearchMonitor_BeginInitialPropagation(self)

Before the initial propagation.

def EndInitialPropagation(self):
2530    def EndInitialPropagation(self):
2531        r"""After the initial propagation."""
2532        return _pywrapcp.SearchMonitor_EndInitialPropagation(self)

After the initial propagation.

def AcceptSolution(self):
2534    def AcceptSolution(self):
2535        r"""
2536        This method is called when a solution is found. It asserts whether the
2537        solution is valid. A value of false indicates that the solution
2538        should be discarded.
2539        """
2540        return _pywrapcp.SearchMonitor_AcceptSolution(self)

This method is called when a solution is found. It asserts whether the solution is valid. A value of false indicates that the solution should be discarded.

def AtSolution(self):
2542    def AtSolution(self):
2543        r"""
2544        This method is called when a valid solution is found. If the
2545        return value is true, then search will resume after. If the result
2546        is false, then search will stop there.
2547        """
2548        return _pywrapcp.SearchMonitor_AtSolution(self)

This method is called when a valid solution is found. If the return value is true, then search will resume after. If the result is false, then search will stop there.

def NoMoreSolutions(self):
2550    def NoMoreSolutions(self):
2551        r"""When the search tree is finished."""
2552        return _pywrapcp.SearchMonitor_NoMoreSolutions(self)

When the search tree is finished.

def LocalOptimum(self):
2554    def LocalOptimum(self):
2555        r"""
2556        When a local optimum is reached. If 'true' is returned, the last solution
2557        is discarded and the search proceeds with the next one.
2558        """
2559        return _pywrapcp.SearchMonitor_LocalOptimum(self)

When a local optimum is reached. If 'true' is returned, the last solution is discarded and the search proceeds with the next one.

def AcceptDelta(self, delta, deltadelta):
2561    def AcceptDelta(self, delta, deltadelta):
2562        
2563        return _pywrapcp.SearchMonitor_AcceptDelta(self, delta, deltadelta)
def AcceptNeighbor(self):
2565    def AcceptNeighbor(self):
2566        r"""After accepting a neighbor during local search."""
2567        return _pywrapcp.SearchMonitor_AcceptNeighbor(self)

After accepting a neighbor during local search.

def ProgressPercent(self):
2569    def ProgressPercent(self):
2570        r"""
2571        Returns a percentage representing the propress of the search before
2572        reaching limits.
2573        """
2574        return _pywrapcp.SearchMonitor_ProgressPercent(self)

Returns a percentage representing the propress of the search before reaching limits.

def solver(self):
2576    def solver(self):
2577        return _pywrapcp.SearchMonitor_solver(self)
Inherited Members
BaseObject
DebugString
class IntExpr(PropagationBaseObject):
2591class IntExpr(PropagationBaseObject):
2592    r"""
2593    The class IntExpr is the base of all integer expressions in
2594    constraint programming.
2595    It contains the basic protocol for an expression:
2596      - setting and modifying its bound
2597      - querying if it is bound
2598      - listening to events modifying its bounds
2599      - casting it into a variable (instance of IntVar)
2600    """
2601
2602    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2603
2604    def __init__(self, *args, **kwargs):
2605        raise AttributeError("No constructor defined - class is abstract")
2606
2607    def Min(self):
2608        return _pywrapcp.IntExpr_Min(self)
2609
2610    def SetMin(self, m):
2611        return _pywrapcp.IntExpr_SetMin(self, m)
2612
2613    def Max(self):
2614        return _pywrapcp.IntExpr_Max(self)
2615
2616    def SetMax(self, m):
2617        return _pywrapcp.IntExpr_SetMax(self, m)
2618
2619    def SetRange(self, l, u):
2620        r"""This method sets both the min and the max of the expression."""
2621        return _pywrapcp.IntExpr_SetRange(self, l, u)
2622
2623    def SetValue(self, v):
2624        r"""This method sets the value of the expression."""
2625        return _pywrapcp.IntExpr_SetValue(self, v)
2626
2627    def Bound(self):
2628        r"""Returns true if the min and the max of the expression are equal."""
2629        return _pywrapcp.IntExpr_Bound(self)
2630
2631    def IsVar(self):
2632        r"""Returns true if the expression is indeed a variable."""
2633        return _pywrapcp.IntExpr_IsVar(self)
2634
2635    def Var(self):
2636        r"""Creates a variable from the expression."""
2637        return _pywrapcp.IntExpr_Var(self)
2638
2639    def VarWithName(self, name):
2640        r"""
2641        Creates a variable from the expression and set the name of the
2642        resulting var. If the expression is already a variable, then it
2643        will set the name of the expression, possibly overwriting it.
2644        This is just a shortcut to Var() followed by set_name().
2645        """
2646        return _pywrapcp.IntExpr_VarWithName(self, name)
2647
2648    def WhenRange(self, *args):
2649        r"""
2650        *Overload 1:*
2651        Attach a demon that will watch the min or the max of the expression.
2652
2653        |
2654
2655        *Overload 2:*
2656        Attach a demon that will watch the min or the max of the expression.
2657        """
2658        return _pywrapcp.IntExpr_WhenRange(self, *args)
2659
2660    def __repr__(self):
2661        return _pywrapcp.IntExpr___repr__(self)
2662
2663    def __str__(self):
2664        return _pywrapcp.IntExpr___str__(self)
2665
2666    def __add__(self, *args):
2667        return _pywrapcp.IntExpr___add__(self, *args)
2668
2669    def __radd__(self, v):
2670        return _pywrapcp.IntExpr___radd__(self, v)
2671
2672    def __sub__(self, *args):
2673        return _pywrapcp.IntExpr___sub__(self, *args)
2674
2675    def __rsub__(self, v):
2676        return _pywrapcp.IntExpr___rsub__(self, v)
2677
2678    def __mul__(self, *args):
2679        return _pywrapcp.IntExpr___mul__(self, *args)
2680
2681    def __rmul__(self, v):
2682        return _pywrapcp.IntExpr___rmul__(self, v)
2683
2684    def __floordiv__(self, *args):
2685        return _pywrapcp.IntExpr___floordiv__(self, *args)
2686
2687    def __mod__(self, *args):
2688        return _pywrapcp.IntExpr___mod__(self, *args)
2689
2690    def __neg__(self):
2691        return _pywrapcp.IntExpr___neg__(self)
2692
2693    def __abs__(self):
2694        return _pywrapcp.IntExpr___abs__(self)
2695
2696    def Square(self):
2697        return _pywrapcp.IntExpr_Square(self)
2698
2699    def __eq__(self, *args):
2700        return _pywrapcp.IntExpr___eq__(self, *args)
2701
2702    def __ne__(self, *args):
2703        return _pywrapcp.IntExpr___ne__(self, *args)
2704
2705    def __ge__(self, *args):
2706        return _pywrapcp.IntExpr___ge__(self, *args)
2707
2708    def __gt__(self, *args):
2709        return _pywrapcp.IntExpr___gt__(self, *args)
2710
2711    def __le__(self, *args):
2712        return _pywrapcp.IntExpr___le__(self, *args)
2713
2714    def __lt__(self, *args):
2715        return _pywrapcp.IntExpr___lt__(self, *args)
2716
2717    def MapTo(self, vars):
2718        return _pywrapcp.IntExpr_MapTo(self, vars)
2719
2720    def IndexOf(self, *args):
2721        return _pywrapcp.IntExpr_IndexOf(self, *args)
2722
2723    def IsMember(self, values):
2724        return _pywrapcp.IntExpr_IsMember(self, values)
2725
2726    def Member(self, values):
2727        return _pywrapcp.IntExpr_Member(self, values)
2728
2729    def NotMember(self, starts, ends):
2730        return _pywrapcp.IntExpr_NotMember(self, starts, ends)

The class IntExpr is the base of all integer expressions in constraint programming.

It contains the basic protocol for an expression:
  • setting and modifying its bound
  • querying if it is bound
  • listening to events modifying its bounds
  • casting it into a variable (instance of IntVar)
IntExpr(*args, **kwargs)
2604    def __init__(self, *args, **kwargs):
2605        raise AttributeError("No constructor defined - class is abstract")
thisown
2602    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Min(self):
2607    def Min(self):
2608        return _pywrapcp.IntExpr_Min(self)
def SetMin(self, m):
2610    def SetMin(self, m):
2611        return _pywrapcp.IntExpr_SetMin(self, m)
def Max(self):
2613    def Max(self):
2614        return _pywrapcp.IntExpr_Max(self)
def SetMax(self, m):
2616    def SetMax(self, m):
2617        return _pywrapcp.IntExpr_SetMax(self, m)
def SetRange(self, l, u):
2619    def SetRange(self, l, u):
2620        r"""This method sets both the min and the max of the expression."""
2621        return _pywrapcp.IntExpr_SetRange(self, l, u)

This method sets both the min and the max of the expression.

def SetValue(self, v):
2623    def SetValue(self, v):
2624        r"""This method sets the value of the expression."""
2625        return _pywrapcp.IntExpr_SetValue(self, v)

This method sets the value of the expression.

def Bound(self):
2627    def Bound(self):
2628        r"""Returns true if the min and the max of the expression are equal."""
2629        return _pywrapcp.IntExpr_Bound(self)

Returns true if the min and the max of the expression are equal.

def IsVar(self):
2631    def IsVar(self):
2632        r"""Returns true if the expression is indeed a variable."""
2633        return _pywrapcp.IntExpr_IsVar(self)

Returns true if the expression is indeed a variable.

def Var(self):
2635    def Var(self):
2636        r"""Creates a variable from the expression."""
2637        return _pywrapcp.IntExpr_Var(self)

Creates a variable from the expression.

def VarWithName(self, name):
2639    def VarWithName(self, name):
2640        r"""
2641        Creates a variable from the expression and set the name of the
2642        resulting var. If the expression is already a variable, then it
2643        will set the name of the expression, possibly overwriting it.
2644        This is just a shortcut to Var() followed by set_name().
2645        """
2646        return _pywrapcp.IntExpr_VarWithName(self, name)

Creates a variable from the expression and set the name of the resulting var. If the expression is already a variable, then it will set the name of the expression, possibly overwriting it. This is just a shortcut to Var() followed by set_name().

def WhenRange(self, *args):
2648    def WhenRange(self, *args):
2649        r"""
2650        *Overload 1:*
2651        Attach a demon that will watch the min or the max of the expression.
2652
2653        |
2654
2655        *Overload 2:*
2656        Attach a demon that will watch the min or the max of the expression.
2657        """
2658        return _pywrapcp.IntExpr_WhenRange(self, *args)

Overload 1: Attach a demon that will watch the min or the max of the expression.

|

Overload 2: Attach a demon that will watch the min or the max of the expression.

def Square(self):
2696    def Square(self):
2697        return _pywrapcp.IntExpr_Square(self)
def MapTo(self, vars):
2717    def MapTo(self, vars):
2718        return _pywrapcp.IntExpr_MapTo(self, vars)
def IndexOf(self, *args):
2720    def IndexOf(self, *args):
2721        return _pywrapcp.IntExpr_IndexOf(self, *args)
def IsMember(self, values):
2723    def IsMember(self, values):
2724        return _pywrapcp.IntExpr_IsMember(self, values)
def Member(self, values):
2726    def Member(self, values):
2727        return _pywrapcp.IntExpr_Member(self, values)
def NotMember(self, starts, ends):
2729    def NotMember(self, starts, ends):
2730        return _pywrapcp.IntExpr_NotMember(self, starts, ends)
class IntVarIterator(BaseObject):
2734class IntVarIterator(BaseObject):
2735    r"""
2736     The class Iterator has two direct subclasses. HoleIterators
2737     iterates over all holes, that is value removed between the
2738     current min and max of the variable since the last time the
2739     variable was processed in the queue. DomainIterators iterates
2740     over all elements of the variable domain. Both iterators are not
2741     robust to domain changes. Hole iterators can also report values outside
2742     the current min and max of the variable.
2743     HoleIterators should only be called from a demon attached to the
2744     variable that has created this iterator.
2745     IntVar* current_var;
2746     std::unique_ptr<IntVarIterator> it(current_var->MakeHoleIterator(false));
2747     for (const int64_t hole : InitAndGetValues(it)) {
2748    use the hole
2749     }
2750    """
2751
2752    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2753
2754    def __init__(self, *args, **kwargs):
2755        raise AttributeError("No constructor defined - class is abstract")
2756    __repr__ = _swig_repr
2757
2758    def Init(self):
2759        r"""This method must be called before each loop."""
2760        return _pywrapcp.IntVarIterator_Init(self)
2761
2762    def Ok(self):
2763        r"""This method indicates if we can call Value() or not."""
2764        return _pywrapcp.IntVarIterator_Ok(self)
2765
2766    def Value(self):
2767        r"""This method returns the current value of the iterator."""
2768        return _pywrapcp.IntVarIterator_Value(self)
2769
2770    def Next(self):
2771        r"""This method moves the iterator to the next value."""
2772        return _pywrapcp.IntVarIterator_Next(self)
2773
2774    def DebugString(self):
2775        r"""Pretty Print."""
2776        return _pywrapcp.IntVarIterator_DebugString(self)
2777
2778    def __iter__(self):
2779      self.Init()
2780      return self
2781
2782    def next(self):
2783      if self.Ok():
2784        result = self.Value()
2785        self.Next()
2786        return result
2787      else:
2788        raise StopIteration()
2789
2790    def __next__(self):
2791      return self.next()

The class Iterator has two direct subclasses. HoleIterators iterates over all holes, that is value removed between the current min and max of the variable since the last time the variable was processed in the queue. DomainIterators iterates over all elements of the variable domain. Both iterators are not robust to domain changes. Hole iterators can also report values outside the current min and max of the variable. HoleIterators should only be called from a demon attached to the variable that has created this iterator. IntVar* current_var; std::unique_ptr it(current_var->MakeHoleIterator(false)); for (const int64_t hole : InitAndGetValues(it)) { use the hole }

IntVarIterator(*args, **kwargs)
2754    def __init__(self, *args, **kwargs):
2755        raise AttributeError("No constructor defined - class is abstract")
thisown
2752    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Init(self):
2758    def Init(self):
2759        r"""This method must be called before each loop."""
2760        return _pywrapcp.IntVarIterator_Init(self)

This method must be called before each loop.

def Ok(self):
2762    def Ok(self):
2763        r"""This method indicates if we can call Value() or not."""
2764        return _pywrapcp.IntVarIterator_Ok(self)

This method indicates if we can call Value() or not.

def Value(self):
2766    def Value(self):
2767        r"""This method returns the current value of the iterator."""
2768        return _pywrapcp.IntVarIterator_Value(self)

This method returns the current value of the iterator.

def Next(self):
2770    def Next(self):
2771        r"""This method moves the iterator to the next value."""
2772        return _pywrapcp.IntVarIterator_Next(self)

This method moves the iterator to the next value.

def DebugString(self):
2774    def DebugString(self):
2775        r"""Pretty Print."""
2776        return _pywrapcp.IntVarIterator_DebugString(self)

Pretty Print.

def next(self):
2782    def next(self):
2783      if self.Ok():
2784        result = self.Value()
2785        self.Next()
2786        return result
2787      else:
2788        raise StopIteration()
class IntVar(IntExpr):
2796class IntVar(IntExpr):
2797    r"""
2798    The class IntVar is a subset of IntExpr. In addition to the
2799    IntExpr protocol, it offers persistence, removing values from the domains,
2800    and a finer model for events.
2801    """
2802
2803    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2804
2805    def __init__(self, *args, **kwargs):
2806        raise AttributeError("No constructor defined - class is abstract")
2807
2808    def IsVar(self):
2809        return _pywrapcp.IntVar_IsVar(self)
2810
2811    def Var(self):
2812        return _pywrapcp.IntVar_Var(self)
2813
2814    def Value(self):
2815        r"""
2816        This method returns the value of the variable. This method checks
2817        before that the variable is bound.
2818        """
2819        return _pywrapcp.IntVar_Value(self)
2820
2821    def RemoveValue(self, v):
2822        r"""This method removes the value 'v' from the domain of the variable."""
2823        return _pywrapcp.IntVar_RemoveValue(self, v)
2824
2825    def RemoveInterval(self, l, u):
2826        r"""
2827        This method removes the interval 'l' .. 'u' from the domain of
2828        the variable. It assumes that 'l' <= 'u'.
2829        """
2830        return _pywrapcp.IntVar_RemoveInterval(self, l, u)
2831
2832    def RemoveValues(self, values):
2833        r"""This method remove the values from the domain of the variable."""
2834        return _pywrapcp.IntVar_RemoveValues(self, values)
2835
2836    def SetValues(self, values):
2837        r"""This method intersects the current domain with the values in the array."""
2838        return _pywrapcp.IntVar_SetValues(self, values)
2839
2840    def WhenBound(self, *args):
2841        r"""
2842        *Overload 1:*
2843        This method attaches a demon that will be awakened when the
2844        variable is bound.
2845
2846        |
2847
2848        *Overload 2:*
2849        This method attaches a closure that will be awakened when the
2850        variable is bound.
2851        """
2852        return _pywrapcp.IntVar_WhenBound(self, *args)
2853
2854    def WhenDomain(self, *args):
2855        r"""
2856        *Overload 1:*
2857        This method attaches a demon that will watch any domain
2858        modification of the domain of the variable.
2859
2860        |
2861
2862        *Overload 2:*
2863        This method attaches a closure that will watch any domain
2864        modification of the domain of the variable.
2865        """
2866        return _pywrapcp.IntVar_WhenDomain(self, *args)
2867
2868    def Size(self):
2869        r"""This method returns the number of values in the domain of the variable."""
2870        return _pywrapcp.IntVar_Size(self)
2871
2872    def Contains(self, v):
2873        r"""
2874        This method returns whether the value 'v' is in the domain of the
2875        variable.
2876        """
2877        return _pywrapcp.IntVar_Contains(self, v)
2878
2879    def HoleIteratorAux(self, reversible):
2880        r"""
2881        Creates a hole iterator. When 'reversible' is false, the returned
2882        object is created on the normal C++ heap and the solver does NOT
2883        take ownership of the object.
2884        """
2885        return _pywrapcp.IntVar_HoleIteratorAux(self, reversible)
2886
2887    def DomainIteratorAux(self, reversible):
2888        r"""
2889        Creates a domain iterator. When 'reversible' is false, the
2890        returned object is created on the normal C++ heap and the solver
2891        does NOT take ownership of the object.
2892        """
2893        return _pywrapcp.IntVar_DomainIteratorAux(self, reversible)
2894
2895    def OldMin(self):
2896        r"""Returns the previous min."""
2897        return _pywrapcp.IntVar_OldMin(self)
2898
2899    def OldMax(self):
2900        r"""Returns the previous max."""
2901        return _pywrapcp.IntVar_OldMax(self)
2902
2903    def __repr__(self):
2904        return _pywrapcp.IntVar___repr__(self)
2905
2906    def __str__(self):
2907        return _pywrapcp.IntVar___str__(self)
2908
2909    def DomainIterator(self):
2910      return iter(self.DomainIteratorAux(False))
2911
2912    def HoleIterator(self):
2913      return iter(self.HoleIteratorAux(False))

The class IntVar is a subset of IntExpr. In addition to the IntExpr protocol, it offers persistence, removing values from the domains, and a finer model for events.

IntVar(*args, **kwargs)
2805    def __init__(self, *args, **kwargs):
2806        raise AttributeError("No constructor defined - class is abstract")
thisown
2803    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def IsVar(self):
2808    def IsVar(self):
2809        return _pywrapcp.IntVar_IsVar(self)

Returns true if the expression is indeed a variable.

def Var(self):
2811    def Var(self):
2812        return _pywrapcp.IntVar_Var(self)

Creates a variable from the expression.

def Value(self):
2814    def Value(self):
2815        r"""
2816        This method returns the value of the variable. This method checks
2817        before that the variable is bound.
2818        """
2819        return _pywrapcp.IntVar_Value(self)

This method returns the value of the variable. This method checks before that the variable is bound.

def RemoveValue(self, v):
2821    def RemoveValue(self, v):
2822        r"""This method removes the value 'v' from the domain of the variable."""
2823        return _pywrapcp.IntVar_RemoveValue(self, v)

This method removes the value 'v' from the domain of the variable.

def RemoveInterval(self, l, u):
2825    def RemoveInterval(self, l, u):
2826        r"""
2827        This method removes the interval 'l' .. 'u' from the domain of
2828        the variable. It assumes that 'l' <= 'u'.
2829        """
2830        return _pywrapcp.IntVar_RemoveInterval(self, l, u)

This method removes the interval 'l' .. 'u' from the domain of the variable. It assumes that 'l' <= 'u'.

def RemoveValues(self, values):
2832    def RemoveValues(self, values):
2833        r"""This method remove the values from the domain of the variable."""
2834        return _pywrapcp.IntVar_RemoveValues(self, values)

This method remove the values from the domain of the variable.

def SetValues(self, values):
2836    def SetValues(self, values):
2837        r"""This method intersects the current domain with the values in the array."""
2838        return _pywrapcp.IntVar_SetValues(self, values)

This method intersects the current domain with the values in the array.

def WhenBound(self, *args):
2840    def WhenBound(self, *args):
2841        r"""
2842        *Overload 1:*
2843        This method attaches a demon that will be awakened when the
2844        variable is bound.
2845
2846        |
2847
2848        *Overload 2:*
2849        This method attaches a closure that will be awakened when the
2850        variable is bound.
2851        """
2852        return _pywrapcp.IntVar_WhenBound(self, *args)

Overload 1: This method attaches a demon that will be awakened when the variable is bound.

|

Overload 2: This method attaches a closure that will be awakened when the variable is bound.

def WhenDomain(self, *args):
2854    def WhenDomain(self, *args):
2855        r"""
2856        *Overload 1:*
2857        This method attaches a demon that will watch any domain
2858        modification of the domain of the variable.
2859
2860        |
2861
2862        *Overload 2:*
2863        This method attaches a closure that will watch any domain
2864        modification of the domain of the variable.
2865        """
2866        return _pywrapcp.IntVar_WhenDomain(self, *args)

Overload 1: This method attaches a demon that will watch any domain modification of the domain of the variable.

|

Overload 2: This method attaches a closure that will watch any domain modification of the domain of the variable.

def Size(self):
2868    def Size(self):
2869        r"""This method returns the number of values in the domain of the variable."""
2870        return _pywrapcp.IntVar_Size(self)

This method returns the number of values in the domain of the variable.

def Contains(self, v):
2872    def Contains(self, v):
2873        r"""
2874        This method returns whether the value 'v' is in the domain of the
2875        variable.
2876        """
2877        return _pywrapcp.IntVar_Contains(self, v)

This method returns whether the value 'v' is in the domain of the variable.

def HoleIteratorAux(self, reversible):
2879    def HoleIteratorAux(self, reversible):
2880        r"""
2881        Creates a hole iterator. When 'reversible' is false, the returned
2882        object is created on the normal C++ heap and the solver does NOT
2883        take ownership of the object.
2884        """
2885        return _pywrapcp.IntVar_HoleIteratorAux(self, reversible)

Creates a hole iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.

def DomainIteratorAux(self, reversible):
2887    def DomainIteratorAux(self, reversible):
2888        r"""
2889        Creates a domain iterator. When 'reversible' is false, the
2890        returned object is created on the normal C++ heap and the solver
2891        does NOT take ownership of the object.
2892        """
2893        return _pywrapcp.IntVar_DomainIteratorAux(self, reversible)

Creates a domain iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.

def OldMin(self):
2895    def OldMin(self):
2896        r"""Returns the previous min."""
2897        return _pywrapcp.IntVar_OldMin(self)

Returns the previous min.

def OldMax(self):
2899    def OldMax(self):
2900        r"""Returns the previous max."""
2901        return _pywrapcp.IntVar_OldMax(self)

Returns the previous max.

def DomainIterator(self):
2909    def DomainIterator(self):
2910      return iter(self.DomainIteratorAux(False))
def HoleIterator(self):
2912    def HoleIterator(self):
2913      return iter(self.HoleIteratorAux(False))
class SolutionCollector(SearchMonitor):
2918class SolutionCollector(SearchMonitor):
2919    r"""
2920    This class is the root class of all solution collectors.
2921    It implements a basic query API to be used independently
2922    of the collector used.
2923    """
2924
2925    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
2926
2927    def __init__(self, *args, **kwargs):
2928        raise AttributeError("No constructor defined")
2929    __repr__ = _swig_repr
2930
2931    def DebugString(self):
2932        return _pywrapcp.SolutionCollector_DebugString(self)
2933
2934    def Add(self, *args):
2935        r"""Add API."""
2936        return _pywrapcp.SolutionCollector_Add(self, *args)
2937
2938    def AddObjective(self, objective):
2939        return _pywrapcp.SolutionCollector_AddObjective(self, objective)
2940
2941    def EnterSearch(self):
2942        r"""Beginning of the search."""
2943        return _pywrapcp.SolutionCollector_EnterSearch(self)
2944
2945    def SolutionCount(self):
2946        r"""Returns how many solutions were stored during the search."""
2947        return _pywrapcp.SolutionCollector_SolutionCount(self)
2948
2949    def Solution(self, n):
2950        r"""Returns the nth solution."""
2951        return _pywrapcp.SolutionCollector_Solution(self, n)
2952
2953    def WallTime(self, n):
2954        r"""Returns the wall time in ms for the nth solution."""
2955        return _pywrapcp.SolutionCollector_WallTime(self, n)
2956
2957    def Branches(self, n):
2958        r"""Returns the number of branches when the nth solution was found."""
2959        return _pywrapcp.SolutionCollector_Branches(self, n)
2960
2961    def Failures(self, n):
2962        r"""
2963        Returns the number of failures encountered at the time of the nth
2964        solution.
2965        """
2966        return _pywrapcp.SolutionCollector_Failures(self, n)
2967
2968    def ObjectiveValue(self, n):
2969        r"""Returns the objective value of the nth solution."""
2970        return _pywrapcp.SolutionCollector_ObjectiveValue(self, n)
2971
2972    def Value(self, n, var):
2973        r"""This is a shortcut to get the Value of 'var' in the nth solution."""
2974        return _pywrapcp.SolutionCollector_Value(self, n, var)
2975
2976    def StartValue(self, n, var):
2977        r"""This is a shortcut to get the StartValue of 'var' in the nth solution."""
2978        return _pywrapcp.SolutionCollector_StartValue(self, n, var)
2979
2980    def EndValue(self, n, var):
2981        r"""This is a shortcut to get the EndValue of 'var' in the nth solution."""
2982        return _pywrapcp.SolutionCollector_EndValue(self, n, var)
2983
2984    def DurationValue(self, n, var):
2985        r"""This is a shortcut to get the DurationValue of 'var' in the nth solution."""
2986        return _pywrapcp.SolutionCollector_DurationValue(self, n, var)
2987
2988    def PerformedValue(self, n, var):
2989        r"""This is a shortcut to get the PerformedValue of 'var' in the nth solution."""
2990        return _pywrapcp.SolutionCollector_PerformedValue(self, n, var)
2991
2992    def ForwardSequence(self, n, var):
2993        r"""
2994        This is a shortcut to get the ForwardSequence of 'var' in the
2995        nth solution. The forward sequence is the list of ranked interval
2996        variables starting from the start of the sequence.
2997        """
2998        return _pywrapcp.SolutionCollector_ForwardSequence(self, n, var)
2999
3000    def BackwardSequence(self, n, var):
3001        r"""
3002        This is a shortcut to get the BackwardSequence of 'var' in the
3003        nth solution. The backward sequence is the list of ranked interval
3004        variables starting from the end of the sequence.
3005        """
3006        return _pywrapcp.SolutionCollector_BackwardSequence(self, n, var)
3007
3008    def Unperformed(self, n, var):
3009        r"""
3010        This is a shortcut to get the list of unperformed of 'var' in the
3011        nth solution.
3012        """
3013        return _pywrapcp.SolutionCollector_Unperformed(self, n, var)

This class is the root class of all solution collectors. It implements a basic query API to be used independently of the collector used.

SolutionCollector(*args, **kwargs)
2927    def __init__(self, *args, **kwargs):
2928        raise AttributeError("No constructor defined")
thisown
2925    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def DebugString(self):
2931    def DebugString(self):
2932        return _pywrapcp.SolutionCollector_DebugString(self)
def Add(self, *args):
2934    def Add(self, *args):
2935        r"""Add API."""
2936        return _pywrapcp.SolutionCollector_Add(self, *args)

Add API.

def AddObjective(self, objective):
2938    def AddObjective(self, objective):
2939        return _pywrapcp.SolutionCollector_AddObjective(self, objective)
def EnterSearch(self):
2941    def EnterSearch(self):
2942        r"""Beginning of the search."""
2943        return _pywrapcp.SolutionCollector_EnterSearch(self)

Beginning of the search.

def SolutionCount(self):
2945    def SolutionCount(self):
2946        r"""Returns how many solutions were stored during the search."""
2947        return _pywrapcp.SolutionCollector_SolutionCount(self)

Returns how many solutions were stored during the search.

def Solution(self, n):
2949    def Solution(self, n):
2950        r"""Returns the nth solution."""
2951        return _pywrapcp.SolutionCollector_Solution(self, n)

Returns the nth solution.

def WallTime(self, n):
2953    def WallTime(self, n):
2954        r"""Returns the wall time in ms for the nth solution."""
2955        return _pywrapcp.SolutionCollector_WallTime(self, n)

Returns the wall time in ms for the nth solution.

def Branches(self, n):
2957    def Branches(self, n):
2958        r"""Returns the number of branches when the nth solution was found."""
2959        return _pywrapcp.SolutionCollector_Branches(self, n)

Returns the number of branches when the nth solution was found.

def Failures(self, n):
2961    def Failures(self, n):
2962        r"""
2963        Returns the number of failures encountered at the time of the nth
2964        solution.
2965        """
2966        return _pywrapcp.SolutionCollector_Failures(self, n)

Returns the number of failures encountered at the time of the nth solution.

def ObjectiveValue(self, n):
2968    def ObjectiveValue(self, n):
2969        r"""Returns the objective value of the nth solution."""
2970        return _pywrapcp.SolutionCollector_ObjectiveValue(self, n)

Returns the objective value of the nth solution.

def Value(self, n, var):
2972    def Value(self, n, var):
2973        r"""This is a shortcut to get the Value of 'var' in the nth solution."""
2974        return _pywrapcp.SolutionCollector_Value(self, n, var)

This is a shortcut to get the Value of 'var' in the nth solution.

def StartValue(self, n, var):
2976    def StartValue(self, n, var):
2977        r"""This is a shortcut to get the StartValue of 'var' in the nth solution."""
2978        return _pywrapcp.SolutionCollector_StartValue(self, n, var)

This is a shortcut to get the StartValue of 'var' in the nth solution.

def EndValue(self, n, var):
2980    def EndValue(self, n, var):
2981        r"""This is a shortcut to get the EndValue of 'var' in the nth solution."""
2982        return _pywrapcp.SolutionCollector_EndValue(self, n, var)

This is a shortcut to get the EndValue of 'var' in the nth solution.

def DurationValue(self, n, var):
2984    def DurationValue(self, n, var):
2985        r"""This is a shortcut to get the DurationValue of 'var' in the nth solution."""
2986        return _pywrapcp.SolutionCollector_DurationValue(self, n, var)

This is a shortcut to get the DurationValue of 'var' in the nth solution.

def PerformedValue(self, n, var):
2988    def PerformedValue(self, n, var):
2989        r"""This is a shortcut to get the PerformedValue of 'var' in the nth solution."""
2990        return _pywrapcp.SolutionCollector_PerformedValue(self, n, var)

This is a shortcut to get the PerformedValue of 'var' in the nth solution.

def ForwardSequence(self, n, var):
2992    def ForwardSequence(self, n, var):
2993        r"""
2994        This is a shortcut to get the ForwardSequence of 'var' in the
2995        nth solution. The forward sequence is the list of ranked interval
2996        variables starting from the start of the sequence.
2997        """
2998        return _pywrapcp.SolutionCollector_ForwardSequence(self, n, var)

This is a shortcut to get the ForwardSequence of 'var' in the nth solution. The forward sequence is the list of ranked interval variables starting from the start of the sequence.

def BackwardSequence(self, n, var):
3000    def BackwardSequence(self, n, var):
3001        r"""
3002        This is a shortcut to get the BackwardSequence of 'var' in the
3003        nth solution. The backward sequence is the list of ranked interval
3004        variables starting from the end of the sequence.
3005        """
3006        return _pywrapcp.SolutionCollector_BackwardSequence(self, n, var)

This is a shortcut to get the BackwardSequence of 'var' in the nth solution. The backward sequence is the list of ranked interval variables starting from the end of the sequence.

def Unperformed(self, n, var):
3008    def Unperformed(self, n, var):
3009        r"""
3010        This is a shortcut to get the list of unperformed of 'var' in the
3011        nth solution.
3012        """
3013        return _pywrapcp.SolutionCollector_Unperformed(self, n, var)

This is a shortcut to get the list of unperformed of 'var' in the nth solution.

class OptimizeVar:
3017class OptimizeVar(object):
3018    r"""
3019    This class encapsulates an objective. It requires the direction
3020    (minimize or maximize), the variable to optimize, and the
3021    improvement step.
3022    """
3023
3024    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3025
3026    def __init__(self, *args, **kwargs):
3027        raise AttributeError("No constructor defined")
3028    __repr__ = _swig_repr
3029
3030    def Best(self):
3031        r"""Returns the best value found during search."""
3032        return _pywrapcp.OptimizeVar_Best(self)
3033
3034    def BeginNextDecision(self, db):
3035        r"""Internal methods."""
3036        return _pywrapcp.OptimizeVar_BeginNextDecision(self, db)
3037
3038    def RefuteDecision(self, d):
3039        return _pywrapcp.OptimizeVar_RefuteDecision(self, d)
3040
3041    def AtSolution(self):
3042        return _pywrapcp.OptimizeVar_AtSolution(self)
3043
3044    def AcceptSolution(self):
3045        return _pywrapcp.OptimizeVar_AcceptSolution(self)
3046
3047    def DebugString(self):
3048        return _pywrapcp.OptimizeVar_DebugString(self)
3049    __swig_destroy__ = _pywrapcp.delete_OptimizeVar

This class encapsulates an objective. It requires the direction (minimize or maximize), the variable to optimize, and the improvement step.

OptimizeVar(*args, **kwargs)
3026    def __init__(self, *args, **kwargs):
3027        raise AttributeError("No constructor defined")
thisown
3024    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Best(self):
3030    def Best(self):
3031        r"""Returns the best value found during search."""
3032        return _pywrapcp.OptimizeVar_Best(self)

Returns the best value found during search.

def BeginNextDecision(self, db):
3034    def BeginNextDecision(self, db):
3035        r"""Internal methods."""
3036        return _pywrapcp.OptimizeVar_BeginNextDecision(self, db)

Internal methods.

def RefuteDecision(self, d):
3038    def RefuteDecision(self, d):
3039        return _pywrapcp.OptimizeVar_RefuteDecision(self, d)
def AtSolution(self):
3041    def AtSolution(self):
3042        return _pywrapcp.OptimizeVar_AtSolution(self)
def AcceptSolution(self):
3044    def AcceptSolution(self):
3045        return _pywrapcp.OptimizeVar_AcceptSolution(self)
def DebugString(self):
3047    def DebugString(self):
3048        return _pywrapcp.OptimizeVar_DebugString(self)
class SearchLimit(SearchMonitor):
3053class SearchLimit(SearchMonitor):
3054    r"""Base class of all search limits."""
3055
3056    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3057
3058    def __init__(self, *args, **kwargs):
3059        raise AttributeError("No constructor defined - class is abstract")
3060    __repr__ = _swig_repr
3061    __swig_destroy__ = _pywrapcp.delete_SearchLimit
3062
3063    def Crossed(self):
3064        r"""Returns true if the limit has been crossed."""
3065        return _pywrapcp.SearchLimit_Crossed(self)
3066
3067    def Check(self):
3068        r"""
3069        This method is called to check the status of the limit. A return
3070        value of true indicates that we have indeed crossed the limit. In
3071        that case, this method will not be called again and the remaining
3072        search will be discarded.
3073        """
3074        return _pywrapcp.SearchLimit_Check(self)
3075
3076    def Init(self):
3077        r"""This method is called when the search limit is initialized."""
3078        return _pywrapcp.SearchLimit_Init(self)
3079
3080    def EnterSearch(self):
3081        r"""Internal methods."""
3082        return _pywrapcp.SearchLimit_EnterSearch(self)
3083
3084    def BeginNextDecision(self, b):
3085        return _pywrapcp.SearchLimit_BeginNextDecision(self, b)
3086
3087    def RefuteDecision(self, d):
3088        return _pywrapcp.SearchLimit_RefuteDecision(self, d)
3089
3090    def DebugString(self):
3091        return _pywrapcp.SearchLimit_DebugString(self)

Base class of all search limits.

SearchLimit(*args, **kwargs)
3058    def __init__(self, *args, **kwargs):
3059        raise AttributeError("No constructor defined - class is abstract")
thisown
3056    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Crossed(self):
3063    def Crossed(self):
3064        r"""Returns true if the limit has been crossed."""
3065        return _pywrapcp.SearchLimit_Crossed(self)

Returns true if the limit has been crossed.

def Check(self):
3067    def Check(self):
3068        r"""
3069        This method is called to check the status of the limit. A return
3070        value of true indicates that we have indeed crossed the limit. In
3071        that case, this method will not be called again and the remaining
3072        search will be discarded.
3073        """
3074        return _pywrapcp.SearchLimit_Check(self)

This method is called to check the status of the limit. A return value of true indicates that we have indeed crossed the limit. In that case, this method will not be called again and the remaining search will be discarded.

def Init(self):
3076    def Init(self):
3077        r"""This method is called when the search limit is initialized."""
3078        return _pywrapcp.SearchLimit_Init(self)

This method is called when the search limit is initialized.

def EnterSearch(self):
3080    def EnterSearch(self):
3081        r"""Internal methods."""
3082        return _pywrapcp.SearchLimit_EnterSearch(self)

Internal methods.

def BeginNextDecision(self, b):
3084    def BeginNextDecision(self, b):
3085        return _pywrapcp.SearchLimit_BeginNextDecision(self, b)

Before calling DecisionBuilder::Next.

def RefuteDecision(self, d):
3087    def RefuteDecision(self, d):
3088        return _pywrapcp.SearchLimit_RefuteDecision(self, d)

Before refuting the decision.

def DebugString(self):
3090    def DebugString(self):
3091        return _pywrapcp.SearchLimit_DebugString(self)
class IntervalVar(PropagationBaseObject):
3095class IntervalVar(PropagationBaseObject):
3096    r"""
3097    Interval variables are often used in scheduling. The main characteristics
3098    of an IntervalVar are the start position, duration, and end
3099    date. All these characteristics can be queried and set, and demons can
3100    be posted on their modifications.
3101
3102    An important aspect is optionality: an IntervalVar can be performed or not.
3103    If unperformed, then it simply does not exist, and its characteristics
3104    cannot be accessed any more. An interval var is automatically marked
3105    as unperformed when it is not consistent anymore (start greater
3106    than end, duration < 0...)
3107    """
3108
3109    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3110
3111    def __init__(self, *args, **kwargs):
3112        raise AttributeError("No constructor defined - class is abstract")
3113
3114    def StartMin(self):
3115        r"""
3116        These methods query, set, and watch the start position of the
3117        interval var.
3118        """
3119        return _pywrapcp.IntervalVar_StartMin(self)
3120
3121    def StartMax(self):
3122        return _pywrapcp.IntervalVar_StartMax(self)
3123
3124    def SetStartMin(self, m):
3125        return _pywrapcp.IntervalVar_SetStartMin(self, m)
3126
3127    def SetStartMax(self, m):
3128        return _pywrapcp.IntervalVar_SetStartMax(self, m)
3129
3130    def SetStartRange(self, mi, ma):
3131        return _pywrapcp.IntervalVar_SetStartRange(self, mi, ma)
3132
3133    def OldStartMin(self):
3134        return _pywrapcp.IntervalVar_OldStartMin(self)
3135
3136    def OldStartMax(self):
3137        return _pywrapcp.IntervalVar_OldStartMax(self)
3138
3139    def WhenStartRange(self, *args):
3140        return _pywrapcp.IntervalVar_WhenStartRange(self, *args)
3141
3142    def WhenStartBound(self, *args):
3143        return _pywrapcp.IntervalVar_WhenStartBound(self, *args)
3144
3145    def DurationMin(self):
3146        r"""These methods query, set, and watch the duration of the interval var."""
3147        return _pywrapcp.IntervalVar_DurationMin(self)
3148
3149    def DurationMax(self):
3150        return _pywrapcp.IntervalVar_DurationMax(self)
3151
3152    def SetDurationMin(self, m):
3153        return _pywrapcp.IntervalVar_SetDurationMin(self, m)
3154
3155    def SetDurationMax(self, m):
3156        return _pywrapcp.IntervalVar_SetDurationMax(self, m)
3157
3158    def SetDurationRange(self, mi, ma):
3159        return _pywrapcp.IntervalVar_SetDurationRange(self, mi, ma)
3160
3161    def OldDurationMin(self):
3162        return _pywrapcp.IntervalVar_OldDurationMin(self)
3163
3164    def OldDurationMax(self):
3165        return _pywrapcp.IntervalVar_OldDurationMax(self)
3166
3167    def WhenDurationRange(self, *args):
3168        return _pywrapcp.IntervalVar_WhenDurationRange(self, *args)
3169
3170    def WhenDurationBound(self, *args):
3171        return _pywrapcp.IntervalVar_WhenDurationBound(self, *args)
3172
3173    def EndMin(self):
3174        r"""These methods query, set, and watch the end position of the interval var."""
3175        return _pywrapcp.IntervalVar_EndMin(self)
3176
3177    def EndMax(self):
3178        return _pywrapcp.IntervalVar_EndMax(self)
3179
3180    def SetEndMin(self, m):
3181        return _pywrapcp.IntervalVar_SetEndMin(self, m)
3182
3183    def SetEndMax(self, m):
3184        return _pywrapcp.IntervalVar_SetEndMax(self, m)
3185
3186    def SetEndRange(self, mi, ma):
3187        return _pywrapcp.IntervalVar_SetEndRange(self, mi, ma)
3188
3189    def OldEndMin(self):
3190        return _pywrapcp.IntervalVar_OldEndMin(self)
3191
3192    def OldEndMax(self):
3193        return _pywrapcp.IntervalVar_OldEndMax(self)
3194
3195    def WhenEndRange(self, *args):
3196        return _pywrapcp.IntervalVar_WhenEndRange(self, *args)
3197
3198    def WhenEndBound(self, *args):
3199        return _pywrapcp.IntervalVar_WhenEndBound(self, *args)
3200
3201    def MustBePerformed(self):
3202        r"""
3203        These methods query, set, and watch the performed status of the
3204        interval var.
3205        """
3206        return _pywrapcp.IntervalVar_MustBePerformed(self)
3207
3208    def MayBePerformed(self):
3209        return _pywrapcp.IntervalVar_MayBePerformed(self)
3210
3211    def CannotBePerformed(self):
3212        return _pywrapcp.IntervalVar_CannotBePerformed(self)
3213
3214    def IsPerformedBound(self):
3215        return _pywrapcp.IntervalVar_IsPerformedBound(self)
3216
3217    def SetPerformed(self, val):
3218        return _pywrapcp.IntervalVar_SetPerformed(self, val)
3219
3220    def WasPerformedBound(self):
3221        return _pywrapcp.IntervalVar_WasPerformedBound(self)
3222
3223    def WhenPerformedBound(self, *args):
3224        return _pywrapcp.IntervalVar_WhenPerformedBound(self, *args)
3225
3226    def WhenAnything(self, *args):
3227        r"""
3228        *Overload 1:*
3229        Attaches a demon awakened when anything about this interval changes.
3230
3231        |
3232
3233        *Overload 2:*
3234        Attaches a closure awakened when anything about this interval changes.
3235        """
3236        return _pywrapcp.IntervalVar_WhenAnything(self, *args)
3237
3238    def StartExpr(self):
3239        r"""
3240        These methods create expressions encapsulating the start, end
3241        and duration of the interval var. Please note that these must not
3242        be used if the interval var is unperformed.
3243        """
3244        return _pywrapcp.IntervalVar_StartExpr(self)
3245
3246    def DurationExpr(self):
3247        return _pywrapcp.IntervalVar_DurationExpr(self)
3248
3249    def EndExpr(self):
3250        return _pywrapcp.IntervalVar_EndExpr(self)
3251
3252    def PerformedExpr(self):
3253        return _pywrapcp.IntervalVar_PerformedExpr(self)
3254
3255    def SafeStartExpr(self, unperformed_value):
3256        r"""
3257        These methods create expressions encapsulating the start, end
3258        and duration of the interval var. If the interval var is
3259        unperformed, they will return the unperformed_value.
3260        """
3261        return _pywrapcp.IntervalVar_SafeStartExpr(self, unperformed_value)
3262
3263    def SafeDurationExpr(self, unperformed_value):
3264        return _pywrapcp.IntervalVar_SafeDurationExpr(self, unperformed_value)
3265
3266    def SafeEndExpr(self, unperformed_value):
3267        return _pywrapcp.IntervalVar_SafeEndExpr(self, unperformed_value)
3268
3269    def EndsAfterEnd(self, other):
3270        return _pywrapcp.IntervalVar_EndsAfterEnd(self, other)
3271
3272    def EndsAfterEndWithDelay(self, other, delay):
3273        return _pywrapcp.IntervalVar_EndsAfterEndWithDelay(self, other, delay)
3274
3275    def EndsAfterStart(self, other):
3276        return _pywrapcp.IntervalVar_EndsAfterStart(self, other)
3277
3278    def EndsAfterStartWithDelay(self, other, delay):
3279        return _pywrapcp.IntervalVar_EndsAfterStartWithDelay(self, other, delay)
3280
3281    def EndsAtEnd(self, other):
3282        return _pywrapcp.IntervalVar_EndsAtEnd(self, other)
3283
3284    def EndsAtEndWithDelay(self, other, delay):
3285        return _pywrapcp.IntervalVar_EndsAtEndWithDelay(self, other, delay)
3286
3287    def EndsAtStart(self, other):
3288        return _pywrapcp.IntervalVar_EndsAtStart(self, other)
3289
3290    def EndsAtStartWithDelay(self, other, delay):
3291        return _pywrapcp.IntervalVar_EndsAtStartWithDelay(self, other, delay)
3292
3293    def StartsAfterEnd(self, other):
3294        return _pywrapcp.IntervalVar_StartsAfterEnd(self, other)
3295
3296    def StartsAfterEndWithDelay(self, other, delay):
3297        return _pywrapcp.IntervalVar_StartsAfterEndWithDelay(self, other, delay)
3298
3299    def StartsAfterStart(self, other):
3300        return _pywrapcp.IntervalVar_StartsAfterStart(self, other)
3301
3302    def StartsAfterStartWithDelay(self, other, delay):
3303        return _pywrapcp.IntervalVar_StartsAfterStartWithDelay(self, other, delay)
3304
3305    def StartsAtEnd(self, other):
3306        return _pywrapcp.IntervalVar_StartsAtEnd(self, other)
3307
3308    def StartsAtEndWithDelay(self, other, delay):
3309        return _pywrapcp.IntervalVar_StartsAtEndWithDelay(self, other, delay)
3310
3311    def StartsAtStart(self, other):
3312        return _pywrapcp.IntervalVar_StartsAtStart(self, other)
3313
3314    def StartsAtStartWithDelay(self, other, delay):
3315        return _pywrapcp.IntervalVar_StartsAtStartWithDelay(self, other, delay)
3316
3317    def StaysInSync(self, other):
3318        return _pywrapcp.IntervalVar_StaysInSync(self, other)
3319
3320    def StaysInSyncWithDelay(self, other, delay):
3321        return _pywrapcp.IntervalVar_StaysInSyncWithDelay(self, other, delay)
3322
3323    def EndsAfter(self, date):
3324        return _pywrapcp.IntervalVar_EndsAfter(self, date)
3325
3326    def EndsAt(self, date):
3327        return _pywrapcp.IntervalVar_EndsAt(self, date)
3328
3329    def EndsBefore(self, date):
3330        return _pywrapcp.IntervalVar_EndsBefore(self, date)
3331
3332    def StartsAfter(self, date):
3333        return _pywrapcp.IntervalVar_StartsAfter(self, date)
3334
3335    def StartsAt(self, date):
3336        return _pywrapcp.IntervalVar_StartsAt(self, date)
3337
3338    def StartsBefore(self, date):
3339        return _pywrapcp.IntervalVar_StartsBefore(self, date)
3340
3341    def CrossesDate(self, date):
3342        return _pywrapcp.IntervalVar_CrossesDate(self, date)
3343
3344    def AvoidsDate(self, date):
3345        return _pywrapcp.IntervalVar_AvoidsDate(self, date)
3346
3347    def __repr__(self):
3348        return _pywrapcp.IntervalVar___repr__(self)
3349
3350    def __str__(self):
3351        return _pywrapcp.IntervalVar___str__(self)

Interval variables are often used in scheduling. The main characteristics of an IntervalVar are the start position, duration, and end date. All these characteristics can be queried and set, and demons can be posted on their modifications.

An important aspect is optionality: an IntervalVar can be performed or not. If unperformed, then it simply does not exist, and its characteristics cannot be accessed any more. An interval var is automatically marked as unperformed when it is not consistent anymore (start greater than end, duration < 0...)

IntervalVar(*args, **kwargs)
3111    def __init__(self, *args, **kwargs):
3112        raise AttributeError("No constructor defined - class is abstract")
thisown
3109    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def StartMin(self):
3114    def StartMin(self):
3115        r"""
3116        These methods query, set, and watch the start position of the
3117        interval var.
3118        """
3119        return _pywrapcp.IntervalVar_StartMin(self)

These methods query, set, and watch the start position of the interval var.

def StartMax(self):
3121    def StartMax(self):
3122        return _pywrapcp.IntervalVar_StartMax(self)
def SetStartMin(self, m):
3124    def SetStartMin(self, m):
3125        return _pywrapcp.IntervalVar_SetStartMin(self, m)
def SetStartMax(self, m):
3127    def SetStartMax(self, m):
3128        return _pywrapcp.IntervalVar_SetStartMax(self, m)
def SetStartRange(self, mi, ma):
3130    def SetStartRange(self, mi, ma):
3131        return _pywrapcp.IntervalVar_SetStartRange(self, mi, ma)
def OldStartMin(self):
3133    def OldStartMin(self):
3134        return _pywrapcp.IntervalVar_OldStartMin(self)
def OldStartMax(self):
3136    def OldStartMax(self):
3137        return _pywrapcp.IntervalVar_OldStartMax(self)
def WhenStartRange(self, *args):
3139    def WhenStartRange(self, *args):
3140        return _pywrapcp.IntervalVar_WhenStartRange(self, *args)
def WhenStartBound(self, *args):
3142    def WhenStartBound(self, *args):
3143        return _pywrapcp.IntervalVar_WhenStartBound(self, *args)
def DurationMin(self):
3145    def DurationMin(self):
3146        r"""These methods query, set, and watch the duration of the interval var."""
3147        return _pywrapcp.IntervalVar_DurationMin(self)

These methods query, set, and watch the duration of the interval var.

def DurationMax(self):
3149    def DurationMax(self):
3150        return _pywrapcp.IntervalVar_DurationMax(self)
def SetDurationMin(self, m):
3152    def SetDurationMin(self, m):
3153        return _pywrapcp.IntervalVar_SetDurationMin(self, m)
def SetDurationMax(self, m):
3155    def SetDurationMax(self, m):
3156        return _pywrapcp.IntervalVar_SetDurationMax(self, m)
def SetDurationRange(self, mi, ma):
3158    def SetDurationRange(self, mi, ma):
3159        return _pywrapcp.IntervalVar_SetDurationRange(self, mi, ma)
def OldDurationMin(self):
3161    def OldDurationMin(self):
3162        return _pywrapcp.IntervalVar_OldDurationMin(self)
def OldDurationMax(self):
3164    def OldDurationMax(self):
3165        return _pywrapcp.IntervalVar_OldDurationMax(self)
def WhenDurationRange(self, *args):
3167    def WhenDurationRange(self, *args):
3168        return _pywrapcp.IntervalVar_WhenDurationRange(self, *args)
def WhenDurationBound(self, *args):
3170    def WhenDurationBound(self, *args):
3171        return _pywrapcp.IntervalVar_WhenDurationBound(self, *args)
def EndMin(self):
3173    def EndMin(self):
3174        r"""These methods query, set, and watch the end position of the interval var."""
3175        return _pywrapcp.IntervalVar_EndMin(self)

These methods query, set, and watch the end position of the interval var.

def EndMax(self):
3177    def EndMax(self):
3178        return _pywrapcp.IntervalVar_EndMax(self)
def SetEndMin(self, m):
3180    def SetEndMin(self, m):
3181        return _pywrapcp.IntervalVar_SetEndMin(self, m)
def SetEndMax(self, m):
3183    def SetEndMax(self, m):
3184        return _pywrapcp.IntervalVar_SetEndMax(self, m)
def SetEndRange(self, mi, ma):
3186    def SetEndRange(self, mi, ma):
3187        return _pywrapcp.IntervalVar_SetEndRange(self, mi, ma)
def OldEndMin(self):
3189    def OldEndMin(self):
3190        return _pywrapcp.IntervalVar_OldEndMin(self)
def OldEndMax(self):
3192    def OldEndMax(self):
3193        return _pywrapcp.IntervalVar_OldEndMax(self)
def WhenEndRange(self, *args):
3195    def WhenEndRange(self, *args):
3196        return _pywrapcp.IntervalVar_WhenEndRange(self, *args)
def WhenEndBound(self, *args):
3198    def WhenEndBound(self, *args):
3199        return _pywrapcp.IntervalVar_WhenEndBound(self, *args)
def MustBePerformed(self):
3201    def MustBePerformed(self):
3202        r"""
3203        These methods query, set, and watch the performed status of the
3204        interval var.
3205        """
3206        return _pywrapcp.IntervalVar_MustBePerformed(self)

These methods query, set, and watch the performed status of the interval var.

def MayBePerformed(self):
3208    def MayBePerformed(self):
3209        return _pywrapcp.IntervalVar_MayBePerformed(self)
def CannotBePerformed(self):
3211    def CannotBePerformed(self):
3212        return _pywrapcp.IntervalVar_CannotBePerformed(self)
def IsPerformedBound(self):
3214    def IsPerformedBound(self):
3215        return _pywrapcp.IntervalVar_IsPerformedBound(self)
def SetPerformed(self, val):
3217    def SetPerformed(self, val):
3218        return _pywrapcp.IntervalVar_SetPerformed(self, val)
def WasPerformedBound(self):
3220    def WasPerformedBound(self):
3221        return _pywrapcp.IntervalVar_WasPerformedBound(self)
def WhenPerformedBound(self, *args):
3223    def WhenPerformedBound(self, *args):
3224        return _pywrapcp.IntervalVar_WhenPerformedBound(self, *args)
def WhenAnything(self, *args):
3226    def WhenAnything(self, *args):
3227        r"""
3228        *Overload 1:*
3229        Attaches a demon awakened when anything about this interval changes.
3230
3231        |
3232
3233        *Overload 2:*
3234        Attaches a closure awakened when anything about this interval changes.
3235        """
3236        return _pywrapcp.IntervalVar_WhenAnything(self, *args)

Overload 1: Attaches a demon awakened when anything about this interval changes.

|

Overload 2: Attaches a closure awakened when anything about this interval changes.

def StartExpr(self):
3238    def StartExpr(self):
3239        r"""
3240        These methods create expressions encapsulating the start, end
3241        and duration of the interval var. Please note that these must not
3242        be used if the interval var is unperformed.
3243        """
3244        return _pywrapcp.IntervalVar_StartExpr(self)

These methods create expressions encapsulating the start, end and duration of the interval var. Please note that these must not be used if the interval var is unperformed.

def DurationExpr(self):
3246    def DurationExpr(self):
3247        return _pywrapcp.IntervalVar_DurationExpr(self)
def EndExpr(self):
3249    def EndExpr(self):
3250        return _pywrapcp.IntervalVar_EndExpr(self)
def PerformedExpr(self):
3252    def PerformedExpr(self):
3253        return _pywrapcp.IntervalVar_PerformedExpr(self)
def SafeStartExpr(self, unperformed_value):
3255    def SafeStartExpr(self, unperformed_value):
3256        r"""
3257        These methods create expressions encapsulating the start, end
3258        and duration of the interval var. If the interval var is
3259        unperformed, they will return the unperformed_value.
3260        """
3261        return _pywrapcp.IntervalVar_SafeStartExpr(self, unperformed_value)

These methods create expressions encapsulating the start, end and duration of the interval var. If the interval var is unperformed, they will return the unperformed_value.

def SafeDurationExpr(self, unperformed_value):
3263    def SafeDurationExpr(self, unperformed_value):
3264        return _pywrapcp.IntervalVar_SafeDurationExpr(self, unperformed_value)
def SafeEndExpr(self, unperformed_value):
3266    def SafeEndExpr(self, unperformed_value):
3267        return _pywrapcp.IntervalVar_SafeEndExpr(self, unperformed_value)
def EndsAfterEnd(self, other):
3269    def EndsAfterEnd(self, other):
3270        return _pywrapcp.IntervalVar_EndsAfterEnd(self, other)
def EndsAfterEndWithDelay(self, other, delay):
3272    def EndsAfterEndWithDelay(self, other, delay):
3273        return _pywrapcp.IntervalVar_EndsAfterEndWithDelay(self, other, delay)
def EndsAfterStart(self, other):
3275    def EndsAfterStart(self, other):
3276        return _pywrapcp.IntervalVar_EndsAfterStart(self, other)
def EndsAfterStartWithDelay(self, other, delay):
3278    def EndsAfterStartWithDelay(self, other, delay):
3279        return _pywrapcp.IntervalVar_EndsAfterStartWithDelay(self, other, delay)
def EndsAtEnd(self, other):
3281    def EndsAtEnd(self, other):
3282        return _pywrapcp.IntervalVar_EndsAtEnd(self, other)
def EndsAtEndWithDelay(self, other, delay):
3284    def EndsAtEndWithDelay(self, other, delay):
3285        return _pywrapcp.IntervalVar_EndsAtEndWithDelay(self, other, delay)
def EndsAtStart(self, other):
3287    def EndsAtStart(self, other):
3288        return _pywrapcp.IntervalVar_EndsAtStart(self, other)
def EndsAtStartWithDelay(self, other, delay):
3290    def EndsAtStartWithDelay(self, other, delay):
3291        return _pywrapcp.IntervalVar_EndsAtStartWithDelay(self, other, delay)
def StartsAfterEnd(self, other):
3293    def StartsAfterEnd(self, other):
3294        return _pywrapcp.IntervalVar_StartsAfterEnd(self, other)
def StartsAfterEndWithDelay(self, other, delay):
3296    def StartsAfterEndWithDelay(self, other, delay):
3297        return _pywrapcp.IntervalVar_StartsAfterEndWithDelay(self, other, delay)
def StartsAfterStart(self, other):
3299    def StartsAfterStart(self, other):
3300        return _pywrapcp.IntervalVar_StartsAfterStart(self, other)
def StartsAfterStartWithDelay(self, other, delay):
3302    def StartsAfterStartWithDelay(self, other, delay):
3303        return _pywrapcp.IntervalVar_StartsAfterStartWithDelay(self, other, delay)
def StartsAtEnd(self, other):
3305    def StartsAtEnd(self, other):
3306        return _pywrapcp.IntervalVar_StartsAtEnd(self, other)
def StartsAtEndWithDelay(self, other, delay):
3308    def StartsAtEndWithDelay(self, other, delay):
3309        return _pywrapcp.IntervalVar_StartsAtEndWithDelay(self, other, delay)
def StartsAtStart(self, other):
3311    def StartsAtStart(self, other):
3312        return _pywrapcp.IntervalVar_StartsAtStart(self, other)
def StartsAtStartWithDelay(self, other, delay):
3314    def StartsAtStartWithDelay(self, other, delay):
3315        return _pywrapcp.IntervalVar_StartsAtStartWithDelay(self, other, delay)
def StaysInSync(self, other):
3317    def StaysInSync(self, other):
3318        return _pywrapcp.IntervalVar_StaysInSync(self, other)
def StaysInSyncWithDelay(self, other, delay):
3320    def StaysInSyncWithDelay(self, other, delay):
3321        return _pywrapcp.IntervalVar_StaysInSyncWithDelay(self, other, delay)
def EndsAfter(self, date):
3323    def EndsAfter(self, date):
3324        return _pywrapcp.IntervalVar_EndsAfter(self, date)
def EndsAt(self, date):
3326    def EndsAt(self, date):
3327        return _pywrapcp.IntervalVar_EndsAt(self, date)
def EndsBefore(self, date):
3329    def EndsBefore(self, date):
3330        return _pywrapcp.IntervalVar_EndsBefore(self, date)
def StartsAfter(self, date):
3332    def StartsAfter(self, date):
3333        return _pywrapcp.IntervalVar_StartsAfter(self, date)
def StartsAt(self, date):
3335    def StartsAt(self, date):
3336        return _pywrapcp.IntervalVar_StartsAt(self, date)
def StartsBefore(self, date):
3338    def StartsBefore(self, date):
3339        return _pywrapcp.IntervalVar_StartsBefore(self, date)
def CrossesDate(self, date):
3341    def CrossesDate(self, date):
3342        return _pywrapcp.IntervalVar_CrossesDate(self, date)
def AvoidsDate(self, date):
3344    def AvoidsDate(self, date):
3345        return _pywrapcp.IntervalVar_AvoidsDate(self, date)
class SequenceVar(PropagationBaseObject):
3355class SequenceVar(PropagationBaseObject):
3356    r"""
3357    A sequence variable is a variable whose domain is a set of possible
3358    orderings of the interval variables. It allows ordering of tasks. It
3359    has two sets of methods: ComputePossibleFirstsAndLasts(), which
3360    returns the list of interval variables that can be ranked first or
3361    last; and RankFirst/RankNotFirst/RankLast/RankNotLast, which can be
3362    used to create the search decision.
3363    """
3364
3365    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3366
3367    def __init__(self, *args, **kwargs):
3368        raise AttributeError("No constructor defined")
3369
3370    def DebugString(self):
3371        return _pywrapcp.SequenceVar_DebugString(self)
3372
3373    def RankFirst(self, index):
3374        r"""
3375        Ranks the index_th interval var first of all unranked interval
3376        vars. After that, it will no longer be considered ranked.
3377        """
3378        return _pywrapcp.SequenceVar_RankFirst(self, index)
3379
3380    def RankNotFirst(self, index):
3381        r"""
3382        Indicates that the index_th interval var will not be ranked first
3383        of all currently unranked interval vars.
3384        """
3385        return _pywrapcp.SequenceVar_RankNotFirst(self, index)
3386
3387    def RankLast(self, index):
3388        r"""
3389        Ranks the index_th interval var first of all unranked interval
3390        vars. After that, it will no longer be considered ranked.
3391        """
3392        return _pywrapcp.SequenceVar_RankLast(self, index)
3393
3394    def RankNotLast(self, index):
3395        r"""
3396        Indicates that the index_th interval var will not be ranked first
3397        of all currently unranked interval vars.
3398        """
3399        return _pywrapcp.SequenceVar_RankNotLast(self, index)
3400
3401    def Interval(self, index):
3402        r"""Returns the index_th interval of the sequence."""
3403        return _pywrapcp.SequenceVar_Interval(self, index)
3404
3405    def Next(self, index):
3406        r"""Returns the next of the index_th interval of the sequence."""
3407        return _pywrapcp.SequenceVar_Next(self, index)
3408
3409    def Size(self):
3410        r"""Returns the number of interval vars in the sequence."""
3411        return _pywrapcp.SequenceVar_Size(self)
3412
3413    def __repr__(self):
3414        return _pywrapcp.SequenceVar___repr__(self)
3415
3416    def __str__(self):
3417        return _pywrapcp.SequenceVar___str__(self)

A sequence variable is a variable whose domain is a set of possible orderings of the interval variables. It allows ordering of tasks. It has two sets of methods: ComputePossibleFirstsAndLasts(), which returns the list of interval variables that can be ranked first or last; and RankFirst/RankNotFirst/RankLast/RankNotLast, which can be used to create the search decision.

SequenceVar(*args, **kwargs)
3367    def __init__(self, *args, **kwargs):
3368        raise AttributeError("No constructor defined")
thisown
3365    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def DebugString(self):
3370    def DebugString(self):
3371        return _pywrapcp.SequenceVar_DebugString(self)
def RankFirst(self, index):
3373    def RankFirst(self, index):
3374        r"""
3375        Ranks the index_th interval var first of all unranked interval
3376        vars. After that, it will no longer be considered ranked.
3377        """
3378        return _pywrapcp.SequenceVar_RankFirst(self, index)

Ranks the index_th interval var first of all unranked interval vars. After that, it will no longer be considered ranked.

def RankNotFirst(self, index):
3380    def RankNotFirst(self, index):
3381        r"""
3382        Indicates that the index_th interval var will not be ranked first
3383        of all currently unranked interval vars.
3384        """
3385        return _pywrapcp.SequenceVar_RankNotFirst(self, index)

Indicates that the index_th interval var will not be ranked first of all currently unranked interval vars.

def RankLast(self, index):
3387    def RankLast(self, index):
3388        r"""
3389        Ranks the index_th interval var first of all unranked interval
3390        vars. After that, it will no longer be considered ranked.
3391        """
3392        return _pywrapcp.SequenceVar_RankLast(self, index)

Ranks the index_th interval var first of all unranked interval vars. After that, it will no longer be considered ranked.

def RankNotLast(self, index):
3394    def RankNotLast(self, index):
3395        r"""
3396        Indicates that the index_th interval var will not be ranked first
3397        of all currently unranked interval vars.
3398        """
3399        return _pywrapcp.SequenceVar_RankNotLast(self, index)

Indicates that the index_th interval var will not be ranked first of all currently unranked interval vars.

def Interval(self, index):
3401    def Interval(self, index):
3402        r"""Returns the index_th interval of the sequence."""
3403        return _pywrapcp.SequenceVar_Interval(self, index)

Returns the index_th interval of the sequence.

def Next(self, index):
3405    def Next(self, index):
3406        r"""Returns the next of the index_th interval of the sequence."""
3407        return _pywrapcp.SequenceVar_Next(self, index)

Returns the next of the index_th interval of the sequence.

def Size(self):
3409    def Size(self):
3410        r"""Returns the number of interval vars in the sequence."""
3411        return _pywrapcp.SequenceVar_Size(self)

Returns the number of interval vars in the sequence.

Inherited Members
PropagationBaseObject
solver
Name
class AssignmentElement:
3421class AssignmentElement(object):
3422    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3423
3424    def __init__(self, *args, **kwargs):
3425        raise AttributeError("No constructor defined")
3426    __repr__ = _swig_repr
3427
3428    def Activate(self):
3429        return _pywrapcp.AssignmentElement_Activate(self)
3430
3431    def Deactivate(self):
3432        return _pywrapcp.AssignmentElement_Deactivate(self)
3433
3434    def Activated(self):
3435        return _pywrapcp.AssignmentElement_Activated(self)
3436    __swig_destroy__ = _pywrapcp.delete_AssignmentElement
AssignmentElement(*args, **kwargs)
3424    def __init__(self, *args, **kwargs):
3425        raise AttributeError("No constructor defined")
thisown
3422    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Activate(self):
3428    def Activate(self):
3429        return _pywrapcp.AssignmentElement_Activate(self)
def Deactivate(self):
3431    def Deactivate(self):
3432        return _pywrapcp.AssignmentElement_Deactivate(self)
def Activated(self):
3434    def Activated(self):
3435        return _pywrapcp.AssignmentElement_Activated(self)
class IntVarElement(AssignmentElement):
3440class IntVarElement(AssignmentElement):
3441    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3442
3443    def __init__(self, *args, **kwargs):
3444        raise AttributeError("No constructor defined")
3445    __repr__ = _swig_repr
3446
3447    def Var(self):
3448        return _pywrapcp.IntVarElement_Var(self)
3449
3450    def Min(self):
3451        return _pywrapcp.IntVarElement_Min(self)
3452
3453    def SetMin(self, m):
3454        return _pywrapcp.IntVarElement_SetMin(self, m)
3455
3456    def Max(self):
3457        return _pywrapcp.IntVarElement_Max(self)
3458
3459    def SetMax(self, m):
3460        return _pywrapcp.IntVarElement_SetMax(self, m)
3461
3462    def Value(self):
3463        return _pywrapcp.IntVarElement_Value(self)
3464
3465    def Bound(self):
3466        return _pywrapcp.IntVarElement_Bound(self)
3467
3468    def SetRange(self, l, u):
3469        return _pywrapcp.IntVarElement_SetRange(self, l, u)
3470
3471    def SetValue(self, v):
3472        return _pywrapcp.IntVarElement_SetValue(self, v)
3473
3474    def __eq__(self, element):
3475        return _pywrapcp.IntVarElement___eq__(self, element)
3476
3477    def __ne__(self, element):
3478        return _pywrapcp.IntVarElement___ne__(self, element)
3479    __swig_destroy__ = _pywrapcp.delete_IntVarElement
IntVarElement(*args, **kwargs)
3443    def __init__(self, *args, **kwargs):
3444        raise AttributeError("No constructor defined")
thisown
3441    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Var(self):
3447    def Var(self):
3448        return _pywrapcp.IntVarElement_Var(self)
def Min(self):
3450    def Min(self):
3451        return _pywrapcp.IntVarElement_Min(self)
def SetMin(self, m):
3453    def SetMin(self, m):
3454        return _pywrapcp.IntVarElement_SetMin(self, m)
def Max(self):
3456    def Max(self):
3457        return _pywrapcp.IntVarElement_Max(self)
def SetMax(self, m):
3459    def SetMax(self, m):
3460        return _pywrapcp.IntVarElement_SetMax(self, m)
def Value(self):
3462    def Value(self):
3463        return _pywrapcp.IntVarElement_Value(self)
def Bound(self):
3465    def Bound(self):
3466        return _pywrapcp.IntVarElement_Bound(self)
def SetRange(self, l, u):
3468    def SetRange(self, l, u):
3469        return _pywrapcp.IntVarElement_SetRange(self, l, u)
def SetValue(self, v):
3471    def SetValue(self, v):
3472        return _pywrapcp.IntVarElement_SetValue(self, v)
class IntervalVarElement(AssignmentElement):
3483class IntervalVarElement(AssignmentElement):
3484    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3485
3486    def __init__(self, *args, **kwargs):
3487        raise AttributeError("No constructor defined")
3488    __repr__ = _swig_repr
3489
3490    def Var(self):
3491        return _pywrapcp.IntervalVarElement_Var(self)
3492
3493    def StartMin(self):
3494        return _pywrapcp.IntervalVarElement_StartMin(self)
3495
3496    def StartMax(self):
3497        return _pywrapcp.IntervalVarElement_StartMax(self)
3498
3499    def StartValue(self):
3500        return _pywrapcp.IntervalVarElement_StartValue(self)
3501
3502    def DurationMin(self):
3503        return _pywrapcp.IntervalVarElement_DurationMin(self)
3504
3505    def DurationMax(self):
3506        return _pywrapcp.IntervalVarElement_DurationMax(self)
3507
3508    def DurationValue(self):
3509        return _pywrapcp.IntervalVarElement_DurationValue(self)
3510
3511    def EndMin(self):
3512        return _pywrapcp.IntervalVarElement_EndMin(self)
3513
3514    def EndMax(self):
3515        return _pywrapcp.IntervalVarElement_EndMax(self)
3516
3517    def EndValue(self):
3518        return _pywrapcp.IntervalVarElement_EndValue(self)
3519
3520    def PerformedMin(self):
3521        return _pywrapcp.IntervalVarElement_PerformedMin(self)
3522
3523    def PerformedMax(self):
3524        return _pywrapcp.IntervalVarElement_PerformedMax(self)
3525
3526    def PerformedValue(self):
3527        return _pywrapcp.IntervalVarElement_PerformedValue(self)
3528
3529    def SetStartMin(self, m):
3530        return _pywrapcp.IntervalVarElement_SetStartMin(self, m)
3531
3532    def SetStartMax(self, m):
3533        return _pywrapcp.IntervalVarElement_SetStartMax(self, m)
3534
3535    def SetStartRange(self, mi, ma):
3536        return _pywrapcp.IntervalVarElement_SetStartRange(self, mi, ma)
3537
3538    def SetStartValue(self, v):
3539        return _pywrapcp.IntervalVarElement_SetStartValue(self, v)
3540
3541    def SetDurationMin(self, m):
3542        return _pywrapcp.IntervalVarElement_SetDurationMin(self, m)
3543
3544    def SetDurationMax(self, m):
3545        return _pywrapcp.IntervalVarElement_SetDurationMax(self, m)
3546
3547    def SetDurationRange(self, mi, ma):
3548        return _pywrapcp.IntervalVarElement_SetDurationRange(self, mi, ma)
3549
3550    def SetDurationValue(self, v):
3551        return _pywrapcp.IntervalVarElement_SetDurationValue(self, v)
3552
3553    def SetEndMin(self, m):
3554        return _pywrapcp.IntervalVarElement_SetEndMin(self, m)
3555
3556    def SetEndMax(self, m):
3557        return _pywrapcp.IntervalVarElement_SetEndMax(self, m)
3558
3559    def SetEndRange(self, mi, ma):
3560        return _pywrapcp.IntervalVarElement_SetEndRange(self, mi, ma)
3561
3562    def SetEndValue(self, v):
3563        return _pywrapcp.IntervalVarElement_SetEndValue(self, v)
3564
3565    def SetPerformedMin(self, m):
3566        return _pywrapcp.IntervalVarElement_SetPerformedMin(self, m)
3567
3568    def SetPerformedMax(self, m):
3569        return _pywrapcp.IntervalVarElement_SetPerformedMax(self, m)
3570
3571    def SetPerformedRange(self, mi, ma):
3572        return _pywrapcp.IntervalVarElement_SetPerformedRange(self, mi, ma)
3573
3574    def SetPerformedValue(self, v):
3575        return _pywrapcp.IntervalVarElement_SetPerformedValue(self, v)
3576
3577    def __eq__(self, element):
3578        return _pywrapcp.IntervalVarElement___eq__(self, element)
3579
3580    def __ne__(self, element):
3581        return _pywrapcp.IntervalVarElement___ne__(self, element)
3582    __swig_destroy__ = _pywrapcp.delete_IntervalVarElement
IntervalVarElement(*args, **kwargs)
3486    def __init__(self, *args, **kwargs):
3487        raise AttributeError("No constructor defined")
thisown
3484    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Var(self):
3490    def Var(self):
3491        return _pywrapcp.IntervalVarElement_Var(self)
def StartMin(self):
3493    def StartMin(self):
3494        return _pywrapcp.IntervalVarElement_StartMin(self)
def StartMax(self):
3496    def StartMax(self):
3497        return _pywrapcp.IntervalVarElement_StartMax(self)
def StartValue(self):
3499    def StartValue(self):
3500        return _pywrapcp.IntervalVarElement_StartValue(self)
def DurationMin(self):
3502    def DurationMin(self):
3503        return _pywrapcp.IntervalVarElement_DurationMin(self)
def DurationMax(self):
3505    def DurationMax(self):
3506        return _pywrapcp.IntervalVarElement_DurationMax(self)
def DurationValue(self):
3508    def DurationValue(self):
3509        return _pywrapcp.IntervalVarElement_DurationValue(self)
def EndMin(self):
3511    def EndMin(self):
3512        return _pywrapcp.IntervalVarElement_EndMin(self)
def EndMax(self):
3514    def EndMax(self):
3515        return _pywrapcp.IntervalVarElement_EndMax(self)
def EndValue(self):
3517    def EndValue(self):
3518        return _pywrapcp.IntervalVarElement_EndValue(self)
def PerformedMin(self):
3520    def PerformedMin(self):
3521        return _pywrapcp.IntervalVarElement_PerformedMin(self)
def PerformedMax(self):
3523    def PerformedMax(self):
3524        return _pywrapcp.IntervalVarElement_PerformedMax(self)
def PerformedValue(self):
3526    def PerformedValue(self):
3527        return _pywrapcp.IntervalVarElement_PerformedValue(self)
def SetStartMin(self, m):
3529    def SetStartMin(self, m):
3530        return _pywrapcp.IntervalVarElement_SetStartMin(self, m)
def SetStartMax(self, m):
3532    def SetStartMax(self, m):
3533        return _pywrapcp.IntervalVarElement_SetStartMax(self, m)
def SetStartRange(self, mi, ma):
3535    def SetStartRange(self, mi, ma):
3536        return _pywrapcp.IntervalVarElement_SetStartRange(self, mi, ma)
def SetStartValue(self, v):
3538    def SetStartValue(self, v):
3539        return _pywrapcp.IntervalVarElement_SetStartValue(self, v)
def SetDurationMin(self, m):
3541    def SetDurationMin(self, m):
3542        return _pywrapcp.IntervalVarElement_SetDurationMin(self, m)
def SetDurationMax(self, m):
3544    def SetDurationMax(self, m):
3545        return _pywrapcp.IntervalVarElement_SetDurationMax(self, m)
def SetDurationRange(self, mi, ma):
3547    def SetDurationRange(self, mi, ma):
3548        return _pywrapcp.IntervalVarElement_SetDurationRange(self, mi, ma)
def SetDurationValue(self, v):
3550    def SetDurationValue(self, v):
3551        return _pywrapcp.IntervalVarElement_SetDurationValue(self, v)
def SetEndMin(self, m):
3553    def SetEndMin(self, m):
3554        return _pywrapcp.IntervalVarElement_SetEndMin(self, m)
def SetEndMax(self, m):
3556    def SetEndMax(self, m):
3557        return _pywrapcp.IntervalVarElement_SetEndMax(self, m)
def SetEndRange(self, mi, ma):
3559    def SetEndRange(self, mi, ma):
3560        return _pywrapcp.IntervalVarElement_SetEndRange(self, mi, ma)
def SetEndValue(self, v):
3562    def SetEndValue(self, v):
3563        return _pywrapcp.IntervalVarElement_SetEndValue(self, v)
def SetPerformedMin(self, m):
3565    def SetPerformedMin(self, m):
3566        return _pywrapcp.IntervalVarElement_SetPerformedMin(self, m)
def SetPerformedMax(self, m):
3568    def SetPerformedMax(self, m):
3569        return _pywrapcp.IntervalVarElement_SetPerformedMax(self, m)
def SetPerformedRange(self, mi, ma):
3571    def SetPerformedRange(self, mi, ma):
3572        return _pywrapcp.IntervalVarElement_SetPerformedRange(self, mi, ma)
def SetPerformedValue(self, v):
3574    def SetPerformedValue(self, v):
3575        return _pywrapcp.IntervalVarElement_SetPerformedValue(self, v)
class SequenceVarElement(AssignmentElement):
3586class SequenceVarElement(AssignmentElement):
3587    r"""
3588    The SequenceVarElement stores a partial representation of ranked
3589    interval variables in the underlying sequence variable.
3590    This representation consists of three vectors:
3591      - the forward sequence. That is the list of interval variables
3592        ranked first in the sequence.  The first element of the backward
3593        sequence is the first interval in the sequence variable.
3594      - the backward sequence. That is the list of interval variables
3595        ranked last in the sequence. The first element of the backward
3596        sequence is the last interval in the sequence variable.
3597      - The list of unperformed interval variables.
3598     Furthermore, if all performed variables are ranked, then by
3599     convention, the forward_sequence will contain all such variables
3600     and the backward_sequence will be empty.
3601    """
3602
3603    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3604
3605    def __init__(self, *args, **kwargs):
3606        raise AttributeError("No constructor defined")
3607    __repr__ = _swig_repr
3608
3609    def Var(self):
3610        return _pywrapcp.SequenceVarElement_Var(self)
3611
3612    def ForwardSequence(self):
3613        return _pywrapcp.SequenceVarElement_ForwardSequence(self)
3614
3615    def BackwardSequence(self):
3616        return _pywrapcp.SequenceVarElement_BackwardSequence(self)
3617
3618    def Unperformed(self):
3619        return _pywrapcp.SequenceVarElement_Unperformed(self)
3620
3621    def SetSequence(self, forward_sequence, backward_sequence, unperformed):
3622        return _pywrapcp.SequenceVarElement_SetSequence(self, forward_sequence, backward_sequence, unperformed)
3623
3624    def SetForwardSequence(self, forward_sequence):
3625        return _pywrapcp.SequenceVarElement_SetForwardSequence(self, forward_sequence)
3626
3627    def SetBackwardSequence(self, backward_sequence):
3628        return _pywrapcp.SequenceVarElement_SetBackwardSequence(self, backward_sequence)
3629
3630    def SetUnperformed(self, unperformed):
3631        return _pywrapcp.SequenceVarElement_SetUnperformed(self, unperformed)
3632
3633    def __eq__(self, element):
3634        return _pywrapcp.SequenceVarElement___eq__(self, element)
3635
3636    def __ne__(self, element):
3637        return _pywrapcp.SequenceVarElement___ne__(self, element)
3638    __swig_destroy__ = _pywrapcp.delete_SequenceVarElement

The SequenceVarElement stores a partial representation of ranked interval variables in the underlying sequence variable.

This representation consists of three vectors:
  • the forward sequence. That is the list of interval variables ranked first in the sequence. The first element of the backward sequence is the first interval in the sequence variable.
    • the backward sequence. That is the list of interval variables ranked last in the sequence. The first element of the backward sequence is the last interval in the sequence variable.
    • The list of unperformed interval variables. Furthermore, if all performed variables are ranked, then by convention, the forward_sequence will contain all such variables and the backward_sequence will be empty.
SequenceVarElement(*args, **kwargs)
3605    def __init__(self, *args, **kwargs):
3606        raise AttributeError("No constructor defined")
thisown
3603    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Var(self):
3609    def Var(self):
3610        return _pywrapcp.SequenceVarElement_Var(self)
def ForwardSequence(self):
3612    def ForwardSequence(self):
3613        return _pywrapcp.SequenceVarElement_ForwardSequence(self)
def BackwardSequence(self):
3615    def BackwardSequence(self):
3616        return _pywrapcp.SequenceVarElement_BackwardSequence(self)
def Unperformed(self):
3618    def Unperformed(self):
3619        return _pywrapcp.SequenceVarElement_Unperformed(self)
def SetSequence(self, forward_sequence, backward_sequence, unperformed):
3621    def SetSequence(self, forward_sequence, backward_sequence, unperformed):
3622        return _pywrapcp.SequenceVarElement_SetSequence(self, forward_sequence, backward_sequence, unperformed)
def SetForwardSequence(self, forward_sequence):
3624    def SetForwardSequence(self, forward_sequence):
3625        return _pywrapcp.SequenceVarElement_SetForwardSequence(self, forward_sequence)
def SetBackwardSequence(self, backward_sequence):
3627    def SetBackwardSequence(self, backward_sequence):
3628        return _pywrapcp.SequenceVarElement_SetBackwardSequence(self, backward_sequence)
def SetUnperformed(self, unperformed):
3630    def SetUnperformed(self, unperformed):
3631        return _pywrapcp.SequenceVarElement_SetUnperformed(self, unperformed)
class Assignment(PropagationBaseObject):
3642class Assignment(PropagationBaseObject):
3643    r"""
3644    An Assignment is a variable -> domains mapping, used
3645    to report solutions to the user.
3646    """
3647
3648    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3649
3650    def __init__(self, *args, **kwargs):
3651        raise AttributeError("No constructor defined")
3652    __repr__ = _swig_repr
3653
3654    def Clear(self):
3655        return _pywrapcp.Assignment_Clear(self)
3656
3657    def Empty(self):
3658        return _pywrapcp.Assignment_Empty(self)
3659
3660    def Size(self):
3661        return _pywrapcp.Assignment_Size(self)
3662
3663    def NumIntVars(self):
3664        return _pywrapcp.Assignment_NumIntVars(self)
3665
3666    def NumIntervalVars(self):
3667        return _pywrapcp.Assignment_NumIntervalVars(self)
3668
3669    def NumSequenceVars(self):
3670        return _pywrapcp.Assignment_NumSequenceVars(self)
3671
3672    def Store(self):
3673        return _pywrapcp.Assignment_Store(self)
3674
3675    def Restore(self):
3676        return _pywrapcp.Assignment_Restore(self)
3677
3678    def Load(self, *args):
3679        r"""
3680        Loads an assignment from a file; does not add variables to the
3681        assignment (only the variables contained in the assignment are modified).
3682        """
3683        return _pywrapcp.Assignment_Load(self, *args)
3684
3685    def Save(self, *args):
3686        r"""Saves the assignment to a file."""
3687        return _pywrapcp.Assignment_Save(self, *args)
3688
3689    def AddObjective(self, v):
3690        return _pywrapcp.Assignment_AddObjective(self, v)
3691
3692    def Objective(self):
3693        return _pywrapcp.Assignment_Objective(self)
3694
3695    def HasObjective(self):
3696        return _pywrapcp.Assignment_HasObjective(self)
3697
3698    def ObjectiveMin(self):
3699        return _pywrapcp.Assignment_ObjectiveMin(self)
3700
3701    def ObjectiveMax(self):
3702        return _pywrapcp.Assignment_ObjectiveMax(self)
3703
3704    def ObjectiveValue(self):
3705        return _pywrapcp.Assignment_ObjectiveValue(self)
3706
3707    def ObjectiveBound(self):
3708        return _pywrapcp.Assignment_ObjectiveBound(self)
3709
3710    def SetObjectiveMin(self, m):
3711        return _pywrapcp.Assignment_SetObjectiveMin(self, m)
3712
3713    def SetObjectiveMax(self, m):
3714        return _pywrapcp.Assignment_SetObjectiveMax(self, m)
3715
3716    def SetObjectiveValue(self, value):
3717        return _pywrapcp.Assignment_SetObjectiveValue(self, value)
3718
3719    def SetObjectiveRange(self, l, u):
3720        return _pywrapcp.Assignment_SetObjectiveRange(self, l, u)
3721
3722    def Min(self, var):
3723        return _pywrapcp.Assignment_Min(self, var)
3724
3725    def Max(self, var):
3726        return _pywrapcp.Assignment_Max(self, var)
3727
3728    def Value(self, var):
3729        return _pywrapcp.Assignment_Value(self, var)
3730
3731    def Bound(self, var):
3732        return _pywrapcp.Assignment_Bound(self, var)
3733
3734    def SetMin(self, var, m):
3735        return _pywrapcp.Assignment_SetMin(self, var, m)
3736
3737    def SetMax(self, var, m):
3738        return _pywrapcp.Assignment_SetMax(self, var, m)
3739
3740    def SetRange(self, var, l, u):
3741        return _pywrapcp.Assignment_SetRange(self, var, l, u)
3742
3743    def SetValue(self, var, value):
3744        return _pywrapcp.Assignment_SetValue(self, var, value)
3745
3746    def StartMin(self, var):
3747        return _pywrapcp.Assignment_StartMin(self, var)
3748
3749    def StartMax(self, var):
3750        return _pywrapcp.Assignment_StartMax(self, var)
3751
3752    def StartValue(self, var):
3753        return _pywrapcp.Assignment_StartValue(self, var)
3754
3755    def DurationMin(self, var):
3756        return _pywrapcp.Assignment_DurationMin(self, var)
3757
3758    def DurationMax(self, var):
3759        return _pywrapcp.Assignment_DurationMax(self, var)
3760
3761    def DurationValue(self, var):
3762        return _pywrapcp.Assignment_DurationValue(self, var)
3763
3764    def EndMin(self, var):
3765        return _pywrapcp.Assignment_EndMin(self, var)
3766
3767    def EndMax(self, var):
3768        return _pywrapcp.Assignment_EndMax(self, var)
3769
3770    def EndValue(self, var):
3771        return _pywrapcp.Assignment_EndValue(self, var)
3772
3773    def PerformedMin(self, var):
3774        return _pywrapcp.Assignment_PerformedMin(self, var)
3775
3776    def PerformedMax(self, var):
3777        return _pywrapcp.Assignment_PerformedMax(self, var)
3778
3779    def PerformedValue(self, var):
3780        return _pywrapcp.Assignment_PerformedValue(self, var)
3781
3782    def SetStartMin(self, var, m):
3783        return _pywrapcp.Assignment_SetStartMin(self, var, m)
3784
3785    def SetStartMax(self, var, m):
3786        return _pywrapcp.Assignment_SetStartMax(self, var, m)
3787
3788    def SetStartRange(self, var, mi, ma):
3789        return _pywrapcp.Assignment_SetStartRange(self, var, mi, ma)
3790
3791    def SetStartValue(self, var, value):
3792        return _pywrapcp.Assignment_SetStartValue(self, var, value)
3793
3794    def SetDurationMin(self, var, m):
3795        return _pywrapcp.Assignment_SetDurationMin(self, var, m)
3796
3797    def SetDurationMax(self, var, m):
3798        return _pywrapcp.Assignment_SetDurationMax(self, var, m)
3799
3800    def SetDurationRange(self, var, mi, ma):
3801        return _pywrapcp.Assignment_SetDurationRange(self, var, mi, ma)
3802
3803    def SetDurationValue(self, var, value):
3804        return _pywrapcp.Assignment_SetDurationValue(self, var, value)
3805
3806    def SetEndMin(self, var, m):
3807        return _pywrapcp.Assignment_SetEndMin(self, var, m)
3808
3809    def SetEndMax(self, var, m):
3810        return _pywrapcp.Assignment_SetEndMax(self, var, m)
3811
3812    def SetEndRange(self, var, mi, ma):
3813        return _pywrapcp.Assignment_SetEndRange(self, var, mi, ma)
3814
3815    def SetEndValue(self, var, value):
3816        return _pywrapcp.Assignment_SetEndValue(self, var, value)
3817
3818    def SetPerformedMin(self, var, m):
3819        return _pywrapcp.Assignment_SetPerformedMin(self, var, m)
3820
3821    def SetPerformedMax(self, var, m):
3822        return _pywrapcp.Assignment_SetPerformedMax(self, var, m)
3823
3824    def SetPerformedRange(self, var, mi, ma):
3825        return _pywrapcp.Assignment_SetPerformedRange(self, var, mi, ma)
3826
3827    def SetPerformedValue(self, var, value):
3828        return _pywrapcp.Assignment_SetPerformedValue(self, var, value)
3829
3830    def Add(self, *args):
3831        return _pywrapcp.Assignment_Add(self, *args)
3832
3833    def ForwardSequence(self, var):
3834        return _pywrapcp.Assignment_ForwardSequence(self, var)
3835
3836    def BackwardSequence(self, var):
3837        return _pywrapcp.Assignment_BackwardSequence(self, var)
3838
3839    def Unperformed(self, var):
3840        return _pywrapcp.Assignment_Unperformed(self, var)
3841
3842    def SetSequence(self, var, forward_sequence, backward_sequence, unperformed):
3843        return _pywrapcp.Assignment_SetSequence(self, var, forward_sequence, backward_sequence, unperformed)
3844
3845    def SetForwardSequence(self, var, forward_sequence):
3846        return _pywrapcp.Assignment_SetForwardSequence(self, var, forward_sequence)
3847
3848    def SetBackwardSequence(self, var, backward_sequence):
3849        return _pywrapcp.Assignment_SetBackwardSequence(self, var, backward_sequence)
3850
3851    def SetUnperformed(self, var, unperformed):
3852        return _pywrapcp.Assignment_SetUnperformed(self, var, unperformed)
3853
3854    def Activate(self, *args):
3855        return _pywrapcp.Assignment_Activate(self, *args)
3856
3857    def Deactivate(self, *args):
3858        return _pywrapcp.Assignment_Deactivate(self, *args)
3859
3860    def Activated(self, *args):
3861        return _pywrapcp.Assignment_Activated(self, *args)
3862
3863    def DebugString(self):
3864        return _pywrapcp.Assignment_DebugString(self)
3865
3866    def IntVarContainer(self):
3867        return _pywrapcp.Assignment_IntVarContainer(self)
3868
3869    def MutableIntVarContainer(self):
3870        return _pywrapcp.Assignment_MutableIntVarContainer(self)
3871
3872    def IntervalVarContainer(self):
3873        return _pywrapcp.Assignment_IntervalVarContainer(self)
3874
3875    def MutableIntervalVarContainer(self):
3876        return _pywrapcp.Assignment_MutableIntervalVarContainer(self)
3877
3878    def SequenceVarContainer(self):
3879        return _pywrapcp.Assignment_SequenceVarContainer(self)
3880
3881    def MutableSequenceVarContainer(self):
3882        return _pywrapcp.Assignment_MutableSequenceVarContainer(self)
3883
3884    def __eq__(self, assignment):
3885        return _pywrapcp.Assignment___eq__(self, assignment)
3886
3887    def __ne__(self, assignment):
3888        return _pywrapcp.Assignment___ne__(self, assignment)

An Assignment is a variable -> domains mapping, used to report solutions to the user.

Assignment(*args, **kwargs)
3650    def __init__(self, *args, **kwargs):
3651        raise AttributeError("No constructor defined")
thisown
3648    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Clear(self):
3654    def Clear(self):
3655        return _pywrapcp.Assignment_Clear(self)
def Empty(self):
3657    def Empty(self):
3658        return _pywrapcp.Assignment_Empty(self)
def Size(self):
3660    def Size(self):
3661        return _pywrapcp.Assignment_Size(self)
def NumIntVars(self):
3663    def NumIntVars(self):
3664        return _pywrapcp.Assignment_NumIntVars(self)
def NumIntervalVars(self):
3666    def NumIntervalVars(self):
3667        return _pywrapcp.Assignment_NumIntervalVars(self)
def NumSequenceVars(self):
3669    def NumSequenceVars(self):
3670        return _pywrapcp.Assignment_NumSequenceVars(self)
def Store(self):
3672    def Store(self):
3673        return _pywrapcp.Assignment_Store(self)
def Restore(self):
3675    def Restore(self):
3676        return _pywrapcp.Assignment_Restore(self)
def Load(self, *args):
3678    def Load(self, *args):
3679        r"""
3680        Loads an assignment from a file; does not add variables to the
3681        assignment (only the variables contained in the assignment are modified).
3682        """
3683        return _pywrapcp.Assignment_Load(self, *args)

Loads an assignment from a file; does not add variables to the assignment (only the variables contained in the assignment are modified).

def Save(self, *args):
3685    def Save(self, *args):
3686        r"""Saves the assignment to a file."""
3687        return _pywrapcp.Assignment_Save(self, *args)

Saves the assignment to a file.

def AddObjective(self, v):
3689    def AddObjective(self, v):
3690        return _pywrapcp.Assignment_AddObjective(self, v)
def Objective(self):
3692    def Objective(self):
3693        return _pywrapcp.Assignment_Objective(self)
def HasObjective(self):
3695    def HasObjective(self):
3696        return _pywrapcp.Assignment_HasObjective(self)
def ObjectiveMin(self):
3698    def ObjectiveMin(self):
3699        return _pywrapcp.Assignment_ObjectiveMin(self)
def ObjectiveMax(self):
3701    def ObjectiveMax(self):
3702        return _pywrapcp.Assignment_ObjectiveMax(self)
def ObjectiveValue(self):
3704    def ObjectiveValue(self):
3705        return _pywrapcp.Assignment_ObjectiveValue(self)
def ObjectiveBound(self):
3707    def ObjectiveBound(self):
3708        return _pywrapcp.Assignment_ObjectiveBound(self)
def SetObjectiveMin(self, m):
3710    def SetObjectiveMin(self, m):
3711        return _pywrapcp.Assignment_SetObjectiveMin(self, m)
def SetObjectiveMax(self, m):
3713    def SetObjectiveMax(self, m):
3714        return _pywrapcp.Assignment_SetObjectiveMax(self, m)
def SetObjectiveValue(self, value):
3716    def SetObjectiveValue(self, value):
3717        return _pywrapcp.Assignment_SetObjectiveValue(self, value)
def SetObjectiveRange(self, l, u):
3719    def SetObjectiveRange(self, l, u):
3720        return _pywrapcp.Assignment_SetObjectiveRange(self, l, u)
def Min(self, var):
3722    def Min(self, var):
3723        return _pywrapcp.Assignment_Min(self, var)
def Max(self, var):
3725    def Max(self, var):
3726        return _pywrapcp.Assignment_Max(self, var)
def Value(self, var):
3728    def Value(self, var):
3729        return _pywrapcp.Assignment_Value(self, var)
def Bound(self, var):
3731    def Bound(self, var):
3732        return _pywrapcp.Assignment_Bound(self, var)
def SetMin(self, var, m):
3734    def SetMin(self, var, m):
3735        return _pywrapcp.Assignment_SetMin(self, var, m)
def SetMax(self, var, m):
3737    def SetMax(self, var, m):
3738        return _pywrapcp.Assignment_SetMax(self, var, m)
def SetRange(self, var, l, u):
3740    def SetRange(self, var, l, u):
3741        return _pywrapcp.Assignment_SetRange(self, var, l, u)
def SetValue(self, var, value):
3743    def SetValue(self, var, value):
3744        return _pywrapcp.Assignment_SetValue(self, var, value)
def StartMin(self, var):
3746    def StartMin(self, var):
3747        return _pywrapcp.Assignment_StartMin(self, var)
def StartMax(self, var):
3749    def StartMax(self, var):
3750        return _pywrapcp.Assignment_StartMax(self, var)
def StartValue(self, var):
3752    def StartValue(self, var):
3753        return _pywrapcp.Assignment_StartValue(self, var)
def DurationMin(self, var):
3755    def DurationMin(self, var):
3756        return _pywrapcp.Assignment_DurationMin(self, var)
def DurationMax(self, var):
3758    def DurationMax(self, var):
3759        return _pywrapcp.Assignment_DurationMax(self, var)
def DurationValue(self, var):
3761    def DurationValue(self, var):
3762        return _pywrapcp.Assignment_DurationValue(self, var)
def EndMin(self, var):
3764    def EndMin(self, var):
3765        return _pywrapcp.Assignment_EndMin(self, var)
def EndMax(self, var):
3767    def EndMax(self, var):
3768        return _pywrapcp.Assignment_EndMax(self, var)
def EndValue(self, var):
3770    def EndValue(self, var):
3771        return _pywrapcp.Assignment_EndValue(self, var)
def PerformedMin(self, var):
3773    def PerformedMin(self, var):
3774        return _pywrapcp.Assignment_PerformedMin(self, var)
def PerformedMax(self, var):
3776    def PerformedMax(self, var):
3777        return _pywrapcp.Assignment_PerformedMax(self, var)
def PerformedValue(self, var):
3779    def PerformedValue(self, var):
3780        return _pywrapcp.Assignment_PerformedValue(self, var)
def SetStartMin(self, var, m):
3782    def SetStartMin(self, var, m):
3783        return _pywrapcp.Assignment_SetStartMin(self, var, m)
def SetStartMax(self, var, m):
3785    def SetStartMax(self, var, m):
3786        return _pywrapcp.Assignment_SetStartMax(self, var, m)
def SetStartRange(self, var, mi, ma):
3788    def SetStartRange(self, var, mi, ma):
3789        return _pywrapcp.Assignment_SetStartRange(self, var, mi, ma)
def SetStartValue(self, var, value):
3791    def SetStartValue(self, var, value):
3792        return _pywrapcp.Assignment_SetStartValue(self, var, value)
def SetDurationMin(self, var, m):
3794    def SetDurationMin(self, var, m):
3795        return _pywrapcp.Assignment_SetDurationMin(self, var, m)
def SetDurationMax(self, var, m):
3797    def SetDurationMax(self, var, m):
3798        return _pywrapcp.Assignment_SetDurationMax(self, var, m)
def SetDurationRange(self, var, mi, ma):
3800    def SetDurationRange(self, var, mi, ma):
3801        return _pywrapcp.Assignment_SetDurationRange(self, var, mi, ma)
def SetDurationValue(self, var, value):
3803    def SetDurationValue(self, var, value):
3804        return _pywrapcp.Assignment_SetDurationValue(self, var, value)
def SetEndMin(self, var, m):
3806    def SetEndMin(self, var, m):
3807        return _pywrapcp.Assignment_SetEndMin(self, var, m)
def SetEndMax(self, var, m):
3809    def SetEndMax(self, var, m):
3810        return _pywrapcp.Assignment_SetEndMax(self, var, m)
def SetEndRange(self, var, mi, ma):
3812    def SetEndRange(self, var, mi, ma):
3813        return _pywrapcp.Assignment_SetEndRange(self, var, mi, ma)
def SetEndValue(self, var, value):
3815    def SetEndValue(self, var, value):
3816        return _pywrapcp.Assignment_SetEndValue(self, var, value)
def SetPerformedMin(self, var, m):
3818    def SetPerformedMin(self, var, m):
3819        return _pywrapcp.Assignment_SetPerformedMin(self, var, m)
def SetPerformedMax(self, var, m):
3821    def SetPerformedMax(self, var, m):
3822        return _pywrapcp.Assignment_SetPerformedMax(self, var, m)
def SetPerformedRange(self, var, mi, ma):
3824    def SetPerformedRange(self, var, mi, ma):
3825        return _pywrapcp.Assignment_SetPerformedRange(self, var, mi, ma)
def SetPerformedValue(self, var, value):
3827    def SetPerformedValue(self, var, value):
3828        return _pywrapcp.Assignment_SetPerformedValue(self, var, value)
def Add(self, *args):
3830    def Add(self, *args):
3831        return _pywrapcp.Assignment_Add(self, *args)
def ForwardSequence(self, var):
3833    def ForwardSequence(self, var):
3834        return _pywrapcp.Assignment_ForwardSequence(self, var)
def BackwardSequence(self, var):
3836    def BackwardSequence(self, var):
3837        return _pywrapcp.Assignment_BackwardSequence(self, var)
def Unperformed(self, var):
3839    def Unperformed(self, var):
3840        return _pywrapcp.Assignment_Unperformed(self, var)
def SetSequence(self, var, forward_sequence, backward_sequence, unperformed):
3842    def SetSequence(self, var, forward_sequence, backward_sequence, unperformed):
3843        return _pywrapcp.Assignment_SetSequence(self, var, forward_sequence, backward_sequence, unperformed)
def SetForwardSequence(self, var, forward_sequence):
3845    def SetForwardSequence(self, var, forward_sequence):
3846        return _pywrapcp.Assignment_SetForwardSequence(self, var, forward_sequence)
def SetBackwardSequence(self, var, backward_sequence):
3848    def SetBackwardSequence(self, var, backward_sequence):
3849        return _pywrapcp.Assignment_SetBackwardSequence(self, var, backward_sequence)
def SetUnperformed(self, var, unperformed):
3851    def SetUnperformed(self, var, unperformed):
3852        return _pywrapcp.Assignment_SetUnperformed(self, var, unperformed)
def Activate(self, *args):
3854    def Activate(self, *args):
3855        return _pywrapcp.Assignment_Activate(self, *args)
def Deactivate(self, *args):
3857    def Deactivate(self, *args):
3858        return _pywrapcp.Assignment_Deactivate(self, *args)
def Activated(self, *args):
3860    def Activated(self, *args):
3861        return _pywrapcp.Assignment_Activated(self, *args)
def DebugString(self):
3863    def DebugString(self):
3864        return _pywrapcp.Assignment_DebugString(self)
def IntVarContainer(self):
3866    def IntVarContainer(self):
3867        return _pywrapcp.Assignment_IntVarContainer(self)
def MutableIntVarContainer(self):
3869    def MutableIntVarContainer(self):
3870        return _pywrapcp.Assignment_MutableIntVarContainer(self)
def IntervalVarContainer(self):
3872    def IntervalVarContainer(self):
3873        return _pywrapcp.Assignment_IntervalVarContainer(self)
def MutableIntervalVarContainer(self):
3875    def MutableIntervalVarContainer(self):
3876        return _pywrapcp.Assignment_MutableIntervalVarContainer(self)
def SequenceVarContainer(self):
3878    def SequenceVarContainer(self):
3879        return _pywrapcp.Assignment_SequenceVarContainer(self)
def MutableSequenceVarContainer(self):
3881    def MutableSequenceVarContainer(self):
3882        return _pywrapcp.Assignment_MutableSequenceVarContainer(self)
Inherited Members
PropagationBaseObject
solver
Name
class Pack(Constraint):
3895class Pack(Constraint):
3896    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3897
3898    def __init__(self, *args, **kwargs):
3899        raise AttributeError("No constructor defined")
3900    __repr__ = _swig_repr
3901
3902    def AddWeightedSumLessOrEqualConstantDimension(self, *args):
3903        r"""
3904        *Overload 1:*
3905        Dimensions are additional constraints than can restrict what is
3906        possible with the pack constraint. It can be used to set capacity
3907        limits, to count objects per bin, to compute unassigned
3908        penalties...
3909        This dimension imposes that for all bins b, the weighted sum
3910        (weights[i]) of all objects i assigned to 'b' is less or equal
3911        'bounds[b]'.
3912
3913        |
3914
3915        *Overload 2:*
3916        This dimension imposes that for all bins b, the weighted sum
3917        (weights->Run(i)) of all objects i assigned to 'b' is less or
3918        equal to 'bounds[b]'. Ownership of the callback is transferred to
3919        the pack constraint.
3920
3921        |
3922
3923        *Overload 3:*
3924        This dimension imposes that for all bins b, the weighted sum
3925        (weights->Run(i, b) of all objects i assigned to 'b' is less or
3926        equal to 'bounds[b]'. Ownership of the callback is transferred to
3927        the pack constraint.
3928        """
3929        return _pywrapcp.Pack_AddWeightedSumLessOrEqualConstantDimension(self, *args)
3930
3931    def AddWeightedSumEqualVarDimension(self, *args):
3932        r"""
3933        *Overload 1:*
3934        This dimension imposes that for all bins b, the weighted sum
3935        (weights[i]) of all objects i assigned to 'b' is equal to loads[b].
3936
3937        |
3938
3939        *Overload 2:*
3940        This dimension imposes that for all bins b, the weighted sum
3941        (weights->Run(i, b)) of all objects i assigned to 'b' is equal to
3942        loads[b].
3943        """
3944        return _pywrapcp.Pack_AddWeightedSumEqualVarDimension(self, *args)
3945
3946    def AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity):
3947        r"""
3948        This dimension imposes:
3949        forall b in bins,
3950           sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b]
3951        where is_assigned(i, b) is true if and only if item i is assigned
3952        to the bin b.
3953
3954        This can be used to model shapes of items by linking variables of
3955        the same item on parallel dimensions with an allowed assignment
3956        constraint.
3957        """
3958        return _pywrapcp.Pack_AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity)
3959
3960    def AddWeightedSumOfAssignedDimension(self, weights, cost_var):
3961        r"""
3962        This dimension enforces that cost_var == sum of weights[i] for
3963        all objects 'i' assigned to a bin.
3964        """
3965        return _pywrapcp.Pack_AddWeightedSumOfAssignedDimension(self, weights, cost_var)
3966
3967    def AddCountUsedBinDimension(self, count_var):
3968        r"""
3969        This dimension links 'count_var' to the actual number of bins used in the
3970        pack.
3971        """
3972        return _pywrapcp.Pack_AddCountUsedBinDimension(self, count_var)
3973
3974    def AddCountAssignedItemsDimension(self, count_var):
3975        r"""
3976        This dimension links 'count_var' to the actual number of items
3977        assigned to a bin in the pack.
3978        """
3979        return _pywrapcp.Pack_AddCountAssignedItemsDimension(self, count_var)
3980
3981    def Post(self):
3982        return _pywrapcp.Pack_Post(self)
3983
3984    def InitialPropagateWrapper(self):
3985        return _pywrapcp.Pack_InitialPropagateWrapper(self)
3986
3987    def DebugString(self):
3988        return _pywrapcp.Pack_DebugString(self)

A constraint is the main modeling object. It provides two methods:

  • Post() is responsible for creating the demons and attaching them to immediate demons().
  • InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
Pack(*args, **kwargs)
3898    def __init__(self, *args, **kwargs):
3899        raise AttributeError("No constructor defined")
thisown
3896    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def AddWeightedSumLessOrEqualConstantDimension(self, *args):
3902    def AddWeightedSumLessOrEqualConstantDimension(self, *args):
3903        r"""
3904        *Overload 1:*
3905        Dimensions are additional constraints than can restrict what is
3906        possible with the pack constraint. It can be used to set capacity
3907        limits, to count objects per bin, to compute unassigned
3908        penalties...
3909        This dimension imposes that for all bins b, the weighted sum
3910        (weights[i]) of all objects i assigned to 'b' is less or equal
3911        'bounds[b]'.
3912
3913        |
3914
3915        *Overload 2:*
3916        This dimension imposes that for all bins b, the weighted sum
3917        (weights->Run(i)) of all objects i assigned to 'b' is less or
3918        equal to 'bounds[b]'. Ownership of the callback is transferred to
3919        the pack constraint.
3920
3921        |
3922
3923        *Overload 3:*
3924        This dimension imposes that for all bins b, the weighted sum
3925        (weights->Run(i, b) of all objects i assigned to 'b' is less or
3926        equal to 'bounds[b]'. Ownership of the callback is transferred to
3927        the pack constraint.
3928        """
3929        return _pywrapcp.Pack_AddWeightedSumLessOrEqualConstantDimension(self, *args)

Overload 1: Dimensions are additional constraints than can restrict what is possible with the pack constraint. It can be used to set capacity limits, to count objects per bin, to compute unassigned penalties... This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is less or equal 'bounds[b]'.

|

Overload 2: This dimension imposes that for all bins b, the weighted sum (weights->Run(i)) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint.

|

Overload 3: This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b) of all objects i assigned to 'b' is less or equal to 'bounds[b]'. Ownership of the callback is transferred to the pack constraint.

def AddWeightedSumEqualVarDimension(self, *args):
3931    def AddWeightedSumEqualVarDimension(self, *args):
3932        r"""
3933        *Overload 1:*
3934        This dimension imposes that for all bins b, the weighted sum
3935        (weights[i]) of all objects i assigned to 'b' is equal to loads[b].
3936
3937        |
3938
3939        *Overload 2:*
3940        This dimension imposes that for all bins b, the weighted sum
3941        (weights->Run(i, b)) of all objects i assigned to 'b' is equal to
3942        loads[b].
3943        """
3944        return _pywrapcp.Pack_AddWeightedSumEqualVarDimension(self, *args)

Overload 1: This dimension imposes that for all bins b, the weighted sum (weights[i]) of all objects i assigned to 'b' is equal to loads[b].

|

Overload 2: This dimension imposes that for all bins b, the weighted sum (weights->Run(i, b)) of all objects i assigned to 'b' is equal to loads[b].

def AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity):
3946    def AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity):
3947        r"""
3948        This dimension imposes:
3949        forall b in bins,
3950           sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b]
3951        where is_assigned(i, b) is true if and only if item i is assigned
3952        to the bin b.
3953
3954        This can be used to model shapes of items by linking variables of
3955        the same item on parallel dimensions with an allowed assignment
3956        constraint.
3957        """
3958        return _pywrapcp.Pack_AddSumVariableWeightsLessOrEqualConstantDimension(self, usage, capacity)

This dimension imposes: forall b in bins, sum (i in items: usage[i] * is_assigned(i, b)) <= capacity[b] where is_assigned(i, b) is true if and only if item i is assigned to the bin b.

This can be used to model shapes of items by linking variables of the same item on parallel dimensions with an allowed assignment constraint.

def AddWeightedSumOfAssignedDimension(self, weights, cost_var):
3960    def AddWeightedSumOfAssignedDimension(self, weights, cost_var):
3961        r"""
3962        This dimension enforces that cost_var == sum of weights[i] for
3963        all objects 'i' assigned to a bin.
3964        """
3965        return _pywrapcp.Pack_AddWeightedSumOfAssignedDimension(self, weights, cost_var)

This dimension enforces that cost_var == sum of weights[i] for all objects 'i' assigned to a bin.

def AddCountUsedBinDimension(self, count_var):
3967    def AddCountUsedBinDimension(self, count_var):
3968        r"""
3969        This dimension links 'count_var' to the actual number of bins used in the
3970        pack.
3971        """
3972        return _pywrapcp.Pack_AddCountUsedBinDimension(self, count_var)

This dimension links 'count_var' to the actual number of bins used in the pack.

def AddCountAssignedItemsDimension(self, count_var):
3974    def AddCountAssignedItemsDimension(self, count_var):
3975        r"""
3976        This dimension links 'count_var' to the actual number of items
3977        assigned to a bin in the pack.
3978        """
3979        return _pywrapcp.Pack_AddCountAssignedItemsDimension(self, count_var)

This dimension links 'count_var' to the actual number of items assigned to a bin in the pack.

def Post(self):
3981    def Post(self):
3982        return _pywrapcp.Pack_Post(self)

This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.

def InitialPropagateWrapper(self):
3984    def InitialPropagateWrapper(self):
3985        return _pywrapcp.Pack_InitialPropagateWrapper(self)

This method performs the initial propagation of the constraint. It is called just after the post.

def DebugString(self):
3987    def DebugString(self):
3988        return _pywrapcp.Pack_DebugString(self)
class DisjunctiveConstraint(Constraint):
3992class DisjunctiveConstraint(Constraint):
3993    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
3994
3995    def __init__(self, *args, **kwargs):
3996        raise AttributeError("No constructor defined - class is abstract")
3997    __repr__ = _swig_repr
3998
3999    def SequenceVar(self):
4000        r"""Creates a sequence variable from the constraint."""
4001        return _pywrapcp.DisjunctiveConstraint_SequenceVar(self)
4002
4003    def SetTransitionTime(self, transition_time):
4004        r"""
4005        Add a transition time between intervals.  It forces the distance between
4006        the end of interval a and start of interval b that follows it to be at
4007        least transition_time(a, b). This function must always return
4008        a positive or null value.
4009        """
4010        return _pywrapcp.DisjunctiveConstraint_SetTransitionTime(self, transition_time)
4011
4012    def TransitionTime(self, before_index, after_index):
4013        return _pywrapcp.DisjunctiveConstraint_TransitionTime(self, before_index, after_index)

A constraint is the main modeling object. It provides two methods:

  • Post() is responsible for creating the demons and attaching them to immediate demons().
  • InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
DisjunctiveConstraint(*args, **kwargs)
3995    def __init__(self, *args, **kwargs):
3996        raise AttributeError("No constructor defined - class is abstract")
thisown
3993    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def SequenceVar(self):
3999    def SequenceVar(self):
4000        r"""Creates a sequence variable from the constraint."""
4001        return _pywrapcp.DisjunctiveConstraint_SequenceVar(self)

Creates a sequence variable from the constraint.

def SetTransitionTime(self, transition_time):
4003    def SetTransitionTime(self, transition_time):
4004        r"""
4005        Add a transition time between intervals.  It forces the distance between
4006        the end of interval a and start of interval b that follows it to be at
4007        least transition_time(a, b). This function must always return
4008        a positive or null value.
4009        """
4010        return _pywrapcp.DisjunctiveConstraint_SetTransitionTime(self, transition_time)

Add a transition time between intervals. It forces the distance between the end of interval a and start of interval b that follows it to be at least transition_time(a, b). This function must always return a positive or null value.

def TransitionTime(self, before_index, after_index):
4012    def TransitionTime(self, before_index, after_index):
4013        return _pywrapcp.DisjunctiveConstraint_TransitionTime(self, before_index, after_index)
class RevInteger:
4017class RevInteger(object):
4018    r"""
4019    This class adds reversibility to a POD type.
4020    It contains the stamp optimization. i.e. the SaveValue call is done
4021    only once per node of the search tree.  Please note that actual
4022    stamps always starts at 1, thus an initial value of 0 will always
4023    trigger the first SaveValue.
4024    """
4025
4026    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4027    __repr__ = _swig_repr
4028
4029    def __init__(self, val):
4030        _pywrapcp.RevInteger_swiginit(self, _pywrapcp.new_RevInteger(val))
4031
4032    def Value(self):
4033        return _pywrapcp.RevInteger_Value(self)
4034
4035    def SetValue(self, s, val):
4036        return _pywrapcp.RevInteger_SetValue(self, s, val)
4037    __swig_destroy__ = _pywrapcp.delete_RevInteger

This class adds reversibility to a POD type. It contains the stamp optimization. i.e. the SaveValue call is done only once per node of the search tree. Please note that actual stamps always starts at 1, thus an initial value of 0 will always trigger the first SaveValue.

RevInteger(val)
4029    def __init__(self, val):
4030        _pywrapcp.RevInteger_swiginit(self, _pywrapcp.new_RevInteger(val))
thisown
4026    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Value(self):
4032    def Value(self):
4033        return _pywrapcp.RevInteger_Value(self)
def SetValue(self, s, val):
4035    def SetValue(self, s, val):
4036        return _pywrapcp.RevInteger_SetValue(self, s, val)
class NumericalRevInteger(RevInteger):
4041class NumericalRevInteger(RevInteger):
4042    r"""Subclass of Rev<T> which adds numerical operations."""
4043
4044    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4045    __repr__ = _swig_repr
4046
4047    def __init__(self, val):
4048        _pywrapcp.NumericalRevInteger_swiginit(self, _pywrapcp.new_NumericalRevInteger(val))
4049
4050    def Add(self, s, to_add):
4051        return _pywrapcp.NumericalRevInteger_Add(self, s, to_add)
4052
4053    def Incr(self, s):
4054        return _pywrapcp.NumericalRevInteger_Incr(self, s)
4055
4056    def Decr(self, s):
4057        return _pywrapcp.NumericalRevInteger_Decr(self, s)
4058    __swig_destroy__ = _pywrapcp.delete_NumericalRevInteger

Subclass of Rev which adds numerical operations.

NumericalRevInteger(val)
4047    def __init__(self, val):
4048        _pywrapcp.NumericalRevInteger_swiginit(self, _pywrapcp.new_NumericalRevInteger(val))
thisown
4044    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Add(self, s, to_add):
4050    def Add(self, s, to_add):
4051        return _pywrapcp.NumericalRevInteger_Add(self, s, to_add)
def Incr(self, s):
4053    def Incr(self, s):
4054        return _pywrapcp.NumericalRevInteger_Incr(self, s)
def Decr(self, s):
4056    def Decr(self, s):
4057        return _pywrapcp.NumericalRevInteger_Decr(self, s)
Inherited Members
RevInteger
Value
SetValue
class RevBool:
4062class RevBool(object):
4063    r"""
4064    This class adds reversibility to a POD type.
4065    It contains the stamp optimization. i.e. the SaveValue call is done
4066    only once per node of the search tree.  Please note that actual
4067    stamps always starts at 1, thus an initial value of 0 will always
4068    trigger the first SaveValue.
4069    """
4070
4071    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4072    __repr__ = _swig_repr
4073
4074    def __init__(self, val):
4075        _pywrapcp.RevBool_swiginit(self, _pywrapcp.new_RevBool(val))
4076
4077    def Value(self):
4078        return _pywrapcp.RevBool_Value(self)
4079
4080    def SetValue(self, s, val):
4081        return _pywrapcp.RevBool_SetValue(self, s, val)
4082    __swig_destroy__ = _pywrapcp.delete_RevBool

This class adds reversibility to a POD type. It contains the stamp optimization. i.e. the SaveValue call is done only once per node of the search tree. Please note that actual stamps always starts at 1, thus an initial value of 0 will always trigger the first SaveValue.

RevBool(val)
4074    def __init__(self, val):
4075        _pywrapcp.RevBool_swiginit(self, _pywrapcp.new_RevBool(val))
thisown
4071    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Value(self):
4077    def Value(self):
4078        return _pywrapcp.RevBool_Value(self)
def SetValue(self, s, val):
4080    def SetValue(self, s, val):
4081        return _pywrapcp.RevBool_SetValue(self, s, val)
class IntVarContainer:
4086class IntVarContainer(object):
4087    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4088
4089    def __init__(self, *args, **kwargs):
4090        raise AttributeError("No constructor defined")
4091    __repr__ = _swig_repr
4092
4093    def Contains(self, var):
4094        return _pywrapcp.IntVarContainer_Contains(self, var)
4095
4096    def Element(self, index):
4097        return _pywrapcp.IntVarContainer_Element(self, index)
4098
4099    def Size(self):
4100        return _pywrapcp.IntVarContainer_Size(self)
4101
4102    def Store(self):
4103        return _pywrapcp.IntVarContainer_Store(self)
4104
4105    def Restore(self):
4106        return _pywrapcp.IntVarContainer_Restore(self)
4107
4108    def __eq__(self, container):
4109        r"""
4110        Returns true if this and 'container' both represent the same V* -> E map.
4111        Runs in linear time; requires that the == operator on the type E is well
4112        defined.
4113        """
4114        return _pywrapcp.IntVarContainer___eq__(self, container)
4115
4116    def __ne__(self, container):
4117        return _pywrapcp.IntVarContainer___ne__(self, container)
4118    __swig_destroy__ = _pywrapcp.delete_IntVarContainer
IntVarContainer(*args, **kwargs)
4089    def __init__(self, *args, **kwargs):
4090        raise AttributeError("No constructor defined")
thisown
4087    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Contains(self, var):
4093    def Contains(self, var):
4094        return _pywrapcp.IntVarContainer_Contains(self, var)
def Element(self, index):
4096    def Element(self, index):
4097        return _pywrapcp.IntVarContainer_Element(self, index)
def Size(self):
4099    def Size(self):
4100        return _pywrapcp.IntVarContainer_Size(self)
def Store(self):
4102    def Store(self):
4103        return _pywrapcp.IntVarContainer_Store(self)
def Restore(self):
4105    def Restore(self):
4106        return _pywrapcp.IntVarContainer_Restore(self)
class IntervalVarContainer:
4122class IntervalVarContainer(object):
4123    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4124
4125    def __init__(self, *args, **kwargs):
4126        raise AttributeError("No constructor defined")
4127    __repr__ = _swig_repr
4128
4129    def Contains(self, var):
4130        return _pywrapcp.IntervalVarContainer_Contains(self, var)
4131
4132    def Element(self, index):
4133        return _pywrapcp.IntervalVarContainer_Element(self, index)
4134
4135    def Size(self):
4136        return _pywrapcp.IntervalVarContainer_Size(self)
4137
4138    def Store(self):
4139        return _pywrapcp.IntervalVarContainer_Store(self)
4140
4141    def Restore(self):
4142        return _pywrapcp.IntervalVarContainer_Restore(self)
4143
4144    def __eq__(self, container):
4145        r"""
4146        Returns true if this and 'container' both represent the same V* -> E map.
4147        Runs in linear time; requires that the == operator on the type E is well
4148        defined.
4149        """
4150        return _pywrapcp.IntervalVarContainer___eq__(self, container)
4151
4152    def __ne__(self, container):
4153        return _pywrapcp.IntervalVarContainer___ne__(self, container)
4154    __swig_destroy__ = _pywrapcp.delete_IntervalVarContainer
IntervalVarContainer(*args, **kwargs)
4125    def __init__(self, *args, **kwargs):
4126        raise AttributeError("No constructor defined")
thisown
4123    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Contains(self, var):
4129    def Contains(self, var):
4130        return _pywrapcp.IntervalVarContainer_Contains(self, var)
def Element(self, index):
4132    def Element(self, index):
4133        return _pywrapcp.IntervalVarContainer_Element(self, index)
def Size(self):
4135    def Size(self):
4136        return _pywrapcp.IntervalVarContainer_Size(self)
def Store(self):
4138    def Store(self):
4139        return _pywrapcp.IntervalVarContainer_Store(self)
def Restore(self):
4141    def Restore(self):
4142        return _pywrapcp.IntervalVarContainer_Restore(self)
class SequenceVarContainer:
4158class SequenceVarContainer(object):
4159    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4160
4161    def __init__(self, *args, **kwargs):
4162        raise AttributeError("No constructor defined")
4163    __repr__ = _swig_repr
4164
4165    def Contains(self, var):
4166        return _pywrapcp.SequenceVarContainer_Contains(self, var)
4167
4168    def Element(self, index):
4169        return _pywrapcp.SequenceVarContainer_Element(self, index)
4170
4171    def Size(self):
4172        return _pywrapcp.SequenceVarContainer_Size(self)
4173
4174    def Store(self):
4175        return _pywrapcp.SequenceVarContainer_Store(self)
4176
4177    def Restore(self):
4178        return _pywrapcp.SequenceVarContainer_Restore(self)
4179
4180    def __eq__(self, container):
4181        r"""
4182        Returns true if this and 'container' both represent the same V* -> E map.
4183        Runs in linear time; requires that the == operator on the type E is well
4184        defined.
4185        """
4186        return _pywrapcp.SequenceVarContainer___eq__(self, container)
4187
4188    def __ne__(self, container):
4189        return _pywrapcp.SequenceVarContainer___ne__(self, container)
4190    __swig_destroy__ = _pywrapcp.delete_SequenceVarContainer
SequenceVarContainer(*args, **kwargs)
4161    def __init__(self, *args, **kwargs):
4162        raise AttributeError("No constructor defined")
thisown
4159    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Contains(self, var):
4165    def Contains(self, var):
4166        return _pywrapcp.SequenceVarContainer_Contains(self, var)
def Element(self, index):
4168    def Element(self, index):
4169        return _pywrapcp.SequenceVarContainer_Element(self, index)
def Size(self):
4171    def Size(self):
4172        return _pywrapcp.SequenceVarContainer_Size(self)
def Store(self):
4174    def Store(self):
4175        return _pywrapcp.SequenceVarContainer_Store(self)
def Restore(self):
4177    def Restore(self):
4178        return _pywrapcp.SequenceVarContainer_Restore(self)
class LocalSearchOperator(BaseObject):
4194class LocalSearchOperator(BaseObject):
4195    r"""
4196    The base class for all local search operators.
4197
4198    A local search operator is an object that defines the neighborhood of a
4199    solution. In other words, a neighborhood is the set of solutions which can
4200    be reached from a given solution using an operator.
4201
4202    The behavior of the LocalSearchOperator class is similar to iterators.
4203    The operator is synchronized with an assignment (gives the
4204    current values of the variables); this is done in the Start() method.
4205
4206    Then one can iterate over the neighbors using the MakeNextNeighbor method.
4207    This method returns an assignment which represents the incremental changes
4208    to the current solution. It also returns a second assignment representing
4209    the changes to the last solution defined by the neighborhood operator; this
4210    assignment is empty if the neighborhood operator cannot track this
4211    information.
4212    """
4213
4214    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4215
4216    def __init__(self, *args, **kwargs):
4217        raise AttributeError("No constructor defined - class is abstract")
4218    __repr__ = _swig_repr
4219
4220    def NextNeighbor(self, delta, deltadelta):
4221        return _pywrapcp.LocalSearchOperator_NextNeighbor(self, delta, deltadelta)
4222
4223    def Start(self, assignment):
4224        return _pywrapcp.LocalSearchOperator_Start(self, assignment)
4225    def __disown__(self):
4226        self.this.disown()
4227        _pywrapcp.disown_LocalSearchOperator(self)
4228        return weakref.proxy(self)

The base class for all local search operators.

A local search operator is an object that defines the neighborhood of a solution. In other words, a neighborhood is the set of solutions which can be reached from a given solution using an operator.

The behavior of the LocalSearchOperator class is similar to iterators. The operator is synchronized with an assignment (gives the current values of the variables); this is done in the Start() method.

Then one can iterate over the neighbors using the MakeNextNeighbor method. This method returns an assignment which represents the incremental changes to the current solution. It also returns a second assignment representing the changes to the last solution defined by the neighborhood operator; this assignment is empty if the neighborhood operator cannot track this information.

LocalSearchOperator(*args, **kwargs)
4216    def __init__(self, *args, **kwargs):
4217        raise AttributeError("No constructor defined - class is abstract")
thisown
4214    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def NextNeighbor(self, delta, deltadelta):
4220    def NextNeighbor(self, delta, deltadelta):
4221        return _pywrapcp.LocalSearchOperator_NextNeighbor(self, delta, deltadelta)
def Start(self, assignment):
4223    def Start(self, assignment):
4224        return _pywrapcp.LocalSearchOperator_Start(self, assignment)
Inherited Members
BaseObject
DebugString
class IntVarLocalSearchOperator(LocalSearchOperator):
4232class IntVarLocalSearchOperator(LocalSearchOperator):
4233    r"""
4234    Specialization of LocalSearchOperator built from an array of IntVars
4235    which specifies the scope of the operator.
4236    This class also takes care of storing current variable values in Start(),
4237    keeps track of changes done by the operator and builds the delta.
4238    The Deactivate() method can be used to perform Large Neighborhood Search.
4239    """
4240
4241    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4242    __repr__ = _swig_repr
4243
4244    def __init__(self, vars, keep_inverse_values=False):
4245        if self.__class__ == IntVarLocalSearchOperator:
4246            _self = None
4247        else:
4248            _self = self
4249        _pywrapcp.IntVarLocalSearchOperator_swiginit(self, _pywrapcp.new_IntVarLocalSearchOperator(_self, vars, keep_inverse_values))
4250    __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchOperator
4251
4252    def Start(self, assignment):
4253        r"""
4254        This method should not be overridden. Override OnStart() instead which is
4255        called before exiting this method.
4256        """
4257        return _pywrapcp.IntVarLocalSearchOperator_Start(self, assignment)
4258
4259    def IsIncremental(self):
4260        return _pywrapcp.IntVarLocalSearchOperator_IsIncremental(self)
4261
4262    def Size(self):
4263        return _pywrapcp.IntVarLocalSearchOperator_Size(self)
4264
4265    def Value(self, index):
4266        r"""
4267        Returns the value in the current assignment of the variable of given
4268        index.
4269        """
4270        return _pywrapcp.IntVarLocalSearchOperator_Value(self, index)
4271
4272    def Var(self, index):
4273        r"""Returns the variable of given index."""
4274        return _pywrapcp.IntVarLocalSearchOperator_Var(self, index)
4275
4276    def OldValue(self, index):
4277        return _pywrapcp.IntVarLocalSearchOperator_OldValue(self, index)
4278
4279    def PrevValue(self, index):
4280        return _pywrapcp.IntVarLocalSearchOperator_PrevValue(self, index)
4281
4282    def SetValue(self, index, value):
4283        return _pywrapcp.IntVarLocalSearchOperator_SetValue(self, index, value)
4284
4285    def Activated(self, index):
4286        return _pywrapcp.IntVarLocalSearchOperator_Activated(self, index)
4287
4288    def Activate(self, index):
4289        return _pywrapcp.IntVarLocalSearchOperator_Activate(self, index)
4290
4291    def Deactivate(self, index):
4292        return _pywrapcp.IntVarLocalSearchOperator_Deactivate(self, index)
4293
4294    def AddVars(self, vars):
4295        return _pywrapcp.IntVarLocalSearchOperator_AddVars(self, vars)
4296
4297    def OnStart(self):
4298        r"""
4299        Called by Start() after synchronizing the operator with the current
4300        assignment. Should be overridden instead of Start() to avoid calling
4301        IntVarLocalSearchOperator::Start explicitly.
4302        """
4303        return _pywrapcp.IntVarLocalSearchOperator_OnStart(self)
4304
4305    def NextNeighbor(self, delta, deltadelta):
4306        r"""
4307        OnStart() should really be protected, but then SWIG doesn't see it. So we
4308        make it public, but only subclasses should access to it (to override it).
4309        Redefines MakeNextNeighbor to export a simpler interface. The calls to
4310        ApplyChanges() and RevertChanges() are factored in this method, hiding
4311        both delta and deltadelta from subclasses which only need to override
4312        MakeOneNeighbor().
4313        Therefore this method should not be overridden. Override MakeOneNeighbor()
4314        instead.
4315        """
4316        return _pywrapcp.IntVarLocalSearchOperator_NextNeighbor(self, delta, deltadelta)
4317
4318    def OneNeighbor(self):
4319        r"""
4320        Creates a new neighbor. It returns false when the neighborhood is
4321        completely explored.
4322        MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.
4323        """
4324        return _pywrapcp.IntVarLocalSearchOperator_OneNeighbor(self)
4325    def __disown__(self):
4326        self.this.disown()
4327        _pywrapcp.disown_IntVarLocalSearchOperator(self)
4328        return weakref.proxy(self)

Specialization of LocalSearchOperator built from an array of IntVars which specifies the scope of the operator. This class also takes care of storing current variable values in Start(), keeps track of changes done by the operator and builds the delta. The Deactivate() method can be used to perform Large Neighborhood Search.

IntVarLocalSearchOperator(vars, keep_inverse_values=False)
4244    def __init__(self, vars, keep_inverse_values=False):
4245        if self.__class__ == IntVarLocalSearchOperator:
4246            _self = None
4247        else:
4248            _self = self
4249        _pywrapcp.IntVarLocalSearchOperator_swiginit(self, _pywrapcp.new_IntVarLocalSearchOperator(_self, vars, keep_inverse_values))
thisown
4241    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Start(self, assignment):
4252    def Start(self, assignment):
4253        r"""
4254        This method should not be overridden. Override OnStart() instead which is
4255        called before exiting this method.
4256        """
4257        return _pywrapcp.IntVarLocalSearchOperator_Start(self, assignment)

This method should not be overridden. Override OnStart() instead which is called before exiting this method.

def IsIncremental(self):
4259    def IsIncremental(self):
4260        return _pywrapcp.IntVarLocalSearchOperator_IsIncremental(self)
def Size(self):
4262    def Size(self):
4263        return _pywrapcp.IntVarLocalSearchOperator_Size(self)
def Value(self, index):
4265    def Value(self, index):
4266        r"""
4267        Returns the value in the current assignment of the variable of given
4268        index.
4269        """
4270        return _pywrapcp.IntVarLocalSearchOperator_Value(self, index)

Returns the value in the current assignment of the variable of given index.

def Var(self, index):
4272    def Var(self, index):
4273        r"""Returns the variable of given index."""
4274        return _pywrapcp.IntVarLocalSearchOperator_Var(self, index)

Returns the variable of given index.

def OldValue(self, index):
4276    def OldValue(self, index):
4277        return _pywrapcp.IntVarLocalSearchOperator_OldValue(self, index)
def PrevValue(self, index):
4279    def PrevValue(self, index):
4280        return _pywrapcp.IntVarLocalSearchOperator_PrevValue(self, index)
def SetValue(self, index, value):
4282    def SetValue(self, index, value):
4283        return _pywrapcp.IntVarLocalSearchOperator_SetValue(self, index, value)
def Activated(self, index):
4285    def Activated(self, index):
4286        return _pywrapcp.IntVarLocalSearchOperator_Activated(self, index)
def Activate(self, index):
4288    def Activate(self, index):
4289        return _pywrapcp.IntVarLocalSearchOperator_Activate(self, index)
def Deactivate(self, index):
4291    def Deactivate(self, index):
4292        return _pywrapcp.IntVarLocalSearchOperator_Deactivate(self, index)
def AddVars(self, vars):
4294    def AddVars(self, vars):
4295        return _pywrapcp.IntVarLocalSearchOperator_AddVars(self, vars)
def OnStart(self):
4297    def OnStart(self):
4298        r"""
4299        Called by Start() after synchronizing the operator with the current
4300        assignment. Should be overridden instead of Start() to avoid calling
4301        IntVarLocalSearchOperator::Start explicitly.
4302        """
4303        return _pywrapcp.IntVarLocalSearchOperator_OnStart(self)

Called by Start() after synchronizing the operator with the current assignment. Should be overridden instead of Start() to avoid calling IntVarLocalSearchOperator::Start explicitly.

def NextNeighbor(self, delta, deltadelta):
4305    def NextNeighbor(self, delta, deltadelta):
4306        r"""
4307        OnStart() should really be protected, but then SWIG doesn't see it. So we
4308        make it public, but only subclasses should access to it (to override it).
4309        Redefines MakeNextNeighbor to export a simpler interface. The calls to
4310        ApplyChanges() and RevertChanges() are factored in this method, hiding
4311        both delta and deltadelta from subclasses which only need to override
4312        MakeOneNeighbor().
4313        Therefore this method should not be overridden. Override MakeOneNeighbor()
4314        instead.
4315        """
4316        return _pywrapcp.IntVarLocalSearchOperator_NextNeighbor(self, delta, deltadelta)

OnStart() should really be protected, but then SWIG doesn't see it. So we make it public, but only subclasses should access to it (to override it). Redefines MakeNextNeighbor to export a simpler interface. The calls to ApplyChanges() and RevertChanges() are factored in this method, hiding both delta and deltadelta from subclasses which only need to override MakeOneNeighbor(). Therefore this method should not be overridden. Override MakeOneNeighbor() instead.

def OneNeighbor(self):
4318    def OneNeighbor(self):
4319        r"""
4320        Creates a new neighbor. It returns false when the neighborhood is
4321        completely explored.
4322        MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.
4323        """
4324        return _pywrapcp.IntVarLocalSearchOperator_OneNeighbor(self)

Creates a new neighbor. It returns false when the neighborhood is completely explored. MakeNextNeighbor() in a subclass of IntVarLocalSearchOperator.

Inherited Members
BaseObject
DebugString
class BaseLns(IntVarLocalSearchOperator):
4332class BaseLns(IntVarLocalSearchOperator):
4333    r"""
4334    This is the base class for building an Lns operator. An Lns fragment is a
4335    collection of variables which will be relaxed. Fragments are built with
4336    NextFragment(), which returns false if there are no more fragments to build.
4337    Optionally one can override InitFragments, which is called from
4338    LocalSearchOperator::Start to initialize fragment data.
4339
4340    Here's a sample relaxing one variable at a time:
4341
4342    class OneVarLns : public BaseLns {
4343     public:
4344      OneVarLns(const std::vector<IntVar*>& vars) : BaseLns(vars), index_(0) {}
4345      virtual ~OneVarLns() {}
4346      virtual void InitFragments() { index_ = 0; }
4347      virtual bool NextFragment() {
4348        const int size = Size();
4349        if (index_ < size) {
4350          AppendToFragment(index_);
4351          ++index_;
4352          return true;
4353        } else {
4354          return false;
4355        }
4356      }
4357
4358     private:
4359      int index_;
4360    };
4361    """
4362
4363    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4364    __repr__ = _swig_repr
4365
4366    def __init__(self, vars):
4367        if self.__class__ == BaseLns:
4368            _self = None
4369        else:
4370            _self = self
4371        _pywrapcp.BaseLns_swiginit(self, _pywrapcp.new_BaseLns(_self, vars))
4372    __swig_destroy__ = _pywrapcp.delete_BaseLns
4373
4374    def InitFragments(self):
4375        return _pywrapcp.BaseLns_InitFragments(self)
4376
4377    def NextFragment(self):
4378        return _pywrapcp.BaseLns_NextFragment(self)
4379
4380    def AppendToFragment(self, index):
4381        return _pywrapcp.BaseLns_AppendToFragment(self, index)
4382
4383    def FragmentSize(self):
4384        return _pywrapcp.BaseLns_FragmentSize(self)
4385
4386    def __getitem__(self, index):
4387        return _pywrapcp.BaseLns___getitem__(self, index)
4388
4389    def __len__(self):
4390        return _pywrapcp.BaseLns___len__(self)
4391    def __disown__(self):
4392        self.this.disown()
4393        _pywrapcp.disown_BaseLns(self)
4394        return weakref.proxy(self)

This is the base class for building an Lns operator. An Lns fragment is a collection of variables which will be relaxed. Fragments are built with NextFragment(), which returns false if there are no more fragments to build. Optionally one can override InitFragments, which is called from LocalSearchOperator::Start to initialize fragment data.

Here's a sample relaxing one variable at a time:

class OneVarLns : public BaseLns { public: OneVarLns(const std::vector& vars) : BaseLns(vars), index_(0) {} virtual ~OneVarLns() {} virtual void InitFragments() { index_ = 0; } virtual bool NextFragment() { const int size = Size(); if (index_ < size) { AppendToFragment(index_); ++index_; return true; } else { return false; } }

private: int index_; };

BaseLns(vars)
4366    def __init__(self, vars):
4367        if self.__class__ == BaseLns:
4368            _self = None
4369        else:
4370            _self = self
4371        _pywrapcp.BaseLns_swiginit(self, _pywrapcp.new_BaseLns(_self, vars))
thisown
4363    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def InitFragments(self):
4374    def InitFragments(self):
4375        return _pywrapcp.BaseLns_InitFragments(self)
def NextFragment(self):
4377    def NextFragment(self):
4378        return _pywrapcp.BaseLns_NextFragment(self)
def AppendToFragment(self, index):
4380    def AppendToFragment(self, index):
4381        return _pywrapcp.BaseLns_AppendToFragment(self, index)
def FragmentSize(self):
4383    def FragmentSize(self):
4384        return _pywrapcp.BaseLns_FragmentSize(self)
class ChangeValue(IntVarLocalSearchOperator):
4398class ChangeValue(IntVarLocalSearchOperator):
4399    r"""
4400    Defines operators which change the value of variables;
4401    each neighbor corresponds to *one* modified variable.
4402    Sub-classes have to define ModifyValue which determines what the new
4403    variable value is going to be (given the current value and the variable).
4404    """
4405
4406    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4407    __repr__ = _swig_repr
4408
4409    def __init__(self, vars):
4410        if self.__class__ == ChangeValue:
4411            _self = None
4412        else:
4413            _self = self
4414        _pywrapcp.ChangeValue_swiginit(self, _pywrapcp.new_ChangeValue(_self, vars))
4415    __swig_destroy__ = _pywrapcp.delete_ChangeValue
4416
4417    def ModifyValue(self, index, value):
4418        return _pywrapcp.ChangeValue_ModifyValue(self, index, value)
4419
4420    def OneNeighbor(self):
4421        r"""This method should not be overridden. Override ModifyValue() instead."""
4422        return _pywrapcp.ChangeValue_OneNeighbor(self)
4423    def __disown__(self):
4424        self.this.disown()
4425        _pywrapcp.disown_ChangeValue(self)
4426        return weakref.proxy(self)

Defines operators which change the value of variables; each neighbor corresponds to one modified variable. Sub-classes have to define ModifyValue which determines what the new variable value is going to be (given the current value and the variable).

ChangeValue(vars)
4409    def __init__(self, vars):
4410        if self.__class__ == ChangeValue:
4411            _self = None
4412        else:
4413            _self = self
4414        _pywrapcp.ChangeValue_swiginit(self, _pywrapcp.new_ChangeValue(_self, vars))
thisown
4406    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def ModifyValue(self, index, value):
4417    def ModifyValue(self, index, value):
4418        return _pywrapcp.ChangeValue_ModifyValue(self, index, value)
def OneNeighbor(self):
4420    def OneNeighbor(self):
4421        r"""This method should not be overridden. Override ModifyValue() instead."""
4422        return _pywrapcp.ChangeValue_OneNeighbor(self)

This method should not be overridden. Override ModifyValue() instead.

class LocalSearchFilter(BaseObject):
4430class LocalSearchFilter(BaseObject):
4431    r"""
4432    Local Search Filters are used for fast neighbor pruning.
4433    Filtering a move is done in several phases:
4434    - in the Relax phase, filters determine which parts of their internals
4435      will be changed by the candidate, and modify intermediary State
4436    - in the Accept phase, filters check that the candidate is feasible,
4437    - if the Accept phase succeeds, the solver may decide to trigger a
4438      Synchronize phase that makes filters change their internal representation
4439      to the last candidate,
4440    - otherwise (Accept fails or the solver does not want to synchronize),
4441      a Revert phase makes filters erase any intermediary State generated by the
4442      Relax and Accept phases.
4443    A given filter has phases called with the following pattern:
4444    (Relax.Accept.Synchronize | Relax.Accept.Revert | Relax.Revert)*.
4445    Filters's Revert() is always called in the reverse order their Accept() was
4446    called, to allow late filters to use state done/undone by early filters'
4447    Accept()/Revert().
4448    """
4449
4450    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4451
4452    def __init__(self, *args, **kwargs):
4453        raise AttributeError("No constructor defined - class is abstract")
4454    __repr__ = _swig_repr
4455
4456    def Accept(self, delta, deltadelta, objective_min, objective_max):
4457        r"""
4458        Accepts a "delta" given the assignment with which the filter has been
4459        synchronized; the delta holds the variables which have been modified and
4460        their new value.
4461        If the filter represents a part of the global objective, its contribution
4462        must be between objective_min and objective_max.
4463        Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1,
4464        for the assignment (a,1), (b,0), the delta (b,1) will be rejected
4465        but the delta (a,0) will be accepted.
4466        TODO(user): Remove arguments when there are no more need for those.
4467        """
4468        return _pywrapcp.LocalSearchFilter_Accept(self, delta, deltadelta, objective_min, objective_max)
4469
4470    def IsIncremental(self):
4471        return _pywrapcp.LocalSearchFilter_IsIncremental(self)
4472
4473    def Synchronize(self, assignment, delta):
4474        r"""
4475        Synchronizes the filter with the current solution, delta being the
4476        difference with the solution passed to the previous call to Synchronize()
4477        or IncrementalSynchronize(). 'delta' can be used to incrementally
4478        synchronizing the filter with the new solution by only considering the
4479        changes in delta.
4480        """
4481        return _pywrapcp.LocalSearchFilter_Synchronize(self, assignment, delta)
4482    __swig_destroy__ = _pywrapcp.delete_LocalSearchFilter

Local Search Filters are used for fast neighbor pruning. Filtering a move is done in several phases:

  • in the Relax phase, filters determine which parts of their internals will be changed by the candidate, and modify intermediary State
  • in the Accept phase, filters check that the candidate is feasible,
  • if the Accept phase succeeds, the solver may decide to trigger a Synchronize phase that makes filters change their internal representation to the last candidate,
  • otherwise (Accept fails or the solver does not want to synchronize), a Revert phase makes filters erase any intermediary State generated by the Relax and Accept phases. A given filter has phases called with the following pattern: (Relax.Accept.Synchronize | Relax.Accept.Revert | Relax.Revert)*. Filters's Revert() is always called in the reverse order their Accept() was called, to allow late filters to use state done/undone by early filters' Accept()/Revert().
LocalSearchFilter(*args, **kwargs)
4452    def __init__(self, *args, **kwargs):
4453        raise AttributeError("No constructor defined - class is abstract")
thisown
4450    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Accept(self, delta, deltadelta, objective_min, objective_max):
4456    def Accept(self, delta, deltadelta, objective_min, objective_max):
4457        r"""
4458        Accepts a "delta" given the assignment with which the filter has been
4459        synchronized; the delta holds the variables which have been modified and
4460        their new value.
4461        If the filter represents a part of the global objective, its contribution
4462        must be between objective_min and objective_max.
4463        Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1,
4464        for the assignment (a,1), (b,0), the delta (b,1) will be rejected
4465        but the delta (a,0) will be accepted.
4466        TODO(user): Remove arguments when there are no more need for those.
4467        """
4468        return _pywrapcp.LocalSearchFilter_Accept(self, delta, deltadelta, objective_min, objective_max)

Accepts a "delta" given the assignment with which the filter has been synchronized; the delta holds the variables which have been modified and their new value. If the filter represents a part of the global objective, its contribution must be between objective_min and objective_max. Sample: supposing one wants to maintain a[0,1] + b[0,1] <= 1, for the assignment (a,1), (b,0), the delta (b,1) will be rejected but the delta (a,0) will be accepted. TODO(user): Remove arguments when there are no more need for those.

def IsIncremental(self):
4470    def IsIncremental(self):
4471        return _pywrapcp.LocalSearchFilter_IsIncremental(self)
def Synchronize(self, assignment, delta):
4473    def Synchronize(self, assignment, delta):
4474        r"""
4475        Synchronizes the filter with the current solution, delta being the
4476        difference with the solution passed to the previous call to Synchronize()
4477        or IncrementalSynchronize(). 'delta' can be used to incrementally
4478        synchronizing the filter with the new solution by only considering the
4479        changes in delta.
4480        """
4481        return _pywrapcp.LocalSearchFilter_Synchronize(self, assignment, delta)

Synchronizes the filter with the current solution, delta being the difference with the solution passed to the previous call to Synchronize() or IncrementalSynchronize(). 'delta' can be used to incrementally synchronizing the filter with the new solution by only considering the changes in delta.

Inherited Members
BaseObject
DebugString
class LocalSearchFilterManager(BaseObject):
4486class LocalSearchFilterManager(BaseObject):
4487    r"""
4488    Filter manager: when a move is made, filters are executed to decide whether
4489    the solution is feasible and compute parts of the new cost. This class
4490    schedules filter execution and composes costs as a sum.
4491    """
4492
4493    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4494    __repr__ = _swig_repr
4495
4496    def DebugString(self):
4497        return _pywrapcp.LocalSearchFilterManager_DebugString(self)
4498
4499    def __init__(self, *args):
4500        _pywrapcp.LocalSearchFilterManager_swiginit(self, _pywrapcp.new_LocalSearchFilterManager(*args))
4501
4502    def Accept(self, monitor, delta, deltadelta, objective_min, objective_max):
4503        r"""
4504        Returns true iff all filters return true, and the sum of their accepted
4505        objectives is between objective_min and objective_max.
4506        The monitor has its Begin/EndFiltering events triggered.
4507        """
4508        return _pywrapcp.LocalSearchFilterManager_Accept(self, monitor, delta, deltadelta, objective_min, objective_max)
4509
4510    def Synchronize(self, assignment, delta):
4511        r"""Synchronizes all filters to assignment."""
4512        return _pywrapcp.LocalSearchFilterManager_Synchronize(self, assignment, delta)
4513    __swig_destroy__ = _pywrapcp.delete_LocalSearchFilterManager

Filter manager: when a move is made, filters are executed to decide whether the solution is feasible and compute parts of the new cost. This class schedules filter execution and composes costs as a sum.

LocalSearchFilterManager(*args)
4499    def __init__(self, *args):
4500        _pywrapcp.LocalSearchFilterManager_swiginit(self, _pywrapcp.new_LocalSearchFilterManager(*args))
thisown
4493    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def DebugString(self):
4496    def DebugString(self):
4497        return _pywrapcp.LocalSearchFilterManager_DebugString(self)
def Accept(self, monitor, delta, deltadelta, objective_min, objective_max):
4502    def Accept(self, monitor, delta, deltadelta, objective_min, objective_max):
4503        r"""
4504        Returns true iff all filters return true, and the sum of their accepted
4505        objectives is between objective_min and objective_max.
4506        The monitor has its Begin/EndFiltering events triggered.
4507        """
4508        return _pywrapcp.LocalSearchFilterManager_Accept(self, monitor, delta, deltadelta, objective_min, objective_max)

Returns true iff all filters return true, and the sum of their accepted objectives is between objective_min and objective_max. The monitor has its Begin/EndFiltering events triggered.

def Synchronize(self, assignment, delta):
4510    def Synchronize(self, assignment, delta):
4511        r"""Synchronizes all filters to assignment."""
4512        return _pywrapcp.LocalSearchFilterManager_Synchronize(self, assignment, delta)

Synchronizes all filters to assignment.

class IntVarLocalSearchFilter(LocalSearchFilter):
4517class IntVarLocalSearchFilter(LocalSearchFilter):
4518    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4519    __repr__ = _swig_repr
4520
4521    def __init__(self, vars):
4522        if self.__class__ == IntVarLocalSearchFilter:
4523            _self = None
4524        else:
4525            _self = self
4526        _pywrapcp.IntVarLocalSearchFilter_swiginit(self, _pywrapcp.new_IntVarLocalSearchFilter(_self, vars))
4527    __swig_destroy__ = _pywrapcp.delete_IntVarLocalSearchFilter
4528
4529    def Synchronize(self, assignment, delta):
4530        r"""
4531        This method should not be overridden. Override OnSynchronize() instead
4532        which is called before exiting this method.
4533        """
4534        return _pywrapcp.IntVarLocalSearchFilter_Synchronize(self, assignment, delta)
4535
4536    def Size(self):
4537        return _pywrapcp.IntVarLocalSearchFilter_Size(self)
4538
4539    def Value(self, index):
4540        return _pywrapcp.IntVarLocalSearchFilter_Value(self, index)
4541
4542    def IndexFromVar(self, var):
4543        return _pywrapcp.IntVarLocalSearchFilter_IndexFromVar(self, var)
4544    def __disown__(self):
4545        self.this.disown()
4546        _pywrapcp.disown_IntVarLocalSearchFilter(self)
4547        return weakref.proxy(self)

Local Search Filters are used for fast neighbor pruning. Filtering a move is done in several phases:

  • in the Relax phase, filters determine which parts of their internals will be changed by the candidate, and modify intermediary State
  • in the Accept phase, filters check that the candidate is feasible,
  • if the Accept phase succeeds, the solver may decide to trigger a Synchronize phase that makes filters change their internal representation to the last candidate,
  • otherwise (Accept fails or the solver does not want to synchronize), a Revert phase makes filters erase any intermediary State generated by the Relax and Accept phases. A given filter has phases called with the following pattern: (Relax.Accept.Synchronize | Relax.Accept.Revert | Relax.Revert)*. Filters's Revert() is always called in the reverse order their Accept() was called, to allow late filters to use state done/undone by early filters' Accept()/Revert().
IntVarLocalSearchFilter(vars)
4521    def __init__(self, vars):
4522        if self.__class__ == IntVarLocalSearchFilter:
4523            _self = None
4524        else:
4525            _self = self
4526        _pywrapcp.IntVarLocalSearchFilter_swiginit(self, _pywrapcp.new_IntVarLocalSearchFilter(_self, vars))
thisown
4518    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Synchronize(self, assignment, delta):
4529    def Synchronize(self, assignment, delta):
4530        r"""
4531        This method should not be overridden. Override OnSynchronize() instead
4532        which is called before exiting this method.
4533        """
4534        return _pywrapcp.IntVarLocalSearchFilter_Synchronize(self, assignment, delta)

This method should not be overridden. Override OnSynchronize() instead which is called before exiting this method.

def Size(self):
4536    def Size(self):
4537        return _pywrapcp.IntVarLocalSearchFilter_Size(self)
def Value(self, index):
4539    def Value(self, index):
4540        return _pywrapcp.IntVarLocalSearchFilter_Value(self, index)
def IndexFromVar(self, var):
4542    def IndexFromVar(self, var):
4543        return _pywrapcp.IntVarLocalSearchFilter_IndexFromVar(self, var)
class BooleanVar(IntVar):
4551class BooleanVar(IntVar):
4552    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4553
4554    def __init__(self, *args, **kwargs):
4555        raise AttributeError("No constructor defined - class is abstract")
4556    __repr__ = _swig_repr
4557
4558    def Min(self):
4559        return _pywrapcp.BooleanVar_Min(self)
4560
4561    def SetMin(self, m):
4562        return _pywrapcp.BooleanVar_SetMin(self, m)
4563
4564    def Max(self):
4565        return _pywrapcp.BooleanVar_Max(self)
4566
4567    def SetMax(self, m):
4568        return _pywrapcp.BooleanVar_SetMax(self, m)
4569
4570    def SetRange(self, mi, ma):
4571        return _pywrapcp.BooleanVar_SetRange(self, mi, ma)
4572
4573    def Bound(self):
4574        return _pywrapcp.BooleanVar_Bound(self)
4575
4576    def Value(self):
4577        return _pywrapcp.BooleanVar_Value(self)
4578
4579    def RemoveValue(self, v):
4580        return _pywrapcp.BooleanVar_RemoveValue(self, v)
4581
4582    def RemoveInterval(self, l, u):
4583        return _pywrapcp.BooleanVar_RemoveInterval(self, l, u)
4584
4585    def WhenBound(self, d):
4586        return _pywrapcp.BooleanVar_WhenBound(self, d)
4587
4588    def WhenRange(self, d):
4589        return _pywrapcp.BooleanVar_WhenRange(self, d)
4590
4591    def WhenDomain(self, d):
4592        return _pywrapcp.BooleanVar_WhenDomain(self, d)
4593
4594    def Size(self):
4595        return _pywrapcp.BooleanVar_Size(self)
4596
4597    def Contains(self, v):
4598        return _pywrapcp.BooleanVar_Contains(self, v)
4599
4600    def HoleIteratorAux(self, reversible):
4601        return _pywrapcp.BooleanVar_HoleIteratorAux(self, reversible)
4602
4603    def DomainIteratorAux(self, reversible):
4604        return _pywrapcp.BooleanVar_DomainIteratorAux(self, reversible)
4605
4606    def DebugString(self):
4607        return _pywrapcp.BooleanVar_DebugString(self)

The class IntVar is a subset of IntExpr. In addition to the IntExpr protocol, it offers persistence, removing values from the domains, and a finer model for events.

BooleanVar(*args, **kwargs)
4554    def __init__(self, *args, **kwargs):
4555        raise AttributeError("No constructor defined - class is abstract")
thisown
4552    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Min(self):
4558    def Min(self):
4559        return _pywrapcp.BooleanVar_Min(self)
def SetMin(self, m):
4561    def SetMin(self, m):
4562        return _pywrapcp.BooleanVar_SetMin(self, m)
def Max(self):
4564    def Max(self):
4565        return _pywrapcp.BooleanVar_Max(self)
def SetMax(self, m):
4567    def SetMax(self, m):
4568        return _pywrapcp.BooleanVar_SetMax(self, m)
def SetRange(self, mi, ma):
4570    def SetRange(self, mi, ma):
4571        return _pywrapcp.BooleanVar_SetRange(self, mi, ma)

This method sets both the min and the max of the expression.

def Bound(self):
4573    def Bound(self):
4574        return _pywrapcp.BooleanVar_Bound(self)

Returns true if the min and the max of the expression are equal.

def Value(self):
4576    def Value(self):
4577        return _pywrapcp.BooleanVar_Value(self)

This method returns the value of the variable. This method checks before that the variable is bound.

def RemoveValue(self, v):
4579    def RemoveValue(self, v):
4580        return _pywrapcp.BooleanVar_RemoveValue(self, v)

This method removes the value 'v' from the domain of the variable.

def RemoveInterval(self, l, u):
4582    def RemoveInterval(self, l, u):
4583        return _pywrapcp.BooleanVar_RemoveInterval(self, l, u)

This method removes the interval 'l' .. 'u' from the domain of the variable. It assumes that 'l' <= 'u'.

def WhenBound(self, d):
4585    def WhenBound(self, d):
4586        return _pywrapcp.BooleanVar_WhenBound(self, d)

Overload 1: This method attaches a demon that will be awakened when the variable is bound.

|

Overload 2: This method attaches a closure that will be awakened when the variable is bound.

def WhenRange(self, d):
4588    def WhenRange(self, d):
4589        return _pywrapcp.BooleanVar_WhenRange(self, d)

Overload 1: Attach a demon that will watch the min or the max of the expression.

|

Overload 2: Attach a demon that will watch the min or the max of the expression.

def WhenDomain(self, d):
4591    def WhenDomain(self, d):
4592        return _pywrapcp.BooleanVar_WhenDomain(self, d)

Overload 1: This method attaches a demon that will watch any domain modification of the domain of the variable.

|

Overload 2: This method attaches a closure that will watch any domain modification of the domain of the variable.

def Size(self):
4594    def Size(self):
4595        return _pywrapcp.BooleanVar_Size(self)

This method returns the number of values in the domain of the variable.

def Contains(self, v):
4597    def Contains(self, v):
4598        return _pywrapcp.BooleanVar_Contains(self, v)

This method returns whether the value 'v' is in the domain of the variable.

def HoleIteratorAux(self, reversible):
4600    def HoleIteratorAux(self, reversible):
4601        return _pywrapcp.BooleanVar_HoleIteratorAux(self, reversible)

Creates a hole iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.

def DomainIteratorAux(self, reversible):
4603    def DomainIteratorAux(self, reversible):
4604        return _pywrapcp.BooleanVar_DomainIteratorAux(self, reversible)

Creates a domain iterator. When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.

def DebugString(self):
4606    def DebugString(self):
4607        return _pywrapcp.BooleanVar_DebugString(self)
class PyDecision(Decision):
4612class PyDecision(Decision):
4613  def ApplyWrapper(self, solver):
4614    try:
4615       self.Apply(solver)
4616    except Exception as e:
4617      if 'CP Solver fail' in str(e):
4618        solver.ShouldFail()
4619      else:
4620        raise
4621
4622  def RefuteWrapper(self, solver):
4623    try:
4624       self.Refute(solver)
4625    except Exception as e:
4626      if 'CP Solver fail' in str(e):
4627        solver.ShouldFail()
4628      else:
4629        raise
4630
4631  def DebugString(self):
4632    return "PyDecision"

A Decision represents a choice point in the search tree. The two main methods are Apply() to go left, or Refute() to go right.

def ApplyWrapper(self, solver):
4613  def ApplyWrapper(self, solver):
4614    try:
4615       self.Apply(solver)
4616    except Exception as e:
4617      if 'CP Solver fail' in str(e):
4618        solver.ShouldFail()
4619      else:
4620        raise

Apply will be called first when the decision is executed.

def RefuteWrapper(self, solver):
4622  def RefuteWrapper(self, solver):
4623    try:
4624       self.Refute(solver)
4625    except Exception as e:
4626      if 'CP Solver fail' in str(e):
4627        solver.ShouldFail()
4628      else:
4629        raise

Refute will be called after a backtrack.

def DebugString(self):
4631  def DebugString(self):
4632    return "PyDecision"
Inherited Members
Decision
thisown
class PyDecisionBuilder(DecisionBuilder):
4635class PyDecisionBuilder(DecisionBuilder):
4636  def NextWrapper(self, solver):
4637    try:
4638      return self.Next(solver)
4639    except Exception as e:
4640      if 'CP Solver fail' in str(e):
4641        return solver.FailDecision()
4642      else:
4643        raise
4644
4645  def DebugString(self):
4646    return "PyDecisionBuilder"

A DecisionBuilder is responsible for creating the search tree. The important method is Next(), which returns the next decision to execute.

def NextWrapper(self, solver):
4636  def NextWrapper(self, solver):
4637    try:
4638      return self.Next(solver)
4639    except Exception as e:
4640      if 'CP Solver fail' in str(e):
4641        return solver.FailDecision()
4642      else:
4643        raise

This is the main method of the decision builder class. It must return a decision (an instance of the class Decision). If it returns nullptr, this means that the decision builder has finished its work.

def DebugString(self):
4645  def DebugString(self):
4646    return "PyDecisionBuilder"
Inherited Members
DecisionBuilder
thisown
class PyDemon(Demon):
4649class PyDemon(Demon):
4650  def RunWrapper(self, solver):
4651    try:
4652      self.Run(solver)
4653    except Exception as e:
4654      if 'CP Solver fail' in str(e):
4655        solver.ShouldFail()
4656      else:
4657        raise
4658
4659  def DebugString(self):
4660    return "PyDemon"

A Demon is the base element of a propagation queue. It is the main object responsible for implementing the actual propagation of the constraint and pruning the inconsistent values in the domains of the variables. The main concept is that demons are listeners that are attached to the variables and listen to their modifications.

There are two methods:
  • Run() is the actual method called when the demon is processed.
  • priority() returns its priority. Standard priorities are slow, normal or fast. "immediate" is reserved for variables and is treated separately.
def RunWrapper(self, solver):
4650  def RunWrapper(self, solver):
4651    try:
4652      self.Run(solver)
4653    except Exception as e:
4654      if 'CP Solver fail' in str(e):
4655        solver.ShouldFail()
4656      else:
4657        raise

This is the main callback of the demon.

def DebugString(self):
4659  def DebugString(self):
4660    return "PyDemon"
class PyConstraintDemon(PyDemon):
4663class PyConstraintDemon(PyDemon):
4664  def __init__(self, ct, method, delayed, *args):
4665    super().__init__()
4666    self.__constraint = ct
4667    self.__method = method
4668    self.__delayed = delayed
4669    self.__args = args
4670
4671  def Run(self, solver):
4672    self.__method(self.__constraint, *self.__args)
4673
4674  def Priority(self):
4675    return Solver.DELAYED_PRIORITY if self.__delayed else Solver.NORMAL_PRIORITY
4676
4677  def DebugString(self):
4678    return 'PyConstraintDemon'

A Demon is the base element of a propagation queue. It is the main object responsible for implementing the actual propagation of the constraint and pruning the inconsistent values in the domains of the variables. The main concept is that demons are listeners that are attached to the variables and listen to their modifications.

There are two methods:
  • Run() is the actual method called when the demon is processed.
  • priority() returns its priority. Standard priorities are slow, normal or fast. "immediate" is reserved for variables and is treated separately.
PyConstraintDemon(ct, method, delayed, *args)
4664  def __init__(self, ct, method, delayed, *args):
4665    super().__init__()
4666    self.__constraint = ct
4667    self.__method = method
4668    self.__delayed = delayed
4669    self.__args = args

This indicates the priority of a demon. Immediate demons are treated separately and corresponds to variables.

def Run(self, solver):
4671  def Run(self, solver):
4672    self.__method(self.__constraint, *self.__args)
def Priority(self):
4674  def Priority(self):
4675    return Solver.DELAYED_PRIORITY if self.__delayed else Solver.NORMAL_PRIORITY

This method returns the priority of the demon. Usually a demon is fast, slow or normal. Immediate demons are reserved for internal use to maintain variables.

def DebugString(self):
4677  def DebugString(self):
4678    return 'PyConstraintDemon'
class PyConstraint(Constraint):
4681class PyConstraint(Constraint):
4682  def __init__(self, solver):
4683    super().__init__(solver)
4684    self.__demons = []
4685
4686  def Demon(self, method, *args):
4687    demon = PyConstraintDemon(self, method, False, *args)
4688    self.__demons.append(demon)
4689    return demon
4690
4691  def DelayedDemon(self, method, *args):
4692    demon = PyConstraintDemon(self, method, True, *args)
4693    self.__demons.append(demon)
4694    return demon
4695
4696  def InitialPropagateDemon(self):
4697    return self.solver().ConstraintInitialPropagateCallback(self)
4698
4699  def DelayedInitialPropagateDemon(self):
4700    return self.solver().DelayedConstraintInitialPropagateCallback(self)
4701
4702  def InitialPropagateWrapper(self):
4703    try:
4704      self.InitialPropagate()
4705    except Exception as e:
4706      if 'CP Solver fail' in str(e):
4707        self.solver().ShouldFail()
4708      else:
4709        raise
4710
4711  def DebugString(self):
4712    return "PyConstraint"

A constraint is the main modeling object. It provides two methods:

  • Post() is responsible for creating the demons and attaching them to immediate demons().
  • InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
PyConstraint(solver)
4682  def __init__(self, solver):
4683    super().__init__(solver)
4684    self.__demons = []
def Demon(self, method, *args):
4686  def Demon(self, method, *args):
4687    demon = PyConstraintDemon(self, method, False, *args)
4688    self.__demons.append(demon)
4689    return demon
def DelayedDemon(self, method, *args):
4691  def DelayedDemon(self, method, *args):
4692    demon = PyConstraintDemon(self, method, True, *args)
4693    self.__demons.append(demon)
4694    return demon
def InitialPropagateDemon(self):
4696  def InitialPropagateDemon(self):
4697    return self.solver().ConstraintInitialPropagateCallback(self)
def DelayedInitialPropagateDemon(self):
4699  def DelayedInitialPropagateDemon(self):
4700    return self.solver().DelayedConstraintInitialPropagateCallback(self)
def InitialPropagateWrapper(self):
4702  def InitialPropagateWrapper(self):
4703    try:
4704      self.InitialPropagate()
4705    except Exception as e:
4706      if 'CP Solver fail' in str(e):
4707        self.solver().ShouldFail()
4708      else:
4709        raise

This method performs the initial propagation of the constraint. It is called just after the post.

def DebugString(self):
4711  def DebugString(self):
4712    return "PyConstraint"
class RoutingIndexManager:
4714class RoutingIndexManager(object):
4715    r"""
4716    Manager for any NodeIndex <-> variable index conversion. The routing solver
4717    uses variable indices internally and through its API. These variable indices
4718    are tricky to manage directly because one Node can correspond to a multitude
4719    of variables, depending on the number of times they appear in the model, and
4720    if they're used as start and/or end points. This class aims to simplify
4721    variable index usage, allowing users to use NodeIndex instead.
4722
4723    Usage:
4724
4725      .. code-block:: c++
4726
4727          auto starts_ends = ...;  /// These are NodeIndex.
4728          RoutingIndexManager manager(10, 4, starts_ends);  // 10 nodes, 4 vehicles.
4729          RoutingModel model(manager);
4730
4731    Then, use 'manager.NodeToIndex(node)' whenever model requires a variable
4732    index.
4733
4734    Note: the mapping between node indices and variables indices is subject to
4735    change so no assumption should be made on it. The only guarantee is that
4736    indices range between 0 and n-1, where n = number of vehicles * 2 (for start
4737    and end nodes) + number of non-start or end nodes.
4738    """
4739
4740    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4741    __repr__ = _swig_repr
4742
4743    def __init__(self, *args):
4744        r"""
4745        Creates a NodeIndex to variable index mapping for a problem containing
4746        'num_nodes', 'num_vehicles' and the given starts and ends for each
4747        vehicle. If used, any start/end arrays have to have exactly 'num_vehicles'
4748        elements.
4749        """
4750        _pywrapcp.RoutingIndexManager_swiginit(self, _pywrapcp.new_RoutingIndexManager(*args))
4751
4752    def GetNumberOfNodes(self):
4753        return _pywrapcp.RoutingIndexManager_GetNumberOfNodes(self)
4754
4755    def GetNumberOfVehicles(self):
4756        return _pywrapcp.RoutingIndexManager_GetNumberOfVehicles(self)
4757
4758    def GetNumberOfIndices(self):
4759        return _pywrapcp.RoutingIndexManager_GetNumberOfIndices(self)
4760
4761    def GetStartIndex(self, vehicle):
4762        return _pywrapcp.RoutingIndexManager_GetStartIndex(self, vehicle)
4763
4764    def GetEndIndex(self, vehicle):
4765        return _pywrapcp.RoutingIndexManager_GetEndIndex(self, vehicle)
4766
4767    def NodeToIndex(self, node):
4768        return _pywrapcp.RoutingIndexManager_NodeToIndex(self, node)
4769
4770    def IndexToNode(self, index):
4771        return _pywrapcp.RoutingIndexManager_IndexToNode(self, index)
4772    __swig_destroy__ = _pywrapcp.delete_RoutingIndexManager

Manager for any NodeIndex <-> variable index conversion. The routing solver uses variable indices internally and through its API. These variable indices are tricky to manage directly because one Node can correspond to a multitude of variables, depending on the number of times they appear in the model, and if they're used as start and/or end points. This class aims to simplify variable index usage, allowing users to use NodeIndex instead.

Usage:

```c++

auto starts_ends = ...; /// These are NodeIndex. RoutingIndexManager manager(10, 4, starts_ends); // 10 nodes, 4 vehicles. RoutingModel model(manager); ```

Then, use 'manager.NodeToIndex(node)' whenever model requires a variable index.

Note: the mapping between node indices and variables indices is subject to change so no assumption should be made on it. The only guarantee is that indices range between 0 and n-1, where n = number of vehicles * 2 (for start and end nodes) + number of non-start or end nodes.

RoutingIndexManager(*args)
4743    def __init__(self, *args):
4744        r"""
4745        Creates a NodeIndex to variable index mapping for a problem containing
4746        'num_nodes', 'num_vehicles' and the given starts and ends for each
4747        vehicle. If used, any start/end arrays have to have exactly 'num_vehicles'
4748        elements.
4749        """
4750        _pywrapcp.RoutingIndexManager_swiginit(self, _pywrapcp.new_RoutingIndexManager(*args))

Creates a NodeIndex to variable index mapping for a problem containing 'num_nodes', 'num_vehicles' and the given starts and ends for each vehicle. If used, any start/end arrays have to have exactly 'num_vehicles' elements.

thisown
4740    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def GetNumberOfNodes(self):
4752    def GetNumberOfNodes(self):
4753        return _pywrapcp.RoutingIndexManager_GetNumberOfNodes(self)
def GetNumberOfVehicles(self):
4755    def GetNumberOfVehicles(self):
4756        return _pywrapcp.RoutingIndexManager_GetNumberOfVehicles(self)
def GetNumberOfIndices(self):
4758    def GetNumberOfIndices(self):
4759        return _pywrapcp.RoutingIndexManager_GetNumberOfIndices(self)
def GetStartIndex(self, vehicle):
4761    def GetStartIndex(self, vehicle):
4762        return _pywrapcp.RoutingIndexManager_GetStartIndex(self, vehicle)
def GetEndIndex(self, vehicle):
4764    def GetEndIndex(self, vehicle):
4765        return _pywrapcp.RoutingIndexManager_GetEndIndex(self, vehicle)
def NodeToIndex(self, node):
4767    def NodeToIndex(self, node):
4768        return _pywrapcp.RoutingIndexManager_NodeToIndex(self, node)
def IndexToNode(self, index):
4770    def IndexToNode(self, index):
4771        return _pywrapcp.RoutingIndexManager_IndexToNode(self, index)
def DefaultRoutingModelParameters():
4777def DefaultRoutingModelParameters():
4778    return _pywrapcp.DefaultRoutingModelParameters()
def DefaultRoutingSearchParameters():
4780def DefaultRoutingSearchParameters():
4781    return _pywrapcp.DefaultRoutingSearchParameters()
def FindErrorInRoutingSearchParameters(search_parameters):
4783def FindErrorInRoutingSearchParameters(search_parameters):
4784    r"""
4785    Returns an empty std::string if the routing search parameters are valid, and
4786    a non-empty, human readable error description if they're not.
4787    """
4788    return _pywrapcp.FindErrorInRoutingSearchParameters(search_parameters)

Returns an empty std::string if the routing search parameters are valid, and a non-empty, human readable error description if they're not.

BOOL_UNSPECIFIED = 0
BOOL_FALSE = 2
BOOL_TRUE = 3
class FirstSolutionStrategy:
4792class FirstSolutionStrategy(object):
4793    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4794    __repr__ = _swig_repr
4795
4796    def __init__(self):
4797        _pywrapcp.FirstSolutionStrategy_swiginit(self, _pywrapcp.new_FirstSolutionStrategy())
4798    __swig_destroy__ = _pywrapcp.delete_FirstSolutionStrategy
thisown
4793    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

class LocalSearchMetaheuristic:
4802class LocalSearchMetaheuristic(object):
4803    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4804    __repr__ = _swig_repr
4805
4806    def __init__(self):
4807        _pywrapcp.LocalSearchMetaheuristic_swiginit(self, _pywrapcp.new_LocalSearchMetaheuristic())
4808    __swig_destroy__ = _pywrapcp.delete_LocalSearchMetaheuristic
thisown
4803    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

class RoutingSearchStatus:
4812class RoutingSearchStatus(object):
4813    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4814    __repr__ = _swig_repr
4815
4816    def __init__(self):
4817        _pywrapcp.RoutingSearchStatus_swiginit(self, _pywrapcp.new_RoutingSearchStatus())
4818    __swig_destroy__ = _pywrapcp.delete_RoutingSearchStatus
thisown
4813    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

class PathsMetadata:
4822class PathsMetadata(object):
4823    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4824    __repr__ = _swig_repr
4825
4826    def __init__(self, manager):
4827        _pywrapcp.PathsMetadata_swiginit(self, _pywrapcp.new_PathsMetadata(manager))
4828
4829    def IsStart(self, node):
4830        return _pywrapcp.PathsMetadata_IsStart(self, node)
4831
4832    def IsEnd(self, node):
4833        return _pywrapcp.PathsMetadata_IsEnd(self, node)
4834
4835    def GetPath(self, start_or_end_node):
4836        return _pywrapcp.PathsMetadata_GetPath(self, start_or_end_node)
4837
4838    def NumPaths(self):
4839        return _pywrapcp.PathsMetadata_NumPaths(self)
4840
4841    def Paths(self):
4842        return _pywrapcp.PathsMetadata_Paths(self)
4843
4844    def Starts(self):
4845        return _pywrapcp.PathsMetadata_Starts(self)
4846
4847    def Start(self, path):
4848        return _pywrapcp.PathsMetadata_Start(self, path)
4849
4850    def End(self, path):
4851        return _pywrapcp.PathsMetadata_End(self, path)
4852
4853    def Ends(self):
4854        return _pywrapcp.PathsMetadata_Ends(self)
4855    __swig_destroy__ = _pywrapcp.delete_PathsMetadata
PathsMetadata(manager)
4826    def __init__(self, manager):
4827        _pywrapcp.PathsMetadata_swiginit(self, _pywrapcp.new_PathsMetadata(manager))
thisown
4823    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def IsStart(self, node):
4829    def IsStart(self, node):
4830        return _pywrapcp.PathsMetadata_IsStart(self, node)
def IsEnd(self, node):
4832    def IsEnd(self, node):
4833        return _pywrapcp.PathsMetadata_IsEnd(self, node)
def GetPath(self, start_or_end_node):
4835    def GetPath(self, start_or_end_node):
4836        return _pywrapcp.PathsMetadata_GetPath(self, start_or_end_node)
def NumPaths(self):
4838    def NumPaths(self):
4839        return _pywrapcp.PathsMetadata_NumPaths(self)
def Paths(self):
4841    def Paths(self):
4842        return _pywrapcp.PathsMetadata_Paths(self)
def Starts(self):
4844    def Starts(self):
4845        return _pywrapcp.PathsMetadata_Starts(self)
def Start(self, path):
4847    def Start(self, path):
4848        return _pywrapcp.PathsMetadata_Start(self, path)
def End(self, path):
4850    def End(self, path):
4851        return _pywrapcp.PathsMetadata_End(self, path)
def Ends(self):
4853    def Ends(self):
4854        return _pywrapcp.PathsMetadata_Ends(self)
class RoutingModel:
4859class RoutingModel(object):
4860    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
4861    __repr__ = _swig_repr
4862    PICKUP_AND_DELIVERY_NO_ORDER = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_NO_ORDER
4863    r"""Any precedence is accepted."""
4864    PICKUP_AND_DELIVERY_LIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_LIFO
4865    r"""Deliveries must be performed in reverse order of pickups."""
4866    PICKUP_AND_DELIVERY_FIFO = _pywrapcp.RoutingModel_PICKUP_AND_DELIVERY_FIFO
4867    r"""Deliveries must be performed in the same order as pickups."""
4868
4869    def __init__(self, *args):
4870        r"""
4871        Constructor taking an index manager. The version which does not take
4872        RoutingModelParameters is equivalent to passing
4873        DefaultRoutingModelParameters().
4874        """
4875        _pywrapcp.RoutingModel_swiginit(self, _pywrapcp.new_RoutingModel(*args))
4876    __swig_destroy__ = _pywrapcp.delete_RoutingModel
4877    kTransitEvaluatorSignUnknown = _pywrapcp.RoutingModel_kTransitEvaluatorSignUnknown
4878    kTransitEvaluatorSignPositiveOrZero = _pywrapcp.RoutingModel_kTransitEvaluatorSignPositiveOrZero
4879    kTransitEvaluatorSignNegativeOrZero = _pywrapcp.RoutingModel_kTransitEvaluatorSignNegativeOrZero
4880
4881    def RegisterUnaryTransitVector(self, values):
4882        r"""
4883        Registers 'callback' and returns its index.
4884        The sign parameter allows to notify the solver that the callback only
4885        return values of the given sign. This can help the solver, but passing
4886        an incorrect sign may crash in non-opt compilation mode, and yield
4887        incorrect results in opt.
4888        """
4889        return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)
4890
4891    def RegisterUnaryTransitCallback(self, *args):
4892        return _pywrapcp.RoutingModel_RegisterUnaryTransitCallback(self, *args)
4893
4894    def RegisterTransitMatrix(self, values):
4895        return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values)
4896
4897    def RegisterTransitCallback(self, *args):
4898        return _pywrapcp.RoutingModel_RegisterTransitCallback(self, *args)
4899
4900    def RegisterCumulDependentTransitCallback(self, callback):
4901        return _pywrapcp.RoutingModel_RegisterCumulDependentTransitCallback(self, callback)
4902
4903    def TransitCallback(self, callback_index):
4904        return _pywrapcp.RoutingModel_TransitCallback(self, callback_index)
4905
4906    def UnaryTransitCallbackOrNull(self, callback_index):
4907        return _pywrapcp.RoutingModel_UnaryTransitCallbackOrNull(self, callback_index)
4908
4909    def CumulDependentTransitCallback(self, callback_index):
4910        return _pywrapcp.RoutingModel_CumulDependentTransitCallback(self, callback_index)
4911
4912    def AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name):
4913        r"""
4914        Model creation
4915        Methods to add dimensions to routes; dimensions represent quantities
4916        accumulated at nodes along the routes. They represent quantities such as
4917        weights or volumes carried along the route, or distance or times.
4918        Quantities at a node are represented by "cumul" variables and the increase
4919        or decrease of quantities between nodes are represented by "transit"
4920        variables. These variables are linked as follows:
4921        if j == next(i), cumul(j) = cumul(i) + transit(i, j) + slack(i)
4922        where slack is a positive slack variable (can represent waiting times for
4923        a time dimension).
4924        Setting the value of fix_start_cumul_to_zero to true will force the
4925        "cumul" variable of the start node of all vehicles to be equal to 0.
4926        Creates a dimension where the transit variable is constrained to be
4927        equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the
4928        slack variable and 'capacity' is the upper bound of the cumul variables.
4929        'name' is the name used to reference the dimension; this name is used to
4930        get cumul and transit variables from the routing model.
4931        Returns false if a dimension with the same name has already been created
4932        (and doesn't create the new dimension).
4933        Takes ownership of the callback 'evaluator'.
4934        """
4935        return _pywrapcp.RoutingModel_AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name)
4936
4937    def AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name):
4938        return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name)
4939
4940    def AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4941        return _pywrapcp.RoutingModel_AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
4942
4943    def AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4944        return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
4945
4946    def AddDimensionWithCumulDependentVehicleTransitAndCapacity(self, fixed_evaluator_indices, cumul_dependent_evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4947        r"""
4948        Creates a dimension where the transit variable on arc i->j is the sum of:
4949        - A "fixed" transit value, obtained from the fixed_evaluator_index for
4950          this vehicle, referencing evaluators in transit_evaluators_, and
4951        - A FloatSlopePiecewiseLinearFunction of the cumul of node i, obtained
4952          from the cumul_dependent_evaluator_index of this vehicle, pointing to
4953          an evaluator in cumul_dependent_transit_evaluators_.
4954        """
4955        return _pywrapcp.RoutingModel_AddDimensionWithCumulDependentVehicleTransitAndCapacity(self, fixed_evaluator_indices, cumul_dependent_evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
4956
4957    def AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name):
4958        r"""
4959        Creates a dimension where the transit variable is constrained to be
4960        equal to 'value'; 'capacity' is the upper bound of the cumul variables.
4961        'name' is the name used to reference the dimension; this name is used to
4962        get cumul and transit variables from the routing model.
4963        Returns a pair consisting of an index to the registered unary transit
4964        callback and a bool denoting whether the dimension has been created.
4965        It is false if a dimension with the same name has already been created
4966        (and doesn't create the new dimension but still register a new callback).
4967        """
4968        return _pywrapcp.RoutingModel_AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name)
4969
4970    def AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name):
4971        return _pywrapcp.RoutingModel_AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name)
4972
4973    def AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4974        r"""
4975        Creates a dimension where the transit variable is constrained to be
4976        equal to 'values[i]' for node i; 'capacity' is the upper bound of
4977        the cumul variables. 'name' is the name used to reference the dimension;
4978        this name is used to get cumul and transit variables from the routing
4979        model.
4980        Returns a pair consisting of an index to the registered unary transit
4981        callback and a bool denoting whether the dimension has been created.
4982        It is false if a dimension with the same name has already been created
4983        (and doesn't create the new dimension but still register a new callback).
4984        """
4985        return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)
4986
4987    def AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4988        r"""
4989        Creates a dimension where the transit variable is constrained to be
4990        equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of
4991        the cumul variables. 'name' is the name used to reference the dimension;
4992        this name is used to get cumul and transit variables from the routing
4993        model.
4994        Returns a pair consisting of an index to the registered transit callback
4995        and a bool denoting whether the dimension has been created.
4996        It is false if a dimension with the same name has already been created
4997        (and doesn't create the new dimension but still register a new callback).
4998        """
4999        return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)
5000
5001    def GetAllDimensionNames(self):
5002        r"""Outputs the names of all dimensions added to the routing engine."""
5003        return _pywrapcp.RoutingModel_GetAllDimensionNames(self)
5004
5005    def GetDimensions(self):
5006        r"""Returns all dimensions of the model."""
5007        return _pywrapcp.RoutingModel_GetDimensions(self)
5008
5009    def GetDimensionsWithSoftOrSpanCosts(self):
5010        r"""Returns dimensions with soft or vehicle span costs."""
5011        return _pywrapcp.RoutingModel_GetDimensionsWithSoftOrSpanCosts(self)
5012
5013    def GetUnaryDimensions(self):
5014        r"""Returns dimensions for which all transit evaluators are unary."""
5015        return _pywrapcp.RoutingModel_GetUnaryDimensions(self)
5016
5017    def GetDimensionsWithGlobalCumulOptimizers(self):
5018        r"""Returns the dimensions which have [global|local]_dimension_optimizers_."""
5019        return _pywrapcp.RoutingModel_GetDimensionsWithGlobalCumulOptimizers(self)
5020
5021    def GetDimensionsWithLocalCumulOptimizers(self):
5022        return _pywrapcp.RoutingModel_GetDimensionsWithLocalCumulOptimizers(self)
5023
5024    def HasGlobalCumulOptimizer(self, dimension):
5025        r"""Returns whether the given dimension has global/local cumul optimizers."""
5026        return _pywrapcp.RoutingModel_HasGlobalCumulOptimizer(self, dimension)
5027
5028    def HasLocalCumulOptimizer(self, dimension):
5029        return _pywrapcp.RoutingModel_HasLocalCumulOptimizer(self, dimension)
5030
5031    def GetMutableGlobalCumulLPOptimizer(self, dimension):
5032        r"""
5033        Returns the global/local dimension cumul optimizer for a given dimension,
5034        or nullptr if there is none.
5035        """
5036        return _pywrapcp.RoutingModel_GetMutableGlobalCumulLPOptimizer(self, dimension)
5037
5038    def GetMutableGlobalCumulMPOptimizer(self, dimension):
5039        return _pywrapcp.RoutingModel_GetMutableGlobalCumulMPOptimizer(self, dimension)
5040
5041    def GetMutableLocalCumulLPOptimizer(self, dimension):
5042        return _pywrapcp.RoutingModel_GetMutableLocalCumulLPOptimizer(self, dimension)
5043
5044    def GetMutableLocalCumulMPOptimizer(self, dimension):
5045        return _pywrapcp.RoutingModel_GetMutableLocalCumulMPOptimizer(self, dimension)
5046
5047    def HasDimension(self, dimension_name):
5048        r"""Returns true if a dimension exists for a given dimension name."""
5049        return _pywrapcp.RoutingModel_HasDimension(self, dimension_name)
5050
5051    def GetDimensionOrDie(self, dimension_name):
5052        r"""Returns a dimension from its name. Dies if the dimension does not exist."""
5053        return _pywrapcp.RoutingModel_GetDimensionOrDie(self, dimension_name)
5054
5055    def GetMutableDimension(self, dimension_name):
5056        r"""
5057        Returns a dimension from its name. Returns nullptr if the dimension does
5058        not exist.
5059        """
5060        return _pywrapcp.RoutingModel_GetMutableDimension(self, dimension_name)
5061
5062    def SetPrimaryConstrainedDimension(self, dimension_name):
5063        r"""
5064        Set the given dimension as "primary constrained". As of August 2013, this
5065        is only used by ArcIsMoreConstrainedThanArc().
5066        "dimension" must be the name of an existing dimension, or be empty, in
5067        which case there will not be a primary dimension after this call.
5068        """
5069        return _pywrapcp.RoutingModel_SetPrimaryConstrainedDimension(self, dimension_name)
5070
5071    def GetPrimaryConstrainedDimension(self):
5072        r"""Get the primary constrained dimension, or an empty string if it is unset."""
5073        return _pywrapcp.RoutingModel_GetPrimaryConstrainedDimension(self)
5074
5075    def GetResourceGroup(self, rg_index):
5076        return _pywrapcp.RoutingModel_GetResourceGroup(self, rg_index)
5077
5078    def GetDimensionResourceGroupIndices(self, dimension):
5079        r"""
5080        Returns the indices of resource groups for this dimension. This method can
5081        only be called after the model has been closed.
5082        """
5083        return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndices(self, dimension)
5084
5085    def GetDimensionResourceGroupIndex(self, dimension):
5086        r"""
5087        Returns the index of the resource group attached to the dimension.
5088        DCHECKS that there's exactly one resource group for this dimension.
5089        """
5090        return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndex(self, dimension)
5091    PENALIZE_ONCE = _pywrapcp.RoutingModel_PENALIZE_ONCE
5092    PENALIZE_PER_INACTIVE = _pywrapcp.RoutingModel_PENALIZE_PER_INACTIVE
5093
5094    def AddDisjunction(self, *args):
5095        r"""
5096        Adds a disjunction constraint on the indices: exactly 'max_cardinality' of
5097        the indices are active. Start and end indices of any vehicle cannot be
5098        part of a disjunction.
5099
5100        If a penalty is given, at most 'max_cardinality' of the indices can be
5101        active, and if less are active, 'penalty' is payed per inactive index if
5102        the penalty cost is set to `PENALIZE_PER_INACTIVE`.
5103        This is equivalent to adding the constraint:
5104            p + Sum(i)active[i] == max_cardinality
5105        where p is an integer variable.
5106        If the penalty cost is set to `PENALIZE_ONCE`, then 'penalty' is payed
5107        once if there are less than `max_cardinality` of the indices active.
5108        This is equivalent to adding the constraint:
5109            p == (Sum(i)active[i] != max_cardinality)
5110        where p is a boolean variable.
5111        The following cost is added to the cost function: p * penalty.
5112        'penalty' must be positive to make the disjunction optional; a negative
5113        penalty will force 'max_cardinality' indices of the disjunction to be
5114        performed, and therefore p == 0.
5115        Note: passing a vector with a single index will model an optional index
5116        with a penalty cost if it is not visited.
5117        """
5118        return _pywrapcp.RoutingModel_AddDisjunction(self, *args)
5119
5120    def GetDisjunctionIndices(self, index):
5121        r"""Returns the indices of the disjunctions to which an index belongs."""
5122        return _pywrapcp.RoutingModel_GetDisjunctionIndices(self, index)
5123
5124    def GetDisjunctionPenalty(self, index):
5125        r"""Returns the penalty of the node disjunction of index 'index'."""
5126        return _pywrapcp.RoutingModel_GetDisjunctionPenalty(self, index)
5127
5128    def GetDisjunctionMaxCardinality(self, index):
5129        r"""
5130        Returns the maximum number of possible active nodes of the node
5131        disjunction of index 'index'.
5132        """
5133        return _pywrapcp.RoutingModel_GetDisjunctionMaxCardinality(self, index)
5134
5135    def GetDisjunctionPenaltyCostBehavior(self, index):
5136        r"""
5137        Returns the 'PenaltyCostBehavior' used by the disjunction of index
5138        'index'.
5139        """
5140        return _pywrapcp.RoutingModel_GetDisjunctionPenaltyCostBehavior(self, index)
5141
5142    def GetNumberOfDisjunctions(self):
5143        r"""Returns the number of node disjunctions in the model."""
5144        return _pywrapcp.RoutingModel_GetNumberOfDisjunctions(self)
5145
5146    def HasMandatoryDisjunctions(self):
5147        r"""
5148        Returns true if the model contains mandatory disjunctions (ones with
5149        kNoPenalty as penalty).
5150        """
5151        return _pywrapcp.RoutingModel_HasMandatoryDisjunctions(self)
5152
5153    def HasMaxCardinalityConstrainedDisjunctions(self):
5154        r"""
5155        Returns true if the model contains at least one disjunction which is
5156        constrained by its max_cardinality.
5157        """
5158        return _pywrapcp.RoutingModel_HasMaxCardinalityConstrainedDisjunctions(self)
5159
5160    def GetPerfectBinaryDisjunctions(self):
5161        r"""
5162        Returns the list of all perfect binary disjunctions, as pairs of variable
5163        indices: a disjunction is "perfect" when its variables do not appear in
5164        any other disjunction. Each pair is sorted (lowest variable index first),
5165        and the output vector is also sorted (lowest pairs first).
5166        """
5167        return _pywrapcp.RoutingModel_GetPerfectBinaryDisjunctions(self)
5168
5169    def IgnoreDisjunctionsAlreadyForcedToZero(self):
5170        r"""
5171        SPECIAL: Makes the solver ignore all the disjunctions whose active
5172        variables are all trivially zero (i.e. Max() == 0), by setting their
5173        max_cardinality to 0.
5174        This can be useful when using the BaseBinaryDisjunctionNeighborhood
5175        operators, in the context of arc-based routing.
5176        """
5177        return _pywrapcp.RoutingModel_IgnoreDisjunctionsAlreadyForcedToZero(self)
5178
5179    def AddSoftSameVehicleConstraint(self, indices, cost):
5180        r"""
5181        Adds a soft constraint to force a set of variable indices to be on the
5182        same vehicle. If all nodes are not on the same vehicle, each extra vehicle
5183        used adds 'cost' to the cost function.
5184        """
5185        return _pywrapcp.RoutingModel_AddSoftSameVehicleConstraint(self, indices, cost)
5186
5187    def SetAllowedVehiclesForIndex(self, vehicles, index):
5188        r"""
5189        Sets the vehicles which can visit a given node. If the node is in a
5190        disjunction, this will not prevent it from being unperformed.
5191        Specifying an empty vector of vehicles has no effect (all vehicles
5192        will be allowed to visit the node).
5193        """
5194        return _pywrapcp.RoutingModel_SetAllowedVehiclesForIndex(self, vehicles, index)
5195
5196    def IsVehicleAllowedForIndex(self, vehicle, index):
5197        r"""Returns true if a vehicle is allowed to visit a given node."""
5198        return _pywrapcp.RoutingModel_IsVehicleAllowedForIndex(self, vehicle, index)
5199
5200    def AddPickupAndDelivery(self, pickup, delivery):
5201        r"""
5202        Notifies that index1 and index2 form a pair of nodes which should belong
5203        to the same route. This methods helps the search find better solutions,
5204        especially in the local search phase.
5205        It should be called each time you have an equality constraint linking
5206        the vehicle variables of two node (including for instance pickup and
5207        delivery problems):
5208            Solver* const solver = routing.solver();
5209            int64_t index1 = manager.NodeToIndex(node1);
5210            int64_t index2 = manager.NodeToIndex(node2);
5211            solver->AddConstraint(solver->MakeEquality(
5212                routing.VehicleVar(index1),
5213                routing.VehicleVar(index2)));
5214            routing.AddPickupAndDelivery(index1, index2);
5215        """
5216        return _pywrapcp.RoutingModel_AddPickupAndDelivery(self, pickup, delivery)
5217
5218    def AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction):
5219        r"""
5220        Same as AddPickupAndDelivery but notifying that the performed node from
5221        the disjunction of index 'pickup_disjunction' is on the same route as the
5222        performed node from the disjunction of index 'delivery_disjunction'.
5223        """
5224        return _pywrapcp.RoutingModel_AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction)
5225
5226    def GetPickupPosition(self, node_index):
5227        r"""Returns the pickup and delivery positions where the node is a pickup."""
5228        return _pywrapcp.RoutingModel_GetPickupPosition(self, node_index)
5229
5230    def GetDeliveryPosition(self, node_index):
5231        r"""Returns the pickup and delivery positions where the node is a delivery."""
5232        return _pywrapcp.RoutingModel_GetDeliveryPosition(self, node_index)
5233
5234    def IsPickup(self, node_index):
5235        r"""Returns whether the node is a pickup (resp. delivery)."""
5236        return _pywrapcp.RoutingModel_IsPickup(self, node_index)
5237
5238    def IsDelivery(self, node_index):
5239        return _pywrapcp.RoutingModel_IsDelivery(self, node_index)
5240
5241    def SetPickupAndDeliveryPolicyOfAllVehicles(self, policy):
5242        r"""
5243        Sets the Pickup and delivery policy of all vehicles. It is equivalent to
5244        calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.
5245        """
5246        return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfAllVehicles(self, policy)
5247
5248    def SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle):
5249        return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle)
5250
5251    def GetPickupAndDeliveryPolicyOfVehicle(self, vehicle):
5252        return _pywrapcp.RoutingModel_GetPickupAndDeliveryPolicyOfVehicle(self, vehicle)
5253
5254    def GetNumOfSingletonNodes(self):
5255        r"""
5256        Returns the number of non-start/end nodes which do not appear in a
5257        pickup/delivery pair.
5258        """
5259        return _pywrapcp.RoutingModel_GetNumOfSingletonNodes(self)
5260
5261    def GetFirstMatchingPickupDeliverySibling(self, node, is_match):
5262        return _pywrapcp.RoutingModel_GetFirstMatchingPickupDeliverySibling(self, node, is_match)
5263    TYPE_ADDED_TO_VEHICLE = _pywrapcp.RoutingModel_TYPE_ADDED_TO_VEHICLE
5264    r"""When visited, the number of types 'T' on the vehicle increases by one."""
5265    ADDED_TYPE_REMOVED_FROM_VEHICLE = _pywrapcp.RoutingModel_ADDED_TYPE_REMOVED_FROM_VEHICLE
5266    r"""
5267    When visited, one instance of type 'T' previously added to the route
5268    (TYPE_ADDED_TO_VEHICLE), if any, is removed from the vehicle.
5269    If the type was not previously added to the route or all added instances
5270    have already been removed, this visit has no effect on the types.
5271    """
5272    TYPE_ON_VEHICLE_UP_TO_VISIT = _pywrapcp.RoutingModel_TYPE_ON_VEHICLE_UP_TO_VISIT
5273    r"""
5274    With the following policy, the visit enforces that type 'T' is
5275    considered on the route from its start until this node is visited.
5276    """
5277    TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = _pywrapcp.RoutingModel_TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
5278    r"""
5279    The visit doesn't have an impact on the number of types 'T' on the
5280    route, as it's (virtually) added and removed directly.
5281    This policy can be used for visits which are part of an incompatibility
5282    or requirement set without affecting the type count on the route.
5283    """
5284
5285    def SetVisitType(self, index, type, type_policy):
5286        return _pywrapcp.RoutingModel_SetVisitType(self, index, type, type_policy)
5287
5288    def GetVisitType(self, index):
5289        return _pywrapcp.RoutingModel_GetVisitType(self, index)
5290
5291    def GetSingleNodesOfType(self, type):
5292        return _pywrapcp.RoutingModel_GetSingleNodesOfType(self, type)
5293
5294    def GetPairIndicesOfType(self, type):
5295        return _pywrapcp.RoutingModel_GetPairIndicesOfType(self, type)
5296
5297    def GetVisitTypePolicy(self, index):
5298        return _pywrapcp.RoutingModel_GetVisitTypePolicy(self, index)
5299
5300    def GetNumberOfVisitTypes(self):
5301        return _pywrapcp.RoutingModel_GetNumberOfVisitTypes(self)
5302
5303    def AddHardTypeIncompatibility(self, type1, type2):
5304        r"""
5305        Incompatibilities:
5306        Two nodes with "hard" incompatible types cannot share the same route at
5307        all, while with a "temporal" incompatibility they can't be on the same
5308        route at the same time.
5309        NOTE: To avoid unnecessary memory reallocations, it is recommended to only
5310        add incompatibilities once all the existing types have been set with
5311        SetVisitType().
5312        """
5313        return _pywrapcp.RoutingModel_AddHardTypeIncompatibility(self, type1, type2)
5314
5315    def AddTemporalTypeIncompatibility(self, type1, type2):
5316        return _pywrapcp.RoutingModel_AddTemporalTypeIncompatibility(self, type1, type2)
5317
5318    def GetHardTypeIncompatibilitiesOfType(self, type):
5319        r"""Returns visit types incompatible with a given type."""
5320        return _pywrapcp.RoutingModel_GetHardTypeIncompatibilitiesOfType(self, type)
5321
5322    def GetTemporalTypeIncompatibilitiesOfType(self, type):
5323        return _pywrapcp.RoutingModel_GetTemporalTypeIncompatibilitiesOfType(self, type)
5324
5325    def HasHardTypeIncompatibilities(self):
5326        r"""
5327        Returns true iff any hard (resp. temporal) type incompatibilities have
5328        been added to the model.
5329        """
5330        return _pywrapcp.RoutingModel_HasHardTypeIncompatibilities(self)
5331
5332    def HasTemporalTypeIncompatibilities(self):
5333        return _pywrapcp.RoutingModel_HasTemporalTypeIncompatibilities(self)
5334
5335    def AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives):
5336        r"""
5337        Requirements:
5338        NOTE: As of 2019-04, cycles in the requirement graph are not supported,
5339        and lead to the dependent nodes being skipped if possible (otherwise
5340        the model is considered infeasible).
5341        The following functions specify that "dependent_type" requires at least
5342        one of the types in "required_type_alternatives".
5343
5344        For same-vehicle requirements, a node of dependent type type_D requires at
5345        least one node of type type_R among the required alternatives on the same
5346        route.
5347        NOTE: To avoid unnecessary memory reallocations, it is recommended to only
5348        add requirements once all the existing types have been set with
5349        SetVisitType().
5350        """
5351        return _pywrapcp.RoutingModel_AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives)
5352
5353    def AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives):
5354        r"""
5355        If type_D depends on type_R when adding type_D, any node_D of type_D and
5356        VisitTypePolicy TYPE_ADDED_TO_VEHICLE or
5357        TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its
5358        vehicle at the time node_D is visited.
5359        """
5360        return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives)
5361
5362    def AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives):
5363        r"""
5364        The following requirements apply when visiting dependent nodes that remove
5365        their type from the route, i.e. type_R must be on the vehicle when type_D
5366        of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE,
5367        TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is
5368        visited.
5369        """
5370        return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives)
5371
5372    def GetSameVehicleRequiredTypeAlternativesOfType(self, type):
5373        r"""
5374        Returns the set of same-vehicle requirement alternatives for the given
5375        type.
5376        """
5377        return _pywrapcp.RoutingModel_GetSameVehicleRequiredTypeAlternativesOfType(self, type)
5378
5379    def GetRequiredTypeAlternativesWhenAddingType(self, type):
5380        r"""Returns the set of requirement alternatives when adding the given type."""
5381        return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenAddingType(self, type)
5382
5383    def GetRequiredTypeAlternativesWhenRemovingType(self, type):
5384        r"""Returns the set of requirement alternatives when removing the given type."""
5385        return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenRemovingType(self, type)
5386
5387    def HasSameVehicleTypeRequirements(self):
5388        r"""
5389        Returns true iff any same-route (resp. temporal) type requirements have
5390        been added to the model.
5391        """
5392        return _pywrapcp.RoutingModel_HasSameVehicleTypeRequirements(self)
5393
5394    def HasTemporalTypeRequirements(self):
5395        return _pywrapcp.RoutingModel_HasTemporalTypeRequirements(self)
5396
5397    def HasTypeRegulations(self):
5398        r"""
5399        Returns true iff the model has any incompatibilities or requirements set
5400        on node types.
5401        """
5402        return _pywrapcp.RoutingModel_HasTypeRegulations(self)
5403
5404    def UnperformedPenalty(self, var_index):
5405        r"""
5406        Get the "unperformed" penalty of a node. This is only well defined if the
5407        node is only part of a single Disjunction, and that disjunction has a
5408        penalty. For forced active nodes returns max int64_t. In all other cases,
5409        this returns 0.
5410        """
5411        return _pywrapcp.RoutingModel_UnperformedPenalty(self, var_index)
5412
5413    def UnperformedPenaltyOrValue(self, default_value, var_index):
5414        r"""
5415        Same as above except that it returns default_value instead of 0 when
5416        penalty is not well defined (default value is passed as first argument to
5417        simplify the usage of the method in a callback).
5418        """
5419        return _pywrapcp.RoutingModel_UnperformedPenaltyOrValue(self, default_value, var_index)
5420
5421    def GetDepot(self):
5422        r"""
5423        Returns the variable index of the first starting or ending node of all
5424        routes. If all routes start  and end at the same node (single depot), this
5425        is the node returned.
5426        """
5427        return _pywrapcp.RoutingModel_GetDepot(self)
5428
5429    def SetMaximumNumberOfActiveVehicles(self, max_active_vehicles):
5430        r"""
5431        Constrains the maximum number of active vehicles, aka the number of
5432        vehicles which do not have an empty route. For instance, this can be used
5433        to limit the number of routes in the case where there are fewer drivers
5434        than vehicles and that the fleet of vehicle is heterogeneous.
5435        """
5436        return _pywrapcp.RoutingModel_SetMaximumNumberOfActiveVehicles(self, max_active_vehicles)
5437
5438    def GetMaximumNumberOfActiveVehicles(self):
5439        r"""Returns the maximum number of active vehicles."""
5440        return _pywrapcp.RoutingModel_GetMaximumNumberOfActiveVehicles(self)
5441
5442    def SetArcCostEvaluatorOfAllVehicles(self, evaluator_index):
5443        r"""
5444        Sets the cost function of the model such that the cost of a segment of a
5445        route between node 'from' and 'to' is evaluator(from, to), whatever the
5446        route or vehicle performing the route.
5447        """
5448        return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfAllVehicles(self, evaluator_index)
5449
5450    def SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle):
5451        r"""Sets the cost function for a given vehicle route."""
5452        return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle)
5453
5454    def SetFixedCostOfAllVehicles(self, cost):
5455        r"""
5456        Sets the fixed cost of all vehicle routes. It is equivalent to calling
5457        SetFixedCostOfVehicle on all vehicle routes.
5458        """
5459        return _pywrapcp.RoutingModel_SetFixedCostOfAllVehicles(self, cost)
5460
5461    def SetFixedCostOfVehicle(self, cost, vehicle):
5462        r"""Sets the fixed cost of one vehicle route."""
5463        return _pywrapcp.RoutingModel_SetFixedCostOfVehicle(self, cost, vehicle)
5464
5465    def GetFixedCostOfVehicle(self, vehicle):
5466        r"""
5467        Returns the route fixed cost taken into account if the route of the
5468        vehicle is not empty, aka there's at least one node on the route other
5469        than the first and last nodes.
5470        """
5471        return _pywrapcp.RoutingModel_GetFixedCostOfVehicle(self, vehicle)
5472
5473    def SetPathEnergyCostOfVehicle(self, force, distance, cost_per_unit, vehicle):
5474        return _pywrapcp.RoutingModel_SetPathEnergyCostOfVehicle(self, force, distance, cost_per_unit, vehicle)
5475
5476    def SetPathEnergyCostsOfVehicle(self, force, distance, threshold, cost_per_unit_below_threshold, cost_per_unit_above_threshold, vehicle):
5477        return _pywrapcp.RoutingModel_SetPathEnergyCostsOfVehicle(self, force, distance, threshold, cost_per_unit_below_threshold, cost_per_unit_above_threshold, vehicle)
5478
5479    def SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor):
5480        r"""
5481        The following methods set the linear and quadratic cost factors of
5482        vehicles (must be positive values). The default value of these parameters
5483        is zero for all vehicles.
5484
5485        When set, the cost_ of the model will contain terms aiming at reducing the
5486        number of vehicles used in the model, by adding the following to the
5487        objective for every vehicle v:
5488        INDICATOR(v used in the model) *
5489          [linear_cost_factor_of_vehicle_[v]
5490           - quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)]
5491        i.e. for every used vehicle, we add the linear factor as fixed cost, and
5492        subtract the square of the route length multiplied by the quadratic
5493        factor. This second term aims at making the routes as dense as possible.
5494
5495        Sets the linear and quadratic cost factor of all vehicles.
5496        """
5497        return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor)
5498
5499    def SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle):
5500        r"""Sets the linear and quadratic cost factor of the given vehicle."""
5501        return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle)
5502
5503    def GetAmortizedLinearCostFactorOfVehicles(self):
5504        return _pywrapcp.RoutingModel_GetAmortizedLinearCostFactorOfVehicles(self)
5505
5506    def GetAmortizedQuadraticCostFactorOfVehicles(self):
5507        return _pywrapcp.RoutingModel_GetAmortizedQuadraticCostFactorOfVehicles(self)
5508
5509    def AddRouteConstraint(self, route_evaluator, costs_are_homogeneous_across_vehicles=False):
5510        return _pywrapcp.RoutingModel_AddRouteConstraint(self, route_evaluator, costs_are_homogeneous_across_vehicles)
5511
5512    def GetRouteCost(self, route):
5513        return _pywrapcp.RoutingModel_GetRouteCost(self, route)
5514
5515    def SetVehicleUsedWhenEmpty(self, is_used, vehicle):
5516        return _pywrapcp.RoutingModel_SetVehicleUsedWhenEmpty(self, is_used, vehicle)
5517
5518    def IsVehicleUsedWhenEmpty(self, vehicle):
5519        return _pywrapcp.RoutingModel_IsVehicleUsedWhenEmpty(self, vehicle)
5520
5521    def SetFirstSolutionEvaluator(self, evaluator):
5522        r"""
5523        Gets/sets the evaluator used during the search. Only relevant when
5524        RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY.
5525        Takes ownership of evaluator.
5526        """
5527        return _pywrapcp.RoutingModel_SetFirstSolutionEvaluator(self, evaluator)
5528
5529    def SetFirstSolutionHint(self, hint):
5530        r"""
5531        Adds a hint to be used by first solution strategies. The hint assignment
5532        must outlive the search.
5533        As of 2024-12, only used by LOCAL_CHEAPEST_INSERTION and
5534        LOCAL_CHEAPEST_COST_INSERTION.
5535        """
5536        return _pywrapcp.RoutingModel_SetFirstSolutionHint(self, hint)
5537
5538    def GetFirstSolutionHint(self):
5539        r"""Returns the current hint assignment."""
5540        return _pywrapcp.RoutingModel_GetFirstSolutionHint(self)
5541
5542    def AddLocalSearchOperator(self, ls_operator):
5543        r"""
5544        Adds a local search operator to the set of operators used to solve the
5545        vehicle routing problem.
5546        """
5547        return _pywrapcp.RoutingModel_AddLocalSearchOperator(self, ls_operator)
5548
5549    def AddSearchMonitor(self, monitor):
5550        r"""Adds a search monitor to the search used to solve the routing model."""
5551        return _pywrapcp.RoutingModel_AddSearchMonitor(self, monitor)
5552
5553    def AddEnterSearchCallback(self, callback):
5554        return _pywrapcp.RoutingModel_AddEnterSearchCallback(self, callback)
5555
5556    def AddAtSolutionCallback(self, callback, track_unchecked_neighbors=False):
5557        r"""
5558        Adds a callback called each time a solution is found during the search.
5559        This is a shortcut to creating a monitor to call the callback on
5560        AtSolution() and adding it with AddSearchMonitor.
5561        If track_unchecked_neighbors is true, the callback will also be called on
5562        AcceptUncheckedNeighbor() events, which is useful to grab solutions
5563        obtained when solver_parameters.check_solution_period > 1 (aka fastLS).
5564        """
5565        return _pywrapcp.RoutingModel_AddAtSolutionCallback(self, callback, track_unchecked_neighbors)
5566
5567    def AddRestoreDimensionValuesResetCallback(self, callback):
5568        return _pywrapcp.RoutingModel_AddRestoreDimensionValuesResetCallback(self, callback)
5569
5570    def AddVariableMinimizedByFinalizer(self, var):
5571        r"""
5572        Adds a variable to minimize in the solution finalizer. The solution
5573        finalizer is called each time a solution is found during the search and
5574        allows to instantiate secondary variables (such as dimension cumul
5575        variables).
5576        """
5577        return _pywrapcp.RoutingModel_AddVariableMinimizedByFinalizer(self, var)
5578
5579    def AddVariableMaximizedByFinalizer(self, var):
5580        r"""
5581        Adds a variable to maximize in the solution finalizer (see above for
5582        information on the solution finalizer).
5583        """
5584        return _pywrapcp.RoutingModel_AddVariableMaximizedByFinalizer(self, var)
5585
5586    def AddWeightedVariableMinimizedByFinalizer(self, var, cost):
5587        r"""
5588        Adds a variable to minimize in the solution finalizer, with a weighted
5589        priority: the higher the more priority it has.
5590        """
5591        return _pywrapcp.RoutingModel_AddWeightedVariableMinimizedByFinalizer(self, var, cost)
5592
5593    def AddWeightedVariableMaximizedByFinalizer(self, var, cost):
5594        r"""
5595        Adds a variable to maximize in the solution finalizer, with a weighted
5596        priority: the higher the more priority it has.
5597        """
5598        return _pywrapcp.RoutingModel_AddWeightedVariableMaximizedByFinalizer(self, var, cost)
5599
5600    def AddVariableTargetToFinalizer(self, var, target):
5601        r"""
5602        Add a variable to set the closest possible to the target value in the
5603        solution finalizer.
5604        """
5605        return _pywrapcp.RoutingModel_AddVariableTargetToFinalizer(self, var, target)
5606
5607    def AddWeightedVariableTargetToFinalizer(self, var, target, cost):
5608        r"""
5609        Same as above with a weighted priority: the higher the cost, the more
5610        priority it has to be set close to the target value.
5611        """
5612        return _pywrapcp.RoutingModel_AddWeightedVariableTargetToFinalizer(self, var, target, cost)
5613
5614    def CloseModel(self):
5615        r"""
5616        Closes the current routing model; after this method is called, no
5617        modification to the model can be done, but RoutesToAssignment becomes
5618        available. Note that CloseModel() is automatically called by Solve() and
5619        other methods that produce solution.
5620        This is equivalent to calling
5621        CloseModelWithParameters(DefaultRoutingSearchParameters()).
5622        """
5623        return _pywrapcp.RoutingModel_CloseModel(self)
5624
5625    def CloseModelWithParameters(self, search_parameters):
5626        r"""
5627        Same as above taking search parameters (as of 10/2015 some the parameters
5628        have to be set when closing the model).
5629        """
5630        return _pywrapcp.RoutingModel_CloseModelWithParameters(self, search_parameters)
5631
5632    def Solve(self, assignment=None):
5633        r"""
5634        Solves the current routing model; closes the current model.
5635        This is equivalent to calling
5636        SolveWithParameters(DefaultRoutingSearchParameters())
5637        or
5638        SolveFromAssignmentWithParameters(assignment,
5639                                          DefaultRoutingSearchParameters()).
5640        """
5641        return _pywrapcp.RoutingModel_Solve(self, assignment)
5642
5643    def SolveWithParameters(self, search_parameters, solutions=None):
5644        r"""
5645        Solves the current routing model with the given parameters. If 'solutions'
5646        is specified, it will contain the k best solutions found during the search
5647        (from worst to best, including the one returned by this method), where k
5648        corresponds to the 'number_of_solutions_to_collect' in
5649        'search_parameters'. Note that the Assignment returned by the method and
5650        the ones in solutions are owned by the underlying solver and should not be
5651        deleted.
5652        """
5653        return _pywrapcp.RoutingModel_SolveWithParameters(self, search_parameters, solutions)
5654
5655    def SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions=None):
5656        r"""
5657        Same as above, except that if assignment is not null, it will be used as
5658        the initial solution.
5659        """
5660        return _pywrapcp.RoutingModel_SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions)
5661
5662    def FastSolveFromAssignmentWithParameters(self, assignment, search_parameters, check_solution_in_cp, touched=None):
5663        r"""
5664        Improves a given assignment using unchecked local search.
5665        If check_solution_in_cp is true the final solution will be checked with
5666        the CP solver.
5667        As of 11/2023, only works with greedy descent.
5668        """
5669        return _pywrapcp.RoutingModel_FastSolveFromAssignmentWithParameters(self, assignment, search_parameters, check_solution_in_cp, touched)
5670
5671    def SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions=None):
5672        r"""
5673        Same as above but will try all assignments in order as first solutions
5674        until one succeeds.
5675        """
5676        return _pywrapcp.RoutingModel_SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions)
5677
5678    def SolveWithIteratedLocalSearch(self, search_parameters):
5679        r"""
5680        Solves the current routing model by using an Iterated Local Search
5681        approach.
5682        """
5683        return _pywrapcp.RoutingModel_SolveWithIteratedLocalSearch(self, search_parameters)
5684
5685    def SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment):
5686        r"""
5687        Given a "source_model" and its "source_assignment", resets
5688        "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_
5689        if costs aren't homogeneous across vehicles) of "this" model, with the
5690        values set according to those in "other_assignment".
5691        The objective_element of target_assignment is set to this->cost_.
5692        """
5693        return _pywrapcp.RoutingModel_SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment)
5694
5695    def ComputeLowerBound(self):
5696        r"""
5697        Computes a lower bound to the routing problem solving a linear assignment
5698        problem. The routing model must be closed before calling this method.
5699        Note that problems with node disjunction constraints (including optional
5700        nodes) and non-homogenous costs are not supported (the method returns 0 in
5701        these cases).
5702        """
5703        return _pywrapcp.RoutingModel_ComputeLowerBound(self)
5704
5705    def objective_lower_bound(self):
5706        r"""
5707        Returns the current lower bound found by internal solvers during the
5708        search.
5709        """
5710        return _pywrapcp.RoutingModel_objective_lower_bound(self)
5711
5712    def status(self):
5713        r"""Returns the current status of the routing model."""
5714        return _pywrapcp.RoutingModel_status(self)
5715
5716    def enable_deep_serialization(self):
5717        r"""Returns the value of the internal enable_deep_serialization_ parameter."""
5718        return _pywrapcp.RoutingModel_enable_deep_serialization(self)
5719
5720    def ApplyLocks(self, locks):
5721        r"""
5722        Applies a lock chain to the next search. 'locks' represents an ordered
5723        vector of nodes representing a partial route which will be fixed during
5724        the next search; it will constrain next variables such that:
5725        next[locks[i]] == locks[i+1].
5726
5727        Returns the next variable at the end of the locked chain; this variable is
5728        not locked. An assignment containing the locks can be obtained by calling
5729        PreAssignment().
5730        """
5731        return _pywrapcp.RoutingModel_ApplyLocks(self, locks)
5732
5733    def ApplyLocksToAllVehicles(self, locks, close_routes):
5734        r"""
5735        Applies lock chains to all vehicles to the next search, such that locks[p]
5736        is the lock chain for route p. Returns false if the locks do not contain
5737        valid routes; expects that the routes do not contain the depots,
5738        i.e. there are empty vectors in place of empty routes.
5739        If close_routes is set to true, adds the end nodes to the route of each
5740        vehicle and deactivates other nodes.
5741        An assignment containing the locks can be obtained by calling
5742        PreAssignment().
5743        """
5744        return _pywrapcp.RoutingModel_ApplyLocksToAllVehicles(self, locks, close_routes)
5745
5746    def PreAssignment(self):
5747        r"""
5748        Returns an assignment used to fix some of the variables of the problem.
5749        In practice, this assignment locks partial routes of the problem. This
5750        can be used in the context of locking the parts of the routes which have
5751        already been driven in online routing problems.
5752        """
5753        return _pywrapcp.RoutingModel_PreAssignment(self)
5754
5755    def MutablePreAssignment(self):
5756        return _pywrapcp.RoutingModel_MutablePreAssignment(self)
5757
5758    def WriteAssignment(self, file_name):
5759        r"""
5760        Writes the current solution to a file containing an AssignmentProto.
5761        Returns false if the file cannot be opened or if there is no current
5762        solution.
5763        """
5764        return _pywrapcp.RoutingModel_WriteAssignment(self, file_name)
5765
5766    def ReadAssignment(self, file_name):
5767        r"""
5768        Reads an assignment from a file and returns the current solution.
5769        Returns nullptr if the file cannot be opened or if the assignment is not
5770        valid.
5771        """
5772        return _pywrapcp.RoutingModel_ReadAssignment(self, file_name)
5773
5774    def RestoreAssignment(self, solution):
5775        r"""
5776        Restores an assignment as a solution in the routing model and returns the
5777        new solution. Returns nullptr if the assignment is not valid.
5778        """
5779        return _pywrapcp.RoutingModel_RestoreAssignment(self, solution)
5780
5781    def ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices):
5782        r"""
5783        Restores the routes as the current solution. Returns nullptr if the
5784        solution cannot be restored (routes do not contain a valid solution). Note
5785        that calling this method will run the solver to assign values to the
5786        dimension variables; this may take considerable amount of time, especially
5787        when using dimensions with slack.
5788        """
5789        return _pywrapcp.RoutingModel_ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices)
5790
5791    def RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment):
5792        r"""
5793        Fills an assignment from a specification of the routes of the
5794        vehicles. The routes are specified as lists of variable indices that
5795        appear on the routes of the vehicles. The indices of the outer vector in
5796        'routes' correspond to vehicles IDs, the inner vector contains the
5797        variable indices on the routes for the given vehicle. The inner vectors
5798        must not contain the start and end indices, as these are determined by the
5799        routing model.  Sets the value of NextVars in the assignment, adding the
5800        variables to the assignment if necessary. The method does not touch other
5801        variables in the assignment. The method can only be called after the model
5802        is closed.  With ignore_inactive_indices set to false, this method will
5803        fail (return nullptr) in case some of the route contain indices that are
5804        deactivated in the model; when set to true, these indices will be
5805        skipped.  Returns true if routes were successfully
5806        loaded. However, such assignment still might not be a valid
5807        solution to the routing problem due to more complex constraints;
5808        it is advisible to call solver()->CheckSolution() afterwards.
5809        """
5810        return _pywrapcp.RoutingModel_RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment)
5811
5812    def AssignmentToRoutes(self, assignment, routes):
5813        r"""
5814        Converts the solution in the given assignment to routes for all vehicles.
5815        Expects that assignment contains a valid solution (i.e. routes for all
5816        vehicles end with an end index for that vehicle).
5817        """
5818        return _pywrapcp.RoutingModel_AssignmentToRoutes(self, assignment, routes)
5819
5820    def CompactAssignment(self, assignment):
5821        r"""
5822        Converts the solution in the given assignment to routes for all vehicles.
5823        If the returned vector is route_indices, route_indices[i][j] is the index
5824        for jth location visited on route i. Note that contrary to
5825        AssignmentToRoutes, the vectors do include start and end locations.
5826        Returns a compacted version of the given assignment, in which all vehicles
5827        with id lower or equal to some N have non-empty routes, and all vehicles
5828        with id greater than N have empty routes. Does not take ownership of the
5829        returned object.
5830        If found, the cost of the compact assignment is the same as in the
5831        original assignment and it preserves the values of 'active' variables.
5832        Returns nullptr if a compact assignment was not found.
5833        This method only works in homogenous mode, and it only swaps equivalent
5834        vehicles (vehicles with the same start and end nodes). When creating the
5835        compact assignment, the empty plan is replaced by the route assigned to
5836        the compatible vehicle with the highest id. Note that with more complex
5837        constraints on vehicle variables, this method might fail even if a compact
5838        solution exists.
5839        This method changes the vehicle and dimension variables as necessary.
5840        While compacting the solution, only basic checks on vehicle variables are
5841        performed; if one of these checks fails no attempts to repair it are made
5842        (instead, the method returns nullptr).
5843        """
5844        return _pywrapcp.RoutingModel_CompactAssignment(self, assignment)
5845
5846    def CompactAndCheckAssignment(self, assignment):
5847        r"""
5848        Same as CompactAssignment() but also checks the validity of the final
5849        compact solution; if it is not valid, no attempts to repair it are made
5850        (instead, the method returns nullptr).
5851        """
5852        return _pywrapcp.RoutingModel_CompactAndCheckAssignment(self, assignment)
5853
5854    def AddToAssignment(self, var):
5855        r"""Adds an extra variable to the vehicle routing assignment."""
5856        return _pywrapcp.RoutingModel_AddToAssignment(self, var)
5857
5858    def AddIntervalToAssignment(self, interval):
5859        return _pywrapcp.RoutingModel_AddIntervalToAssignment(self, interval)
5860
5861    def PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached=None):
5862        r"""
5863        For every dimension in the model with an optimizer in
5864        local/global_dimension_optimizers_, this method tries to pack the cumul
5865        values of the dimension, such that:
5866        - The cumul costs (span costs, soft lower and upper bound costs, etc) are
5867          minimized.
5868        - The cumuls of the ends of the routes are minimized for this given
5869          minimal cumul cost.
5870        - Given these minimal end cumuls, the route start cumuls are maximized.
5871        Returns the assignment resulting from allocating these packed cumuls with
5872        the solver, and nullptr if these cumuls could not be set by the solver.
5873        """
5874        return _pywrapcp.RoutingModel_PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached)
5875
5876    def GetOrCreateNodeNeighborsByCostClass(self, *args):
5877        r"""
5878        *Overload 1:*
5879        Returns neighbors of all nodes for every cost class. The result is cached
5880        and is computed once. The number of neighbors considered is based on a
5881        ratio of non-vehicle nodes, specified by neighbors_ratio, with a minimum
5882        of min-neighbors node considered.
5883
5884        |
5885
5886        *Overload 2:*
5887        Returns parameters.num_neighbors neighbors of all nodes for every cost
5888        class. The result is cached and is computed once.
5889        """
5890        return _pywrapcp.RoutingModel_GetOrCreateNodeNeighborsByCostClass(self, *args)
5891
5892    def AddLocalSearchFilter(self, filter):
5893        r"""
5894        Adds a custom local search filter to the list of filters used to speed up
5895        local search by pruning unfeasible variable assignments.
5896        Calling this method after the routing model has been closed (CloseModel()
5897        or Solve() has been called) has no effect.
5898        The routing model does not take ownership of the filter.
5899        """
5900        return _pywrapcp.RoutingModel_AddLocalSearchFilter(self, filter)
5901
5902    def Start(self, vehicle):
5903        r"""
5904        Model inspection.
5905        Returns the variable index of the starting node of a vehicle route.
5906        """
5907        return _pywrapcp.RoutingModel_Start(self, vehicle)
5908
5909    def End(self, vehicle):
5910        r"""Returns the variable index of the ending node of a vehicle route."""
5911        return _pywrapcp.RoutingModel_End(self, vehicle)
5912
5913    def IsStart(self, index):
5914        r"""Returns true if 'index' represents the first node of a route."""
5915        return _pywrapcp.RoutingModel_IsStart(self, index)
5916
5917    def IsEnd(self, index):
5918        r"""Returns true if 'index' represents the last node of a route."""
5919        return _pywrapcp.RoutingModel_IsEnd(self, index)
5920
5921    def VehicleIndex(self, index):
5922        r"""
5923        Returns the vehicle of the given start/end index, and -1 if the given
5924        index is not a vehicle start/end.
5925        """
5926        return _pywrapcp.RoutingModel_VehicleIndex(self, index)
5927
5928    def Next(self, assignment, index):
5929        r"""
5930        Assignment inspection
5931        Returns the variable index of the node directly after the node
5932        corresponding to 'index' in 'assignment'.
5933        """
5934        return _pywrapcp.RoutingModel_Next(self, assignment, index)
5935
5936    def IsVehicleUsed(self, assignment, vehicle):
5937        r"""Returns true if the route of 'vehicle' is non empty in 'assignment'."""
5938        return _pywrapcp.RoutingModel_IsVehicleUsed(self, assignment, vehicle)
5939
5940    def NextVar(self, index):
5941        r"""
5942        Returns the next variable of the node corresponding to index. Note that
5943        NextVar(index) == index is equivalent to ActiveVar(index) == 0.
5944        """
5945        return _pywrapcp.RoutingModel_NextVar(self, index)
5946
5947    def ActiveVar(self, index):
5948        r"""Returns the active variable of the node corresponding to index."""
5949        return _pywrapcp.RoutingModel_ActiveVar(self, index)
5950
5951    def ActiveVehicleVar(self, vehicle):
5952        r"""
5953        Returns the active variable of the vehicle. It will be equal to 1 iff the
5954        route of the vehicle is not empty, 0 otherwise.
5955        """
5956        return _pywrapcp.RoutingModel_ActiveVehicleVar(self, vehicle)
5957
5958    def VehicleRouteConsideredVar(self, vehicle):
5959        r"""
5960        Returns the variable specifying whether or not the given vehicle route is
5961        considered for costs and constraints. It will be equal to 1 iff the route
5962        of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.
5963        """
5964        return _pywrapcp.RoutingModel_VehicleRouteConsideredVar(self, vehicle)
5965
5966    def VehicleVar(self, index):
5967        r"""
5968        Returns the vehicle variable of the node corresponding to index. Note that
5969        VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.
5970        """
5971        return _pywrapcp.RoutingModel_VehicleVar(self, index)
5972
5973    def ResourceVar(self, vehicle, resource_group):
5974        r"""
5975        Returns the resource variable for the given vehicle index in the given
5976        resource group. If a vehicle doesn't require a resource from the
5977        corresponding resource group, then ResourceVar(v, r_g) == -1.
5978        """
5979        return _pywrapcp.RoutingModel_ResourceVar(self, vehicle, resource_group)
5980
5981    def CostVar(self):
5982        r"""Returns the global cost variable which is being minimized."""
5983        return _pywrapcp.RoutingModel_CostVar(self)
5984
5985    def GetArcCostForVehicle(self, from_index, to_index, vehicle):
5986        r"""
5987        Returns the cost of the transit arc between two nodes for a given vehicle.
5988        Input are variable indices of node. This returns 0 if vehicle < 0.
5989        """
5990        return _pywrapcp.RoutingModel_GetArcCostForVehicle(self, from_index, to_index, vehicle)
5991
5992    def CostsAreHomogeneousAcrossVehicles(self):
5993        r"""Whether costs are homogeneous across all vehicles."""
5994        return _pywrapcp.RoutingModel_CostsAreHomogeneousAcrossVehicles(self)
5995
5996    def GetHomogeneousCost(self, from_index, to_index):
5997        r"""
5998        Returns the cost of the segment between two nodes supposing all vehicle
5999        costs are the same (returns the cost for the first vehicle otherwise).
6000        """
6001        return _pywrapcp.RoutingModel_GetHomogeneousCost(self, from_index, to_index)
6002
6003    def GetArcCostForFirstSolution(self, from_index, to_index):
6004        r"""
6005        Returns the cost of the arc in the context of the first solution strategy.
6006        This is typically a simplification of the actual cost; see the .cc.
6007        """
6008        return _pywrapcp.RoutingModel_GetArcCostForFirstSolution(self, from_index, to_index)
6009
6010    def GetArcCostForClass(self, from_index, to_index, cost_class_index):
6011        r"""
6012        Returns the cost of the segment between two nodes for a given cost
6013        class. Input are variable indices of nodes and the cost class.
6014        Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the
6015        returned cost won't necessarily be zero: only some of the components
6016        of the cost that depend on the cost class will be omited. See the code
6017        for details.
6018        """
6019        return _pywrapcp.RoutingModel_GetArcCostForClass(self, from_index, to_index, cost_class_index)
6020
6021    def GetCostClassIndexOfVehicle(self, vehicle):
6022        r"""Get the cost class index of the given vehicle."""
6023        return _pywrapcp.RoutingModel_GetCostClassIndexOfVehicle(self, vehicle)
6024
6025    def HasVehicleWithCostClassIndex(self, cost_class_index):
6026        r"""
6027        Returns true iff the model contains a vehicle with the given
6028        cost_class_index.
6029        """
6030        return _pywrapcp.RoutingModel_HasVehicleWithCostClassIndex(self, cost_class_index)
6031
6032    def GetCostClassesCount(self):
6033        r"""Returns the number of different cost classes in the model."""
6034        return _pywrapcp.RoutingModel_GetCostClassesCount(self)
6035
6036    def GetNonZeroCostClassesCount(self):
6037        r"""Ditto, minus the 'always zero', built-in cost class."""
6038        return _pywrapcp.RoutingModel_GetNonZeroCostClassesCount(self)
6039
6040    def GetVehicleClassIndexOfVehicle(self, vehicle):
6041        return _pywrapcp.RoutingModel_GetVehicleClassIndexOfVehicle(self, vehicle)
6042
6043    def GetVehicleOfClass(self, vehicle_class):
6044        r"""
6045        Returns a vehicle of the given vehicle class, and -1 if there are no
6046        vehicles for this class.
6047        """
6048        return _pywrapcp.RoutingModel_GetVehicleOfClass(self, vehicle_class)
6049
6050    def GetVehicleClassesCount(self):
6051        r"""Returns the number of different vehicle classes in the model."""
6052        return _pywrapcp.RoutingModel_GetVehicleClassesCount(self)
6053
6054    def GetSameVehicleIndicesOfIndex(self, node):
6055        r"""Returns variable indices of nodes constrained to be on the same route."""
6056        return _pywrapcp.RoutingModel_GetSameVehicleIndicesOfIndex(self, node)
6057
6058    def GetSameActivityIndicesOfIndex(self, node):
6059        r"""Returns variable indices of nodes constrained to have the same activity."""
6060        return _pywrapcp.RoutingModel_GetSameActivityIndicesOfIndex(self, node)
6061
6062    def GetSameActivityGroupOfIndex(self, node):
6063        r"""Returns the same activity group of the node."""
6064        return _pywrapcp.RoutingModel_GetSameActivityGroupOfIndex(self, node)
6065
6066    def GetSameActivityGroupsCount(self):
6067        r"""Returns the number of same activity groups."""
6068        return _pywrapcp.RoutingModel_GetSameActivityGroupsCount(self)
6069
6070    def GetSameActivityIndicesOfGroup(self, group):
6071        r"""Returns variable indices of nodes in the same activity group."""
6072        return _pywrapcp.RoutingModel_GetSameActivityIndicesOfGroup(self, group)
6073
6074    def GetVehicleTypeContainer(self):
6075        return _pywrapcp.RoutingModel_GetVehicleTypeContainer(self)
6076
6077    def ArcIsMoreConstrainedThanArc(self, _from, to1, to2):
6078        r"""
6079        Returns whether the arc from->to1 is more constrained than from->to2,
6080        taking into account, in order:
6081        - whether the destination node isn't an end node
6082        - whether the destination node is mandatory
6083        - whether the destination node is bound to the same vehicle as the source
6084        - the "primary constrained" dimension (see SetPrimaryConstrainedDimension)
6085        It then breaks ties using, in order:
6086        - the arc cost (taking unperformed penalties into account)
6087        - the size of the vehicle vars of "to1" and "to2" (lowest size wins)
6088        - the value: the lowest value of the indices to1 and to2 wins.
6089        See the .cc for details.
6090        The more constrained arc is typically preferable when building a
6091        first solution. This method is intended to be used as a callback for the
6092        BestValueByComparisonSelector value selector.
6093        Args:
6094          from: the variable index of the source node
6095          to1: the variable index of the first candidate destination node.
6096          to2: the variable index of the second candidate destination node.
6097        """
6098        return _pywrapcp.RoutingModel_ArcIsMoreConstrainedThanArc(self, _from, to1, to2)
6099
6100    def DebugOutputAssignment(self, solution_assignment, dimension_to_print):
6101        r"""
6102        Print some debugging information about an assignment, including the
6103        feasible intervals of the CumulVar for dimension "dimension_to_print"
6104        at each step of the routes.
6105        If "dimension_to_print" is omitted, all dimensions will be printed.
6106        """
6107        return _pywrapcp.RoutingModel_DebugOutputAssignment(self, solution_assignment, dimension_to_print)
6108
6109    def CheckIfAssignmentIsFeasible(self, assignment, call_at_solution_monitors):
6110        r"""
6111        Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair
6112        containing the minimum and maximum of the CumulVar of the jth node on
6113        route i.
6114        - cumul_bounds[i][j].first is the minimum.
6115        - cumul_bounds[i][j].second is the maximum.
6116        Checks if an assignment is feasible.
6117        """
6118        return _pywrapcp.RoutingModel_CheckIfAssignmentIsFeasible(self, assignment, call_at_solution_monitors)
6119
6120    def solver(self):
6121        r"""
6122        Returns the underlying constraint solver. Can be used to add extra
6123        constraints and/or modify search algorithms.
6124        """
6125        return _pywrapcp.RoutingModel_solver(self)
6126
6127    def CheckLimit(self, *args):
6128        r"""
6129        Returns true if the search limit has been crossed with the given time
6130        offset.
6131        """
6132        return _pywrapcp.RoutingModel_CheckLimit(self, *args)
6133
6134    def RemainingTime(self):
6135        r"""Returns the time left in the search limit."""
6136        return _pywrapcp.RoutingModel_RemainingTime(self)
6137
6138    def UpdateTimeLimit(self, time_limit):
6139        r"""Updates the time limit of the search limit."""
6140        return _pywrapcp.RoutingModel_UpdateTimeLimit(self, time_limit)
6141
6142    def TimeBuffer(self):
6143        r"""Returns the time buffer to safely return a solution."""
6144        return _pywrapcp.RoutingModel_TimeBuffer(self)
6145
6146    def GetMutableCPSatInterrupt(self):
6147        r"""Returns the atomic<bool> to stop the CP-SAT solver."""
6148        return _pywrapcp.RoutingModel_GetMutableCPSatInterrupt(self)
6149
6150    def GetMutableCPInterrupt(self):
6151        r"""Returns the atomic<bool> to stop the CP solver."""
6152        return _pywrapcp.RoutingModel_GetMutableCPInterrupt(self)
6153
6154    def CancelSearch(self):
6155        r"""Cancels the current search."""
6156        return _pywrapcp.RoutingModel_CancelSearch(self)
6157
6158    def nodes(self):
6159        r"""
6160        Sizes and indices
6161        Returns the number of nodes in the model.
6162        """
6163        return _pywrapcp.RoutingModel_nodes(self)
6164
6165    def vehicles(self):
6166        r"""Returns the number of vehicle routes in the model."""
6167        return _pywrapcp.RoutingModel_vehicles(self)
6168
6169    def Size(self):
6170        r"""Returns the number of next variables in the model."""
6171        return _pywrapcp.RoutingModel_Size(self)
6172
6173    def GetNumberOfDecisionsInFirstSolution(self, search_parameters):
6174        r"""
6175        Returns statistics on first solution search, number of decisions sent to
6176        filters, number of decisions rejected by filters.
6177        """
6178        return _pywrapcp.RoutingModel_GetNumberOfDecisionsInFirstSolution(self, search_parameters)
6179
6180    def GetNumberOfRejectsInFirstSolution(self, search_parameters):
6181        return _pywrapcp.RoutingModel_GetNumberOfRejectsInFirstSolution(self, search_parameters)
6182
6183    def GetAutomaticFirstSolutionStrategy(self):
6184        r"""Returns the automatic first solution strategy selected."""
6185        return _pywrapcp.RoutingModel_GetAutomaticFirstSolutionStrategy(self)
6186
6187    def IsMatchingModel(self):
6188        r"""Returns true if a vehicle/node matching problem is detected."""
6189        return _pywrapcp.RoutingModel_IsMatchingModel(self)
6190
6191    def AreRoutesInterdependent(self, parameters):
6192        r"""
6193        Returns true if routes are interdependent. This means that any
6194        modification to a route might impact another.
6195        """
6196        return _pywrapcp.RoutingModel_AreRoutesInterdependent(self, parameters)
6197
6198    def MakeGuidedSlackFinalizer(self, dimension, initializer):
6199        r"""
6200        The next few members are in the public section only for testing purposes.
6201
6202        MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a
6203        dimension using a callback to choose which values to start with.
6204        The finalizer works only when all next variables in the model have
6205        been fixed. It has the following two characteristics:
6206        1. It follows the routes defined by the nexts variables when choosing a
6207           variable to make a decision on.
6208        2. When it comes to choose a value for the slack of node i, the decision
6209           builder first calls the callback with argument i, and supposingly the
6210           returned value is x it creates decisions slack[i] = x, slack[i] = x +
6211           1, slack[i] = x - 1, slack[i] = x + 2, etc.
6212        """
6213        return _pywrapcp.RoutingModel_MakeGuidedSlackFinalizer(self, dimension, initializer)
6214
6215    def MakeSelfDependentDimensionFinalizer(self, dimension):
6216        r"""
6217        MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a
6218        self-dependent dimension. It makes an extensive use of the caches of the
6219        state dependent transits.
6220        In detail, MakeSelfDependentDimensionFinalizer returns a composition of a
6221        local search decision builder with a greedy descent operator for the cumul
6222        of the start of each route and a guided slack finalizer. Provided there
6223        are no time windows and the maximum slacks are large enough, once the
6224        cumul of the start of route is fixed, the guided finalizer can find
6225        optimal values of the slacks for the rest of the route in time
6226        proportional to the length of the route. Therefore the composed finalizer
6227        generally works in time O(log(t)*n*m), where t is the latest possible
6228        departute time, n is the number of nodes in the network and m is the
6229        number of vehicles.
6230        """
6231        return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension)
6232
6233    def GetPathsMetadata(self):
6234        return _pywrapcp.RoutingModel_GetPathsMetadata(self)
6235
6236    def GetVehiclesOfSameClass(self, start_end_index):
6237        r"""
6238        Returns indices of the vehicles which are in the same vehicle class as the
6239        vehicle starting or ending at start_end_index.
6240        """
6241        return _pywrapcp.RoutingModel_GetVehiclesOfSameClass(self, start_end_index)
6242
6243    def GetSameVehicleClassArcs(self, from_index, to_index):
6244        r"""
6245        Returns all arcs which are equivalent to the {from_index, to_index} arc
6246        wrt vehicle classes. Arcs will be returned only if from_index is the
6247        start of a vehicle or if to_index is the end of a vehicle. The returned
6248        arcs will then be starting or ending at start or end nodes of vehicles in
6249        the same vehicle class. The input arc is included in the returned vector.
6250        """
6251        return _pywrapcp.RoutingModel_GetSameVehicleClassArcs(self, from_index, to_index)
RoutingModel(*args)
4869    def __init__(self, *args):
4870        r"""
4871        Constructor taking an index manager. The version which does not take
4872        RoutingModelParameters is equivalent to passing
4873        DefaultRoutingModelParameters().
4874        """
4875        _pywrapcp.RoutingModel_swiginit(self, _pywrapcp.new_RoutingModel(*args))

Constructor taking an index manager. The version which does not take RoutingModelParameters is equivalent to passing DefaultRoutingModelParameters().

thisown
4860    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

PICKUP_AND_DELIVERY_NO_ORDER = 0

Any precedence is accepted.

PICKUP_AND_DELIVERY_LIFO = 1

Deliveries must be performed in reverse order of pickups.

PICKUP_AND_DELIVERY_FIFO = 2

Deliveries must be performed in the same order as pickups.

kTransitEvaluatorSignUnknown = 0
kTransitEvaluatorSignPositiveOrZero = 1
kTransitEvaluatorSignNegativeOrZero = 2
def RegisterUnaryTransitVector(self, values):
4881    def RegisterUnaryTransitVector(self, values):
4882        r"""
4883        Registers 'callback' and returns its index.
4884        The sign parameter allows to notify the solver that the callback only
4885        return values of the given sign. This can help the solver, but passing
4886        an incorrect sign may crash in non-opt compilation mode, and yield
4887        incorrect results in opt.
4888        """
4889        return _pywrapcp.RoutingModel_RegisterUnaryTransitVector(self, values)

Registers 'callback' and returns its index. The sign parameter allows to notify the solver that the callback only return values of the given sign. This can help the solver, but passing an incorrect sign may crash in non-opt compilation mode, and yield incorrect results in opt.

def RegisterUnaryTransitCallback(self, *args):
4891    def RegisterUnaryTransitCallback(self, *args):
4892        return _pywrapcp.RoutingModel_RegisterUnaryTransitCallback(self, *args)
def RegisterTransitMatrix(self, values):
4894    def RegisterTransitMatrix(self, values):
4895        return _pywrapcp.RoutingModel_RegisterTransitMatrix(self, values)
def RegisterTransitCallback(self, *args):
4897    def RegisterTransitCallback(self, *args):
4898        return _pywrapcp.RoutingModel_RegisterTransitCallback(self, *args)
def RegisterCumulDependentTransitCallback(self, callback):
4900    def RegisterCumulDependentTransitCallback(self, callback):
4901        return _pywrapcp.RoutingModel_RegisterCumulDependentTransitCallback(self, callback)
def TransitCallback(self, callback_index):
4903    def TransitCallback(self, callback_index):
4904        return _pywrapcp.RoutingModel_TransitCallback(self, callback_index)
def UnaryTransitCallbackOrNull(self, callback_index):
4906    def UnaryTransitCallbackOrNull(self, callback_index):
4907        return _pywrapcp.RoutingModel_UnaryTransitCallbackOrNull(self, callback_index)
def CumulDependentTransitCallback(self, callback_index):
4909    def CumulDependentTransitCallback(self, callback_index):
4910        return _pywrapcp.RoutingModel_CumulDependentTransitCallback(self, callback_index)
def AddDimension( self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name):
4912    def AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name):
4913        r"""
4914        Model creation
4915        Methods to add dimensions to routes; dimensions represent quantities
4916        accumulated at nodes along the routes. They represent quantities such as
4917        weights or volumes carried along the route, or distance or times.
4918        Quantities at a node are represented by "cumul" variables and the increase
4919        or decrease of quantities between nodes are represented by "transit"
4920        variables. These variables are linked as follows:
4921        if j == next(i), cumul(j) = cumul(i) + transit(i, j) + slack(i)
4922        where slack is a positive slack variable (can represent waiting times for
4923        a time dimension).
4924        Setting the value of fix_start_cumul_to_zero to true will force the
4925        "cumul" variable of the start node of all vehicles to be equal to 0.
4926        Creates a dimension where the transit variable is constrained to be
4927        equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the
4928        slack variable and 'capacity' is the upper bound of the cumul variables.
4929        'name' is the name used to reference the dimension; this name is used to
4930        get cumul and transit variables from the routing model.
4931        Returns false if a dimension with the same name has already been created
4932        (and doesn't create the new dimension).
4933        Takes ownership of the callback 'evaluator'.
4934        """
4935        return _pywrapcp.RoutingModel_AddDimension(self, evaluator_index, slack_max, capacity, fix_start_cumul_to_zero, name)

Model creation Methods to add dimensions to routes; dimensions represent quantities accumulated at nodes along the routes. They represent quantities such as weights or volumes carried along the route, or distance or times. Quantities at a node are represented by "cumul" variables and the increase or decrease of quantities between nodes are represented by "transit" variables. These variables are linked as follows: if j == next(i), cumul(j) = cumul(i) + transit(i, j) + slack(i) where slack is a positive slack variable (can represent waiting times for a time dimension). Setting the value of fix_start_cumul_to_zero to true will force the "cumul" variable of the start node of all vehicles to be equal to 0. Creates a dimension where the transit variable is constrained to be equal to evaluator(i, next(i)); 'slack_max' is the upper bound of the slack variable and 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns false if a dimension with the same name has already been created (and doesn't create the new dimension). Takes ownership of the callback 'evaluator'.

def AddDimensionWithVehicleTransits( self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name):
4937    def AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name):
4938        return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransits(self, evaluator_indices, slack_max, capacity, fix_start_cumul_to_zero, name)
def AddDimensionWithVehicleCapacity( self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4940    def AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4941        return _pywrapcp.RoutingModel_AddDimensionWithVehicleCapacity(self, evaluator_index, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
def AddDimensionWithVehicleTransitAndCapacity( self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4943    def AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4944        return _pywrapcp.RoutingModel_AddDimensionWithVehicleTransitAndCapacity(self, evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)
def AddDimensionWithCumulDependentVehicleTransitAndCapacity( self, fixed_evaluator_indices, cumul_dependent_evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4946    def AddDimensionWithCumulDependentVehicleTransitAndCapacity(self, fixed_evaluator_indices, cumul_dependent_evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name):
4947        r"""
4948        Creates a dimension where the transit variable on arc i->j is the sum of:
4949        - A "fixed" transit value, obtained from the fixed_evaluator_index for
4950          this vehicle, referencing evaluators in transit_evaluators_, and
4951        - A FloatSlopePiecewiseLinearFunction of the cumul of node i, obtained
4952          from the cumul_dependent_evaluator_index of this vehicle, pointing to
4953          an evaluator in cumul_dependent_transit_evaluators_.
4954        """
4955        return _pywrapcp.RoutingModel_AddDimensionWithCumulDependentVehicleTransitAndCapacity(self, fixed_evaluator_indices, cumul_dependent_evaluator_indices, slack_max, vehicle_capacities, fix_start_cumul_to_zero, name)

Creates a dimension where the transit variable on arc i->j is the sum of:

  • A "fixed" transit value, obtained from the fixed_evaluator_index for this vehicle, referencing evaluators in transit_evaluators_, and
  • A FloatSlopePiecewiseLinearFunction of the cumul of node i, obtained from the cumul_dependent_evaluator_index of this vehicle, pointing to an evaluator in cumul_dependent_transit_evaluators_.
def AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name):
4957    def AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name):
4958        r"""
4959        Creates a dimension where the transit variable is constrained to be
4960        equal to 'value'; 'capacity' is the upper bound of the cumul variables.
4961        'name' is the name used to reference the dimension; this name is used to
4962        get cumul and transit variables from the routing model.
4963        Returns a pair consisting of an index to the registered unary transit
4964        callback and a bool denoting whether the dimension has been created.
4965        It is false if a dimension with the same name has already been created
4966        (and doesn't create the new dimension but still register a new callback).
4967        """
4968        return _pywrapcp.RoutingModel_AddConstantDimensionWithSlack(self, value, capacity, slack_max, fix_start_cumul_to_zero, name)

Creates a dimension where the transit variable is constrained to be equal to 'value'; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered unary transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).

def AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name):
4970    def AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name):
4971        return _pywrapcp.RoutingModel_AddConstantDimension(self, value, capacity, fix_start_cumul_to_zero, name)
def AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4973    def AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4974        r"""
4975        Creates a dimension where the transit variable is constrained to be
4976        equal to 'values[i]' for node i; 'capacity' is the upper bound of
4977        the cumul variables. 'name' is the name used to reference the dimension;
4978        this name is used to get cumul and transit variables from the routing
4979        model.
4980        Returns a pair consisting of an index to the registered unary transit
4981        callback and a bool denoting whether the dimension has been created.
4982        It is false if a dimension with the same name has already been created
4983        (and doesn't create the new dimension but still register a new callback).
4984        """
4985        return _pywrapcp.RoutingModel_AddVectorDimension(self, values, capacity, fix_start_cumul_to_zero, name)

Creates a dimension where the transit variable is constrained to be equal to 'values[i]' for node i; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered unary transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).

def AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4987    def AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name):
4988        r"""
4989        Creates a dimension where the transit variable is constrained to be
4990        equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of
4991        the cumul variables. 'name' is the name used to reference the dimension;
4992        this name is used to get cumul and transit variables from the routing
4993        model.
4994        Returns a pair consisting of an index to the registered transit callback
4995        and a bool denoting whether the dimension has been created.
4996        It is false if a dimension with the same name has already been created
4997        (and doesn't create the new dimension but still register a new callback).
4998        """
4999        return _pywrapcp.RoutingModel_AddMatrixDimension(self, values, capacity, fix_start_cumul_to_zero, name)

Creates a dimension where the transit variable is constrained to be equal to 'values[i][next(i)]' for node i; 'capacity' is the upper bound of the cumul variables. 'name' is the name used to reference the dimension; this name is used to get cumul and transit variables from the routing model. Returns a pair consisting of an index to the registered transit callback and a bool denoting whether the dimension has been created. It is false if a dimension with the same name has already been created (and doesn't create the new dimension but still register a new callback).

def GetAllDimensionNames(self):
5001    def GetAllDimensionNames(self):
5002        r"""Outputs the names of all dimensions added to the routing engine."""
5003        return _pywrapcp.RoutingModel_GetAllDimensionNames(self)

Outputs the names of all dimensions added to the routing engine.

def GetDimensions(self):
5005    def GetDimensions(self):
5006        r"""Returns all dimensions of the model."""
5007        return _pywrapcp.RoutingModel_GetDimensions(self)

Returns all dimensions of the model.

def GetDimensionsWithSoftOrSpanCosts(self):
5009    def GetDimensionsWithSoftOrSpanCosts(self):
5010        r"""Returns dimensions with soft or vehicle span costs."""
5011        return _pywrapcp.RoutingModel_GetDimensionsWithSoftOrSpanCosts(self)

Returns dimensions with soft or vehicle span costs.

def GetUnaryDimensions(self):
5013    def GetUnaryDimensions(self):
5014        r"""Returns dimensions for which all transit evaluators are unary."""
5015        return _pywrapcp.RoutingModel_GetUnaryDimensions(self)

Returns dimensions for which all transit evaluators are unary.

def GetDimensionsWithGlobalCumulOptimizers(self):
5017    def GetDimensionsWithGlobalCumulOptimizers(self):
5018        r"""Returns the dimensions which have [global|local]_dimension_optimizers_."""
5019        return _pywrapcp.RoutingModel_GetDimensionsWithGlobalCumulOptimizers(self)

Returns the dimensions which have [global|local]_dimension_optimizers_.

def GetDimensionsWithLocalCumulOptimizers(self):
5021    def GetDimensionsWithLocalCumulOptimizers(self):
5022        return _pywrapcp.RoutingModel_GetDimensionsWithLocalCumulOptimizers(self)
def HasGlobalCumulOptimizer(self, dimension):
5024    def HasGlobalCumulOptimizer(self, dimension):
5025        r"""Returns whether the given dimension has global/local cumul optimizers."""
5026        return _pywrapcp.RoutingModel_HasGlobalCumulOptimizer(self, dimension)

Returns whether the given dimension has global/local cumul optimizers.

def HasLocalCumulOptimizer(self, dimension):
5028    def HasLocalCumulOptimizer(self, dimension):
5029        return _pywrapcp.RoutingModel_HasLocalCumulOptimizer(self, dimension)
def GetMutableGlobalCumulLPOptimizer(self, dimension):
5031    def GetMutableGlobalCumulLPOptimizer(self, dimension):
5032        r"""
5033        Returns the global/local dimension cumul optimizer for a given dimension,
5034        or nullptr if there is none.
5035        """
5036        return _pywrapcp.RoutingModel_GetMutableGlobalCumulLPOptimizer(self, dimension)

Returns the global/local dimension cumul optimizer for a given dimension, or nullptr if there is none.

def GetMutableGlobalCumulMPOptimizer(self, dimension):
5038    def GetMutableGlobalCumulMPOptimizer(self, dimension):
5039        return _pywrapcp.RoutingModel_GetMutableGlobalCumulMPOptimizer(self, dimension)
def GetMutableLocalCumulLPOptimizer(self, dimension):
5041    def GetMutableLocalCumulLPOptimizer(self, dimension):
5042        return _pywrapcp.RoutingModel_GetMutableLocalCumulLPOptimizer(self, dimension)
def GetMutableLocalCumulMPOptimizer(self, dimension):
5044    def GetMutableLocalCumulMPOptimizer(self, dimension):
5045        return _pywrapcp.RoutingModel_GetMutableLocalCumulMPOptimizer(self, dimension)
def HasDimension(self, dimension_name):
5047    def HasDimension(self, dimension_name):
5048        r"""Returns true if a dimension exists for a given dimension name."""
5049        return _pywrapcp.RoutingModel_HasDimension(self, dimension_name)

Returns true if a dimension exists for a given dimension name.

def GetDimensionOrDie(self, dimension_name):
5051    def GetDimensionOrDie(self, dimension_name):
5052        r"""Returns a dimension from its name. Dies if the dimension does not exist."""
5053        return _pywrapcp.RoutingModel_GetDimensionOrDie(self, dimension_name)

Returns a dimension from its name. Dies if the dimension does not exist.

def GetMutableDimension(self, dimension_name):
5055    def GetMutableDimension(self, dimension_name):
5056        r"""
5057        Returns a dimension from its name. Returns nullptr if the dimension does
5058        not exist.
5059        """
5060        return _pywrapcp.RoutingModel_GetMutableDimension(self, dimension_name)

Returns a dimension from its name. Returns nullptr if the dimension does not exist.

def SetPrimaryConstrainedDimension(self, dimension_name):
5062    def SetPrimaryConstrainedDimension(self, dimension_name):
5063        r"""
5064        Set the given dimension as "primary constrained". As of August 2013, this
5065        is only used by ArcIsMoreConstrainedThanArc().
5066        "dimension" must be the name of an existing dimension, or be empty, in
5067        which case there will not be a primary dimension after this call.
5068        """
5069        return _pywrapcp.RoutingModel_SetPrimaryConstrainedDimension(self, dimension_name)

Set the given dimension as "primary constrained". As of August 2013, this is only used by ArcIsMoreConstrainedThanArc(). "dimension" must be the name of an existing dimension, or be empty, in which case there will not be a primary dimension after this call.

def GetPrimaryConstrainedDimension(self):
5071    def GetPrimaryConstrainedDimension(self):
5072        r"""Get the primary constrained dimension, or an empty string if it is unset."""
5073        return _pywrapcp.RoutingModel_GetPrimaryConstrainedDimension(self)

Get the primary constrained dimension, or an empty string if it is unset.

def GetResourceGroup(self, rg_index):
5075    def GetResourceGroup(self, rg_index):
5076        return _pywrapcp.RoutingModel_GetResourceGroup(self, rg_index)
def GetDimensionResourceGroupIndices(self, dimension):
5078    def GetDimensionResourceGroupIndices(self, dimension):
5079        r"""
5080        Returns the indices of resource groups for this dimension. This method can
5081        only be called after the model has been closed.
5082        """
5083        return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndices(self, dimension)

Returns the indices of resource groups for this dimension. This method can only be called after the model has been closed.

def GetDimensionResourceGroupIndex(self, dimension):
5085    def GetDimensionResourceGroupIndex(self, dimension):
5086        r"""
5087        Returns the index of the resource group attached to the dimension.
5088        DCHECKS that there's exactly one resource group for this dimension.
5089        """
5090        return _pywrapcp.RoutingModel_GetDimensionResourceGroupIndex(self, dimension)

Returns the index of the resource group attached to the dimension. DCHECKS that there's exactly one resource group for this dimension.

PENALIZE_ONCE = 0
PENALIZE_PER_INACTIVE = 1
def AddDisjunction(self, *args):
5094    def AddDisjunction(self, *args):
5095        r"""
5096        Adds a disjunction constraint on the indices: exactly 'max_cardinality' of
5097        the indices are active. Start and end indices of any vehicle cannot be
5098        part of a disjunction.
5099
5100        If a penalty is given, at most 'max_cardinality' of the indices can be
5101        active, and if less are active, 'penalty' is payed per inactive index if
5102        the penalty cost is set to `PENALIZE_PER_INACTIVE`.
5103        This is equivalent to adding the constraint:
5104            p + Sum(i)active[i] == max_cardinality
5105        where p is an integer variable.
5106        If the penalty cost is set to `PENALIZE_ONCE`, then 'penalty' is payed
5107        once if there are less than `max_cardinality` of the indices active.
5108        This is equivalent to adding the constraint:
5109            p == (Sum(i)active[i] != max_cardinality)
5110        where p is a boolean variable.
5111        The following cost is added to the cost function: p * penalty.
5112        'penalty' must be positive to make the disjunction optional; a negative
5113        penalty will force 'max_cardinality' indices of the disjunction to be
5114        performed, and therefore p == 0.
5115        Note: passing a vector with a single index will model an optional index
5116        with a penalty cost if it is not visited.
5117        """
5118        return _pywrapcp.RoutingModel_AddDisjunction(self, *args)

Adds a disjunction constraint on the indices: exactly 'max_cardinality' of the indices are active. Start and end indices of any vehicle cannot be part of a disjunction.

If a penalty is given, at most 'max_cardinality' of the indices can be active, and if less are active, 'penalty' is payed per inactive index if the penalty cost is set to PENALIZE_PER_INACTIVE.

This is equivalent to adding the constraint:

p + Sum(i)active[i] == max_cardinality

where p is an integer variable. If the penalty cost is set to PENALIZE_ONCE, then 'penalty' is payed once if there are less than max_cardinality of the indices active.

This is equivalent to adding the constraint:

p == (Sum(i)active[i] != max_cardinality)

where p is a boolean variable. The following cost is added to the cost function: p * penalty. 'penalty' must be positive to make the disjunction optional; a negative penalty will force 'max_cardinality' indices of the disjunction to be performed, and therefore p == 0. Note: passing a vector with a single index will model an optional index with a penalty cost if it is not visited.

def GetDisjunctionIndices(self, index):
5120    def GetDisjunctionIndices(self, index):
5121        r"""Returns the indices of the disjunctions to which an index belongs."""
5122        return _pywrapcp.RoutingModel_GetDisjunctionIndices(self, index)

Returns the indices of the disjunctions to which an index belongs.

def GetDisjunctionPenalty(self, index):
5124    def GetDisjunctionPenalty(self, index):
5125        r"""Returns the penalty of the node disjunction of index 'index'."""
5126        return _pywrapcp.RoutingModel_GetDisjunctionPenalty(self, index)

Returns the penalty of the node disjunction of index 'index'.

def GetDisjunctionMaxCardinality(self, index):
5128    def GetDisjunctionMaxCardinality(self, index):
5129        r"""
5130        Returns the maximum number of possible active nodes of the node
5131        disjunction of index 'index'.
5132        """
5133        return _pywrapcp.RoutingModel_GetDisjunctionMaxCardinality(self, index)

Returns the maximum number of possible active nodes of the node disjunction of index 'index'.

def GetDisjunctionPenaltyCostBehavior(self, index):
5135    def GetDisjunctionPenaltyCostBehavior(self, index):
5136        r"""
5137        Returns the 'PenaltyCostBehavior' used by the disjunction of index
5138        'index'.
5139        """
5140        return _pywrapcp.RoutingModel_GetDisjunctionPenaltyCostBehavior(self, index)

Returns the 'PenaltyCostBehavior' used by the disjunction of index 'index'.

def GetNumberOfDisjunctions(self):
5142    def GetNumberOfDisjunctions(self):
5143        r"""Returns the number of node disjunctions in the model."""
5144        return _pywrapcp.RoutingModel_GetNumberOfDisjunctions(self)

Returns the number of node disjunctions in the model.

def HasMandatoryDisjunctions(self):
5146    def HasMandatoryDisjunctions(self):
5147        r"""
5148        Returns true if the model contains mandatory disjunctions (ones with
5149        kNoPenalty as penalty).
5150        """
5151        return _pywrapcp.RoutingModel_HasMandatoryDisjunctions(self)

Returns true if the model contains mandatory disjunctions (ones with kNoPenalty as penalty).

def HasMaxCardinalityConstrainedDisjunctions(self):
5153    def HasMaxCardinalityConstrainedDisjunctions(self):
5154        r"""
5155        Returns true if the model contains at least one disjunction which is
5156        constrained by its max_cardinality.
5157        """
5158        return _pywrapcp.RoutingModel_HasMaxCardinalityConstrainedDisjunctions(self)

Returns true if the model contains at least one disjunction which is constrained by its max_cardinality.

def GetPerfectBinaryDisjunctions(self):
5160    def GetPerfectBinaryDisjunctions(self):
5161        r"""
5162        Returns the list of all perfect binary disjunctions, as pairs of variable
5163        indices: a disjunction is "perfect" when its variables do not appear in
5164        any other disjunction. Each pair is sorted (lowest variable index first),
5165        and the output vector is also sorted (lowest pairs first).
5166        """
5167        return _pywrapcp.RoutingModel_GetPerfectBinaryDisjunctions(self)

Returns the list of all perfect binary disjunctions, as pairs of variable indices: a disjunction is "perfect" when its variables do not appear in any other disjunction. Each pair is sorted (lowest variable index first), and the output vector is also sorted (lowest pairs first).

def IgnoreDisjunctionsAlreadyForcedToZero(self):
5169    def IgnoreDisjunctionsAlreadyForcedToZero(self):
5170        r"""
5171        SPECIAL: Makes the solver ignore all the disjunctions whose active
5172        variables are all trivially zero (i.e. Max() == 0), by setting their
5173        max_cardinality to 0.
5174        This can be useful when using the BaseBinaryDisjunctionNeighborhood
5175        operators, in the context of arc-based routing.
5176        """
5177        return _pywrapcp.RoutingModel_IgnoreDisjunctionsAlreadyForcedToZero(self)

SPECIAL: Makes the solver ignore all the disjunctions whose active variables are all trivially zero (i.e. Max() == 0), by setting their max_cardinality to 0. This can be useful when using the BaseBinaryDisjunctionNeighborhood operators, in the context of arc-based routing.

def AddSoftSameVehicleConstraint(self, indices, cost):
5179    def AddSoftSameVehicleConstraint(self, indices, cost):
5180        r"""
5181        Adds a soft constraint to force a set of variable indices to be on the
5182        same vehicle. If all nodes are not on the same vehicle, each extra vehicle
5183        used adds 'cost' to the cost function.
5184        """
5185        return _pywrapcp.RoutingModel_AddSoftSameVehicleConstraint(self, indices, cost)

Adds a soft constraint to force a set of variable indices to be on the same vehicle. If all nodes are not on the same vehicle, each extra vehicle used adds 'cost' to the cost function.

def SetAllowedVehiclesForIndex(self, vehicles, index):
5187    def SetAllowedVehiclesForIndex(self, vehicles, index):
5188        r"""
5189        Sets the vehicles which can visit a given node. If the node is in a
5190        disjunction, this will not prevent it from being unperformed.
5191        Specifying an empty vector of vehicles has no effect (all vehicles
5192        will be allowed to visit the node).
5193        """
5194        return _pywrapcp.RoutingModel_SetAllowedVehiclesForIndex(self, vehicles, index)

Sets the vehicles which can visit a given node. If the node is in a disjunction, this will not prevent it from being unperformed. Specifying an empty vector of vehicles has no effect (all vehicles will be allowed to visit the node).

def IsVehicleAllowedForIndex(self, vehicle, index):
5196    def IsVehicleAllowedForIndex(self, vehicle, index):
5197        r"""Returns true if a vehicle is allowed to visit a given node."""
5198        return _pywrapcp.RoutingModel_IsVehicleAllowedForIndex(self, vehicle, index)

Returns true if a vehicle is allowed to visit a given node.

def AddPickupAndDelivery(self, pickup, delivery):
5200    def AddPickupAndDelivery(self, pickup, delivery):
5201        r"""
5202        Notifies that index1 and index2 form a pair of nodes which should belong
5203        to the same route. This methods helps the search find better solutions,
5204        especially in the local search phase.
5205        It should be called each time you have an equality constraint linking
5206        the vehicle variables of two node (including for instance pickup and
5207        delivery problems):
5208            Solver* const solver = routing.solver();
5209            int64_t index1 = manager.NodeToIndex(node1);
5210            int64_t index2 = manager.NodeToIndex(node2);
5211            solver->AddConstraint(solver->MakeEquality(
5212                routing.VehicleVar(index1),
5213                routing.VehicleVar(index2)));
5214            routing.AddPickupAndDelivery(index1, index2);
5215        """
5216        return _pywrapcp.RoutingModel_AddPickupAndDelivery(self, pickup, delivery)

Notifies that index1 and index2 form a pair of nodes which should belong to the same route. This methods helps the search find better solutions, especially in the local search phase. It should be called each time you have an equality constraint linking the vehicle variables of two node (including for instance pickup and delivery problems): Solver* const solver = routing.solver(); int64_t index1 = manager.NodeToIndex(node1); int64_t index2 = manager.NodeToIndex(node2); solver->AddConstraint(solver->MakeEquality( routing.VehicleVar(index1), routing.VehicleVar(index2))); routing.AddPickupAndDelivery(index1, index2);

def AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction):
5218    def AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction):
5219        r"""
5220        Same as AddPickupAndDelivery but notifying that the performed node from
5221        the disjunction of index 'pickup_disjunction' is on the same route as the
5222        performed node from the disjunction of index 'delivery_disjunction'.
5223        """
5224        return _pywrapcp.RoutingModel_AddPickupAndDeliverySets(self, pickup_disjunction, delivery_disjunction)

Same as AddPickupAndDelivery but notifying that the performed node from the disjunction of index 'pickup_disjunction' is on the same route as the performed node from the disjunction of index 'delivery_disjunction'.

def GetPickupPosition(self, node_index):
5226    def GetPickupPosition(self, node_index):
5227        r"""Returns the pickup and delivery positions where the node is a pickup."""
5228        return _pywrapcp.RoutingModel_GetPickupPosition(self, node_index)

Returns the pickup and delivery positions where the node is a pickup.

def GetDeliveryPosition(self, node_index):
5230    def GetDeliveryPosition(self, node_index):
5231        r"""Returns the pickup and delivery positions where the node is a delivery."""
5232        return _pywrapcp.RoutingModel_GetDeliveryPosition(self, node_index)

Returns the pickup and delivery positions where the node is a delivery.

def IsPickup(self, node_index):
5234    def IsPickup(self, node_index):
5235        r"""Returns whether the node is a pickup (resp. delivery)."""
5236        return _pywrapcp.RoutingModel_IsPickup(self, node_index)

Returns whether the node is a pickup (resp. delivery).

def IsDelivery(self, node_index):
5238    def IsDelivery(self, node_index):
5239        return _pywrapcp.RoutingModel_IsDelivery(self, node_index)
def SetPickupAndDeliveryPolicyOfAllVehicles(self, policy):
5241    def SetPickupAndDeliveryPolicyOfAllVehicles(self, policy):
5242        r"""
5243        Sets the Pickup and delivery policy of all vehicles. It is equivalent to
5244        calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.
5245        """
5246        return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfAllVehicles(self, policy)

Sets the Pickup and delivery policy of all vehicles. It is equivalent to calling SetPickupAndDeliveryPolicyOfVehicle on all vehicles.

def SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle):
5248    def SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle):
5249        return _pywrapcp.RoutingModel_SetPickupAndDeliveryPolicyOfVehicle(self, policy, vehicle)
def GetPickupAndDeliveryPolicyOfVehicle(self, vehicle):
5251    def GetPickupAndDeliveryPolicyOfVehicle(self, vehicle):
5252        return _pywrapcp.RoutingModel_GetPickupAndDeliveryPolicyOfVehicle(self, vehicle)
def GetNumOfSingletonNodes(self):
5254    def GetNumOfSingletonNodes(self):
5255        r"""
5256        Returns the number of non-start/end nodes which do not appear in a
5257        pickup/delivery pair.
5258        """
5259        return _pywrapcp.RoutingModel_GetNumOfSingletonNodes(self)

Returns the number of non-start/end nodes which do not appear in a pickup/delivery pair.

def GetFirstMatchingPickupDeliverySibling(self, node, is_match):
5261    def GetFirstMatchingPickupDeliverySibling(self, node, is_match):
5262        return _pywrapcp.RoutingModel_GetFirstMatchingPickupDeliverySibling(self, node, is_match)
TYPE_ADDED_TO_VEHICLE = 0

When visited, the number of types 'T' on the vehicle increases by one.

ADDED_TYPE_REMOVED_FROM_VEHICLE = 1

When visited, one instance of type 'T' previously added to the route (TYPE_ADDED_TO_VEHICLE), if any, is removed from the vehicle. If the type was not previously added to the route or all added instances have already been removed, this visit has no effect on the types.

TYPE_ON_VEHICLE_UP_TO_VISIT = 2

With the following policy, the visit enforces that type 'T' is considered on the route from its start until this node is visited.

TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED = 3

The visit doesn't have an impact on the number of types 'T' on the route, as it's (virtually) added and removed directly. This policy can be used for visits which are part of an incompatibility or requirement set without affecting the type count on the route.

def SetVisitType(self, index, type, type_policy):
5285    def SetVisitType(self, index, type, type_policy):
5286        return _pywrapcp.RoutingModel_SetVisitType(self, index, type, type_policy)
def GetVisitType(self, index):
5288    def GetVisitType(self, index):
5289        return _pywrapcp.RoutingModel_GetVisitType(self, index)
def GetSingleNodesOfType(self, type):
5291    def GetSingleNodesOfType(self, type):
5292        return _pywrapcp.RoutingModel_GetSingleNodesOfType(self, type)
def GetPairIndicesOfType(self, type):
5294    def GetPairIndicesOfType(self, type):
5295        return _pywrapcp.RoutingModel_GetPairIndicesOfType(self, type)
def GetVisitTypePolicy(self, index):
5297    def GetVisitTypePolicy(self, index):
5298        return _pywrapcp.RoutingModel_GetVisitTypePolicy(self, index)
def GetNumberOfVisitTypes(self):
5300    def GetNumberOfVisitTypes(self):
5301        return _pywrapcp.RoutingModel_GetNumberOfVisitTypes(self)
def AddHardTypeIncompatibility(self, type1, type2):
5303    def AddHardTypeIncompatibility(self, type1, type2):
5304        r"""
5305        Incompatibilities:
5306        Two nodes with "hard" incompatible types cannot share the same route at
5307        all, while with a "temporal" incompatibility they can't be on the same
5308        route at the same time.
5309        NOTE: To avoid unnecessary memory reallocations, it is recommended to only
5310        add incompatibilities once all the existing types have been set with
5311        SetVisitType().
5312        """
5313        return _pywrapcp.RoutingModel_AddHardTypeIncompatibility(self, type1, type2)

Incompatibilities: Two nodes with "hard" incompatible types cannot share the same route at all, while with a "temporal" incompatibility they can't be on the same route at the same time. NOTE: To avoid unnecessary memory reallocations, it is recommended to only add incompatibilities once all the existing types have been set with SetVisitType().

def AddTemporalTypeIncompatibility(self, type1, type2):
5315    def AddTemporalTypeIncompatibility(self, type1, type2):
5316        return _pywrapcp.RoutingModel_AddTemporalTypeIncompatibility(self, type1, type2)
def GetHardTypeIncompatibilitiesOfType(self, type):
5318    def GetHardTypeIncompatibilitiesOfType(self, type):
5319        r"""Returns visit types incompatible with a given type."""
5320        return _pywrapcp.RoutingModel_GetHardTypeIncompatibilitiesOfType(self, type)

Returns visit types incompatible with a given type.

def GetTemporalTypeIncompatibilitiesOfType(self, type):
5322    def GetTemporalTypeIncompatibilitiesOfType(self, type):
5323        return _pywrapcp.RoutingModel_GetTemporalTypeIncompatibilitiesOfType(self, type)
def HasHardTypeIncompatibilities(self):
5325    def HasHardTypeIncompatibilities(self):
5326        r"""
5327        Returns true iff any hard (resp. temporal) type incompatibilities have
5328        been added to the model.
5329        """
5330        return _pywrapcp.RoutingModel_HasHardTypeIncompatibilities(self)

Returns true iff any hard (resp. temporal) type incompatibilities have been added to the model.

def HasTemporalTypeIncompatibilities(self):
5332    def HasTemporalTypeIncompatibilities(self):
5333        return _pywrapcp.RoutingModel_HasTemporalTypeIncompatibilities(self)
def AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives):
5335    def AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives):
5336        r"""
5337        Requirements:
5338        NOTE: As of 2019-04, cycles in the requirement graph are not supported,
5339        and lead to the dependent nodes being skipped if possible (otherwise
5340        the model is considered infeasible).
5341        The following functions specify that "dependent_type" requires at least
5342        one of the types in "required_type_alternatives".
5343
5344        For same-vehicle requirements, a node of dependent type type_D requires at
5345        least one node of type type_R among the required alternatives on the same
5346        route.
5347        NOTE: To avoid unnecessary memory reallocations, it is recommended to only
5348        add requirements once all the existing types have been set with
5349        SetVisitType().
5350        """
5351        return _pywrapcp.RoutingModel_AddSameVehicleRequiredTypeAlternatives(self, dependent_type, required_type_alternatives)

Requirements: NOTE: As of 2019-04, cycles in the requirement graph are not supported, and lead to the dependent nodes being skipped if possible (otherwise the model is considered infeasible). The following functions specify that "dependent_type" requires at least one of the types in "required_type_alternatives".

For same-vehicle requirements, a node of dependent type type_D requires at least one node of type type_R among the required alternatives on the same route. NOTE: To avoid unnecessary memory reallocations, it is recommended to only add requirements once all the existing types have been set with SetVisitType().

def AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives):
5353    def AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives):
5354        r"""
5355        If type_D depends on type_R when adding type_D, any node_D of type_D and
5356        VisitTypePolicy TYPE_ADDED_TO_VEHICLE or
5357        TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its
5358        vehicle at the time node_D is visited.
5359        """
5360        return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenAddingType(self, dependent_type, required_type_alternatives)

If type_D depends on type_R when adding type_D, any node_D of type_D and VisitTypePolicy TYPE_ADDED_TO_VEHICLE or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED requires at least one type_R on its vehicle at the time node_D is visited.

def AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives):
5362    def AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives):
5363        r"""
5364        The following requirements apply when visiting dependent nodes that remove
5365        their type from the route, i.e. type_R must be on the vehicle when type_D
5366        of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE,
5367        TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is
5368        visited.
5369        """
5370        return _pywrapcp.RoutingModel_AddRequiredTypeAlternativesWhenRemovingType(self, dependent_type, required_type_alternatives)

The following requirements apply when visiting dependent nodes that remove their type from the route, i.e. type_R must be on the vehicle when type_D of VisitTypePolicy ADDED_TYPE_REMOVED_FROM_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT or TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED is visited.

def GetSameVehicleRequiredTypeAlternativesOfType(self, type):
5372    def GetSameVehicleRequiredTypeAlternativesOfType(self, type):
5373        r"""
5374        Returns the set of same-vehicle requirement alternatives for the given
5375        type.
5376        """
5377        return _pywrapcp.RoutingModel_GetSameVehicleRequiredTypeAlternativesOfType(self, type)

Returns the set of same-vehicle requirement alternatives for the given type.

def GetRequiredTypeAlternativesWhenAddingType(self, type):
5379    def GetRequiredTypeAlternativesWhenAddingType(self, type):
5380        r"""Returns the set of requirement alternatives when adding the given type."""
5381        return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenAddingType(self, type)

Returns the set of requirement alternatives when adding the given type.

def GetRequiredTypeAlternativesWhenRemovingType(self, type):
5383    def GetRequiredTypeAlternativesWhenRemovingType(self, type):
5384        r"""Returns the set of requirement alternatives when removing the given type."""
5385        return _pywrapcp.RoutingModel_GetRequiredTypeAlternativesWhenRemovingType(self, type)

Returns the set of requirement alternatives when removing the given type.

def HasSameVehicleTypeRequirements(self):
5387    def HasSameVehicleTypeRequirements(self):
5388        r"""
5389        Returns true iff any same-route (resp. temporal) type requirements have
5390        been added to the model.
5391        """
5392        return _pywrapcp.RoutingModel_HasSameVehicleTypeRequirements(self)

Returns true iff any same-route (resp. temporal) type requirements have been added to the model.

def HasTemporalTypeRequirements(self):
5394    def HasTemporalTypeRequirements(self):
5395        return _pywrapcp.RoutingModel_HasTemporalTypeRequirements(self)
def HasTypeRegulations(self):
5397    def HasTypeRegulations(self):
5398        r"""
5399        Returns true iff the model has any incompatibilities or requirements set
5400        on node types.
5401        """
5402        return _pywrapcp.RoutingModel_HasTypeRegulations(self)

Returns true iff the model has any incompatibilities or requirements set on node types.

def UnperformedPenalty(self, var_index):
5404    def UnperformedPenalty(self, var_index):
5405        r"""
5406        Get the "unperformed" penalty of a node. This is only well defined if the
5407        node is only part of a single Disjunction, and that disjunction has a
5408        penalty. For forced active nodes returns max int64_t. In all other cases,
5409        this returns 0.
5410        """
5411        return _pywrapcp.RoutingModel_UnperformedPenalty(self, var_index)

Get the "unperformed" penalty of a node. This is only well defined if the node is only part of a single Disjunction, and that disjunction has a penalty. For forced active nodes returns max int64_t. In all other cases, this returns 0.

def UnperformedPenaltyOrValue(self, default_value, var_index):
5413    def UnperformedPenaltyOrValue(self, default_value, var_index):
5414        r"""
5415        Same as above except that it returns default_value instead of 0 when
5416        penalty is not well defined (default value is passed as first argument to
5417        simplify the usage of the method in a callback).
5418        """
5419        return _pywrapcp.RoutingModel_UnperformedPenaltyOrValue(self, default_value, var_index)

Same as above except that it returns default_value instead of 0 when penalty is not well defined (default value is passed as first argument to simplify the usage of the method in a callback).

def GetDepot(self):
5421    def GetDepot(self):
5422        r"""
5423        Returns the variable index of the first starting or ending node of all
5424        routes. If all routes start  and end at the same node (single depot), this
5425        is the node returned.
5426        """
5427        return _pywrapcp.RoutingModel_GetDepot(self)

Returns the variable index of the first starting or ending node of all routes. If all routes start and end at the same node (single depot), this is the node returned.

def SetMaximumNumberOfActiveVehicles(self, max_active_vehicles):
5429    def SetMaximumNumberOfActiveVehicles(self, max_active_vehicles):
5430        r"""
5431        Constrains the maximum number of active vehicles, aka the number of
5432        vehicles which do not have an empty route. For instance, this can be used
5433        to limit the number of routes in the case where there are fewer drivers
5434        than vehicles and that the fleet of vehicle is heterogeneous.
5435        """
5436        return _pywrapcp.RoutingModel_SetMaximumNumberOfActiveVehicles(self, max_active_vehicles)

Constrains the maximum number of active vehicles, aka the number of vehicles which do not have an empty route. For instance, this can be used to limit the number of routes in the case where there are fewer drivers than vehicles and that the fleet of vehicle is heterogeneous.

def GetMaximumNumberOfActiveVehicles(self):
5438    def GetMaximumNumberOfActiveVehicles(self):
5439        r"""Returns the maximum number of active vehicles."""
5440        return _pywrapcp.RoutingModel_GetMaximumNumberOfActiveVehicles(self)

Returns the maximum number of active vehicles.

def SetArcCostEvaluatorOfAllVehicles(self, evaluator_index):
5442    def SetArcCostEvaluatorOfAllVehicles(self, evaluator_index):
5443        r"""
5444        Sets the cost function of the model such that the cost of a segment of a
5445        route between node 'from' and 'to' is evaluator(from, to), whatever the
5446        route or vehicle performing the route.
5447        """
5448        return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfAllVehicles(self, evaluator_index)

Sets the cost function of the model such that the cost of a segment of a route between node 'from' and 'to' is evaluator(from, to), whatever the route or vehicle performing the route.

def SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle):
5450    def SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle):
5451        r"""Sets the cost function for a given vehicle route."""
5452        return _pywrapcp.RoutingModel_SetArcCostEvaluatorOfVehicle(self, evaluator_index, vehicle)

Sets the cost function for a given vehicle route.

def SetFixedCostOfAllVehicles(self, cost):
5454    def SetFixedCostOfAllVehicles(self, cost):
5455        r"""
5456        Sets the fixed cost of all vehicle routes. It is equivalent to calling
5457        SetFixedCostOfVehicle on all vehicle routes.
5458        """
5459        return _pywrapcp.RoutingModel_SetFixedCostOfAllVehicles(self, cost)

Sets the fixed cost of all vehicle routes. It is equivalent to calling SetFixedCostOfVehicle on all vehicle routes.

def SetFixedCostOfVehicle(self, cost, vehicle):
5461    def SetFixedCostOfVehicle(self, cost, vehicle):
5462        r"""Sets the fixed cost of one vehicle route."""
5463        return _pywrapcp.RoutingModel_SetFixedCostOfVehicle(self, cost, vehicle)

Sets the fixed cost of one vehicle route.

def GetFixedCostOfVehicle(self, vehicle):
5465    def GetFixedCostOfVehicle(self, vehicle):
5466        r"""
5467        Returns the route fixed cost taken into account if the route of the
5468        vehicle is not empty, aka there's at least one node on the route other
5469        than the first and last nodes.
5470        """
5471        return _pywrapcp.RoutingModel_GetFixedCostOfVehicle(self, vehicle)

Returns the route fixed cost taken into account if the route of the vehicle is not empty, aka there's at least one node on the route other than the first and last nodes.

def SetPathEnergyCostOfVehicle(self, force, distance, cost_per_unit, vehicle):
5473    def SetPathEnergyCostOfVehicle(self, force, distance, cost_per_unit, vehicle):
5474        return _pywrapcp.RoutingModel_SetPathEnergyCostOfVehicle(self, force, distance, cost_per_unit, vehicle)
def SetPathEnergyCostsOfVehicle( self, force, distance, threshold, cost_per_unit_below_threshold, cost_per_unit_above_threshold, vehicle):
5476    def SetPathEnergyCostsOfVehicle(self, force, distance, threshold, cost_per_unit_below_threshold, cost_per_unit_above_threshold, vehicle):
5477        return _pywrapcp.RoutingModel_SetPathEnergyCostsOfVehicle(self, force, distance, threshold, cost_per_unit_below_threshold, cost_per_unit_above_threshold, vehicle)
def SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor):
5479    def SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor):
5480        r"""
5481        The following methods set the linear and quadratic cost factors of
5482        vehicles (must be positive values). The default value of these parameters
5483        is zero for all vehicles.
5484
5485        When set, the cost_ of the model will contain terms aiming at reducing the
5486        number of vehicles used in the model, by adding the following to the
5487        objective for every vehicle v:
5488        INDICATOR(v used in the model) *
5489          [linear_cost_factor_of_vehicle_[v]
5490           - quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)]
5491        i.e. for every used vehicle, we add the linear factor as fixed cost, and
5492        subtract the square of the route length multiplied by the quadratic
5493        factor. This second term aims at making the routes as dense as possible.
5494
5495        Sets the linear and quadratic cost factor of all vehicles.
5496        """
5497        return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfAllVehicles(self, linear_cost_factor, quadratic_cost_factor)

The following methods set the linear and quadratic cost factors of vehicles (must be positive values). The default value of these parameters is zero for all vehicles.

When set, the cost_ of the model will contain terms aiming at reducing the number of vehicles used in the model, by adding the following to the objective for every vehicle v: INDICATOR(v used in the model) * [linear_cost_factor_of_vehicle_[v]

  • quadratic_cost_factor_of_vehicle_[v]*(square of length of route v)] i.e. for every used vehicle, we add the linear factor as fixed cost, and subtract the square of the route length multiplied by the quadratic factor. This second term aims at making the routes as dense as possible.

Sets the linear and quadratic cost factor of all vehicles.

def SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle):
5499    def SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle):
5500        r"""Sets the linear and quadratic cost factor of the given vehicle."""
5501        return _pywrapcp.RoutingModel_SetAmortizedCostFactorsOfVehicle(self, linear_cost_factor, quadratic_cost_factor, vehicle)

Sets the linear and quadratic cost factor of the given vehicle.

def GetAmortizedLinearCostFactorOfVehicles(self):
5503    def GetAmortizedLinearCostFactorOfVehicles(self):
5504        return _pywrapcp.RoutingModel_GetAmortizedLinearCostFactorOfVehicles(self)
def GetAmortizedQuadraticCostFactorOfVehicles(self):
5506    def GetAmortizedQuadraticCostFactorOfVehicles(self):
5507        return _pywrapcp.RoutingModel_GetAmortizedQuadraticCostFactorOfVehicles(self)
def AddRouteConstraint(self, route_evaluator, costs_are_homogeneous_across_vehicles=False):
5509    def AddRouteConstraint(self, route_evaluator, costs_are_homogeneous_across_vehicles=False):
5510        return _pywrapcp.RoutingModel_AddRouteConstraint(self, route_evaluator, costs_are_homogeneous_across_vehicles)
def GetRouteCost(self, route):
5512    def GetRouteCost(self, route):
5513        return _pywrapcp.RoutingModel_GetRouteCost(self, route)
def SetVehicleUsedWhenEmpty(self, is_used, vehicle):
5515    def SetVehicleUsedWhenEmpty(self, is_used, vehicle):
5516        return _pywrapcp.RoutingModel_SetVehicleUsedWhenEmpty(self, is_used, vehicle)
def IsVehicleUsedWhenEmpty(self, vehicle):
5518    def IsVehicleUsedWhenEmpty(self, vehicle):
5519        return _pywrapcp.RoutingModel_IsVehicleUsedWhenEmpty(self, vehicle)
def SetFirstSolutionEvaluator(self, evaluator):
5521    def SetFirstSolutionEvaluator(self, evaluator):
5522        r"""
5523        Gets/sets the evaluator used during the search. Only relevant when
5524        RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY.
5525        Takes ownership of evaluator.
5526        """
5527        return _pywrapcp.RoutingModel_SetFirstSolutionEvaluator(self, evaluator)

Gets/sets the evaluator used during the search. Only relevant when RoutingSearchParameters.first_solution_strategy = EVALUATOR_STRATEGY. Takes ownership of evaluator.

def SetFirstSolutionHint(self, hint):
5529    def SetFirstSolutionHint(self, hint):
5530        r"""
5531        Adds a hint to be used by first solution strategies. The hint assignment
5532        must outlive the search.
5533        As of 2024-12, only used by LOCAL_CHEAPEST_INSERTION and
5534        LOCAL_CHEAPEST_COST_INSERTION.
5535        """
5536        return _pywrapcp.RoutingModel_SetFirstSolutionHint(self, hint)

Adds a hint to be used by first solution strategies. The hint assignment must outlive the search. As of 2024-12, only used by LOCAL_CHEAPEST_INSERTION and LOCAL_CHEAPEST_COST_INSERTION.

def GetFirstSolutionHint(self):
5538    def GetFirstSolutionHint(self):
5539        r"""Returns the current hint assignment."""
5540        return _pywrapcp.RoutingModel_GetFirstSolutionHint(self)

Returns the current hint assignment.

def AddLocalSearchOperator(self, ls_operator):
5542    def AddLocalSearchOperator(self, ls_operator):
5543        r"""
5544        Adds a local search operator to the set of operators used to solve the
5545        vehicle routing problem.
5546        """
5547        return _pywrapcp.RoutingModel_AddLocalSearchOperator(self, ls_operator)

Adds a local search operator to the set of operators used to solve the vehicle routing problem.

def AddSearchMonitor(self, monitor):
5549    def AddSearchMonitor(self, monitor):
5550        r"""Adds a search monitor to the search used to solve the routing model."""
5551        return _pywrapcp.RoutingModel_AddSearchMonitor(self, monitor)

Adds a search monitor to the search used to solve the routing model.

def AddEnterSearchCallback(self, callback):
5553    def AddEnterSearchCallback(self, callback):
5554        return _pywrapcp.RoutingModel_AddEnterSearchCallback(self, callback)
def AddAtSolutionCallback(self, callback, track_unchecked_neighbors=False):
5556    def AddAtSolutionCallback(self, callback, track_unchecked_neighbors=False):
5557        r"""
5558        Adds a callback called each time a solution is found during the search.
5559        This is a shortcut to creating a monitor to call the callback on
5560        AtSolution() and adding it with AddSearchMonitor.
5561        If track_unchecked_neighbors is true, the callback will also be called on
5562        AcceptUncheckedNeighbor() events, which is useful to grab solutions
5563        obtained when solver_parameters.check_solution_period > 1 (aka fastLS).
5564        """
5565        return _pywrapcp.RoutingModel_AddAtSolutionCallback(self, callback, track_unchecked_neighbors)

Adds a callback called each time a solution is found during the search. This is a shortcut to creating a monitor to call the callback on AtSolution() and adding it with AddSearchMonitor. If track_unchecked_neighbors is true, the callback will also be called on AcceptUncheckedNeighbor() events, which is useful to grab solutions obtained when solver_parameters.check_solution_period > 1 (aka fastLS).

def AddRestoreDimensionValuesResetCallback(self, callback):
5567    def AddRestoreDimensionValuesResetCallback(self, callback):
5568        return _pywrapcp.RoutingModel_AddRestoreDimensionValuesResetCallback(self, callback)
def AddVariableMinimizedByFinalizer(self, var):
5570    def AddVariableMinimizedByFinalizer(self, var):
5571        r"""
5572        Adds a variable to minimize in the solution finalizer. The solution
5573        finalizer is called each time a solution is found during the search and
5574        allows to instantiate secondary variables (such as dimension cumul
5575        variables).
5576        """
5577        return _pywrapcp.RoutingModel_AddVariableMinimizedByFinalizer(self, var)

Adds a variable to minimize in the solution finalizer. The solution finalizer is called each time a solution is found during the search and allows to instantiate secondary variables (such as dimension cumul variables).

def AddVariableMaximizedByFinalizer(self, var):
5579    def AddVariableMaximizedByFinalizer(self, var):
5580        r"""
5581        Adds a variable to maximize in the solution finalizer (see above for
5582        information on the solution finalizer).
5583        """
5584        return _pywrapcp.RoutingModel_AddVariableMaximizedByFinalizer(self, var)

Adds a variable to maximize in the solution finalizer (see above for information on the solution finalizer).

def AddWeightedVariableMinimizedByFinalizer(self, var, cost):
5586    def AddWeightedVariableMinimizedByFinalizer(self, var, cost):
5587        r"""
5588        Adds a variable to minimize in the solution finalizer, with a weighted
5589        priority: the higher the more priority it has.
5590        """
5591        return _pywrapcp.RoutingModel_AddWeightedVariableMinimizedByFinalizer(self, var, cost)

Adds a variable to minimize in the solution finalizer, with a weighted priority: the higher the more priority it has.

def AddWeightedVariableMaximizedByFinalizer(self, var, cost):
5593    def AddWeightedVariableMaximizedByFinalizer(self, var, cost):
5594        r"""
5595        Adds a variable to maximize in the solution finalizer, with a weighted
5596        priority: the higher the more priority it has.
5597        """
5598        return _pywrapcp.RoutingModel_AddWeightedVariableMaximizedByFinalizer(self, var, cost)

Adds a variable to maximize in the solution finalizer, with a weighted priority: the higher the more priority it has.

def AddVariableTargetToFinalizer(self, var, target):
5600    def AddVariableTargetToFinalizer(self, var, target):
5601        r"""
5602        Add a variable to set the closest possible to the target value in the
5603        solution finalizer.
5604        """
5605        return _pywrapcp.RoutingModel_AddVariableTargetToFinalizer(self, var, target)

Add a variable to set the closest possible to the target value in the solution finalizer.

def AddWeightedVariableTargetToFinalizer(self, var, target, cost):
5607    def AddWeightedVariableTargetToFinalizer(self, var, target, cost):
5608        r"""
5609        Same as above with a weighted priority: the higher the cost, the more
5610        priority it has to be set close to the target value.
5611        """
5612        return _pywrapcp.RoutingModel_AddWeightedVariableTargetToFinalizer(self, var, target, cost)

Same as above with a weighted priority: the higher the cost, the more priority it has to be set close to the target value.

def CloseModel(self):
5614    def CloseModel(self):
5615        r"""
5616        Closes the current routing model; after this method is called, no
5617        modification to the model can be done, but RoutesToAssignment becomes
5618        available. Note that CloseModel() is automatically called by Solve() and
5619        other methods that produce solution.
5620        This is equivalent to calling
5621        CloseModelWithParameters(DefaultRoutingSearchParameters()).
5622        """
5623        return _pywrapcp.RoutingModel_CloseModel(self)

Closes the current routing model; after this method is called, no modification to the model can be done, but RoutesToAssignment becomes available. Note that CloseModel() is automatically called by Solve() and other methods that produce solution. This is equivalent to calling CloseModelWithParameters(DefaultRoutingSearchParameters()).

def CloseModelWithParameters(self, search_parameters):
5625    def CloseModelWithParameters(self, search_parameters):
5626        r"""
5627        Same as above taking search parameters (as of 10/2015 some the parameters
5628        have to be set when closing the model).
5629        """
5630        return _pywrapcp.RoutingModel_CloseModelWithParameters(self, search_parameters)

Same as above taking search parameters (as of 10/2015 some the parameters have to be set when closing the model).

def Solve(self, assignment=None):
5632    def Solve(self, assignment=None):
5633        r"""
5634        Solves the current routing model; closes the current model.
5635        This is equivalent to calling
5636        SolveWithParameters(DefaultRoutingSearchParameters())
5637        or
5638        SolveFromAssignmentWithParameters(assignment,
5639                                          DefaultRoutingSearchParameters()).
5640        """
5641        return _pywrapcp.RoutingModel_Solve(self, assignment)

Solves the current routing model; closes the current model. This is equivalent to calling SolveWithParameters(DefaultRoutingSearchParameters()) or SolveFromAssignmentWithParameters(assignment, DefaultRoutingSearchParameters()).

def SolveWithParameters(self, search_parameters, solutions=None):
5643    def SolveWithParameters(self, search_parameters, solutions=None):
5644        r"""
5645        Solves the current routing model with the given parameters. If 'solutions'
5646        is specified, it will contain the k best solutions found during the search
5647        (from worst to best, including the one returned by this method), where k
5648        corresponds to the 'number_of_solutions_to_collect' in
5649        'search_parameters'. Note that the Assignment returned by the method and
5650        the ones in solutions are owned by the underlying solver and should not be
5651        deleted.
5652        """
5653        return _pywrapcp.RoutingModel_SolveWithParameters(self, search_parameters, solutions)

Solves the current routing model with the given parameters. If 'solutions' is specified, it will contain the k best solutions found during the search (from worst to best, including the one returned by this method), where k corresponds to the 'number_of_solutions_to_collect' in 'search_parameters'. Note that the Assignment returned by the method and the ones in solutions are owned by the underlying solver and should not be deleted.

def SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions=None):
5655    def SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions=None):
5656        r"""
5657        Same as above, except that if assignment is not null, it will be used as
5658        the initial solution.
5659        """
5660        return _pywrapcp.RoutingModel_SolveFromAssignmentWithParameters(self, assignment, search_parameters, solutions)

Same as above, except that if assignment is not null, it will be used as the initial solution.

def FastSolveFromAssignmentWithParameters( self, assignment, search_parameters, check_solution_in_cp, touched=None):
5662    def FastSolveFromAssignmentWithParameters(self, assignment, search_parameters, check_solution_in_cp, touched=None):
5663        r"""
5664        Improves a given assignment using unchecked local search.
5665        If check_solution_in_cp is true the final solution will be checked with
5666        the CP solver.
5667        As of 11/2023, only works with greedy descent.
5668        """
5669        return _pywrapcp.RoutingModel_FastSolveFromAssignmentWithParameters(self, assignment, search_parameters, check_solution_in_cp, touched)

Improves a given assignment using unchecked local search. If check_solution_in_cp is true the final solution will be checked with the CP solver. As of 11/2023, only works with greedy descent.

def SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions=None):
5671    def SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions=None):
5672        r"""
5673        Same as above but will try all assignments in order as first solutions
5674        until one succeeds.
5675        """
5676        return _pywrapcp.RoutingModel_SolveFromAssignmentsWithParameters(self, assignments, search_parameters, solutions)

Same as above but will try all assignments in order as first solutions until one succeeds.

def SolveWithIteratedLocalSearch(self, search_parameters):
5678    def SolveWithIteratedLocalSearch(self, search_parameters):
5679        r"""
5680        Solves the current routing model by using an Iterated Local Search
5681        approach.
5682        """
5683        return _pywrapcp.RoutingModel_SolveWithIteratedLocalSearch(self, search_parameters)

Solves the current routing model by using an Iterated Local Search approach.

def SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment):
5685    def SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment):
5686        r"""
5687        Given a "source_model" and its "source_assignment", resets
5688        "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_
5689        if costs aren't homogeneous across vehicles) of "this" model, with the
5690        values set according to those in "other_assignment".
5691        The objective_element of target_assignment is set to this->cost_.
5692        """
5693        return _pywrapcp.RoutingModel_SetAssignmentFromOtherModelAssignment(self, target_assignment, source_model, source_assignment)

Given a "source_model" and its "source_assignment", resets "target_assignment" with the IntVar variables (nexts_, and vehicle_vars_ if costs aren't homogeneous across vehicles) of "this" model, with the values set according to those in "other_assignment". The objective_element of target_assignment is set to this->cost_.

def ComputeLowerBound(self):
5695    def ComputeLowerBound(self):
5696        r"""
5697        Computes a lower bound to the routing problem solving a linear assignment
5698        problem. The routing model must be closed before calling this method.
5699        Note that problems with node disjunction constraints (including optional
5700        nodes) and non-homogenous costs are not supported (the method returns 0 in
5701        these cases).
5702        """
5703        return _pywrapcp.RoutingModel_ComputeLowerBound(self)

Computes a lower bound to the routing problem solving a linear assignment problem. The routing model must be closed before calling this method. Note that problems with node disjunction constraints (including optional nodes) and non-homogenous costs are not supported (the method returns 0 in these cases).

def objective_lower_bound(self):
5705    def objective_lower_bound(self):
5706        r"""
5707        Returns the current lower bound found by internal solvers during the
5708        search.
5709        """
5710        return _pywrapcp.RoutingModel_objective_lower_bound(self)

Returns the current lower bound found by internal solvers during the search.

def status(self):
5712    def status(self):
5713        r"""Returns the current status of the routing model."""
5714        return _pywrapcp.RoutingModel_status(self)

Returns the current status of the routing model.

def enable_deep_serialization(self):
5716    def enable_deep_serialization(self):
5717        r"""Returns the value of the internal enable_deep_serialization_ parameter."""
5718        return _pywrapcp.RoutingModel_enable_deep_serialization(self)

Returns the value of the internal enable_deep_serialization_ parameter.

def ApplyLocks(self, locks):
5720    def ApplyLocks(self, locks):
5721        r"""
5722        Applies a lock chain to the next search. 'locks' represents an ordered
5723        vector of nodes representing a partial route which will be fixed during
5724        the next search; it will constrain next variables such that:
5725        next[locks[i]] == locks[i+1].
5726
5727        Returns the next variable at the end of the locked chain; this variable is
5728        not locked. An assignment containing the locks can be obtained by calling
5729        PreAssignment().
5730        """
5731        return _pywrapcp.RoutingModel_ApplyLocks(self, locks)

Applies a lock chain to the next search. 'locks' represents an ordered vector of nodes representing a partial route which will be fixed during the next search; it will constrain next variables such that: next[locks[i]] == locks[i+1].

Returns the next variable at the end of the locked chain; this variable is not locked. An assignment containing the locks can be obtained by calling PreAssignment().

def ApplyLocksToAllVehicles(self, locks, close_routes):
5733    def ApplyLocksToAllVehicles(self, locks, close_routes):
5734        r"""
5735        Applies lock chains to all vehicles to the next search, such that locks[p]
5736        is the lock chain for route p. Returns false if the locks do not contain
5737        valid routes; expects that the routes do not contain the depots,
5738        i.e. there are empty vectors in place of empty routes.
5739        If close_routes is set to true, adds the end nodes to the route of each
5740        vehicle and deactivates other nodes.
5741        An assignment containing the locks can be obtained by calling
5742        PreAssignment().
5743        """
5744        return _pywrapcp.RoutingModel_ApplyLocksToAllVehicles(self, locks, close_routes)

Applies lock chains to all vehicles to the next search, such that locks[p] is the lock chain for route p. Returns false if the locks do not contain valid routes; expects that the routes do not contain the depots, i.e. there are empty vectors in place of empty routes. If close_routes is set to true, adds the end nodes to the route of each vehicle and deactivates other nodes. An assignment containing the locks can be obtained by calling PreAssignment().

def PreAssignment(self):
5746    def PreAssignment(self):
5747        r"""
5748        Returns an assignment used to fix some of the variables of the problem.
5749        In practice, this assignment locks partial routes of the problem. This
5750        can be used in the context of locking the parts of the routes which have
5751        already been driven in online routing problems.
5752        """
5753        return _pywrapcp.RoutingModel_PreAssignment(self)

Returns an assignment used to fix some of the variables of the problem. In practice, this assignment locks partial routes of the problem. This can be used in the context of locking the parts of the routes which have already been driven in online routing problems.

def MutablePreAssignment(self):
5755    def MutablePreAssignment(self):
5756        return _pywrapcp.RoutingModel_MutablePreAssignment(self)
def WriteAssignment(self, file_name):
5758    def WriteAssignment(self, file_name):
5759        r"""
5760        Writes the current solution to a file containing an AssignmentProto.
5761        Returns false if the file cannot be opened or if there is no current
5762        solution.
5763        """
5764        return _pywrapcp.RoutingModel_WriteAssignment(self, file_name)

Writes the current solution to a file containing an AssignmentProto. Returns false if the file cannot be opened or if there is no current solution.

def ReadAssignment(self, file_name):
5766    def ReadAssignment(self, file_name):
5767        r"""
5768        Reads an assignment from a file and returns the current solution.
5769        Returns nullptr if the file cannot be opened or if the assignment is not
5770        valid.
5771        """
5772        return _pywrapcp.RoutingModel_ReadAssignment(self, file_name)

Reads an assignment from a file and returns the current solution. Returns nullptr if the file cannot be opened or if the assignment is not valid.

def RestoreAssignment(self, solution):
5774    def RestoreAssignment(self, solution):
5775        r"""
5776        Restores an assignment as a solution in the routing model and returns the
5777        new solution. Returns nullptr if the assignment is not valid.
5778        """
5779        return _pywrapcp.RoutingModel_RestoreAssignment(self, solution)

Restores an assignment as a solution in the routing model and returns the new solution. Returns nullptr if the assignment is not valid.

def ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices):
5781    def ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices):
5782        r"""
5783        Restores the routes as the current solution. Returns nullptr if the
5784        solution cannot be restored (routes do not contain a valid solution). Note
5785        that calling this method will run the solver to assign values to the
5786        dimension variables; this may take considerable amount of time, especially
5787        when using dimensions with slack.
5788        """
5789        return _pywrapcp.RoutingModel_ReadAssignmentFromRoutes(self, routes, ignore_inactive_indices)

Restores the routes as the current solution. Returns nullptr if the solution cannot be restored (routes do not contain a valid solution). Note that calling this method will run the solver to assign values to the dimension variables; this may take considerable amount of time, especially when using dimensions with slack.

def RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment):
5791    def RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment):
5792        r"""
5793        Fills an assignment from a specification of the routes of the
5794        vehicles. The routes are specified as lists of variable indices that
5795        appear on the routes of the vehicles. The indices of the outer vector in
5796        'routes' correspond to vehicles IDs, the inner vector contains the
5797        variable indices on the routes for the given vehicle. The inner vectors
5798        must not contain the start and end indices, as these are determined by the
5799        routing model.  Sets the value of NextVars in the assignment, adding the
5800        variables to the assignment if necessary. The method does not touch other
5801        variables in the assignment. The method can only be called after the model
5802        is closed.  With ignore_inactive_indices set to false, this method will
5803        fail (return nullptr) in case some of the route contain indices that are
5804        deactivated in the model; when set to true, these indices will be
5805        skipped.  Returns true if routes were successfully
5806        loaded. However, such assignment still might not be a valid
5807        solution to the routing problem due to more complex constraints;
5808        it is advisible to call solver()->CheckSolution() afterwards.
5809        """
5810        return _pywrapcp.RoutingModel_RoutesToAssignment(self, routes, ignore_inactive_indices, close_routes, assignment)

Fills an assignment from a specification of the routes of the vehicles. The routes are specified as lists of variable indices that appear on the routes of the vehicles. The indices of the outer vector in 'routes' correspond to vehicles IDs, the inner vector contains the variable indices on the routes for the given vehicle. The inner vectors must not contain the start and end indices, as these are determined by the routing model. Sets the value of NextVars in the assignment, adding the variables to the assignment if necessary. The method does not touch other variables in the assignment. The method can only be called after the model is closed. With ignore_inactive_indices set to false, this method will fail (return nullptr) in case some of the route contain indices that are deactivated in the model; when set to true, these indices will be skipped. Returns true if routes were successfully loaded. However, such assignment still might not be a valid solution to the routing problem due to more complex constraints; it is advisible to call solver()->CheckSolution() afterwards.

def AssignmentToRoutes(self, assignment, routes):
5812    def AssignmentToRoutes(self, assignment, routes):
5813        r"""
5814        Converts the solution in the given assignment to routes for all vehicles.
5815        Expects that assignment contains a valid solution (i.e. routes for all
5816        vehicles end with an end index for that vehicle).
5817        """
5818        return _pywrapcp.RoutingModel_AssignmentToRoutes(self, assignment, routes)

Converts the solution in the given assignment to routes for all vehicles. Expects that assignment contains a valid solution (i.e. routes for all vehicles end with an end index for that vehicle).

def CompactAssignment(self, assignment):
5820    def CompactAssignment(self, assignment):
5821        r"""
5822        Converts the solution in the given assignment to routes for all vehicles.
5823        If the returned vector is route_indices, route_indices[i][j] is the index
5824        for jth location visited on route i. Note that contrary to
5825        AssignmentToRoutes, the vectors do include start and end locations.
5826        Returns a compacted version of the given assignment, in which all vehicles
5827        with id lower or equal to some N have non-empty routes, and all vehicles
5828        with id greater than N have empty routes. Does not take ownership of the
5829        returned object.
5830        If found, the cost of the compact assignment is the same as in the
5831        original assignment and it preserves the values of 'active' variables.
5832        Returns nullptr if a compact assignment was not found.
5833        This method only works in homogenous mode, and it only swaps equivalent
5834        vehicles (vehicles with the same start and end nodes). When creating the
5835        compact assignment, the empty plan is replaced by the route assigned to
5836        the compatible vehicle with the highest id. Note that with more complex
5837        constraints on vehicle variables, this method might fail even if a compact
5838        solution exists.
5839        This method changes the vehicle and dimension variables as necessary.
5840        While compacting the solution, only basic checks on vehicle variables are
5841        performed; if one of these checks fails no attempts to repair it are made
5842        (instead, the method returns nullptr).
5843        """
5844        return _pywrapcp.RoutingModel_CompactAssignment(self, assignment)

Converts the solution in the given assignment to routes for all vehicles. If the returned vector is route_indices, route_indices[i][j] is the index for jth location visited on route i. Note that contrary to AssignmentToRoutes, the vectors do include start and end locations. Returns a compacted version of the given assignment, in which all vehicles with id lower or equal to some N have non-empty routes, and all vehicles with id greater than N have empty routes. Does not take ownership of the returned object. If found, the cost of the compact assignment is the same as in the original assignment and it preserves the values of 'active' variables. Returns nullptr if a compact assignment was not found. This method only works in homogenous mode, and it only swaps equivalent vehicles (vehicles with the same start and end nodes). When creating the compact assignment, the empty plan is replaced by the route assigned to the compatible vehicle with the highest id. Note that with more complex constraints on vehicle variables, this method might fail even if a compact solution exists. This method changes the vehicle and dimension variables as necessary. While compacting the solution, only basic checks on vehicle variables are performed; if one of these checks fails no attempts to repair it are made (instead, the method returns nullptr).

def CompactAndCheckAssignment(self, assignment):
5846    def CompactAndCheckAssignment(self, assignment):
5847        r"""
5848        Same as CompactAssignment() but also checks the validity of the final
5849        compact solution; if it is not valid, no attempts to repair it are made
5850        (instead, the method returns nullptr).
5851        """
5852        return _pywrapcp.RoutingModel_CompactAndCheckAssignment(self, assignment)

Same as CompactAssignment() but also checks the validity of the final compact solution; if it is not valid, no attempts to repair it are made (instead, the method returns nullptr).

def AddToAssignment(self, var):
5854    def AddToAssignment(self, var):
5855        r"""Adds an extra variable to the vehicle routing assignment."""
5856        return _pywrapcp.RoutingModel_AddToAssignment(self, var)

Adds an extra variable to the vehicle routing assignment.

def AddIntervalToAssignment(self, interval):
5858    def AddIntervalToAssignment(self, interval):
5859        return _pywrapcp.RoutingModel_AddIntervalToAssignment(self, interval)
def PackCumulsOfOptimizerDimensionsFromAssignment( self, original_assignment, duration_limit, time_limit_was_reached=None):
5861    def PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached=None):
5862        r"""
5863        For every dimension in the model with an optimizer in
5864        local/global_dimension_optimizers_, this method tries to pack the cumul
5865        values of the dimension, such that:
5866        - The cumul costs (span costs, soft lower and upper bound costs, etc) are
5867          minimized.
5868        - The cumuls of the ends of the routes are minimized for this given
5869          minimal cumul cost.
5870        - Given these minimal end cumuls, the route start cumuls are maximized.
5871        Returns the assignment resulting from allocating these packed cumuls with
5872        the solver, and nullptr if these cumuls could not be set by the solver.
5873        """
5874        return _pywrapcp.RoutingModel_PackCumulsOfOptimizerDimensionsFromAssignment(self, original_assignment, duration_limit, time_limit_was_reached)

For every dimension in the model with an optimizer in local/global_dimension_optimizers_, this method tries to pack the cumul values of the dimension, such that:

  • The cumul costs (span costs, soft lower and upper bound costs, etc) are minimized.
  • The cumuls of the ends of the routes are minimized for this given minimal cumul cost.
  • Given these minimal end cumuls, the route start cumuls are maximized. Returns the assignment resulting from allocating these packed cumuls with the solver, and nullptr if these cumuls could not be set by the solver.
def GetOrCreateNodeNeighborsByCostClass(self, *args):
5876    def GetOrCreateNodeNeighborsByCostClass(self, *args):
5877        r"""
5878        *Overload 1:*
5879        Returns neighbors of all nodes for every cost class. The result is cached
5880        and is computed once. The number of neighbors considered is based on a
5881        ratio of non-vehicle nodes, specified by neighbors_ratio, with a minimum
5882        of min-neighbors node considered.
5883
5884        |
5885
5886        *Overload 2:*
5887        Returns parameters.num_neighbors neighbors of all nodes for every cost
5888        class. The result is cached and is computed once.
5889        """
5890        return _pywrapcp.RoutingModel_GetOrCreateNodeNeighborsByCostClass(self, *args)

Overload 1: Returns neighbors of all nodes for every cost class. The result is cached and is computed once. The number of neighbors considered is based on a ratio of non-vehicle nodes, specified by neighbors_ratio, with a minimum of min-neighbors node considered.

|

Overload 2: Returns parameters.num_neighbors neighbors of all nodes for every cost class. The result is cached and is computed once.

def AddLocalSearchFilter(self, filter):
5892    def AddLocalSearchFilter(self, filter):
5893        r"""
5894        Adds a custom local search filter to the list of filters used to speed up
5895        local search by pruning unfeasible variable assignments.
5896        Calling this method after the routing model has been closed (CloseModel()
5897        or Solve() has been called) has no effect.
5898        The routing model does not take ownership of the filter.
5899        """
5900        return _pywrapcp.RoutingModel_AddLocalSearchFilter(self, filter)

Adds a custom local search filter to the list of filters used to speed up local search by pruning unfeasible variable assignments. Calling this method after the routing model has been closed (CloseModel() or Solve() has been called) has no effect. The routing model does not take ownership of the filter.

def Start(self, vehicle):
5902    def Start(self, vehicle):
5903        r"""
5904        Model inspection.
5905        Returns the variable index of the starting node of a vehicle route.
5906        """
5907        return _pywrapcp.RoutingModel_Start(self, vehicle)

Model inspection. Returns the variable index of the starting node of a vehicle route.

def End(self, vehicle):
5909    def End(self, vehicle):
5910        r"""Returns the variable index of the ending node of a vehicle route."""
5911        return _pywrapcp.RoutingModel_End(self, vehicle)

Returns the variable index of the ending node of a vehicle route.

def IsStart(self, index):
5913    def IsStart(self, index):
5914        r"""Returns true if 'index' represents the first node of a route."""
5915        return _pywrapcp.RoutingModel_IsStart(self, index)

Returns true if 'index' represents the first node of a route.

def IsEnd(self, index):
5917    def IsEnd(self, index):
5918        r"""Returns true if 'index' represents the last node of a route."""
5919        return _pywrapcp.RoutingModel_IsEnd(self, index)

Returns true if 'index' represents the last node of a route.

def VehicleIndex(self, index):
5921    def VehicleIndex(self, index):
5922        r"""
5923        Returns the vehicle of the given start/end index, and -1 if the given
5924        index is not a vehicle start/end.
5925        """
5926        return _pywrapcp.RoutingModel_VehicleIndex(self, index)

Returns the vehicle of the given start/end index, and -1 if the given index is not a vehicle start/end.

def Next(self, assignment, index):
5928    def Next(self, assignment, index):
5929        r"""
5930        Assignment inspection
5931        Returns the variable index of the node directly after the node
5932        corresponding to 'index' in 'assignment'.
5933        """
5934        return _pywrapcp.RoutingModel_Next(self, assignment, index)

Assignment inspection Returns the variable index of the node directly after the node corresponding to 'index' in 'assignment'.

def IsVehicleUsed(self, assignment, vehicle):
5936    def IsVehicleUsed(self, assignment, vehicle):
5937        r"""Returns true if the route of 'vehicle' is non empty in 'assignment'."""
5938        return _pywrapcp.RoutingModel_IsVehicleUsed(self, assignment, vehicle)

Returns true if the route of 'vehicle' is non empty in 'assignment'.

def NextVar(self, index):
5940    def NextVar(self, index):
5941        r"""
5942        Returns the next variable of the node corresponding to index. Note that
5943        NextVar(index) == index is equivalent to ActiveVar(index) == 0.
5944        """
5945        return _pywrapcp.RoutingModel_NextVar(self, index)

Returns the next variable of the node corresponding to index. Note that NextVar(index) == index is equivalent to ActiveVar(index) == 0.

def ActiveVar(self, index):
5947    def ActiveVar(self, index):
5948        r"""Returns the active variable of the node corresponding to index."""
5949        return _pywrapcp.RoutingModel_ActiveVar(self, index)

Returns the active variable of the node corresponding to index.

def ActiveVehicleVar(self, vehicle):
5951    def ActiveVehicleVar(self, vehicle):
5952        r"""
5953        Returns the active variable of the vehicle. It will be equal to 1 iff the
5954        route of the vehicle is not empty, 0 otherwise.
5955        """
5956        return _pywrapcp.RoutingModel_ActiveVehicleVar(self, vehicle)

Returns the active variable of the vehicle. It will be equal to 1 iff the route of the vehicle is not empty, 0 otherwise.

def VehicleRouteConsideredVar(self, vehicle):
5958    def VehicleRouteConsideredVar(self, vehicle):
5959        r"""
5960        Returns the variable specifying whether or not the given vehicle route is
5961        considered for costs and constraints. It will be equal to 1 iff the route
5962        of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.
5963        """
5964        return _pywrapcp.RoutingModel_VehicleRouteConsideredVar(self, vehicle)

Returns the variable specifying whether or not the given vehicle route is considered for costs and constraints. It will be equal to 1 iff the route of the vehicle is not empty OR vehicle_used_when_empty_[vehicle] is true.

def VehicleVar(self, index):
5966    def VehicleVar(self, index):
5967        r"""
5968        Returns the vehicle variable of the node corresponding to index. Note that
5969        VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.
5970        """
5971        return _pywrapcp.RoutingModel_VehicleVar(self, index)

Returns the vehicle variable of the node corresponding to index. Note that VehicleVar(index) == -1 is equivalent to ActiveVar(index) == 0.

def ResourceVar(self, vehicle, resource_group):
5973    def ResourceVar(self, vehicle, resource_group):
5974        r"""
5975        Returns the resource variable for the given vehicle index in the given
5976        resource group. If a vehicle doesn't require a resource from the
5977        corresponding resource group, then ResourceVar(v, r_g) == -1.
5978        """
5979        return _pywrapcp.RoutingModel_ResourceVar(self, vehicle, resource_group)

Returns the resource variable for the given vehicle index in the given resource group. If a vehicle doesn't require a resource from the corresponding resource group, then ResourceVar(v, r_g) == -1.

def CostVar(self):
5981    def CostVar(self):
5982        r"""Returns the global cost variable which is being minimized."""
5983        return _pywrapcp.RoutingModel_CostVar(self)

Returns the global cost variable which is being minimized.

def GetArcCostForVehicle(self, from_index, to_index, vehicle):
5985    def GetArcCostForVehicle(self, from_index, to_index, vehicle):
5986        r"""
5987        Returns the cost of the transit arc between two nodes for a given vehicle.
5988        Input are variable indices of node. This returns 0 if vehicle < 0.
5989        """
5990        return _pywrapcp.RoutingModel_GetArcCostForVehicle(self, from_index, to_index, vehicle)

Returns the cost of the transit arc between two nodes for a given vehicle. Input are variable indices of node. This returns 0 if vehicle < 0.

def CostsAreHomogeneousAcrossVehicles(self):
5992    def CostsAreHomogeneousAcrossVehicles(self):
5993        r"""Whether costs are homogeneous across all vehicles."""
5994        return _pywrapcp.RoutingModel_CostsAreHomogeneousAcrossVehicles(self)

Whether costs are homogeneous across all vehicles.

def GetHomogeneousCost(self, from_index, to_index):
5996    def GetHomogeneousCost(self, from_index, to_index):
5997        r"""
5998        Returns the cost of the segment between two nodes supposing all vehicle
5999        costs are the same (returns the cost for the first vehicle otherwise).
6000        """
6001        return _pywrapcp.RoutingModel_GetHomogeneousCost(self, from_index, to_index)

Returns the cost of the segment between two nodes supposing all vehicle costs are the same (returns the cost for the first vehicle otherwise).

def GetArcCostForFirstSolution(self, from_index, to_index):
6003    def GetArcCostForFirstSolution(self, from_index, to_index):
6004        r"""
6005        Returns the cost of the arc in the context of the first solution strategy.
6006        This is typically a simplification of the actual cost; see the .cc.
6007        """
6008        return _pywrapcp.RoutingModel_GetArcCostForFirstSolution(self, from_index, to_index)

Returns the cost of the arc in the context of the first solution strategy. This is typically a simplification of the actual cost; see the .cc.

def GetArcCostForClass(self, from_index, to_index, cost_class_index):
6010    def GetArcCostForClass(self, from_index, to_index, cost_class_index):
6011        r"""
6012        Returns the cost of the segment between two nodes for a given cost
6013        class. Input are variable indices of nodes and the cost class.
6014        Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the
6015        returned cost won't necessarily be zero: only some of the components
6016        of the cost that depend on the cost class will be omited. See the code
6017        for details.
6018        """
6019        return _pywrapcp.RoutingModel_GetArcCostForClass(self, from_index, to_index, cost_class_index)

Returns the cost of the segment between two nodes for a given cost class. Input are variable indices of nodes and the cost class. Unlike GetArcCostForVehicle(), if cost_class is kNoCost, then the returned cost won't necessarily be zero: only some of the components of the cost that depend on the cost class will be omited. See the code for details.

def GetCostClassIndexOfVehicle(self, vehicle):
6021    def GetCostClassIndexOfVehicle(self, vehicle):
6022        r"""Get the cost class index of the given vehicle."""
6023        return _pywrapcp.RoutingModel_GetCostClassIndexOfVehicle(self, vehicle)

Get the cost class index of the given vehicle.

def HasVehicleWithCostClassIndex(self, cost_class_index):
6025    def HasVehicleWithCostClassIndex(self, cost_class_index):
6026        r"""
6027        Returns true iff the model contains a vehicle with the given
6028        cost_class_index.
6029        """
6030        return _pywrapcp.RoutingModel_HasVehicleWithCostClassIndex(self, cost_class_index)

Returns true iff the model contains a vehicle with the given cost_class_index.

def GetCostClassesCount(self):
6032    def GetCostClassesCount(self):
6033        r"""Returns the number of different cost classes in the model."""
6034        return _pywrapcp.RoutingModel_GetCostClassesCount(self)

Returns the number of different cost classes in the model.

def GetNonZeroCostClassesCount(self):
6036    def GetNonZeroCostClassesCount(self):
6037        r"""Ditto, minus the 'always zero', built-in cost class."""
6038        return _pywrapcp.RoutingModel_GetNonZeroCostClassesCount(self)

Ditto, minus the 'always zero', built-in cost class.

def GetVehicleClassIndexOfVehicle(self, vehicle):
6040    def GetVehicleClassIndexOfVehicle(self, vehicle):
6041        return _pywrapcp.RoutingModel_GetVehicleClassIndexOfVehicle(self, vehicle)
def GetVehicleOfClass(self, vehicle_class):
6043    def GetVehicleOfClass(self, vehicle_class):
6044        r"""
6045        Returns a vehicle of the given vehicle class, and -1 if there are no
6046        vehicles for this class.
6047        """
6048        return _pywrapcp.RoutingModel_GetVehicleOfClass(self, vehicle_class)

Returns a vehicle of the given vehicle class, and -1 if there are no vehicles for this class.

def GetVehicleClassesCount(self):
6050    def GetVehicleClassesCount(self):
6051        r"""Returns the number of different vehicle classes in the model."""
6052        return _pywrapcp.RoutingModel_GetVehicleClassesCount(self)

Returns the number of different vehicle classes in the model.

def GetSameVehicleIndicesOfIndex(self, node):
6054    def GetSameVehicleIndicesOfIndex(self, node):
6055        r"""Returns variable indices of nodes constrained to be on the same route."""
6056        return _pywrapcp.RoutingModel_GetSameVehicleIndicesOfIndex(self, node)

Returns variable indices of nodes constrained to be on the same route.

def GetSameActivityIndicesOfIndex(self, node):
6058    def GetSameActivityIndicesOfIndex(self, node):
6059        r"""Returns variable indices of nodes constrained to have the same activity."""
6060        return _pywrapcp.RoutingModel_GetSameActivityIndicesOfIndex(self, node)

Returns variable indices of nodes constrained to have the same activity.

def GetSameActivityGroupOfIndex(self, node):
6062    def GetSameActivityGroupOfIndex(self, node):
6063        r"""Returns the same activity group of the node."""
6064        return _pywrapcp.RoutingModel_GetSameActivityGroupOfIndex(self, node)

Returns the same activity group of the node.

def GetSameActivityGroupsCount(self):
6066    def GetSameActivityGroupsCount(self):
6067        r"""Returns the number of same activity groups."""
6068        return _pywrapcp.RoutingModel_GetSameActivityGroupsCount(self)

Returns the number of same activity groups.

def GetSameActivityIndicesOfGroup(self, group):
6070    def GetSameActivityIndicesOfGroup(self, group):
6071        r"""Returns variable indices of nodes in the same activity group."""
6072        return _pywrapcp.RoutingModel_GetSameActivityIndicesOfGroup(self, group)

Returns variable indices of nodes in the same activity group.

def GetVehicleTypeContainer(self):
6074    def GetVehicleTypeContainer(self):
6075        return _pywrapcp.RoutingModel_GetVehicleTypeContainer(self)
def ArcIsMoreConstrainedThanArc(self, _from, to1, to2):
6077    def ArcIsMoreConstrainedThanArc(self, _from, to1, to2):
6078        r"""
6079        Returns whether the arc from->to1 is more constrained than from->to2,
6080        taking into account, in order:
6081        - whether the destination node isn't an end node
6082        - whether the destination node is mandatory
6083        - whether the destination node is bound to the same vehicle as the source
6084        - the "primary constrained" dimension (see SetPrimaryConstrainedDimension)
6085        It then breaks ties using, in order:
6086        - the arc cost (taking unperformed penalties into account)
6087        - the size of the vehicle vars of "to1" and "to2" (lowest size wins)
6088        - the value: the lowest value of the indices to1 and to2 wins.
6089        See the .cc for details.
6090        The more constrained arc is typically preferable when building a
6091        first solution. This method is intended to be used as a callback for the
6092        BestValueByComparisonSelector value selector.
6093        Args:
6094          from: the variable index of the source node
6095          to1: the variable index of the first candidate destination node.
6096          to2: the variable index of the second candidate destination node.
6097        """
6098        return _pywrapcp.RoutingModel_ArcIsMoreConstrainedThanArc(self, _from, to1, to2)

Returns whether the arc from->to1 is more constrained than from->to2, taking into account, in order:

  • whether the destination node isn't an end node
  • whether the destination node is mandatory
  • whether the destination node is bound to the same vehicle as the source
  • the "primary constrained" dimension (see SetPrimaryConstrainedDimension) It then breaks ties using, in order:
  • the arc cost (taking unperformed penalties into account)
  • the size of the vehicle vars of "to1" and "to2" (lowest size wins)
  • the value: the lowest value of the indices to1 and to2 wins. See the .cc for details. The more constrained arc is typically preferable when building a first solution. This method is intended to be used as a callback for the BestValueByComparisonSelector value selector.
Arguments:
  • from: the variable index of the source node
  • to1: the variable index of the first candidate destination node.
  • to2: the variable index of the second candidate destination node.
def DebugOutputAssignment(self, solution_assignment, dimension_to_print):
6100    def DebugOutputAssignment(self, solution_assignment, dimension_to_print):
6101        r"""
6102        Print some debugging information about an assignment, including the
6103        feasible intervals of the CumulVar for dimension "dimension_to_print"
6104        at each step of the routes.
6105        If "dimension_to_print" is omitted, all dimensions will be printed.
6106        """
6107        return _pywrapcp.RoutingModel_DebugOutputAssignment(self, solution_assignment, dimension_to_print)

Print some debugging information about an assignment, including the feasible intervals of the CumulVar for dimension "dimension_to_print" at each step of the routes. If "dimension_to_print" is omitted, all dimensions will be printed.

def CheckIfAssignmentIsFeasible(self, assignment, call_at_solution_monitors):
6109    def CheckIfAssignmentIsFeasible(self, assignment, call_at_solution_monitors):
6110        r"""
6111        Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair
6112        containing the minimum and maximum of the CumulVar of the jth node on
6113        route i.
6114        - cumul_bounds[i][j].first is the minimum.
6115        - cumul_bounds[i][j].second is the maximum.
6116        Checks if an assignment is feasible.
6117        """
6118        return _pywrapcp.RoutingModel_CheckIfAssignmentIsFeasible(self, assignment, call_at_solution_monitors)

Returns a vector cumul_bounds, for which cumul_bounds[i][j] is a pair containing the minimum and maximum of the CumulVar of the jth node on route i.

  • cumul_bounds[i][j].first is the minimum.
  • cumul_bounds[i][j].second is the maximum. Checks if an assignment is feasible.
def solver(self):
6120    def solver(self):
6121        r"""
6122        Returns the underlying constraint solver. Can be used to add extra
6123        constraints and/or modify search algorithms.
6124        """
6125        return _pywrapcp.RoutingModel_solver(self)

Returns the underlying constraint solver. Can be used to add extra constraints and/or modify search algorithms.

def CheckLimit(self, *args):
6127    def CheckLimit(self, *args):
6128        r"""
6129        Returns true if the search limit has been crossed with the given time
6130        offset.
6131        """
6132        return _pywrapcp.RoutingModel_CheckLimit(self, *args)

Returns true if the search limit has been crossed with the given time offset.

def RemainingTime(self):
6134    def RemainingTime(self):
6135        r"""Returns the time left in the search limit."""
6136        return _pywrapcp.RoutingModel_RemainingTime(self)

Returns the time left in the search limit.

def UpdateTimeLimit(self, time_limit):
6138    def UpdateTimeLimit(self, time_limit):
6139        r"""Updates the time limit of the search limit."""
6140        return _pywrapcp.RoutingModel_UpdateTimeLimit(self, time_limit)

Updates the time limit of the search limit.

def TimeBuffer(self):
6142    def TimeBuffer(self):
6143        r"""Returns the time buffer to safely return a solution."""
6144        return _pywrapcp.RoutingModel_TimeBuffer(self)

Returns the time buffer to safely return a solution.

def GetMutableCPSatInterrupt(self):
6146    def GetMutableCPSatInterrupt(self):
6147        r"""Returns the atomic<bool> to stop the CP-SAT solver."""
6148        return _pywrapcp.RoutingModel_GetMutableCPSatInterrupt(self)

Returns the atomic to stop the CP-SAT solver.

def GetMutableCPInterrupt(self):
6150    def GetMutableCPInterrupt(self):
6151        r"""Returns the atomic<bool> to stop the CP solver."""
6152        return _pywrapcp.RoutingModel_GetMutableCPInterrupt(self)

Returns the atomic to stop the CP solver.

def CancelSearch(self):
6154    def CancelSearch(self):
6155        r"""Cancels the current search."""
6156        return _pywrapcp.RoutingModel_CancelSearch(self)

Cancels the current search.

def nodes(self):
6158    def nodes(self):
6159        r"""
6160        Sizes and indices
6161        Returns the number of nodes in the model.
6162        """
6163        return _pywrapcp.RoutingModel_nodes(self)

Sizes and indices Returns the number of nodes in the model.

def vehicles(self):
6165    def vehicles(self):
6166        r"""Returns the number of vehicle routes in the model."""
6167        return _pywrapcp.RoutingModel_vehicles(self)

Returns the number of vehicle routes in the model.

def Size(self):
6169    def Size(self):
6170        r"""Returns the number of next variables in the model."""
6171        return _pywrapcp.RoutingModel_Size(self)

Returns the number of next variables in the model.

def GetNumberOfDecisionsInFirstSolution(self, search_parameters):
6173    def GetNumberOfDecisionsInFirstSolution(self, search_parameters):
6174        r"""
6175        Returns statistics on first solution search, number of decisions sent to
6176        filters, number of decisions rejected by filters.
6177        """
6178        return _pywrapcp.RoutingModel_GetNumberOfDecisionsInFirstSolution(self, search_parameters)

Returns statistics on first solution search, number of decisions sent to filters, number of decisions rejected by filters.

def GetNumberOfRejectsInFirstSolution(self, search_parameters):
6180    def GetNumberOfRejectsInFirstSolution(self, search_parameters):
6181        return _pywrapcp.RoutingModel_GetNumberOfRejectsInFirstSolution(self, search_parameters)
def GetAutomaticFirstSolutionStrategy(self):
6183    def GetAutomaticFirstSolutionStrategy(self):
6184        r"""Returns the automatic first solution strategy selected."""
6185        return _pywrapcp.RoutingModel_GetAutomaticFirstSolutionStrategy(self)

Returns the automatic first solution strategy selected.

def IsMatchingModel(self):
6187    def IsMatchingModel(self):
6188        r"""Returns true if a vehicle/node matching problem is detected."""
6189        return _pywrapcp.RoutingModel_IsMatchingModel(self)

Returns true if a vehicle/node matching problem is detected.

def AreRoutesInterdependent(self, parameters):
6191    def AreRoutesInterdependent(self, parameters):
6192        r"""
6193        Returns true if routes are interdependent. This means that any
6194        modification to a route might impact another.
6195        """
6196        return _pywrapcp.RoutingModel_AreRoutesInterdependent(self, parameters)

Returns true if routes are interdependent. This means that any modification to a route might impact another.

def MakeGuidedSlackFinalizer(self, dimension, initializer):
6198    def MakeGuidedSlackFinalizer(self, dimension, initializer):
6199        r"""
6200        The next few members are in the public section only for testing purposes.
6201
6202        MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a
6203        dimension using a callback to choose which values to start with.
6204        The finalizer works only when all next variables in the model have
6205        been fixed. It has the following two characteristics:
6206        1. It follows the routes defined by the nexts variables when choosing a
6207           variable to make a decision on.
6208        2. When it comes to choose a value for the slack of node i, the decision
6209           builder first calls the callback with argument i, and supposingly the
6210           returned value is x it creates decisions slack[i] = x, slack[i] = x +
6211           1, slack[i] = x - 1, slack[i] = x + 2, etc.
6212        """
6213        return _pywrapcp.RoutingModel_MakeGuidedSlackFinalizer(self, dimension, initializer)

The next few members are in the public section only for testing purposes.

MakeGuidedSlackFinalizer creates a DecisionBuilder for the slacks of a dimension using a callback to choose which values to start with. The finalizer works only when all next variables in the model have been fixed. It has the following two characteristics:

  1. It follows the routes defined by the nexts variables when choosing a variable to make a decision on.
  2. When it comes to choose a value for the slack of node i, the decision builder first calls the callback with argument i, and supposingly the returned value is x it creates decisions slack[i] = x, slack[i] = x + 1, slack[i] = x - 1, slack[i] = x + 2, etc.
def MakeSelfDependentDimensionFinalizer(self, dimension):
6215    def MakeSelfDependentDimensionFinalizer(self, dimension):
6216        r"""
6217        MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a
6218        self-dependent dimension. It makes an extensive use of the caches of the
6219        state dependent transits.
6220        In detail, MakeSelfDependentDimensionFinalizer returns a composition of a
6221        local search decision builder with a greedy descent operator for the cumul
6222        of the start of each route and a guided slack finalizer. Provided there
6223        are no time windows and the maximum slacks are large enough, once the
6224        cumul of the start of route is fixed, the guided finalizer can find
6225        optimal values of the slacks for the rest of the route in time
6226        proportional to the length of the route. Therefore the composed finalizer
6227        generally works in time O(log(t)*n*m), where t is the latest possible
6228        departute time, n is the number of nodes in the network and m is the
6229        number of vehicles.
6230        """
6231        return _pywrapcp.RoutingModel_MakeSelfDependentDimensionFinalizer(self, dimension)

MakeSelfDependentDimensionFinalizer is a finalizer for the slacks of a self-dependent dimension. It makes an extensive use of the caches of the state dependent transits. In detail, MakeSelfDependentDimensionFinalizer returns a composition of a local search decision builder with a greedy descent operator for the cumul of the start of each route and a guided slack finalizer. Provided there are no time windows and the maximum slacks are large enough, once the cumul of the start of route is fixed, the guided finalizer can find optimal values of the slacks for the rest of the route in time proportional to the length of the route. Therefore the composed finalizer generally works in time O(log(t)nm), where t is the latest possible departute time, n is the number of nodes in the network and m is the number of vehicles.

def GetPathsMetadata(self):
6233    def GetPathsMetadata(self):
6234        return _pywrapcp.RoutingModel_GetPathsMetadata(self)
def GetVehiclesOfSameClass(self, start_end_index):
6236    def GetVehiclesOfSameClass(self, start_end_index):
6237        r"""
6238        Returns indices of the vehicles which are in the same vehicle class as the
6239        vehicle starting or ending at start_end_index.
6240        """
6241        return _pywrapcp.RoutingModel_GetVehiclesOfSameClass(self, start_end_index)

Returns indices of the vehicles which are in the same vehicle class as the vehicle starting or ending at start_end_index.

def GetSameVehicleClassArcs(self, from_index, to_index):
6243    def GetSameVehicleClassArcs(self, from_index, to_index):
6244        r"""
6245        Returns all arcs which are equivalent to the {from_index, to_index} arc
6246        wrt vehicle classes. Arcs will be returned only if from_index is the
6247        start of a vehicle or if to_index is the end of a vehicle. The returned
6248        arcs will then be starting or ending at start or end nodes of vehicles in
6249        the same vehicle class. The input arc is included in the returned vector.
6250        """
6251        return _pywrapcp.RoutingModel_GetSameVehicleClassArcs(self, from_index, to_index)

Returns all arcs which are equivalent to the {from_index, to_index} arc wrt vehicle classes. Arcs will be returned only if from_index is the start of a vehicle or if to_index is the end of a vehicle. The returned arcs will then be starting or ending at start or end nodes of vehicles in the same vehicle class. The input arc is included in the returned vector.

kNoPenalty = -1
kNoDisjunction = <Swig Object of type 'RoutingDisjunctionIndex *'>
kNoDimension = <Swig Object of type 'RoutingDimensionIndex *'>
cvar = <Swig global variables>
class RoutingModelVisitor(BaseObject):
6260class RoutingModelVisitor(BaseObject):
6261    r"""Routing model visitor."""
6262
6263    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6264    __repr__ = _swig_repr
6265
6266    def __init__(self):
6267        _pywrapcp.RoutingModelVisitor_swiginit(self, _pywrapcp.new_RoutingModelVisitor())
6268    __swig_destroy__ = _pywrapcp.delete_RoutingModelVisitor

Routing model visitor.

thisown
6263    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

kLightElement = 'LightElement'
kLightElement2 = 'LightElement2'
kRemoveValues = 'RemoveValues'
Inherited Members
BaseObject
DebugString
class GlobalVehicleBreaksConstraint(Constraint):
6276class GlobalVehicleBreaksConstraint(Constraint):
6277    r"""
6278    GlobalVehicleBreaksConstraint ensures breaks constraints are enforced on
6279    all vehicles in the dimension passed to its constructor.
6280    It is intended to be used for dimensions representing time.
6281    A break constraint ensures break intervals fit on the route of a vehicle.
6282    For a given vehicle, it forces break intervals to be disjoint from visit
6283    intervals, where visit intervals start at CumulVar(node) and last for
6284    node_visit_transit[node]. Moreover, it ensures that there is enough time
6285    between two consecutive nodes of a route to do transit and vehicle breaks,
6286    i.e. if Next(nodeA) = nodeB, CumulVar(nodeA) = tA and CumulVar(nodeB) = tB,
6287    then SlackVar(nodeA) >= sum_{breaks [tA, tB)} duration(break).
6288    """
6289
6290    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6291    __repr__ = _swig_repr
6292
6293    def __init__(self, dimension):
6294        _pywrapcp.GlobalVehicleBreaksConstraint_swiginit(self, _pywrapcp.new_GlobalVehicleBreaksConstraint(dimension))
6295
6296    def DebugString(self):
6297        return _pywrapcp.GlobalVehicleBreaksConstraint_DebugString(self)
6298
6299    def Post(self):
6300        return _pywrapcp.GlobalVehicleBreaksConstraint_Post(self)
6301
6302    def InitialPropagateWrapper(self):
6303        return _pywrapcp.GlobalVehicleBreaksConstraint_InitialPropagateWrapper(self)
6304    __swig_destroy__ = _pywrapcp.delete_GlobalVehicleBreaksConstraint

GlobalVehicleBreaksConstraint ensures breaks constraints are enforced on all vehicles in the dimension passed to its constructor. It is intended to be used for dimensions representing time. A break constraint ensures break intervals fit on the route of a vehicle. For a given vehicle, it forces break intervals to be disjoint from visit intervals, where visit intervals start at CumulVar(node) and last for node_visit_transit[node]. Moreover, it ensures that there is enough time between two consecutive nodes of a route to do transit and vehicle breaks, i.e. if Next(nodeA) = nodeB, CumulVar(nodeA) = tA and CumulVar(nodeB) = tB, then SlackVar(nodeA) >= sum_{breaks [tA, tB)} duration(break).

GlobalVehicleBreaksConstraint(dimension)
6293    def __init__(self, dimension):
6294        _pywrapcp.GlobalVehicleBreaksConstraint_swiginit(self, _pywrapcp.new_GlobalVehicleBreaksConstraint(dimension))
thisown
6290    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def DebugString(self):
6296    def DebugString(self):
6297        return _pywrapcp.GlobalVehicleBreaksConstraint_DebugString(self)
def Post(self):
6299    def Post(self):
6300        return _pywrapcp.GlobalVehicleBreaksConstraint_Post(self)

This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.

def InitialPropagateWrapper(self):
6302    def InitialPropagateWrapper(self):
6303        return _pywrapcp.GlobalVehicleBreaksConstraint_InitialPropagateWrapper(self)

This method performs the initial propagation of the constraint. It is called just after the post.

class TypeRegulationsChecker:
6308class TypeRegulationsChecker(object):
6309    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6310
6311    def __init__(self, *args, **kwargs):
6312        raise AttributeError("No constructor defined - class is abstract")
6313    __repr__ = _swig_repr
6314    __swig_destroy__ = _pywrapcp.delete_TypeRegulationsChecker
6315
6316    def CheckVehicle(self, vehicle, next_accessor):
6317        return _pywrapcp.TypeRegulationsChecker_CheckVehicle(self, vehicle, next_accessor)
TypeRegulationsChecker(*args, **kwargs)
6311    def __init__(self, *args, **kwargs):
6312        raise AttributeError("No constructor defined - class is abstract")
thisown
6309    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def CheckVehicle(self, vehicle, next_accessor):
6316    def CheckVehicle(self, vehicle, next_accessor):
6317        return _pywrapcp.TypeRegulationsChecker_CheckVehicle(self, vehicle, next_accessor)
class TypeIncompatibilityChecker(TypeRegulationsChecker):
6321class TypeIncompatibilityChecker(TypeRegulationsChecker):
6322    r"""Checker for type incompatibilities."""
6323
6324    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6325    __repr__ = _swig_repr
6326
6327    def __init__(self, model, check_hard_incompatibilities):
6328        _pywrapcp.TypeIncompatibilityChecker_swiginit(self, _pywrapcp.new_TypeIncompatibilityChecker(model, check_hard_incompatibilities))
6329    __swig_destroy__ = _pywrapcp.delete_TypeIncompatibilityChecker

Checker for type incompatibilities.

TypeIncompatibilityChecker(model, check_hard_incompatibilities)
6327    def __init__(self, model, check_hard_incompatibilities):
6328        _pywrapcp.TypeIncompatibilityChecker_swiginit(self, _pywrapcp.new_TypeIncompatibilityChecker(model, check_hard_incompatibilities))
thisown
6324    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

class TypeRequirementChecker(TypeRegulationsChecker):
6333class TypeRequirementChecker(TypeRegulationsChecker):
6334    r"""Checker for type requirements."""
6335
6336    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6337    __repr__ = _swig_repr
6338
6339    def __init__(self, model):
6340        _pywrapcp.TypeRequirementChecker_swiginit(self, _pywrapcp.new_TypeRequirementChecker(model))
6341    __swig_destroy__ = _pywrapcp.delete_TypeRequirementChecker

Checker for type requirements.

TypeRequirementChecker(model)
6339    def __init__(self, model):
6340        _pywrapcp.TypeRequirementChecker_swiginit(self, _pywrapcp.new_TypeRequirementChecker(model))
thisown
6336    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

class TypeRegulationsConstraint(Constraint):
6345class TypeRegulationsConstraint(Constraint):
6346    r"""
6347    The following constraint ensures that incompatibilities and requirements
6348    between types are respected.
6349
6350    It verifies both "hard" and "temporal" incompatibilities.
6351    Two nodes with hard incompatible types cannot be served by the same vehicle
6352    at all, while with a temporal incompatibility they can't be on the same
6353    route at the same time.
6354    The VisitTypePolicy of a node determines how visiting it impacts the type
6355    count on the route.
6356
6357    For example, for
6358    - three temporally incompatible types T1 T2 and T3
6359    - 2 pairs of nodes a1/r1 and a2/r2 of type T1 and T2 respectively, with
6360        - a1 and a2 of VisitTypePolicy TYPE_ADDED_TO_VEHICLE
6361        - r1 and r2 of policy ADDED_TYPE_REMOVED_FROM_VEHICLE
6362    - 3 nodes A, UV and AR of type T3, respectively with type policies
6363      TYPE_ADDED_TO_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT and
6364      TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED
6365    the configurations
6366    UV --> a1 --> r1 --> a2 --> r2,   a1 --> r1 --> a2 --> r2 --> A and
6367    a1 --> r1 --> AR --> a2 --> r2 are acceptable, whereas the configurations
6368    a1 --> a2 --> r1 --> ..., or A --> a1 --> r1 --> ..., or
6369    a1 --> r1 --> UV --> ... are not feasible.
6370
6371    It also verifies same-vehicle and temporal type requirements.
6372    A node of type T_d with a same-vehicle requirement for type T_r needs to be
6373    served by the same vehicle as a node of type T_r.
6374    Temporal requirements, on the other hand, can take effect either when the
6375    dependent type is being added to the route or when it's removed from it,
6376    which is determined by the dependent node's VisitTypePolicy.
6377    In the above example:
6378    - If T3 is required on the same vehicle as T1, A, AR or UV must be on the
6379      same vehicle as a1.
6380    - If T2 is required when adding T1, a2 must be visited *before* a1, and if
6381      r2 is also visited on the route, it must be *after* a1, i.e. T2 must be on
6382      the vehicle when a1 is visited:
6383      ... --> a2 --> ... --> a1 --> ... --> r2 --> ...
6384    - If T3 is required when removing T1, T3 needs to be on the vehicle when
6385      r1 is visited:
6386      ... --> A --> ... --> r1 --> ...   OR   ... --> r1 --> ... --> UV --> ...
6387    """
6388
6389    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6390    __repr__ = _swig_repr
6391
6392    def __init__(self, model):
6393        _pywrapcp.TypeRegulationsConstraint_swiginit(self, _pywrapcp.new_TypeRegulationsConstraint(model))
6394
6395    def Post(self):
6396        return _pywrapcp.TypeRegulationsConstraint_Post(self)
6397
6398    def InitialPropagateWrapper(self):
6399        return _pywrapcp.TypeRegulationsConstraint_InitialPropagateWrapper(self)
6400    __swig_destroy__ = _pywrapcp.delete_TypeRegulationsConstraint

The following constraint ensures that incompatibilities and requirements between types are respected.

It verifies both "hard" and "temporal" incompatibilities. Two nodes with hard incompatible types cannot be served by the same vehicle at all, while with a temporal incompatibility they can't be on the same route at the same time. The VisitTypePolicy of a node determines how visiting it impacts the type count on the route.

For example, for

  • three temporally incompatible types T1 T2 and T3
  • 2 pairs of nodes a1/r1 and a2/r2 of type T1 and T2 respectively, with
    • a1 and a2 of VisitTypePolicy TYPE_ADDED_TO_VEHICLE
    • r1 and r2 of policy ADDED_TYPE_REMOVED_FROM_VEHICLE
  • 3 nodes A, UV and AR of type T3, respectively with type policies TYPE_ADDED_TO_VEHICLE, TYPE_ON_VEHICLE_UP_TO_VISIT and TYPE_SIMULTANEOUSLY_ADDED_AND_REMOVED the configurations UV --> a1 --> r1 --> a2 --> r2, a1 --> r1 --> a2 --> r2 --> A and a1 --> r1 --> AR --> a2 --> r2 are acceptable, whereas the configurations a1 --> a2 --> r1 --> ..., or A --> a1 --> r1 --> ..., or a1 --> r1 --> UV --> ... are not feasible.

It also verifies same-vehicle and temporal type requirements. A node of type T_d with a same-vehicle requirement for type T_r needs to be served by the same vehicle as a node of type T_r. Temporal requirements, on the other hand, can take effect either when the dependent type is being added to the route or when it's removed from it, which is determined by the dependent node's VisitTypePolicy. In the above example:

  • If T3 is required on the same vehicle as T1, A, AR or UV must be on the same vehicle as a1.
  • If T2 is required when adding T1, a2 must be visited before a1, and if r2 is also visited on the route, it must be after a1, i.e. T2 must be on the vehicle when a1 is visited: ... --> a2 --> ... --> a1 --> ... --> r2 --> ...
  • If T3 is required when removing T1, T3 needs to be on the vehicle when r1 is visited: ... --> A --> ... --> r1 --> ... OR ... --> r1 --> ... --> UV --> ...
TypeRegulationsConstraint(model)
6392    def __init__(self, model):
6393        _pywrapcp.TypeRegulationsConstraint_swiginit(self, _pywrapcp.new_TypeRegulationsConstraint(model))
thisown
6389    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def Post(self):
6395    def Post(self):
6396        return _pywrapcp.TypeRegulationsConstraint_Post(self)

This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.

def InitialPropagateWrapper(self):
6398    def InitialPropagateWrapper(self):
6399        return _pywrapcp.TypeRegulationsConstraint_InitialPropagateWrapper(self)

This method performs the initial propagation of the constraint. It is called just after the post.

class BoundCost:
6404class BoundCost(object):
6405    r"""
6406    A structure meant to store soft bounds and associated violation constants.
6407    It is 'Simple' because it has one BoundCost per element,
6408    in contrast to 'Multiple'. Design notes:
6409    - it is meant to store model information to be shared through pointers,
6410      so it disallows copy and assign to avoid accidental duplication.
6411    - it keeps soft bounds as an array of structs to help cache,
6412      because code that uses such bounds typically use both bound and cost.
6413    - soft bounds are named pairs, prevents some mistakes.
6414    - using operator[] to access elements is not interesting,
6415      because the structure will be accessed through pointers, moreover having
6416      to type bound_cost reminds the user of the order if they do a copy
6417      assignment of the element.
6418    """
6419
6420    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6421    __repr__ = _swig_repr
6422    bound = property(_pywrapcp.BoundCost_bound_get, _pywrapcp.BoundCost_bound_set)
6423    cost = property(_pywrapcp.BoundCost_cost_get, _pywrapcp.BoundCost_cost_set)
6424
6425    def __init__(self, *args):
6426        _pywrapcp.BoundCost_swiginit(self, _pywrapcp.new_BoundCost(*args))
6427    __swig_destroy__ = _pywrapcp.delete_BoundCost

A structure meant to store soft bounds and associated violation constants. It is 'Simple' because it has one BoundCost per element, in contrast to 'Multiple'. Design notes:

  • it is meant to store model information to be shared through pointers, so it disallows copy and assign to avoid accidental duplication.
  • it keeps soft bounds as an array of structs to help cache, because code that uses such bounds typically use both bound and cost.
  • soft bounds are named pairs, prevents some mistakes.
  • using operator[] to access elements is not interesting, because the structure will be accessed through pointers, moreover having to type bound_cost reminds the user of the order if they do a copy assignment of the element.
BoundCost(*args)
6425    def __init__(self, *args):
6426        _pywrapcp.BoundCost_swiginit(self, _pywrapcp.new_BoundCost(*args))
thisown
6420    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

bound
cost
class SimpleBoundCosts:
6431class SimpleBoundCosts(object):
6432    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6433    __repr__ = _swig_repr
6434
6435    def __init__(self, num_bounds, default_bound_cost):
6436        _pywrapcp.SimpleBoundCosts_swiginit(self, _pywrapcp.new_SimpleBoundCosts(num_bounds, default_bound_cost))
6437
6438    def bound_cost(self, element):
6439        return _pywrapcp.SimpleBoundCosts_bound_cost(self, element)
6440
6441    def size(self):
6442        return _pywrapcp.SimpleBoundCosts_size(self)
6443    __swig_destroy__ = _pywrapcp.delete_SimpleBoundCosts
SimpleBoundCosts(num_bounds, default_bound_cost)
6435    def __init__(self, num_bounds, default_bound_cost):
6436        _pywrapcp.SimpleBoundCosts_swiginit(self, _pywrapcp.new_SimpleBoundCosts(num_bounds, default_bound_cost))
thisown
6432    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def bound_cost(self, element):
6438    def bound_cost(self, element):
6439        return _pywrapcp.SimpleBoundCosts_bound_cost(self, element)
def size(self):
6441    def size(self):
6442        return _pywrapcp.SimpleBoundCosts_size(self)
class RoutingDimension:
6447class RoutingDimension(object):
6448    r"""
6449    Dimensions represent quantities accumulated at nodes along the routes. They
6450    represent quantities such as weights or volumes carried along the route, or
6451    distance or times.
6452
6453    Quantities at a node are represented by "cumul" variables and the increase
6454    or decrease of quantities between nodes are represented by "transit"
6455    variables. These variables are linked as follows:
6456
6457    if j == next(i),
6458    cumuls(j) = cumuls(i) + transits(i) + slacks(i) +
6459                state_dependent_transits(i)
6460
6461    where slack is a positive slack variable (can represent waiting times for
6462    a time dimension), and state_dependent_transits is a non-purely functional
6463    version of transits_. Favour transits over state_dependent_transits when
6464    possible, because purely functional callbacks allow more optimisations and
6465    make the model faster and easier to solve.
6466    for a given vehicle, it is passed as an external vector, it would be better
6467    to have this information here.
6468    """
6469
6470    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
6471
6472    def __init__(self, *args, **kwargs):
6473        raise AttributeError("No constructor defined")
6474    __repr__ = _swig_repr
6475    __swig_destroy__ = _pywrapcp.delete_RoutingDimension
6476
6477    def model(self):
6478        r"""Returns the model on which the dimension was created."""
6479        return _pywrapcp.RoutingDimension_model(self)
6480
6481    def GetTransitValue(self, from_index, to_index, vehicle):
6482        r"""
6483        Returns the transition value for a given pair of nodes (as var index);
6484        this value is the one taken by the corresponding transit variable when
6485        the 'next' variable for 'from_index' is bound to 'to_index'.
6486        """
6487        return _pywrapcp.RoutingDimension_GetTransitValue(self, from_index, to_index, vehicle)
6488
6489    def GetTransitValueFromClass(self, from_index, to_index, vehicle_class):
6490        r"""
6491        Same as above but taking a vehicle class of the dimension instead of a
6492        vehicle (the class of a vehicle can be obtained with vehicle_to_class()).
6493        """
6494        return _pywrapcp.RoutingDimension_GetTransitValueFromClass(self, from_index, to_index, vehicle_class)
6495
6496    def CumulVar(self, index):
6497        r"""
6498        Get the cumul, transit and slack variables for the given node (given as
6499        int64_t var index).
6500        """
6501        return _pywrapcp.RoutingDimension_CumulVar(self, index)
6502
6503    def TransitVar(self, index):
6504        return _pywrapcp.RoutingDimension_TransitVar(self, index)
6505
6506    def FixedTransitVar(self, index):
6507        return _pywrapcp.RoutingDimension_FixedTransitVar(self, index)
6508
6509    def SlackVar(self, index):
6510        return _pywrapcp.RoutingDimension_SlackVar(self, index)
6511
6512    def SetCumulVarRange(self, index, min, max):
6513        r"""
6514        Some functions to allow users to use the interface without knowing about
6515        the underlying CP model.
6516        Restricts the range of the cumul variable associated to index.
6517        """
6518        return _pywrapcp.RoutingDimension_SetCumulVarRange(self, index, min, max)
6519
6520    def GetCumulVarMin(self, index):
6521        r"""Gets the current minimum of the cumul variable associated to index."""
6522        return _pywrapcp.RoutingDimension_GetCumulVarMin(self, index)
6523
6524    def GetCumulVarMax(self, index):
6525        r"""Gets the current maximum of the cumul variable associated to index."""
6526        return _pywrapcp.RoutingDimension_GetCumulVarMax(self, index)
6527
6528    def SetSpanUpperBoundForVehicle(self, upper_bound, vehicle):
6529        r"""
6530        Sets an upper bound on the dimension span on a given vehicle. This is the
6531        preferred way to limit the "length" of the route of a vehicle according to
6532        a dimension.
6533        """
6534        return _pywrapcp.RoutingDimension_SetSpanUpperBoundForVehicle(self, upper_bound, vehicle)
6535
6536    def SetSpanCostCoefficientForVehicle(self, coefficient, vehicle):
6537        r"""
6538        Sets a cost proportional to the dimension span on a given vehicle,
6539        or on all vehicles at once. "coefficient" must be nonnegative.
6540        This is handy to model costs proportional to idle time when the dimension
6541        represents time.
6542        The cost for a vehicle is
6543          span_cost = coefficient * (dimension end value - dimension start value).
6544        """
6545        return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForVehicle(self, coefficient, vehicle)
6546
6547    def SetSpanCostCoefficientForAllVehicles(self, coefficient):
6548        return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForAllVehicles(self, coefficient)
6549
6550    def SetSlackCostCoefficientForVehicle(self, coefficient, vehicle):
6551        r"""
6552        Sets a cost proportional to the dimension total slack on a given vehicle,
6553        or on all vehicles at once. "coefficient" must be nonnegative.
6554        This is handy to model costs only proportional to idle time when the
6555        dimension represents time.
6556        The cost for a vehicle is
6557          slack_cost = coefficient *
6558                (dimension end value - dimension start value - total_transit).
6559        """
6560        return _pywrapcp.RoutingDimension_SetSlackCostCoefficientForVehicle(self, coefficient, vehicle)
6561
6562    def SetSlackCostCoefficientForAllVehicles(self, coefficient):
6563        return _pywrapcp.RoutingDimension_SetSlackCostCoefficientForAllVehicles(self, coefficient)
6564
6565    def SetGlobalSpanCostCoefficient(self, coefficient):
6566        r"""
6567        Sets a cost proportional to the *global* dimension span, that is the
6568        difference between the largest value of route end cumul variables and
6569        the smallest value of route start cumul variables.
6570        In other words:
6571        global_span_cost =
6572          coefficient * (Max(dimension end value) - Min(dimension start value)).
6573        """
6574        return _pywrapcp.RoutingDimension_SetGlobalSpanCostCoefficient(self, coefficient)
6575
6576    def SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient):
6577        r"""
6578        Sets a soft upper bound to the cumul variable of a given variable index.
6579        If the value of the cumul variable is greater than the bound, a cost
6580        proportional to the difference between this value and the bound is added
6581        to the cost function of the model:
6582          cumulVar <= upper_bound -> cost = 0
6583           cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound)
6584        This is also handy to model tardiness costs when the dimension represents
6585        time.
6586        """
6587        return _pywrapcp.RoutingDimension_SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient)
6588
6589    def HasCumulVarSoftUpperBound(self, index):
6590        r"""
6591        Returns true if a soft upper bound has been set for a given variable
6592        index.
6593        """
6594        return _pywrapcp.RoutingDimension_HasCumulVarSoftUpperBound(self, index)
6595
6596    def GetCumulVarSoftUpperBound(self, index):
6597        r"""
6598        Returns the soft upper bound of a cumul variable for a given variable
6599        index. The "hard" upper bound of the variable is returned if no soft upper
6600        bound has been set.
6601        """
6602        return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBound(self, index)
6603
6604    def GetCumulVarSoftUpperBoundCoefficient(self, index):
6605        r"""
6606        Returns the cost coefficient of the soft upper bound of a cumul variable
6607        for a given variable index. If no soft upper bound has been set, 0 is
6608        returned.
6609        """
6610        return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBoundCoefficient(self, index)
6611
6612    def SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient):
6613        r"""
6614        Sets a soft lower bound to the cumul variable of a given variable index.
6615        If the value of the cumul variable is less than the bound, a cost
6616        proportional to the difference between this value and the bound is added
6617        to the cost function of the model:
6618          cumulVar > lower_bound -> cost = 0
6619          cumulVar <= lower_bound -> cost = coefficient * (lower_bound -
6620                      cumulVar).
6621        This is also handy to model earliness costs when the dimension represents
6622        time.
6623        """
6624        return _pywrapcp.RoutingDimension_SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient)
6625
6626    def HasCumulVarSoftLowerBound(self, index):
6627        r"""
6628        Returns true if a soft lower bound has been set for a given variable
6629        index.
6630        """
6631        return _pywrapcp.RoutingDimension_HasCumulVarSoftLowerBound(self, index)
6632
6633    def GetCumulVarSoftLowerBound(self, index):
6634        r"""
6635        Returns the soft lower bound of a cumul variable for a given variable
6636        index. The "hard" lower bound of the variable is returned if no soft lower
6637        bound has been set.
6638        """
6639        return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBound(self, index)
6640
6641    def GetCumulVarSoftLowerBoundCoefficient(self, index):
6642        r"""
6643        Returns the cost coefficient of the soft lower bound of a cumul variable
6644        for a given variable index. If no soft lower bound has been set, 0 is
6645        returned.
6646        """
6647        return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBoundCoefficient(self, index)
6648
6649    def SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits):
6650        r"""
6651        Sets the breaks for a given vehicle. Breaks are represented by
6652        IntervalVars. They may interrupt transits between nodes and increase
6653        the value of corresponding slack variables.
6654        A break may take place before the start of a vehicle, after the end of
6655        a vehicle, or during a travel i -> j.
6656
6657        In that case, the interval [break.Start(), break.End()) must be a subset
6658        of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In
6659        other words, a break may not overlap any node n's visit, given by
6660        [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)).
6661        This formula considers post_travel(_, start) and pre_travel(end, _) to be
6662        0; pre_travel will never be called on any (_, start) and post_travel will
6663        never we called on any (end, _). If pre_travel_evaluator or
6664        post_travel_evaluator is -1, it will be taken as a function that always
6665        returns 0.
6666        Deprecated, sets pre_travel(i, j) = node_visit_transit[i].
6667        """
6668        return _pywrapcp.RoutingDimension_SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits)
6669
6670    def SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle):
6671        r"""
6672        With breaks supposed to be consecutive, this forces the distance between
6673        breaks of size at least minimum_break_duration to be at most distance.
6674        This supposes that the time until route start and after route end are
6675        infinite breaks.
6676        """
6677        return _pywrapcp.RoutingDimension_SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle)
6678
6679    def InitializeBreaks(self):
6680        r"""
6681        Sets up vehicle_break_intervals_, vehicle_break_distance_duration_,
6682        pre_travel_evaluators and post_travel_evaluators.
6683        """
6684        return _pywrapcp.RoutingDimension_InitializeBreaks(self)
6685
6686    def HasBreakConstraints(self):
6687        r"""Returns true if any break interval or break distance was defined."""
6688        return _pywrapcp.RoutingDimension_HasBreakConstraints(self)
6689
6690    def GetPreTravelEvaluatorOfVehicle(self, vehicle):
6691        return _pywrapcp.RoutingDimension_GetPreTravelEvaluatorOfVehicle(self, vehicle)
6692
6693    def GetPostTravelEvaluatorOfVehicle(self, vehicle):
6694        return _pywrapcp.RoutingDimension_GetPostTravelEvaluatorOfVehicle(self, vehicle)
6695
6696    def base_dimension(self):
6697        r"""Returns the parent in the dependency tree if any or nullptr otherwise."""
6698        return _pywrapcp.RoutingDimension_base_dimension(self)
6699
6700    def ShortestTransitionSlack(self, node):
6701        r"""
6702        It makes sense to use the function only for self-dependent dimension.
6703        For such dimensions the value of the slack of a node determines the
6704        transition cost of the next transit. Provided that
6705          1. cumul[node] is fixed,
6706          2. next[node] and next[next[node]] (if exists) are fixed,
6707        the value of slack[node] for which cumul[next[node]] + transit[next[node]]
6708        is minimized can be found in O(1) using this function.
6709        """
6710        return _pywrapcp.RoutingDimension_ShortestTransitionSlack(self, node)
6711
6712    def name(self):
6713        r"""Returns the name of the dimension."""
6714        return _pywrapcp.RoutingDimension_name(self)
6715
6716    def SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index):
6717        return _pywrapcp.RoutingDimension_SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index)
6718
6719    def HasPickupToDeliveryLimits(self):
6720        return _pywrapcp.RoutingDimension_HasPickupToDeliveryLimits(self)
6721
6722    def AddNodePrecedence(self, first_node, second_node, offset):
6723        return _pywrapcp.RoutingDimension_AddNodePrecedence(self, first_node, second_node, offset)
6724
6725    def GetSpanUpperBoundForVehicle(self, vehicle):
6726        return _pywrapcp.RoutingDimension_GetSpanUpperBoundForVehicle(self, vehicle)
6727
6728    def GetSpanCostCoefficientForVehicle(self, vehicle):
6729        return _pywrapcp.RoutingDimension_GetSpanCostCoefficientForVehicle(self, vehicle)
6730
6731    def GetSlackCostCoefficientForVehicle(self, vehicle):
6732        return _pywrapcp.RoutingDimension_GetSlackCostCoefficientForVehicle(self, vehicle)
6733
6734    def global_span_cost_coefficient(self):
6735        return _pywrapcp.RoutingDimension_global_span_cost_coefficient(self)
6736
6737    def GetGlobalOptimizerOffset(self):
6738        return _pywrapcp.RoutingDimension_GetGlobalOptimizerOffset(self)
6739
6740    def GetLocalOptimizerOffsetForVehicle(self, vehicle):
6741        return _pywrapcp.RoutingDimension_GetLocalOptimizerOffsetForVehicle(self, vehicle)
6742
6743    def SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6744        r"""
6745        If the span of vehicle on this dimension is larger than bound,
6746        the cost will be increased by cost * (span - bound).
6747        """
6748        return _pywrapcp.RoutingDimension_SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)
6749
6750    def HasSoftSpanUpperBounds(self):
6751        return _pywrapcp.RoutingDimension_HasSoftSpanUpperBounds(self)
6752
6753    def GetSoftSpanUpperBoundForVehicle(self, vehicle):
6754        return _pywrapcp.RoutingDimension_GetSoftSpanUpperBoundForVehicle(self, vehicle)
6755
6756    def SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6757        r"""
6758        If the span of vehicle on this dimension is larger than bound,
6759        the cost will be increased by cost * (span - bound)^2.
6760        """
6761        return _pywrapcp.RoutingDimension_SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)
6762
6763    def HasQuadraticCostSoftSpanUpperBounds(self):
6764        return _pywrapcp.RoutingDimension_HasQuadraticCostSoftSpanUpperBounds(self)
6765
6766    def GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle):
6767        return _pywrapcp.RoutingDimension_GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle)

Dimensions represent quantities accumulated at nodes along the routes. They represent quantities such as weights or volumes carried along the route, or distance or times.

Quantities at a node are represented by "cumul" variables and the increase or decrease of quantities between nodes are represented by "transit" variables. These variables are linked as follows:

if j == next(i), cumuls(j) = cumuls(i) + transits(i) + slacks(i) + state_dependent_transits(i)

where slack is a positive slack variable (can represent waiting times for a time dimension), and state_dependent_transits is a non-purely functional version of transits_. Favour transits over state_dependent_transits when possible, because purely functional callbacks allow more optimisations and make the model faster and easier to solve. for a given vehicle, it is passed as an external vector, it would be better to have this information here.

RoutingDimension(*args, **kwargs)
6472    def __init__(self, *args, **kwargs):
6473        raise AttributeError("No constructor defined")
thisown
6470    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

The membership flag

def model(self):
6477    def model(self):
6478        r"""Returns the model on which the dimension was created."""
6479        return _pywrapcp.RoutingDimension_model(self)

Returns the model on which the dimension was created.

def GetTransitValue(self, from_index, to_index, vehicle):
6481    def GetTransitValue(self, from_index, to_index, vehicle):
6482        r"""
6483        Returns the transition value for a given pair of nodes (as var index);
6484        this value is the one taken by the corresponding transit variable when
6485        the 'next' variable for 'from_index' is bound to 'to_index'.
6486        """
6487        return _pywrapcp.RoutingDimension_GetTransitValue(self, from_index, to_index, vehicle)

Returns the transition value for a given pair of nodes (as var index); this value is the one taken by the corresponding transit variable when the 'next' variable for 'from_index' is bound to 'to_index'.

def GetTransitValueFromClass(self, from_index, to_index, vehicle_class):
6489    def GetTransitValueFromClass(self, from_index, to_index, vehicle_class):
6490        r"""
6491        Same as above but taking a vehicle class of the dimension instead of a
6492        vehicle (the class of a vehicle can be obtained with vehicle_to_class()).
6493        """
6494        return _pywrapcp.RoutingDimension_GetTransitValueFromClass(self, from_index, to_index, vehicle_class)

Same as above but taking a vehicle class of the dimension instead of a vehicle (the class of a vehicle can be obtained with vehicle_to_class()).

def CumulVar(self, index):
6496    def CumulVar(self, index):
6497        r"""
6498        Get the cumul, transit and slack variables for the given node (given as
6499        int64_t var index).
6500        """
6501        return _pywrapcp.RoutingDimension_CumulVar(self, index)

Get the cumul, transit and slack variables for the given node (given as int64_t var index).

def TransitVar(self, index):
6503    def TransitVar(self, index):
6504        return _pywrapcp.RoutingDimension_TransitVar(self, index)
def FixedTransitVar(self, index):
6506    def FixedTransitVar(self, index):
6507        return _pywrapcp.RoutingDimension_FixedTransitVar(self, index)
def SlackVar(self, index):
6509    def SlackVar(self, index):
6510        return _pywrapcp.RoutingDimension_SlackVar(self, index)
def SetCumulVarRange(self, index, min, max):
6512    def SetCumulVarRange(self, index, min, max):
6513        r"""
6514        Some functions to allow users to use the interface without knowing about
6515        the underlying CP model.
6516        Restricts the range of the cumul variable associated to index.
6517        """
6518        return _pywrapcp.RoutingDimension_SetCumulVarRange(self, index, min, max)

Some functions to allow users to use the interface without knowing about the underlying CP model. Restricts the range of the cumul variable associated to index.

def GetCumulVarMin(self, index):
6520    def GetCumulVarMin(self, index):
6521        r"""Gets the current minimum of the cumul variable associated to index."""
6522        return _pywrapcp.RoutingDimension_GetCumulVarMin(self, index)

Gets the current minimum of the cumul variable associated to index.

def GetCumulVarMax(self, index):
6524    def GetCumulVarMax(self, index):
6525        r"""Gets the current maximum of the cumul variable associated to index."""
6526        return _pywrapcp.RoutingDimension_GetCumulVarMax(self, index)

Gets the current maximum of the cumul variable associated to index.

def SetSpanUpperBoundForVehicle(self, upper_bound, vehicle):
6528    def SetSpanUpperBoundForVehicle(self, upper_bound, vehicle):
6529        r"""
6530        Sets an upper bound on the dimension span on a given vehicle. This is the
6531        preferred way to limit the "length" of the route of a vehicle according to
6532        a dimension.
6533        """
6534        return _pywrapcp.RoutingDimension_SetSpanUpperBoundForVehicle(self, upper_bound, vehicle)

Sets an upper bound on the dimension span on a given vehicle. This is the preferred way to limit the "length" of the route of a vehicle according to a dimension.

def SetSpanCostCoefficientForVehicle(self, coefficient, vehicle):
6536    def SetSpanCostCoefficientForVehicle(self, coefficient, vehicle):
6537        r"""
6538        Sets a cost proportional to the dimension span on a given vehicle,
6539        or on all vehicles at once. "coefficient" must be nonnegative.
6540        This is handy to model costs proportional to idle time when the dimension
6541        represents time.
6542        The cost for a vehicle is
6543          span_cost = coefficient * (dimension end value - dimension start value).
6544        """
6545        return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForVehicle(self, coefficient, vehicle)

Sets a cost proportional to the dimension span on a given vehicle, or on all vehicles at once. "coefficient" must be nonnegative. This is handy to model costs proportional to idle time when the dimension represents time. The cost for a vehicle is span_cost = coefficient * (dimension end value - dimension start value).

def SetSpanCostCoefficientForAllVehicles(self, coefficient):
6547    def SetSpanCostCoefficientForAllVehicles(self, coefficient):
6548        return _pywrapcp.RoutingDimension_SetSpanCostCoefficientForAllVehicles(self, coefficient)
def SetSlackCostCoefficientForVehicle(self, coefficient, vehicle):
6550    def SetSlackCostCoefficientForVehicle(self, coefficient, vehicle):
6551        r"""
6552        Sets a cost proportional to the dimension total slack on a given vehicle,
6553        or on all vehicles at once. "coefficient" must be nonnegative.
6554        This is handy to model costs only proportional to idle time when the
6555        dimension represents time.
6556        The cost for a vehicle is
6557          slack_cost = coefficient *
6558                (dimension end value - dimension start value - total_transit).
6559        """
6560        return _pywrapcp.RoutingDimension_SetSlackCostCoefficientForVehicle(self, coefficient, vehicle)

Sets a cost proportional to the dimension total slack on a given vehicle, or on all vehicles at once. "coefficient" must be nonnegative. This is handy to model costs only proportional to idle time when the dimension represents time. The cost for a vehicle is slack_cost = coefficient * (dimension end value - dimension start value - total_transit).

def SetSlackCostCoefficientForAllVehicles(self, coefficient):
6562    def SetSlackCostCoefficientForAllVehicles(self, coefficient):
6563        return _pywrapcp.RoutingDimension_SetSlackCostCoefficientForAllVehicles(self, coefficient)
def SetGlobalSpanCostCoefficient(self, coefficient):
6565    def SetGlobalSpanCostCoefficient(self, coefficient):
6566        r"""
6567        Sets a cost proportional to the *global* dimension span, that is the
6568        difference between the largest value of route end cumul variables and
6569        the smallest value of route start cumul variables.
6570        In other words:
6571        global_span_cost =
6572          coefficient * (Max(dimension end value) - Min(dimension start value)).
6573        """
6574        return _pywrapcp.RoutingDimension_SetGlobalSpanCostCoefficient(self, coefficient)

Sets a cost proportional to the global dimension span, that is the difference between the largest value of route end cumul variables and the smallest value of route start cumul variables. In other words: global_span_cost = coefficient * (Max(dimension end value) - Min(dimension start value)).

def SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient):
6576    def SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient):
6577        r"""
6578        Sets a soft upper bound to the cumul variable of a given variable index.
6579        If the value of the cumul variable is greater than the bound, a cost
6580        proportional to the difference between this value and the bound is added
6581        to the cost function of the model:
6582          cumulVar <= upper_bound -> cost = 0
6583           cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound)
6584        This is also handy to model tardiness costs when the dimension represents
6585        time.
6586        """
6587        return _pywrapcp.RoutingDimension_SetCumulVarSoftUpperBound(self, index, upper_bound, coefficient)

Sets a soft upper bound to the cumul variable of a given variable index. If the value of the cumul variable is greater than the bound, a cost proportional to the difference between this value and the bound is added to the cost function of the model: cumulVar <= upper_bound -> cost = 0 cumulVar > upper_bound -> cost = coefficient * (cumulVar - upper_bound) This is also handy to model tardiness costs when the dimension represents time.

def HasCumulVarSoftUpperBound(self, index):
6589    def HasCumulVarSoftUpperBound(self, index):
6590        r"""
6591        Returns true if a soft upper bound has been set for a given variable
6592        index.
6593        """
6594        return _pywrapcp.RoutingDimension_HasCumulVarSoftUpperBound(self, index)

Returns true if a soft upper bound has been set for a given variable index.

def GetCumulVarSoftUpperBound(self, index):
6596    def GetCumulVarSoftUpperBound(self, index):
6597        r"""
6598        Returns the soft upper bound of a cumul variable for a given variable
6599        index. The "hard" upper bound of the variable is returned if no soft upper
6600        bound has been set.
6601        """
6602        return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBound(self, index)

Returns the soft upper bound of a cumul variable for a given variable index. The "hard" upper bound of the variable is returned if no soft upper bound has been set.

def GetCumulVarSoftUpperBoundCoefficient(self, index):
6604    def GetCumulVarSoftUpperBoundCoefficient(self, index):
6605        r"""
6606        Returns the cost coefficient of the soft upper bound of a cumul variable
6607        for a given variable index. If no soft upper bound has been set, 0 is
6608        returned.
6609        """
6610        return _pywrapcp.RoutingDimension_GetCumulVarSoftUpperBoundCoefficient(self, index)

Returns the cost coefficient of the soft upper bound of a cumul variable for a given variable index. If no soft upper bound has been set, 0 is returned.

def SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient):
6612    def SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient):
6613        r"""
6614        Sets a soft lower bound to the cumul variable of a given variable index.
6615        If the value of the cumul variable is less than the bound, a cost
6616        proportional to the difference between this value and the bound is added
6617        to the cost function of the model:
6618          cumulVar > lower_bound -> cost = 0
6619          cumulVar <= lower_bound -> cost = coefficient * (lower_bound -
6620                      cumulVar).
6621        This is also handy to model earliness costs when the dimension represents
6622        time.
6623        """
6624        return _pywrapcp.RoutingDimension_SetCumulVarSoftLowerBound(self, index, lower_bound, coefficient)

Sets a soft lower bound to the cumul variable of a given variable index. If the value of the cumul variable is less than the bound, a cost proportional to the difference between this value and the bound is added to the cost function of the model: cumulVar > lower_bound -> cost = 0 cumulVar <= lower_bound -> cost = coefficient * (lower_bound - cumulVar). This is also handy to model earliness costs when the dimension represents time.

def HasCumulVarSoftLowerBound(self, index):
6626    def HasCumulVarSoftLowerBound(self, index):
6627        r"""
6628        Returns true if a soft lower bound has been set for a given variable
6629        index.
6630        """
6631        return _pywrapcp.RoutingDimension_HasCumulVarSoftLowerBound(self, index)

Returns true if a soft lower bound has been set for a given variable index.

def GetCumulVarSoftLowerBound(self, index):
6633    def GetCumulVarSoftLowerBound(self, index):
6634        r"""
6635        Returns the soft lower bound of a cumul variable for a given variable
6636        index. The "hard" lower bound of the variable is returned if no soft lower
6637        bound has been set.
6638        """
6639        return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBound(self, index)

Returns the soft lower bound of a cumul variable for a given variable index. The "hard" lower bound of the variable is returned if no soft lower bound has been set.

def GetCumulVarSoftLowerBoundCoefficient(self, index):
6641    def GetCumulVarSoftLowerBoundCoefficient(self, index):
6642        r"""
6643        Returns the cost coefficient of the soft lower bound of a cumul variable
6644        for a given variable index. If no soft lower bound has been set, 0 is
6645        returned.
6646        """
6647        return _pywrapcp.RoutingDimension_GetCumulVarSoftLowerBoundCoefficient(self, index)

Returns the cost coefficient of the soft lower bound of a cumul variable for a given variable index. If no soft lower bound has been set, 0 is returned.

def SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits):
6649    def SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits):
6650        r"""
6651        Sets the breaks for a given vehicle. Breaks are represented by
6652        IntervalVars. They may interrupt transits between nodes and increase
6653        the value of corresponding slack variables.
6654        A break may take place before the start of a vehicle, after the end of
6655        a vehicle, or during a travel i -> j.
6656
6657        In that case, the interval [break.Start(), break.End()) must be a subset
6658        of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In
6659        other words, a break may not overlap any node n's visit, given by
6660        [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)).
6661        This formula considers post_travel(_, start) and pre_travel(end, _) to be
6662        0; pre_travel will never be called on any (_, start) and post_travel will
6663        never we called on any (end, _). If pre_travel_evaluator or
6664        post_travel_evaluator is -1, it will be taken as a function that always
6665        returns 0.
6666        Deprecated, sets pre_travel(i, j) = node_visit_transit[i].
6667        """
6668        return _pywrapcp.RoutingDimension_SetBreakIntervalsOfVehicle(self, breaks, vehicle, node_visit_transits)

Sets the breaks for a given vehicle. Breaks are represented by IntervalVars. They may interrupt transits between nodes and increase the value of corresponding slack variables. A break may take place before the start of a vehicle, after the end of a vehicle, or during a travel i -> j.

In that case, the interval [break.Start(), break.End()) must be a subset of [CumulVar(i) + pre_travel(i, j), CumulVar(j) - post_travel(i, j)). In other words, a break may not overlap any node n's visit, given by [CumulVar(n) - post_travel(_, n), CumulVar(n) + pre_travel(n, _)). This formula considers post_travel(_, start) and pre_travel(end, _) to be 0; pre_travel will never be called on any (_, start) and post_travel will never we called on any (end, _). If pre_travel_evaluator or post_travel_evaluator is -1, it will be taken as a function that always returns 0. Deprecated, sets pre_travel(i, j) = node_visit_transit[i].

def SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle):
6670    def SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle):
6671        r"""
6672        With breaks supposed to be consecutive, this forces the distance between
6673        breaks of size at least minimum_break_duration to be at most distance.
6674        This supposes that the time until route start and after route end are
6675        infinite breaks.
6676        """
6677        return _pywrapcp.RoutingDimension_SetBreakDistanceDurationOfVehicle(self, distance, duration, vehicle)

With breaks supposed to be consecutive, this forces the distance between breaks of size at least minimum_break_duration to be at most distance. This supposes that the time until route start and after route end are infinite breaks.

def InitializeBreaks(self):
6679    def InitializeBreaks(self):
6680        r"""
6681        Sets up vehicle_break_intervals_, vehicle_break_distance_duration_,
6682        pre_travel_evaluators and post_travel_evaluators.
6683        """
6684        return _pywrapcp.RoutingDimension_InitializeBreaks(self)

Sets up vehicle_break_intervals_, vehicle_break_distance_duration_, pre_travel_evaluators and post_travel_evaluators.

def HasBreakConstraints(self):
6686    def HasBreakConstraints(self):
6687        r"""Returns true if any break interval or break distance was defined."""
6688        return _pywrapcp.RoutingDimension_HasBreakConstraints(self)

Returns true if any break interval or break distance was defined.

def GetPreTravelEvaluatorOfVehicle(self, vehicle):
6690    def GetPreTravelEvaluatorOfVehicle(self, vehicle):
6691        return _pywrapcp.RoutingDimension_GetPreTravelEvaluatorOfVehicle(self, vehicle)
def GetPostTravelEvaluatorOfVehicle(self, vehicle):
6693    def GetPostTravelEvaluatorOfVehicle(self, vehicle):
6694        return _pywrapcp.RoutingDimension_GetPostTravelEvaluatorOfVehicle(self, vehicle)
def base_dimension(self):
6696    def base_dimension(self):
6697        r"""Returns the parent in the dependency tree if any or nullptr otherwise."""
6698        return _pywrapcp.RoutingDimension_base_dimension(self)

Returns the parent in the dependency tree if any or nullptr otherwise.

def ShortestTransitionSlack(self, node):
6700    def ShortestTransitionSlack(self, node):
6701        r"""
6702        It makes sense to use the function only for self-dependent dimension.
6703        For such dimensions the value of the slack of a node determines the
6704        transition cost of the next transit. Provided that
6705          1. cumul[node] is fixed,
6706          2. next[node] and next[next[node]] (if exists) are fixed,
6707        the value of slack[node] for which cumul[next[node]] + transit[next[node]]
6708        is minimized can be found in O(1) using this function.
6709        """
6710        return _pywrapcp.RoutingDimension_ShortestTransitionSlack(self, node)

It makes sense to use the function only for self-dependent dimension. For such dimensions the value of the slack of a node determines the transition cost of the next transit. Provided that

  1. cumul[node] is fixed,
  2. next[node] and next[next[node]] (if exists) are fixed, the value of slack[node] for which cumul[next[node]] + transit[next[node]] is minimized can be found in O(1) using this function.
def name(self):
6712    def name(self):
6713        r"""Returns the name of the dimension."""
6714        return _pywrapcp.RoutingDimension_name(self)

Returns the name of the dimension.

def SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index):
6716    def SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index):
6717        return _pywrapcp.RoutingDimension_SetPickupToDeliveryLimitFunctionForPair(self, limit_function, pair_index)
def HasPickupToDeliveryLimits(self):
6719    def HasPickupToDeliveryLimits(self):
6720        return _pywrapcp.RoutingDimension_HasPickupToDeliveryLimits(self)
def AddNodePrecedence(self, first_node, second_node, offset):
6722    def AddNodePrecedence(self, first_node, second_node, offset):
6723        return _pywrapcp.RoutingDimension_AddNodePrecedence(self, first_node, second_node, offset)
def GetSpanUpperBoundForVehicle(self, vehicle):
6725    def GetSpanUpperBoundForVehicle(self, vehicle):
6726        return _pywrapcp.RoutingDimension_GetSpanUpperBoundForVehicle(self, vehicle)
def GetSpanCostCoefficientForVehicle(self, vehicle):
6728    def GetSpanCostCoefficientForVehicle(self, vehicle):
6729        return _pywrapcp.RoutingDimension_GetSpanCostCoefficientForVehicle(self, vehicle)
def GetSlackCostCoefficientForVehicle(self, vehicle):
6731    def GetSlackCostCoefficientForVehicle(self, vehicle):
6732        return _pywrapcp.RoutingDimension_GetSlackCostCoefficientForVehicle(self, vehicle)
def global_span_cost_coefficient(self):
6734    def global_span_cost_coefficient(self):
6735        return _pywrapcp.RoutingDimension_global_span_cost_coefficient(self)
def GetGlobalOptimizerOffset(self):
6737    def GetGlobalOptimizerOffset(self):
6738        return _pywrapcp.RoutingDimension_GetGlobalOptimizerOffset(self)
def GetLocalOptimizerOffsetForVehicle(self, vehicle):
6740    def GetLocalOptimizerOffsetForVehicle(self, vehicle):
6741        return _pywrapcp.RoutingDimension_GetLocalOptimizerOffsetForVehicle(self, vehicle)
def SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6743    def SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6744        r"""
6745        If the span of vehicle on this dimension is larger than bound,
6746        the cost will be increased by cost * (span - bound).
6747        """
6748        return _pywrapcp.RoutingDimension_SetSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)

If the span of vehicle on this dimension is larger than bound, the cost will be increased by cost * (span - bound).

def HasSoftSpanUpperBounds(self):
6750    def HasSoftSpanUpperBounds(self):
6751        return _pywrapcp.RoutingDimension_HasSoftSpanUpperBounds(self)
def GetSoftSpanUpperBoundForVehicle(self, vehicle):
6753    def GetSoftSpanUpperBoundForVehicle(self, vehicle):
6754        return _pywrapcp.RoutingDimension_GetSoftSpanUpperBoundForVehicle(self, vehicle)
def SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6756    def SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle):
6757        r"""
6758        If the span of vehicle on this dimension is larger than bound,
6759        the cost will be increased by cost * (span - bound)^2.
6760        """
6761        return _pywrapcp.RoutingDimension_SetQuadraticCostSoftSpanUpperBoundForVehicle(self, bound_cost, vehicle)

If the span of vehicle on this dimension is larger than bound, the cost will be increased by cost * (span - bound)^2.

def HasQuadraticCostSoftSpanUpperBounds(self):
6763    def HasQuadraticCostSoftSpanUpperBounds(self):
6764        return _pywrapcp.RoutingDimension_HasQuadraticCostSoftSpanUpperBounds(self)
def GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle):
6766    def GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle):
6767        return _pywrapcp.RoutingDimension_GetQuadraticCostSoftSpanUpperBoundForVehicle(self, vehicle)
def SolveModelWithSat(model, search_parameters, initial_solution, solution):
6772def SolveModelWithSat(model, search_parameters, initial_solution, solution):
6773    r"""
6774    Attempts to solve the model using the cp-sat solver. As of 5/2019, will
6775    solve the TSP corresponding to the model if it has a single vehicle.
6776    Therefore the resulting solution might not actually be feasible. Will return
6777    false if a solution could not be found.
6778    """
6779    return _pywrapcp.SolveModelWithSat(model, search_parameters, initial_solution, solution)

Attempts to solve the model using the cp-sat solver. As of 5/2019, will solve the TSP corresponding to the model if it has a single vehicle. Therefore the resulting solution might not actually be feasible. Will return false if a solution could not be found.