Class Solver

java.lang.Object
com.google.ortools.constraintsolver.Solver

public class Solver extends Object
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.
  • Field Details

    • swigCMemOwn

      protected transient boolean swigCMemOwn
    • kNumPriorities

      public static final int kNumPriorities
      Number of priorities for demons.
    • INT_VAR_DEFAULT

      public static final int INT_VAR_DEFAULT
      The default behavior is CHOOSE_FIRST_UNBOUND.
    • INT_VAR_SIMPLE

      public static final int INT_VAR_SIMPLE
      The simple selection is CHOOSE_FIRST_UNBOUND.
    • CHOOSE_FIRST_UNBOUND

      public static final int CHOOSE_FIRST_UNBOUND
      Select the first unbound variable.
      Variables are considered in the order of the vector of IntVars used
      to create the selector.
    • CHOOSE_RANDOM

      public static final int CHOOSE_RANDOM
      Randomly select one of the remaining unbound variables.
    • CHOOSE_MIN_SIZE_LOWEST_MIN

      public static final int CHOOSE_MIN_SIZE_LOWEST_MIN
      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

      public static final int CHOOSE_MIN_SIZE_HIGHEST_MIN
      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

      public static final int CHOOSE_MIN_SIZE_LOWEST_MAX
      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

      public static final int CHOOSE_MIN_SIZE_HIGHEST_MAX
      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

      public static final int CHOOSE_LOWEST_MIN
      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

      public static final int CHOOSE_HIGHEST_MAX
      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

      public static final int CHOOSE_MIN_SIZE
      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

      public static final int CHOOSE_MAX_SIZE
      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

      public static final int CHOOSE_MAX_REGRET_ON_MIN
      Among unbound variables, select the variable with the largest
      gap between the first and the second values of the domain.
    • CHOOSE_PATH

      public static final int CHOOSE_PATH
      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

      public static final int INT_VALUE_DEFAULT
      The default behavior is ASSIGN_MIN_VALUE.
    • INT_VALUE_SIMPLE

      public static final int INT_VALUE_SIMPLE
      The simple selection is ASSIGN_MIN_VALUE.
    • ASSIGN_MIN_VALUE

      public static final int ASSIGN_MIN_VALUE
      Selects the min value of the selected variable.
    • ASSIGN_MAX_VALUE

      public static final int ASSIGN_MAX_VALUE
      Selects the max value of the selected variable.
    • ASSIGN_RANDOM_VALUE

      public static final int ASSIGN_RANDOM_VALUE
      Selects randomly one of the possible values of the selected variable.
    • ASSIGN_CENTER_VALUE

      public static final int ASSIGN_CENTER_VALUE
      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

      public static final int SPLIT_LOWER_HALF
      Split the domain in two around the center, and choose the lower
      part first.
    • SPLIT_UPPER_HALF

      public static final int SPLIT_UPPER_HALF
      Split the domain in two around the center, and choose the lower
      part first.
    • CHOOSE_STATIC_GLOBAL_BEST

      public static final int CHOOSE_STATIC_GLOBAL_BEST
      Pairs are compared at the first call of the selector, and results are
      cached. Next calls to the selector use the previous computation, and so
      are not up-to-date, e.g. some <variable, value> pairs may not be
      possible anymore due to propagation since the first to call.
    • CHOOSE_DYNAMIC_GLOBAL_BEST

      public static final int CHOOSE_DYNAMIC_GLOBAL_BEST
      Pairs are compared each time a variable is selected. That way all pairs
      are relevant and evaluation is accurate.
      This strategy runs in O(number-of-pairs) at each variable selection,
      versus O(1) in the static version.
    • SEQUENCE_DEFAULT

      public static final int SEQUENCE_DEFAULT
      Used for scheduling. Not yet implemented.
    • SEQUENCE_SIMPLE

      public static final int SEQUENCE_SIMPLE
    • CHOOSE_MIN_SLACK_RANK_FORWARD

      public static final int CHOOSE_MIN_SLACK_RANK_FORWARD
    • CHOOSE_RANDOM_RANK_FORWARD

      public static final int CHOOSE_RANDOM_RANK_FORWARD
    • INTERVAL_DEFAULT

      public static final int INTERVAL_DEFAULT
      The default is INTERVAL_SET_TIMES_FORWARD.
    • INTERVAL_SIMPLE

      public static final int INTERVAL_SIMPLE
      The simple is INTERVAL_SET_TIMES_FORWARD.
    • INTERVAL_SET_TIMES_FORWARD

      public static final int INTERVAL_SET_TIMES_FORWARD
      Selects the variable with the lowest starting time of all variables,
      and fixes its starting time to this lowest value.
    • INTERVAL_SET_TIMES_BACKWARD

      public static final int INTERVAL_SET_TIMES_BACKWARD
      Selects the variable with the highest ending time of all variables,
      and fixes the ending time to this highest values.
    • TWOOPT

      public static final int TWOOPT
      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

      public static final int OROPT
      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

      public static final int RELOCATE
      Relocate neighborhood with length of 1 (see OROPT comment).
    • EXCHANGE

      public static final int EXCHANGE
      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

      public static final int CROSS
      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

      public static final int MAKEACTIVE
      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

      public static final int MAKEINACTIVE
      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

      public static final int MAKECHAININACTIVE
      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

      public static final int SWAPACTIVE
      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
    • SWAPACTIVECHAIN

      public static final int SWAPACTIVECHAIN
      Operator which replaces a chain of active nodes 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
      1 -> [5] -> 4 with 2 and 3 inactive
    • EXTENDEDSWAPACTIVE

      public static final int EXTENDEDSWAPACTIVE
      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

      public static final int PATHLNS
      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

      public static final int FULLPATHLNS
      Operator which relaxes one entire path and all inactive nodes, thus
      defining num_paths neighbors.
    • UNACTIVELNS

      public static final int UNACTIVELNS
      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

      public static final int INCREMENT
      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

      public static final int DECREMENT
      Operator which defines a neighborhood to decrement values.
      The behavior is the same as INCREMENT, except values are decremented
      instead of incremented.
    • SIMPLELNS

      public static final int SIMPLELNS
      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.
    • LK

      public static final int LK
      Lin-Kernighan local search.
      While the accumulated local gain is positive, perform a 2opt or a 3opt
      move followed by a series of 2opt moves. Return a neighbor for which the
      global gain is positive.
    • TSPOPT

      public static final int TSPOPT
      Sliding TSP operator.
      Uses an exact dynamic programming algorithm to solve the TSP
      corresponding to path sub-chains.
      For a subchain 1 -> 2 -> 3 -> 4 -> 5 -> 6, solves the TSP on
      nodes A, 2, 3, 4, 5, where A is a merger of nodes 1 and 6 such that
      cost(A,i) = cost(1,i) and cost(i,A) = cost(i,6).
    • TSPLNS

      public static final int TSPLNS
      TSP-base LNS.
      Randomly merge consecutive nodes until n "meta"-nodes remain and solve
      the corresponding TSP.
      This is an "unlimited" neighborhood which must be stopped by search
      limits. To force diversification, the operator iteratively forces each
      node to serve as base of a meta-node.
    • GE

      public static final int GE
      Move is accepted when the current objective value >= objective.Min.
    • LE

      public static final int LE
      Move is accepted when the current objective value <= objective.Max.
    • EQ

      public static final int EQ
      Move is accepted when the current objective value is in the interval
      objective.Min .. objective.Max.
    • DELAYED_PRIORITY

      public static final int DELAYED_PRIORITY
      DELAYED_PRIORITY is the lowest priority: Demons will be processed after
      VAR_PRIORITY and NORMAL_PRIORITY demons.
    • VAR_PRIORITY

      public static final int VAR_PRIORITY
      VAR_PRIORITY is between DELAYED_PRIORITY and NORMAL_PRIORITY.
    • NORMAL_PRIORITY

      public static final int NORMAL_PRIORITY
      NORMAL_PRIORITY is the highest priority: Demons will be processed first.
    • ENDS_AFTER_END

      public static final int ENDS_AFTER_END
      t1 ends after t2 end, i.e. End(t1) >= End(t2) + delay.
    • ENDS_AFTER_START

      public static final int ENDS_AFTER_START
      t1 ends after t2 start, i.e. End(t1) >= Start(t2) + delay.
    • ENDS_AT_END

      public static final int ENDS_AT_END
      t1 ends at t2 end, i.e. End(t1) == End(t2) + delay.
    • ENDS_AT_START

      public static final int ENDS_AT_START
      t1 ends at t2 start, i.e. End(t1) == Start(t2) + delay.
    • STARTS_AFTER_END

      public static final int STARTS_AFTER_END
      t1 starts after t2 end, i.e. Start(t1) >= End(t2) + delay.
    • STARTS_AFTER_START

      public static final int STARTS_AFTER_START
      t1 starts after t2 start, i.e. Start(t1) >= Start(t2) + delay.
    • STARTS_AT_END

      public static final int STARTS_AT_END
      t1 starts at t2 end, i.e. Start(t1) == End(t2) + delay.
    • STARTS_AT_START

      public static final int STARTS_AT_START
      t1 starts at t2 start, i.e. Start(t1) == Start(t2) + delay.
    • STAYS_IN_SYNC

      public static final int STAYS_IN_SYNC
      STARTS_AT_START and ENDS_AT_END at the same time.
      t1 starts at t2 start, i.e. Start(t1) == Start(t2) + delay.
      t1 ends at t2 end, i.e. End(t1) == End(t2).
    • ENDS_AFTER

      public static final int ENDS_AFTER
      t ends after d, i.e. End(t) >= d.
    • ENDS_AT

      public static final int ENDS_AT
      t ends at d, i.e. End(t) == d.
    • ENDS_BEFORE

      public static final int ENDS_BEFORE
      t ends before d, i.e. End(t) <= d.
    • STARTS_AFTER

      public static final int STARTS_AFTER
      t starts after d, i.e. Start(t) >= d.
    • STARTS_AT

      public static final int STARTS_AT
      t starts at d, i.e. Start(t) == d.
    • STARTS_BEFORE

      public static final int STARTS_BEFORE
      t starts before d, i.e. Start(t) <= d.
    • CROSS_DATE

      public static final int CROSS_DATE
      STARTS_BEFORE and ENDS_AFTER at the same time, i.e. d is in t.
      t starts before d, i.e. Start(t) <= d.
      t ends after d, i.e. End(t) >= d.
    • AVOID_DATE

      public static final int AVOID_DATE
      STARTS_AFTER or ENDS_BEFORE, i.e. d is not in t.
      t starts after d, i.e. Start(t) >= d.
      t ends before d, i.e. End(t) <= d.
    • NO_CHANGE

      public static final int NO_CHANGE
      Keeps the default behavior, i.e. apply left branch first, and then right
      branch in case of backtracking.
    • KEEP_LEFT

      public static final int KEEP_LEFT
      Right branches are ignored. This is used to make the code faster when
      backtrack makes no sense or is not useful.
      This is faster as there is no need to create one new node per decision.
    • KEEP_RIGHT

      public static final int KEEP_RIGHT
      Left branches are ignored. This is used to make the code faster when
      backtrack makes no sense or is not useful.
      This is faster as there is no need to create one new node per decision.
    • KILL_BOTH

      public static final int KILL_BOTH
      Backtracks to the previous decisions, i.e. left and right branches are
      not applied.
    • SWITCH_BRANCHES

      public static final int SWITCH_BRANCHES
      Applies right branch first. Left branch will be applied in case of
      backtracking.
    • SENTINEL

      public static final int SENTINEL
      This enum is used internally in private methods Solver::PushState and
      Solver::PopState to tag states in the search tree.
    • SIMPLE_MARKER

      public static final int SIMPLE_MARKER
    • CHOICE_POINT

      public static final int CHOICE_POINT
    • REVERSIBLE_ACTION

      public static final int REVERSIBLE_ACTION
    • IN_ROOT_NODE

      public static final int IN_ROOT_NODE
      Executing the root node.
    • AT_SOLUTION

      public static final int AT_SOLUTION
      After successful NextSolution and before EndSearch.
    • NO_MORE_SOLUTIONS

      public static final int NO_MORE_SOLUTIONS
      After failed NextSolution and before EndSearch.
    • PROBLEM_INFEASIBLE

      public static final int PROBLEM_INFEASIBLE
      After search, the model is infeasible.
    • NOT_SET

      public static final int NOT_SET
      Optimization directions.
    • MAXIMIZATION

      public static final int MAXIMIZATION
    • MINIMIZATION

      public static final int MINIMIZATION
  • Constructor Details

  • Method Details

    • getCPtr

      public static long getCPtr(Solver obj)
    • swigRelease

      public static long swigRelease(Solver obj)
    • finalize

      protected void finalize()
      Overrides:
      finalize in class Object
    • delete

      public void delete()
    • makeIntVarArray

      public IntVar[] makeIntVarArray(int count, long min, long max)
    • makeIntVarArray

      public IntVar[] makeIntVarArray(int count, long min, long max, String name)
    • makeBoolVarArray

      public IntVar[] makeBoolVarArray(int count)
    • makeBoolVarArray

      public IntVar[] makeBoolVarArray(int count, String name)
    • makeFixedDurationIntervalVarArray

      public IntervalVar[] makeFixedDurationIntervalVarArray(int count, long start_min, long start_max, long duration, boolean optional)
    • makeFixedDurationIntervalVarArray

      public IntervalVar[] makeFixedDurationIntervalVarArray(int count, long start_min, long start_max, long duration, boolean optional, String name)
    • keepAliveDecisionBuilder

      public void keepAliveDecisionBuilder(DecisionBuilder db)
    • keepAliveDecisionBuilder

      public void keepAliveDecisionBuilder(DecisionBuilder[] dbs)
    • parameters

      public ConstraintSolverParameters parameters()
      Stored Parameters.
    • const_parameters

    • defaultSolverParameters

      public static ConstraintSolverParameters defaultSolverParameters()
      Create a ConstraintSolverParameters proto with all the default values.
    • addConstraint

      public void addConstraint(Constraint 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(...));
    • addCastConstraint

      public void addCastConstraint(CastConstraint constraint, IntVar target_var, IntExpr expr)
      Adds 'constraint' to the solver and marks it as a cast constraint, that
      is, a constraint created calling Var() on an expression. This is used
      internally.
    • solve

      public boolean solve(DecisionBuilder db, SearchMonitor[] monitors)

      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().

      Parameters:
      db - The decision builder that will generate the search tree.
      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.
    • solve

      public boolean solve(DecisionBuilder db)
    • solve

      public boolean solve(DecisionBuilder db, SearchMonitor m1)
    • solve

      public boolean solve(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2)
    • solve

      public boolean solve(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3)
    • solve

      public boolean solve(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3, SearchMonitor m4)
    • newSearch

      public void newSearch(DecisionBuilder db, SearchMonitor[] monitors)


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

      public void newSearch(DecisionBuilder db)
    • newSearch

      public void newSearch(DecisionBuilder db, SearchMonitor m1)
    • newSearch

      public void newSearch(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2)
    • newSearch

      public void newSearch(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3)
    • newSearch

      public void newSearch(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3, SearchMonitor m4)
    • nextSolution

      public boolean nextSolution()
    • restartSearch

      public void restartSearch()
    • endSearch

      public void endSearch()
    • solveAndCommit

      public boolean solveAndCommit(DecisionBuilder db, SearchMonitor[] monitors)

      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.
    • solveAndCommit

      public boolean solveAndCommit(DecisionBuilder db)
    • solveAndCommit

      public boolean solveAndCommit(DecisionBuilder db, SearchMonitor m1)
    • solveAndCommit

      public boolean solveAndCommit(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2)
    • solveAndCommit

      public boolean solveAndCommit(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3)
    • checkAssignment

      public boolean checkAssignment(Assignment solution)
      Checks whether the given assignment satisfies all relevant constraints.
    • checkConstraint

      public boolean checkConstraint(Constraint 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.
    • state

      public int state()
      State of the solver.
    • fail

      public void fail()
      Abandon the current branch in the search tree. A backtrack will follow.
    • toString

      public String toString()
      misc debug string.
      Overrides:
      toString in class Object
    • memoryUsage

      public static long memoryUsage()
      Current memory usage in bytes
    • wallTime

      public long wallTime()
      DEPRECATED: Use Now() instead.
      Time elapsed, in ms since the creation of the solver.
    • branches

      public long branches()
      The number of branches explored since the creation of the solver.
    • solutions

      public long solutions()
      The number of solutions found since the start of the search.
    • unchecked_solutions

      public long unchecked_solutions()
      The number of unchecked solutions found by local search.
    • demon_runs

      public long demon_runs(int p)
      The number of demons executed during search for a given priority.
    • failures

      public long failures()
      The number of failures encountered since the creation of the solver.
    • neighbors

      public long neighbors()
      The number of neighbors created.
    • ClearNeighbors

      public void ClearNeighbors()
      Manipulate neighbors count; to be used for testing purposes only.
      TODO(user): Find a workaround to avoid exposing this.
    • IncrementNeighbors

      public void IncrementNeighbors()
    • filteredNeighbors

      public long filteredNeighbors()
      The number of filtered neighbors (neighbors accepted by filters).
    • acceptedNeighbors

      public long acceptedNeighbors()
      The number of accepted neighbors.
    • stamp

      public long stamp()
      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.
    • fail_stamp

      public long fail_stamp()
      The fail_stamp() is incremented after each backtrack.
    • set_context

      public void set_context(String context)
      Sets the current context of the search.
    • context

      public String context()
      Gets the current context of the search.
    • optimization_direction

      public int optimization_direction()
      The direction of optimization, getter and setter.
    • set_optimization_direction

      public void set_optimization_direction(int direction)
    • SetGuidedLocalSearchPenaltyCallback

      public void SetGuidedLocalSearchPenaltyCallback(LongTernaryOperator penalty_callback)
    • GetGuidedLocalSearchPenalty

      public long GetGuidedLocalSearchPenalty(long i, long j, long k)
    • makeIntVar

      public IntVar makeIntVar(long min, long max, String name)
      MakeIntVar will create the best range based int var for the bounds given.
    • makeIntVar

      public IntVar makeIntVar(long[] values, String name)
      MakeIntVar will create a variable with the given sparse domain.
    • makeIntVar

      public IntVar makeIntVar(int[] values, String name)
      MakeIntVar will create a variable with the given sparse domain.
    • makeIntVar

      public IntVar makeIntVar(long min, long max)
      MakeIntVar will create the best range based int var for the bounds given.
    • makeIntVar

      public IntVar makeIntVar(long[] values)
      MakeIntVar will create a variable with the given sparse domain.
    • makeIntVar

      public IntVar makeIntVar(int[] values)
      MakeIntVar will create a variable with the given sparse domain.
    • makeBoolVar

      public IntVar makeBoolVar(String name)
      MakeBoolVar will create a variable with a {0, 1} domain.
    • makeBoolVar

      public IntVar makeBoolVar()
      MakeBoolVar will create a variable with a {0, 1} domain.
    • makeIntConst

      public IntVar makeIntConst(long val, String name)
      IntConst will create a constant expression.
    • makeIntConst

      public IntVar makeIntConst(long val)
      IntConst will create a constant expression.
    • makeSum

      public IntExpr makeSum(IntExpr left, IntExpr right)
      left + right.
    • makeSum

      public IntExpr makeSum(IntExpr expr, long value)
      expr + value.
    • makeSum

      public IntExpr makeSum(IntVar[] vars)
      sum of all vars.
    • makeScalProd

      public IntExpr makeScalProd(IntVar[] vars, long[] coefs)
      scalar product
    • makeScalProd

      public IntExpr makeScalProd(IntVar[] vars, int[] coefs)
      scalar product
    • makeDifference

      public IntExpr makeDifference(IntExpr left, IntExpr right)
      left - right
    • makeDifference

      public IntExpr makeDifference(long value, IntExpr expr)
      value - expr
    • makeOpposite

      public IntExpr makeOpposite(IntExpr expr)
      -expr
    • makeProd

      public IntExpr makeProd(IntExpr left, IntExpr right)
      left * right
    • makeProd

      public IntExpr makeProd(IntExpr expr, long value)
      expr * value
    • makeDiv

      public IntExpr makeDiv(IntExpr expr, long value)
      expr / value (integer division)
    • makeDiv

      public IntExpr makeDiv(IntExpr numerator, IntExpr denominator)
      numerator / denominator (integer division). Terms need to be positive.
    • makeAbs

      public IntExpr makeAbs(IntExpr expr)
      |expr|
    • makeSquare

      public IntExpr makeSquare(IntExpr expr)
      expr * expr
    • makePower

      public IntExpr makePower(IntExpr expr, long n)
      expr ^ n (n > 0)
    • makeElement

      public IntExpr makeElement(long[] values, IntVar index)
      values[index]
    • makeElement

      public IntExpr makeElement(int[] values, IntVar index)
      values[index]
    • makeElement

      public IntExpr makeElement(LongUnaryOperator values, IntVar index)
      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).
    • makeMonotonicElement

      public IntExpr makeMonotonicElement(LongUnaryOperator values, boolean increasing, IntVar 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.
    • makeElement

      public IntExpr makeElement(LongBinaryOperator values, IntVar index1, IntVar index2)
      2D version of function-based element expression, values(expr1, expr2).
    • makeElement

      public IntExpr makeElement(IntVar[] vars, IntVar index)
      vars[expr]
    • makeIndexExpression

      public IntExpr makeIndexExpression(IntVar[] vars, long value)
      Returns the expression expr such that vars[expr] == value.
      It assumes that vars are all different.
    • makeIfThenElseCt

      public Constraint makeIfThenElseCt(IntVar condition, IntExpr then_expr, IntExpr else_expr, IntVar target_var)
      Special cases with arrays of size two.
    • makeMin

      public IntExpr makeMin(IntVar[] vars)
      std::min(vars)
    • makeMin

      public IntExpr makeMin(IntExpr left, IntExpr right)
      std::min (left, right)
    • makeMin

      public IntExpr makeMin(IntExpr expr, long value)
      std::min(expr, value)
    • makeMin

      public IntExpr makeMin(IntExpr expr, int value)
      std::min(expr, value)
    • makeMax

      public IntExpr makeMax(IntVar[] vars)
      std::max(vars)
    • makeMax

      public IntExpr makeMax(IntExpr left, IntExpr right)
      std::max(left, right)
    • makeMax

      public IntExpr makeMax(IntExpr expr, long value)
      std::max(expr, value)
    • makeMax

      public IntExpr makeMax(IntExpr expr, int value)
      std::max(expr, value)
    • makeConvexPiecewiseExpr

      public IntExpr makeConvexPiecewiseExpr(IntExpr expr, long early_cost, long early_date, long late_date, long late_cost)
      Convex piecewise function.
    • makeSemiContinuousExpr

      public IntExpr makeSemiContinuousExpr(IntExpr expr, long fixed_charge, long step)
      Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b)
      a >= 0 and b >= 0
    • makeModulo

      public IntExpr makeModulo(IntExpr x, long mod)
      General piecewise-linear function expression, built from f(x) where f is
      piecewise-linear. The resulting expression is f(expr).
      expressions.
      Modulo expression x % mod (with the python convention for modulo).
    • makeModulo

      public IntExpr makeModulo(IntExpr x, IntExpr mod)
      Modulo expression x % mod (with the python convention for modulo).
    • makeConditionalExpression

      public IntExpr makeConditionalExpression(IntVar condition, IntExpr expr, long unperformed_value)
      Conditional Expr condition ? expr : unperformed_value
    • makeTrueConstraint

      public Constraint makeTrueConstraint()
      This constraint always succeeds.
    • makeFalseConstraint

      public Constraint makeFalseConstraint()
      This constraint always fails.
    • makeFalseConstraint

      public Constraint makeFalseConstraint(String explanation)
    • makeIsEqualCstCt

      public Constraint makeIsEqualCstCt(IntExpr var, long value, IntVar boolvar)
      boolvar == (var == value)
    • makeIsEqualCstVar

      public IntVar makeIsEqualCstVar(IntExpr var, long value)
      status var of (var == value)
    • makeIsEqualVar

      public Constraint makeIsEqualVar(IntExpr v1, IntExpr v2, IntVar b)
      b == (v1 == v2)
    • makeIsEqualVar

      public IntVar makeIsEqualVar(IntExpr v1, IntExpr v2)
      status var of (v1 == v2)
    • makeEquality

      public Constraint makeEquality(IntExpr left, IntExpr right)
      left == right
    • makeEquality

      public Constraint makeEquality(IntExpr expr, long value)
      expr == value
    • makeEquality

      public Constraint makeEquality(IntExpr expr, int value)
      expr == value
    • makeIsDifferentCstCt

      public Constraint makeIsDifferentCstCt(IntExpr var, long value, IntVar boolvar)
      boolvar == (var != value)
    • makeIsDifferentCstVar

      public IntVar makeIsDifferentCstVar(IntExpr var, long value)
      status var of (var != value)
    • makeIsDifferentCstVar

      public IntVar makeIsDifferentCstVar(IntExpr v1, IntExpr v2)
      status var of (v1 != v2)
    • makeIsDifferentCstCt

      public Constraint makeIsDifferentCstCt(IntExpr v1, IntExpr v2, IntVar b)
      b == (v1 != v2)
    • makeNonEquality

      public Constraint makeNonEquality(IntExpr left, IntExpr right)
      left != right
    • makeNonEquality

      public Constraint makeNonEquality(IntExpr expr, long value)
      expr != value
    • makeNonEquality

      public Constraint makeNonEquality(IntExpr expr, int value)
      expr != value
    • makeIsLessOrEqualCstCt

      public Constraint makeIsLessOrEqualCstCt(IntExpr var, long value, IntVar boolvar)
      boolvar == (var <= value)
    • makeIsLessOrEqualCstVar

      public IntVar makeIsLessOrEqualCstVar(IntExpr var, long value)
      status var of (var <= value)
    • makeIsLessOrEqualVar

      public IntVar makeIsLessOrEqualVar(IntExpr left, IntExpr right)
      status var of (left <= right)
    • makeIsLessOrEqualCt

      public Constraint makeIsLessOrEqualCt(IntExpr left, IntExpr right, IntVar b)
      b == (left <= right)
    • makeLessOrEqual

      public Constraint makeLessOrEqual(IntExpr left, IntExpr right)
      left <= right
    • makeLessOrEqual

      public Constraint makeLessOrEqual(IntExpr expr, long value)
      expr <= value
    • makeLessOrEqual

      public Constraint makeLessOrEqual(IntExpr expr, int value)
      expr <= value
    • makeIsGreaterOrEqualCstCt

      public Constraint makeIsGreaterOrEqualCstCt(IntExpr var, long value, IntVar boolvar)
      boolvar == (var >= value)
    • makeIsGreaterOrEqualCstVar

      public IntVar makeIsGreaterOrEqualCstVar(IntExpr var, long value)
      status var of (var >= value)
    • makeIsGreaterOrEqualVar

      public IntVar makeIsGreaterOrEqualVar(IntExpr left, IntExpr right)
      status var of (left >= right)
    • makeIsGreaterOrEqualCt

      public Constraint makeIsGreaterOrEqualCt(IntExpr left, IntExpr right, IntVar b)
      b == (left >= right)
    • makeGreaterOrEqual

      public Constraint makeGreaterOrEqual(IntExpr left, IntExpr right)
      left >= right
    • makeGreaterOrEqual

      public Constraint makeGreaterOrEqual(IntExpr expr, long value)
      expr >= value
    • makeGreaterOrEqual

      public Constraint makeGreaterOrEqual(IntExpr expr, int value)
      expr >= value
    • makeIsGreaterCstCt

      public Constraint makeIsGreaterCstCt(IntExpr v, long c, IntVar b)
      b == (v > c)
    • makeIsGreaterCstVar

      public IntVar makeIsGreaterCstVar(IntExpr var, long value)
      status var of (var > value)
    • makeIsGreaterVar

      public IntVar makeIsGreaterVar(IntExpr left, IntExpr right)
      status var of (left > right)
    • makeIsGreaterCt

      public Constraint makeIsGreaterCt(IntExpr left, IntExpr right, IntVar b)
      b == (left > right)
    • makeGreater

      public Constraint makeGreater(IntExpr left, IntExpr right)
      left > right
    • makeGreater

      public Constraint makeGreater(IntExpr expr, long value)
      expr > value
    • makeGreater

      public Constraint makeGreater(IntExpr expr, int value)
      expr > value
    • makeIsLessCstCt

      public Constraint makeIsLessCstCt(IntExpr v, long c, IntVar b)
      b == (v < c)
    • makeIsLessCstVar

      public IntVar makeIsLessCstVar(IntExpr var, long value)
      status var of (var < value)
    • makeIsLessVar

      public IntVar makeIsLessVar(IntExpr left, IntExpr right)
      status var of (left < right)
    • makeIsLessCt

      public Constraint makeIsLessCt(IntExpr left, IntExpr right, IntVar b)
      b == (left < right)
    • makeLess

      public Constraint makeLess(IntExpr left, IntExpr right)
      left < right
    • makeLess

      public Constraint makeLess(IntExpr expr, long value)
      expr < value
    • makeLess

      public Constraint makeLess(IntExpr expr, int value)
      expr < value
    • makeSumLessOrEqual

      public Constraint makeSumLessOrEqual(IntVar[] vars, long cst)
      Variation on arrays.
    • makeSumGreaterOrEqual

      public Constraint makeSumGreaterOrEqual(IntVar[] vars, long cst)
    • makeSumEquality

      public Constraint makeSumEquality(IntVar[] vars, long cst)
    • makeSumEquality

      public Constraint makeSumEquality(IntVar[] vars, IntVar var)
    • makeScalProdEquality

      public Constraint makeScalProdEquality(IntVar[] vars, long[] coefficients, long cst)
    • makeScalProdEquality

      public Constraint makeScalProdEquality(IntVar[] vars, int[] coefficients, long cst)
    • makeScalProdEquality

      public Constraint makeScalProdEquality(IntVar[] vars, long[] coefficients, IntVar target)
    • makeScalProdEquality

      public Constraint makeScalProdEquality(IntVar[] vars, int[] coefficients, IntVar target)
    • makeScalProdGreaterOrEqual

      public Constraint makeScalProdGreaterOrEqual(IntVar[] vars, long[] coeffs, long cst)
    • makeScalProdGreaterOrEqual

      public Constraint makeScalProdGreaterOrEqual(IntVar[] vars, int[] coeffs, long cst)
    • makeScalProdLessOrEqual

      public Constraint makeScalProdLessOrEqual(IntVar[] vars, long[] coefficients, long cst)
    • makeScalProdLessOrEqual

      public Constraint makeScalProdLessOrEqual(IntVar[] vars, int[] coefficients, long cst)
    • makeMinEquality

      public Constraint makeMinEquality(IntVar[] vars, IntVar min_var)
    • makeMaxEquality

      public Constraint makeMaxEquality(IntVar[] vars, IntVar max_var)
    • makeElementEquality

      public Constraint makeElementEquality(long[] vals, IntVar index, IntVar target)
    • makeElementEquality

      public Constraint makeElementEquality(int[] vals, IntVar index, IntVar target)
    • makeElementEquality

      public Constraint makeElementEquality(IntVar[] vars, IntVar index, IntVar target)
    • makeElementEquality

      public Constraint makeElementEquality(IntVar[] vars, IntVar index, long target)
    • makeAbsEquality

      public Constraint makeAbsEquality(IntVar var, IntVar abs_var)
      Creates the constraint abs(var) == abs_var.
    • makeIndexOfConstraint

      public Constraint makeIndexOfConstraint(IntVar[] vars, IntVar index, long 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.
    • makeConstraintInitialPropagateCallback

      public Demon makeConstraintInitialPropagateCallback(Constraint ct)
      This method is a specialized case of the MakeConstraintDemon
      method to call the InitiatePropagate of the constraint 'ct'.
    • makeDelayedConstraintInitialPropagateCallback

      public Demon makeDelayedConstraintInitialPropagateCallback(Constraint ct)
      This method is a specialized case of the MakeConstraintDemon
      method to call the InitiatePropagate of the constraint 'ct' with
      low priority.
    • makeClosureDemon

      public Demon makeClosureDemon(Runnable closure)
      Creates a demon from a closure.
    • makeBetweenCt

      public Constraint makeBetweenCt(IntExpr expr, long l, long u)
      (l <= expr <= u)
    • makeNotBetweenCt

      public Constraint makeNotBetweenCt(IntExpr expr, long l, long u)
      (expr < l || expr > u)
      This constraint is lazy as it will not make holes in the domain of
      variables. It will propagate only when expr->Min() >= l
      or expr->Max() <= u.
    • makeIsBetweenCt

      public Constraint makeIsBetweenCt(IntExpr expr, long l, long u, IntVar b)
      b == (l <= expr <= u)
    • makeIsBetweenVar

      public IntVar makeIsBetweenVar(IntExpr v, long l, long u)
    • makeMemberCt

      public Constraint makeMemberCt(IntExpr expr, long[] values)
      expr in set. Propagation is lazy, i.e. this constraint does not
      creates holes in the domain of the variable.
    • makeMemberCt

      public Constraint makeMemberCt(IntExpr expr, int[] values)
    • makeNotMemberCt

      public Constraint makeNotMemberCt(IntExpr expr, long[] values)
      expr not in set.
    • makeNotMemberCt

      public Constraint makeNotMemberCt(IntExpr expr, int[] values)
    • makeNotMemberCt

      public Constraint makeNotMemberCt(IntExpr expr, long[] starts, long[] ends)
      expr should not be in the list of forbidden intervals [start[i]..end[i]].
    • makeNotMemberCt

      public Constraint makeNotMemberCt(IntExpr expr, int[] starts, int[] ends)
      expr should not be in the list of forbidden intervals [start[i]..end[i]].
    • makeIsMemberCt

      public Constraint makeIsMemberCt(IntExpr expr, long[] values, IntVar boolvar)
      boolvar == (expr in set)
    • makeIsMemberCt

      public Constraint makeIsMemberCt(IntExpr expr, int[] values, IntVar boolvar)
    • makeIsMemberVar

      public IntVar makeIsMemberVar(IntExpr expr, long[] values)
    • makeIsMemberVar

      public IntVar makeIsMemberVar(IntExpr expr, int[] values)
    • makeCount

      public Constraint makeCount(IntVar[] vars, long value, long max_count)
      |{i | vars[i] == value}| == max_count
    • makeCount

      public Constraint makeCount(IntVar[] vars, long value, IntVar max_count)
      |{i | vars[i] == value}| == max_count
    • makeDistribute

      public Constraint makeDistribute(IntVar[] vars, long[] values, IntVar[] cards)
      Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]
    • makeDistribute

      public Constraint makeDistribute(IntVar[] vars, int[] values, IntVar[] cards)
      Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]
    • makeDistribute

      public Constraint makeDistribute(IntVar[] vars, IntVar[] cards)
      Aggregated version of count: |{i | v[i] == j}| == cards[j]
    • makeDistribute

      public Constraint makeDistribute(IntVar[] vars, long card_min, long card_max, long card_size)
      Aggregated version of count with bounded cardinalities:
      forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max
    • makeDistribute

      public Constraint makeDistribute(IntVar[] vars, long[] card_min, long[] card_max)
      Aggregated version of count with bounded cardinalities:
      forall j in 0 .. card_size - 1:
      card_min[j] <= |{i | v[i] == j}| <= card_max[j]
    • makeDistribute

      public Constraint makeDistribute(IntVar[] vars, int[] card_min, int[] card_max)
      Aggregated version of count with bounded cardinalities:
      forall j in 0 .. card_size - 1:
      card_min[j] <= |{i | v[i] == j}| <= card_max[j]
    • makeDistribute

      public Constraint makeDistribute(IntVar[] vars, long[] values, long[] card_min, long[] card_max)
      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]
    • makeDistribute

      public Constraint makeDistribute(IntVar[] vars, int[] values, int[] card_min, int[] card_max)
      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]
    • makeDeviation

      public Constraint makeDeviation(IntVar[] vars, IntVar deviation_var, long total_sum)
      Deviation constraint:
      sum_i |n * vars[i] - total_sum| <= deviation_var and
      sum_i vars[i] == total_sum
      n = #vars
    • makeAllDifferent

      public Constraint makeAllDifferent(IntVar[] vars)
      All variables are pairwise different. This corresponds to the
      stronger version of the propagation algorithm.
    • makeAllDifferent

      public Constraint makeAllDifferent(IntVar[] vars, boolean stronger_propagation)
      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.
    • makeAllDifferentExcept

      public Constraint makeAllDifferentExcept(IntVar[] vars, long escape_value)
      All variables are pairwise different, unless they are assigned to
      the escape value.
    • makeSortingConstraint

      public Constraint makeSortingConstraint(IntVar[] vars, IntVar[] 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
    • makeLexicalLess

      public Constraint makeLexicalLess(IntVar[] left, IntVar[] right)
      Creates a constraint that enforces that left is lexicographically less
      than right.
    • makeLexicalLessOrEqual

      public Constraint makeLexicalLessOrEqual(IntVar[] left, IntVar[] right)
      Creates a constraint that enforces that left is lexicographically less
      than or equal to right.
    • MakeLexicalLessOrEqualWithOffsets

      public Constraint MakeLexicalLessOrEqualWithOffsets(IntVar[] left, IntVar[] right, long[] offsets)
      Creates a constraint that enforces that left is lexicographically less
      than or equal to right with an offset. This means that for the first index
      i such that left[i] is not in [right[i] - (offset[i] - 1), right[i]],
      left[i] + offset[i] <= right[i]. Offset values must be > 0.
    • MakeIsLexicalLessOrEqualWithOffsetsCt

      public Constraint MakeIsLexicalLessOrEqualWithOffsetsCt(IntVar[] left, IntVar[] right, long[] offsets, IntVar boolvar)
    • makeInversePermutationConstraint

      public Constraint makeInversePermutationConstraint(IntVar[] left, IntVar[] 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.
    • makeIndexOfFirstMaxValueConstraint

      public Constraint makeIndexOfFirstMaxValueConstraint(IntVar index, IntVar[] vars)
      Creates a constraint that binds the index variable to the index of the
      first variable with the maximum value.
    • makeIndexOfFirstMinValueConstraint

      public Constraint makeIndexOfFirstMinValueConstraint(IntVar index, IntVar[] vars)
      Creates a constraint that binds the index variable to the index of the
      first variable with the minimum value.
    • makeNullIntersect

      public Constraint makeNullIntersect(IntVar[] first_vars, IntVar[] 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.
    • makeNullIntersectExcept

      public Constraint makeNullIntersectExcept(IntVar[] first_vars, IntVar[] second_vars, long 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.
    • makeNoCycle

      public Constraint makeNoCycle(IntVar[] nexts, IntVar[] active, LongPredicate sink_handler)
      Prevent cycles. The "nexts" variables represent the next in the chain.
      "active" variables indicate if the corresponding next variable is active;
      this could be useful to model unperformed nodes in a routing problem.
      A callback can be added to specify sink values (by default sink values
      are values >= vars.size()). Ownership of the callback is passed to the
      constraint.
      If assume_paths is either not specified or true, the constraint assumes
      the "nexts" variables represent paths (and performs a faster propagation);
      otherwise the constraint assumes they represent a forest.
    • makeNoCycle

      public Constraint makeNoCycle(IntVar[] nexts, IntVar[] active)
      Prevent cycles. The "nexts" variables represent the next in the chain.
      "active" variables indicate if the corresponding next variable is active;
      this could be useful to model unperformed nodes in a routing problem.
      A callback can be added to specify sink values (by default sink values
      are values >= vars.size()). Ownership of the callback is passed to the
      constraint.
      If assume_paths is either not specified or true, the constraint assumes
      the "nexts" variables represent paths (and performs a faster propagation);
      otherwise the constraint assumes they represent a forest.
    • makeNoCycle

      public Constraint makeNoCycle(IntVar[] nexts, IntVar[] active, LongPredicate sink_handler, boolean assume_paths)
    • makeCircuit

      public Constraint makeCircuit(IntVar[] nexts)
      Force the "nexts" variable to create a complete Hamiltonian path.
    • makeSubCircuit

      public Constraint makeSubCircuit(IntVar[] nexts)
      Force the "nexts" variable to create a complete Hamiltonian path
      for those that do not loop upon themselves.
    • makePathCumul

      public Constraint makePathCumul(IntVar[] nexts, IntVar[] active, IntVar[] cumuls, IntVar[] transits)
      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.
    • makeDelayedPathCumul

      public Constraint makeDelayedPathCumul(IntVar[] nexts, IntVar[] active, IntVar[] cumuls, IntVar[] transits)
      Delayed version of the same constraint: propagation on the nexts variables
      is delayed until all constraints have propagated.
    • makePathCumul

      public Constraint makePathCumul(IntVar[] nexts, IntVar[] active, IntVar[] cumuls, LongBinaryOperator transit_evaluator)
      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.
    • makePathCumul

      public Constraint makePathCumul(IntVar[] nexts, IntVar[] active, IntVar[] cumuls, IntVar[] slacks, LongBinaryOperator transit_evaluator)
      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.
    • makePathConnected

      public Constraint makePathConnected(IntVar[] nexts, long[] sources, long[] sinks, IntVar[] status)
      Constraint enforcing that status[i] is true iff there's a path defined on
      next variables from sources[i] to sinks[i].
      Check whether more propagation is needed.
    • makeMapDomain

      public Constraint makeMapDomain(IntVar var, IntVar[] actives)
      This constraint maps the domain of 'var' onto the array of
      variables 'actives'. That is
      for all i in [0 .. size - 1]: actives[i] == 1 <=> var->Contains(i);
    • makeAllowedAssignment

      public Constraint makeAllowedAssignment(IntVar[] vars, IntTupleSet tuples)
      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.
    • makeTransitionConstraint

      public Constraint makeTransitionConstraint(IntVar[] vars, IntTupleSet transition_table, long initial_state, long[] final_states)
      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.
    • makeTransitionConstraint

      public Constraint makeTransitionConstraint(IntVar[] vars, IntTupleSet transition_table, long initial_state, int[] final_states)
      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.
    • makeNonOverlappingBoxesConstraint

      public Constraint makeNonOverlappingBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, IntVar[] x_size, IntVar[] y_size)
      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.
    • makeNonOverlappingBoxesConstraint

      public Constraint makeNonOverlappingBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, SWIGTYPE_p_absl__SpanT_long_const_t x_size, SWIGTYPE_p_absl__SpanT_long_const_t y_size)
    • makeNonOverlappingBoxesConstraint

      public Constraint makeNonOverlappingBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, SWIGTYPE_p_absl__SpanT_int_const_t x_size, SWIGTYPE_p_absl__SpanT_int_const_t y_size)
    • makeNonOverlappingNonStrictBoxesConstraint

      public Constraint makeNonOverlappingNonStrictBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, IntVar[] x_size, IntVar[] y_size)
      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 positive.
      Boxes with a zero dimension can be placed anywhere.
    • makeNonOverlappingNonStrictBoxesConstraint

      public Constraint makeNonOverlappingNonStrictBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, SWIGTYPE_p_absl__SpanT_long_const_t x_size, SWIGTYPE_p_absl__SpanT_long_const_t y_size)
    • makeNonOverlappingNonStrictBoxesConstraint

      public Constraint makeNonOverlappingNonStrictBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, SWIGTYPE_p_absl__SpanT_int_const_t x_size, SWIGTYPE_p_absl__SpanT_int_const_t y_size)
    • makePack

      public Pack makePack(IntVar[] vars, int 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.
    • makeFixedDurationIntervalVar

      public IntervalVar makeFixedDurationIntervalVar(long start_min, long start_max, long duration, boolean optional, String name)
      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.
    • makeFixedDurationIntervalVar

      public IntervalVar makeFixedDurationIntervalVar(IntVar start_variable, long duration, String name)
      Creates a performed interval var with a fixed duration. The duration must
      be greater than 0.
    • makeFixedDurationIntervalVar

      public IntervalVar makeFixedDurationIntervalVar(IntVar start_variable, long duration, IntVar performed_variable, String name)
      Creates an interval var with a fixed duration, and performed_variable.
      The duration must be greater than 0.
    • makeFixedInterval

      public IntervalVar makeFixedInterval(long start, long duration, String name)
      Creates a fixed and performed interval.
    • makeIntervalVar

      public IntervalVar makeIntervalVar(long start_min, long start_max, long duration_min, long duration_max, long end_min, long end_max, boolean optional, String name)
      Creates an interval var by specifying the bounds on start,
      duration, and end.
    • makeMirrorInterval

      public IntervalVar makeMirrorInterval(IntervalVar 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.
    • makeFixedDurationStartSyncedOnStartIntervalVar

      public IntervalVar makeFixedDurationStartSyncedOnStartIntervalVar(IntervalVar interval_var, long duration, long 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.
    • makeFixedDurationStartSyncedOnEndIntervalVar

      public IntervalVar makeFixedDurationStartSyncedOnEndIntervalVar(IntervalVar interval_var, long duration, long 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.
    • makeFixedDurationEndSyncedOnStartIntervalVar

      public IntervalVar makeFixedDurationEndSyncedOnStartIntervalVar(IntervalVar interval_var, long duration, long 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.
    • makeFixedDurationEndSyncedOnEndIntervalVar

      public IntervalVar makeFixedDurationEndSyncedOnEndIntervalVar(IntervalVar interval_var, long duration, long 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.
    • makeIntervalRelaxedMin

      public IntervalVar makeIntervalRelaxedMin(IntervalVar 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.
    • makeIntervalRelaxedMax

      public IntervalVar makeIntervalRelaxedMax(IntervalVar 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.
    • makeIntervalVarRelation

      public Constraint makeIntervalVarRelation(IntervalVar t, int r, long d)
      This method creates a relation between an interval var and a
      date.
    • makeIntervalVarRelation

      public Constraint makeIntervalVarRelation(IntervalVar t1, int r, IntervalVar t2)
      This method creates a relation between two interval vars.
    • makeIntervalVarRelationWithDelay

      public Constraint makeIntervalVarRelationWithDelay(IntervalVar t1, int r, IntervalVar t2, long delay)
      This method creates a relation between two interval vars.
      The given delay is added to the second interval.
      i.e.: t1 STARTS_AFTER_END of t2 with a delay of 2
      means t1 will start at least two units of time after the end of t2.
    • makeTemporalDisjunction

      public Constraint makeTemporalDisjunction(IntervalVar t1, IntervalVar t2, IntVar alt)
      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).
    • makeTemporalDisjunction

      public Constraint makeTemporalDisjunction(IntervalVar t1, IntervalVar t2)
      This constraint implements a temporal disjunction between two
      interval vars.
    • makeDisjunctiveConstraint

      public DisjunctiveConstraint makeDisjunctiveConstraint(IntervalVar[] intervals, String name)
      This constraint forces all interval vars into an non-overlapping
      sequence. Intervals with zero duration can be scheduled anywhere.
    • makeStrictDisjunctiveConstraint

      public DisjunctiveConstraint makeStrictDisjunctiveConstraint(IntervalVar[] intervals, String name)
      This constraint forces all interval vars into an non-overlapping
      sequence. Intervals with zero durations cannot overlap with over
      intervals.
    • makeCumulative

      public Constraint makeCumulative(IntervalVar[] intervals, long[] demands, long capacity, String name)
      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.
    • makeCumulative

      public Constraint makeCumulative(IntervalVar[] intervals, int[] demands, long capacity, String name)
      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.
    • makeCumulative

      public Constraint makeCumulative(IntervalVar[] intervals, long[] demands, IntVar capacity, String name)
      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.
    • makeCumulative

      public Constraint makeCumulative(IntervalVar[] intervals, int[] demands, IntVar capacity, String name)
      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.
    • makeCumulative

      public Constraint makeCumulative(IntervalVar[] intervals, IntVar[] demands, long capacity, String name)
      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.
    • makeCumulative

      public Constraint makeCumulative(IntervalVar[] intervals, IntVar[] demands, IntVar capacity, String name)
      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.
    • makeCover

      public Constraint makeCover(IntervalVar[] vars, IntervalVar 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.
    • makeEquality

      public Constraint makeEquality(IntervalVar var1, IntervalVar var2)
      This constraints states that the two interval variables are equal.
    • makeAssignment

      public Assignment makeAssignment()
      This method creates an empty assignment.
    • makeAssignment

      public Assignment makeAssignment(Assignment a)
      This method creates an assignment which is a copy of 'a'.
    • makeFirstSolutionCollector

      public SolutionCollector makeFirstSolutionCollector(Assignment assignment)
      Collect the first solution of the search.
    • makeFirstSolutionCollector

      public SolutionCollector makeFirstSolutionCollector()
      Collect the first solution of the search. The variables will need to
      be added later.
    • makeLastSolutionCollector

      public SolutionCollector makeLastSolutionCollector(Assignment assignment)
      Collect the last solution of the search.
    • makeLastSolutionCollector

      public SolutionCollector makeLastSolutionCollector()
      Collect the last solution of the search. The variables will need to
      be added later.
    • makeBestValueSolutionCollector

      public SolutionCollector makeBestValueSolutionCollector(Assignment assignment, boolean maximize)
      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).
    • MakeBestLexicographicValueSolutionCollector

      public SolutionCollector MakeBestLexicographicValueSolutionCollector(Assignment assignment, SWIGTYPE_p_std__vectorT_bool_t maximize)
      Same as above, but supporting lexicographic objectives; 'maximize'
      specifies the optimization direction for each objective in 'assignment'.
    • makeBestValueSolutionCollector

      public SolutionCollector makeBestValueSolutionCollector(boolean maximize)
      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.
    • MakeBestLexicographicValueSolutionCollector

      public SolutionCollector MakeBestLexicographicValueSolutionCollector(SWIGTYPE_p_std__vectorT_bool_t maximize)
      Same as above, but supporting lexicographic objectives; 'maximize'
      specifies the optimization direction for each objective.
    • makeNBestValueSolutionCollector

      public SolutionCollector makeNBestValueSolutionCollector(Assignment assignment, int solution_count, boolean maximize)
      Same as MakeBestValueSolutionCollector but collects the best
      solution_count solutions. Collected solutions are sorted in increasing
      optimality order (the best solution is the last one).
    • makeNBestValueSolutionCollector

      public SolutionCollector makeNBestValueSolutionCollector(int solution_count, boolean maximize)
    • MakeNBestLexicographicValueSolutionCollector

      public SolutionCollector MakeNBestLexicographicValueSolutionCollector(Assignment assignment, int solution_count, SWIGTYPE_p_std__vectorT_bool_t maximize)
      Same as above but supporting lexicographic objectives; 'maximize'
      specifies the optimization direction for each objective.
    • MakeNBestLexicographicValueSolutionCollector

      public SolutionCollector MakeNBestLexicographicValueSolutionCollector(int solution_count, SWIGTYPE_p_std__vectorT_bool_t maximize)
    • makeAllSolutionCollector

      public SolutionCollector makeAllSolutionCollector(Assignment assignment)
      Collect all solutions of the search.
    • makeAllSolutionCollector

      public SolutionCollector makeAllSolutionCollector()
      Collect all solutions of the search. The variables will need to
      be added later.
    • makeMinimize

      public OptimizeVar makeMinimize(IntVar v, long step)
      Creates a minimization objective.
    • makeMaximize

      public OptimizeVar makeMaximize(IntVar v, long step)
      Creates a maximization objective.
    • makeOptimize

      public OptimizeVar makeOptimize(boolean maximize, IntVar v, long step)
      Creates a objective with a given sense (true = maximization).
    • makeWeightedMinimize

      public OptimizeVar makeWeightedMinimize(IntVar[] sub_objectives, long[] weights, long step)
      Creates a minimization weighted objective. The actual objective is
      scalar_prod(sub_objectives, weights).
    • makeWeightedMinimize

      public OptimizeVar makeWeightedMinimize(IntVar[] sub_objectives, int[] weights, long step)
      Creates a minimization weighted objective. The actual objective is
      scalar_prod(sub_objectives, weights).
    • makeWeightedMaximize

      public OptimizeVar makeWeightedMaximize(IntVar[] sub_objectives, long[] weights, long step)
      Creates a maximization weigthed objective.
    • makeWeightedMaximize

      public OptimizeVar makeWeightedMaximize(IntVar[] sub_objectives, int[] weights, long step)
      Creates a maximization weigthed objective.
    • makeWeightedOptimize

      public OptimizeVar makeWeightedOptimize(boolean maximize, IntVar[] sub_objectives, long[] weights, long step)
      Creates a weighted objective with a given sense (true = maximization).
    • makeWeightedOptimize

      public OptimizeVar makeWeightedOptimize(boolean maximize, IntVar[] sub_objectives, int[] weights, long step)
      Creates a weighted objective with a given sense (true = maximization).
    • MakeLexicographicOptimize

      public OptimizeVar MakeLexicographicOptimize(SWIGTYPE_p_std__vectorT_bool_t maximize, IntVar[] variables, long[] steps)
      Creates a lexicographic objective, following the order of the variables
      given. Each variable has a corresponding optimization direction and step.
    • makeTabuSearch

      public ObjectiveMonitor makeTabuSearch(boolean maximize, IntVar objective, long step, IntVar[] vars, long keep_tenure, long forbid_tenure, double 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.
    • MakeLexicographicTabuSearch

      public ObjectiveMonitor MakeLexicographicTabuSearch(SWIGTYPE_p_std__vectorT_bool_t maximize, IntVar[] objectives, long[] steps, IntVar[] vars, long keep_tenure, long forbid_tenure, double tabu_factor)
    • makeGenericTabuSearch

      public ObjectiveMonitor makeGenericTabuSearch(boolean maximize, IntVar v, long step, IntVar[] tabu_vars, long forbid_tenure)
      Creates a Tabu Search based on the vars |vars|.
      A solution is "tabu" if all the vars in |vars| keep their value.
    • makeSimulatedAnnealing

      public ObjectiveMonitor makeSimulatedAnnealing(boolean maximize, IntVar v, long step, long initial_temperature)
      Creates a Simulated Annealing monitor.
    • MakeLexicographicSimulatedAnnealing

      public ObjectiveMonitor MakeLexicographicSimulatedAnnealing(SWIGTYPE_p_std__vectorT_bool_t maximize, IntVar[] vars, long[] steps, long[] initial_temperatures)
    • MakeRoundRobinCompoundObjectiveMonitor

      public BaseObjectiveMonitor MakeRoundRobinCompoundObjectiveMonitor(SWIGTYPE_p_std__vectorT_operations_research__BaseObjectiveMonitor_p_t monitors, int num_max_local_optima_before_metaheuristic_switch)
      Creates a Guided Local Search monitor.
      Description here: http://en.wikipedia.org/wiki/Guided_Local_Search
    • makeLubyRestart

      public SearchMonitor makeLubyRestart(int 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...).
    • makeConstantRestart

      public SearchMonitor makeConstantRestart(int frequency)
      This search monitor will restart the search periodically after 'frequency'
      failures.
    • makeTimeLimit

      public RegularLimit makeTimeLimit(SWIGTYPE_p_absl__Duration time)
      Creates a search limit that constrains the running time.
    • makeTimeLimit

      public RegularLimit makeTimeLimit(long time_in_ms)
    • makeBranchesLimit

      public RegularLimit makeBranchesLimit(long branches)
      Creates a search limit that constrains the number of branches
      explored in the search tree.
    • makeFailuresLimit

      public RegularLimit makeFailuresLimit(long failures)
      Creates a search limit that constrains the number of failures
      that can happen when exploring the search tree.
    • makeSolutionsLimit

      public RegularLimit makeSolutionsLimit(long solutions)
      Creates a search limit that constrains the number of solutions found
      during the search.
    • makeLimit

      public RegularLimit makeLimit(SWIGTYPE_p_absl__Duration time, long branches, long failures, long solutions, boolean smart_time_check, boolean cumulative)
      Limits the search with the 'time', 'branches', 'failures' and
      'solutions' limits. 'smart_time_check' reduces the calls to the wall
    • makeLimit

      public RegularLimit makeLimit(SWIGTYPE_p_absl__Duration time, long branches, long failures, long solutions, boolean smart_time_check)
      Limits the search with the 'time', 'branches', 'failures' and
      'solutions' limits. 'smart_time_check' reduces the calls to the wall
    • makeLimit

      public RegularLimit makeLimit(SWIGTYPE_p_absl__Duration time, long branches, long failures, long solutions)
      Limits the search with the 'time', 'branches', 'failures' and
      'solutions' limits. 'smart_time_check' reduces the calls to the wall
    • makeLimit

      public RegularLimit makeLimit(RegularLimitParameters proto)
      Creates a search limit from its protobuf description
    • makeLimit

      public RegularLimit makeLimit(long time, long branches, long failures, long solutions, boolean smart_time_check, boolean cumulative)
    • makeLimit

      public RegularLimit makeLimit(long time, long branches, long failures, long solutions, boolean smart_time_check)
    • makeLimit

      public RegularLimit makeLimit(long time, long branches, long failures, long solutions)
    • makeDefaultRegularLimitParameters

      public RegularLimitParameters makeDefaultRegularLimitParameters()
      Creates a regular limit proto containing default values.
    • makeLimit

      public SearchLimit makeLimit(SearchLimit limit_1, SearchLimit limit_2)
      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.
    • MakeImprovementLimit

      public ImprovementSearchLimit MakeImprovementLimit(IntVar objective_var, boolean maximize, double objective_scaling_factor, double objective_offset, double improvement_rate_coefficient, int improvement_rate_solutions_distance)
      Limits the search based on the improvements of 'objective_var'. Stops the
      search when the improvement rate gets lower than a threshold value. This
      threshold value is computed based on the improvement rate during the first
      phase of the search.
    • MakeLexicographicImprovementLimit

      public ImprovementSearchLimit MakeLexicographicImprovementLimit(IntVar[] objective_vars, SWIGTYPE_p_std__vectorT_bool_t maximize, double[] objective_scaling_factors, double[] objective_offsets, double improvement_rate_coefficient, int improvement_rate_solutions_distance)
      Same as MakeImprovementLimit on a lexicographic objective based on
      'objective_vars' and related arguments.
    • makeCustomLimit

      public SearchLimit makeCustomLimit(BooleanSupplier limiter)
      Callback-based search limit. Search stops when limiter returns true; if
      this happens at a leaf the corresponding solution will be rejected.
    • makeSearchLog

      public SearchMonitor makeSearchLog(int branch_period)
      The SearchMonitors below will display a periodic search log
      on LOG(INFO) every branch_period branches explored.
    • makeSearchLog

      public SearchMonitor makeSearchLog(int branch_period, IntVar var)
      At each solution, this monitor also display the var value.
    • makeSearchLog

      public SearchMonitor makeSearchLog(int branch_period, Supplier<String> display_callback)
      At each solution, this monitor will also display result of
      display_callback.
    • makeSearchLog

      public SearchMonitor makeSearchLog(int branch_period, IntVar var, Supplier<String> display_callback)
      At each solution, this monitor will display the 'var' value and the
      result of display_callback.
    • makeSearchLog

      public SearchMonitor makeSearchLog(int branch_period, IntVar[] vars, Supplier<String> display_callback)
      At each solution, this monitor will display the 'vars' values and the
      result of display_callback.
    • makeSearchLog

      public SearchMonitor makeSearchLog(int branch_period, OptimizeVar opt_var)
      OptimizeVar Search Logs
      At each solution, this monitor will also display the 'opt_var' value.
    • makeSearchLog

      public SearchMonitor makeSearchLog(int branch_period, OptimizeVar opt_var, Supplier<String> display_callback)
      Creates a search monitor that will also print the result of the
      display callback.
    • makeSearchTrace

      public SearchMonitor makeSearchTrace(String prefix)
      Creates a search monitor that will trace precisely the behavior of the
      search. Use this only for low level debugging.
    • makeEnterSearchCallback

      public SearchMonitor makeEnterSearchCallback(Runnable callback)
      ----- Callback-based search monitors -----
    • makeExitSearchCallback

      public SearchMonitor makeExitSearchCallback(Runnable callback)
    • makeAtSolutionCallback

      public SearchMonitor makeAtSolutionCallback(Runnable callback)
    • makePrintModelVisitor

      public ModelVisitor makePrintModelVisitor()
      Prints the model.
    • makeStatisticsModelVisitor

      public ModelVisitor makeStatisticsModelVisitor()
      Displays some nice statistics on the model.
    • makeSymmetryManager

      public SearchMonitor makeSymmetryManager(SymmetryBreaker[] visitors)
      Symmetry Breaking.
    • makeSymmetryManager

      public SearchMonitor makeSymmetryManager(SymmetryBreaker v1)
    • makeSymmetryManager

      public SearchMonitor makeSymmetryManager(SymmetryBreaker v1, SymmetryBreaker v2)
    • makeSymmetryManager

      public SearchMonitor makeSymmetryManager(SymmetryBreaker v1, SymmetryBreaker v2, SymmetryBreaker v3)
    • makeSymmetryManager

      public SearchMonitor makeSymmetryManager(SymmetryBreaker v1, SymmetryBreaker v2, SymmetryBreaker v3, SymmetryBreaker v4)
    • makeAssignVariableValue

      public Decision makeAssignVariableValue(IntVar var, long val)
      Decisions.
    • makeVariableLessOrEqualValue

      public Decision makeVariableLessOrEqualValue(IntVar var, long value)
    • makeVariableGreaterOrEqualValue

      public Decision makeVariableGreaterOrEqualValue(IntVar var, long value)
    • makeSplitVariableDomain

      public Decision makeSplitVariableDomain(IntVar var, long val, boolean start_with_lower_half)
    • makeAssignVariableValueOrFail

      public Decision makeAssignVariableValueOrFail(IntVar var, long value)
    • MakeAssignVariableValueOrDoNothing

      public Decision MakeAssignVariableValueOrDoNothing(IntVar var, long value)
    • makeAssignVariablesValues

      public Decision makeAssignVariablesValues(IntVar[] vars, long[] values)
    • MakeAssignVariablesValuesOrDoNothing

      public Decision MakeAssignVariablesValuesOrDoNothing(IntVar[] vars, long[] values)
    • MakeAssignVariablesValuesOrFail

      public Decision MakeAssignVariablesValuesOrFail(IntVar[] vars, long[] values)
    • makeFailDecision

      public Decision makeFailDecision()
    • makeDecision

      public Decision makeDecision(Consumer<Solver> apply, Consumer<Solver> refute)
    • compose

      public DecisionBuilder compose(DecisionBuilder db1, DecisionBuilder db2)
      Creates a decision builder which sequentially composes decision builders.
      At each leaf of a decision builder, the next decision builder is therefore
      called. For instance, Compose(db1, db2) will result in the following tree:
      d1 tree |
      | \ |
      db1 leaves |
      | \ |
      db2 tree db2 tree db2 tree |
    • compose

    • compose

    • compose

      public DecisionBuilder compose(DecisionBuilder[] dbs)
    • tryDecisions

      public DecisionBuilder tryDecisions(DecisionBuilder db1, DecisionBuilder db2)
      Creates a decision builder which will create a search tree where each
      decision builder is called from the top of the search tree. For instance
      the decision builder Try(db1, db2) will entirely explore the search tree
      of db1 then the one of db2, resulting in the following search tree:
      Tree root |
      \ |
      db1 tree db2 tree |

      This is very handy to try a decision builder which partially explores the
      search space and if it fails to try another decision builder.

      "Try"-builders "recursively". For instance, Try(a,b,c,d) will give a tree
      unbalanced to the right, whereas Try(Try(a,b), Try(b,c)) will give a
      balanced tree. Investigate if we should only provide the binary version
      and/or if we should balance automatically.
    • tryDecisions

      public DecisionBuilder tryDecisions(DecisionBuilder db1, DecisionBuilder db2, DecisionBuilder db3)
    • tryDecisions

      public DecisionBuilder tryDecisions(DecisionBuilder db1, DecisionBuilder db2, DecisionBuilder db3, DecisionBuilder db4)
    • tryDecisions

      public DecisionBuilder tryDecisions(DecisionBuilder[] dbs)
    • makePhase

      public DecisionBuilder makePhase(IntVar[] vars, int var_str, int val_str)
      Phases on IntVar arrays.
      for all other functions that have several homonyms in this .h).
    • makePhase

      public DecisionBuilder makePhase(IntVar[] vars, LongUnaryOperator var_evaluator, int val_str)
    • makePhase

      public DecisionBuilder makePhase(IntVar[] vars, int var_str, LongBinaryOperator value_evaluator)
    • makePhase

      public DecisionBuilder makePhase(IntVar[] vars, int var_str, LongTernaryPredicate var_val1_val2_comparator)
      var_val1_val2_comparator(var, val1, val2) is true iff assigning value
      "val1" to variable "var" is better than assigning value "val2".
    • makePhase

      public DecisionBuilder makePhase(IntVar[] vars, LongUnaryOperator var_evaluator, LongBinaryOperator value_evaluator)
    • makePhase

      public DecisionBuilder makePhase(IntVar[] vars, int var_str, LongBinaryOperator value_evaluator, LongUnaryOperator tie_breaker)
    • makePhase

      public DecisionBuilder makePhase(IntVar[] vars, LongUnaryOperator var_evaluator, LongBinaryOperator value_evaluator, LongUnaryOperator tie_breaker)
    • makeDefaultPhase

      public DecisionBuilder makeDefaultPhase(IntVar[] vars)
    • makeDefaultPhase

      public DecisionBuilder makeDefaultPhase(IntVar[] vars, DefaultPhaseParameters parameters)
    • makePhase

      public DecisionBuilder makePhase(IntVar v0, int var_str, int val_str)
      Shortcuts for small arrays.
    • makePhase

      public DecisionBuilder makePhase(IntVar v0, IntVar v1, int var_str, int val_str)
    • makePhase

      public DecisionBuilder makePhase(IntVar v0, IntVar v1, IntVar v2, int var_str, int val_str)
    • makePhase

      public DecisionBuilder makePhase(IntVar v0, IntVar v1, IntVar v2, IntVar v3, int var_str, int val_str)
    • makeScheduleOrPostpone

      public Decision makeScheduleOrPostpone(IntervalVar var, long est, SWIGTYPE_p_long 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.
    • makeScheduleOrExpedite

      public Decision makeScheduleOrExpedite(IntervalVar var, long est, SWIGTYPE_p_long 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.
    • makeRankFirstInterval

      public Decision makeRankFirstInterval(SequenceVar sequence, int index)
      Returns a decision that tries to rank first the ith interval var
      in the sequence variable.
    • makeRankLastInterval

      public Decision makeRankLastInterval(SequenceVar sequence, int index)
      Returns a decision that tries to rank last the ith interval var
      in the sequence variable.
    • makePhase

      public DecisionBuilder makePhase(IntVar[] vars, LongBinaryOperator eval, int str)
      Returns a decision builder which assigns values to variables which
      minimize the values returned by the evaluator. The arguments passed to the
      evaluator callback are the indices of the variables in vars and the values
      of these variables. Ownership of the callback is passed to the decision
      builder.
    • makePhase

      public DecisionBuilder makePhase(IntVar[] vars, LongBinaryOperator eval, LongUnaryOperator tie_breaker, int str)
      Returns a decision builder which assigns values to variables
      which minimize the values returned by the evaluator. In case of
      tie breaks, the second callback is used to choose the best index
      in the array of equivalent pairs with equivalent evaluations. The
      arguments passed to the evaluator callback are the indices of the
      variables in vars and the values of these variables. Ownership of
      the callback is passed to the decision builder.
    • makePhase

      public DecisionBuilder makePhase(IntervalVar[] intervals, int str)
      Scheduling phases.
    • makePhase

      public DecisionBuilder makePhase(SequenceVar[] sequences, int str)
    • makeDecisionBuilderFromAssignment

      public DecisionBuilder makeDecisionBuilderFromAssignment(Assignment assignment, DecisionBuilder db, IntVar[] vars)
      Returns a decision builder for which the left-most leaf corresponds
      to assignment, the rest of the tree being explored using 'db'.
    • makeConstraintAdder

      public DecisionBuilder makeConstraintAdder(Constraint ct)
      Returns a decision builder that will add the given constraint to
      the model.
    • makeSolveOnce

      public DecisionBuilder makeSolveOnce(DecisionBuilder db)
      SolveOnce 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 SolveOnce will
      fail. If there is a solution, it will find it and returns nullptr.
    • makeSolveOnce

      public DecisionBuilder makeSolveOnce(DecisionBuilder db, SearchMonitor monitor1)
    • makeSolveOnce

      public DecisionBuilder makeSolveOnce(DecisionBuilder db, SearchMonitor monitor1, SearchMonitor monitor2)
    • makeSolveOnce

      public DecisionBuilder makeSolveOnce(DecisionBuilder db, SearchMonitor monitor1, SearchMonitor monitor2, SearchMonitor monitor3)
    • makeSolveOnce

      public DecisionBuilder makeSolveOnce(DecisionBuilder db, SearchMonitor monitor1, SearchMonitor monitor2, SearchMonitor monitor3, SearchMonitor monitor4)
    • makeSolveOnce

      public DecisionBuilder makeSolveOnce(DecisionBuilder db, SearchMonitor[] monitors)
    • makeNestedOptimize

      public DecisionBuilder makeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step)
      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.
    • makeNestedOptimize

      public DecisionBuilder makeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor monitor1)
    • makeNestedOptimize

      public DecisionBuilder makeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor monitor1, SearchMonitor monitor2)
    • makeNestedOptimize

      public DecisionBuilder makeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor monitor1, SearchMonitor monitor2, SearchMonitor monitor3)
    • makeNestedOptimize

      public DecisionBuilder makeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor monitor1, SearchMonitor monitor2, SearchMonitor monitor3, SearchMonitor monitor4)
    • makeNestedOptimize

      public DecisionBuilder makeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor[] monitors)
    • makeRestoreAssignment

      public DecisionBuilder makeRestoreAssignment(Assignment assignment)
      Returns a DecisionBuilder which restores an Assignment
      (calls void Assignment::Restore())
    • makeStoreAssignment

      public DecisionBuilder makeStoreAssignment(Assignment assignment)
      Returns a DecisionBuilder which stores an Assignment
      (calls void Assignment::Store())
    • makeOperator

      Local Search Operators.
    • makeOperator

      public LocalSearchOperator makeOperator(IntVar[] vars, int op, SWIGTYPE_p_std__functionT_std__vectorT_int_t_const_Rfint_intF_t get_incoming_neighbors)
      Local Search Operators.
    • makeOperator

      public LocalSearchOperator makeOperator(IntVar[] vars, int op)
      Local Search Operators.
    • makeOperator

      public LocalSearchOperator makeOperator(IntVar[] vars, IntVar[] secondary_vars, int op, SWIGTYPE_p_std__functionT_std__vectorT_int_t_const_Rfint_intF_t get_incoming_neighbors, SWIGTYPE_p_std__functionT_std__vectorT_int_t_const_Rfint_intF_t get_outgoing_neighbors)
    • makeOperator

      public LocalSearchOperator makeOperator(IntVar[] vars, IntVar[] secondary_vars, int op, SWIGTYPE_p_std__functionT_std__vectorT_int_t_const_Rfint_intF_t get_incoming_neighbors)
    • makeOperator

      public LocalSearchOperator makeOperator(IntVar[] vars, IntVar[] secondary_vars, int op)
    • makeOperator

      public LocalSearchOperator makeOperator(IntVar[] vars, LongTernaryOperator evaluator, int op)
    • makeOperator

      public LocalSearchOperator makeOperator(IntVar[] vars, IntVar[] secondary_vars, LongTernaryOperator evaluator, int op)
    • makeRandomLnsOperator

      public LocalSearchOperator makeRandomLnsOperator(IntVar[] vars, int number_of_variables)
      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.
    • makeRandomLnsOperator

      public LocalSearchOperator makeRandomLnsOperator(IntVar[] vars, int number_of_variables, int seed)
    • makeMoveTowardTargetOperator

      public LocalSearchOperator makeMoveTowardTargetOperator(Assignment target)
      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.
    • makeMoveTowardTargetOperator

      public LocalSearchOperator makeMoveTowardTargetOperator(IntVar[] variables, long[] target_values)
      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.
    • concatenateOperators

      public LocalSearchOperator concatenateOperators(LocalSearchOperator[] ops)
      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].
    • concatenateOperators

      public LocalSearchOperator concatenateOperators(LocalSearchOperator[] ops, boolean restart)
    • concatenateOperators

      public LocalSearchOperator concatenateOperators(LocalSearchOperator[] ops, IntIntToLongFunction evaluator)
    • randomConcatenateOperators

      public LocalSearchOperator randomConcatenateOperators(LocalSearchOperator[] ops)
      Randomized version of local search concatenator; calls a random operator
      at each call to MakeNextNeighbor().
    • randomConcatenateOperators

      public LocalSearchOperator randomConcatenateOperators(LocalSearchOperator[] ops, int seed)
      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.
    • MultiArmedBanditConcatenateOperators

      public LocalSearchOperator MultiArmedBanditConcatenateOperators(LocalSearchOperator[] ops, double memory_coefficient, double exploration_coefficient, boolean maximize)
      Creates a local search operator which concatenates a vector of operators.
      Uses Multi-Armed Bandit approach for choosing the next operator to use.
      Sorts operators based on Upper Confidence Bound Algorithm which evaluates
      each operator as sum of average improvement and exploration function.

      Updates the order of operators when accepts a neighbor with objective
      improvement.
    • makeNeighborhoodLimit

      public LocalSearchOperator makeNeighborhoodLimit(LocalSearchOperator op, long 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.
    • makeLocalSearchPhase

      public DecisionBuilder makeLocalSearchPhase(Assignment assignment, LocalSearchPhaseParameters parameters)
      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.
    • makeLocalSearchPhase

      public DecisionBuilder makeLocalSearchPhase(IntVar[] vars, DecisionBuilder first_solution, LocalSearchPhaseParameters parameters)
    • makeLocalSearchPhase

      public DecisionBuilder makeLocalSearchPhase(IntVar[] vars, DecisionBuilder first_solution, DecisionBuilder first_solution_sub_decision_builder, LocalSearchPhaseParameters parameters)
      Variant with a sub_decison_builder specific to the first solution.
    • makeLocalSearchPhase

      public DecisionBuilder makeLocalSearchPhase(SequenceVar[] vars, DecisionBuilder first_solution, LocalSearchPhaseParameters parameters)
    • RunUncheckedLocalSearch

      public Assignment RunUncheckedLocalSearch(Assignment initial_solution, LocalSearchFilterManager filter_manager, LocalSearchOperator ls_operator, SearchMonitor[] monitors, RegularLimit limit, SWIGTYPE_p_absl__flat_hash_setT_operations_research__IntVar_p_t touched)
      Experimental: runs a local search on the given initial solution, checking
      the feasibility and the objective value of solutions using the filter
      manager only (solutions are never restored in the CP world). Only greedy
      descent is supported.
    • RunUncheckedLocalSearch

      public Assignment RunUncheckedLocalSearch(Assignment initial_solution, LocalSearchFilterManager filter_manager, LocalSearchOperator ls_operator, SearchMonitor[] monitors, RegularLimit limit)
      Experimental: runs a local search on the given initial solution, checking
      the feasibility and the objective value of solutions using the filter
      manager only (solutions are never restored in the CP world). Only greedy
      descent is supported.
    • makeDefaultSolutionPool

      public SolutionPool makeDefaultSolutionPool()
      Solution Pool.
    • makeLocalSearchPhaseParameters

      public LocalSearchPhaseParameters makeLocalSearchPhaseParameters(IntVar objective, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder)
      Local Search Phase Parameters
    • makeLocalSearchPhaseParameters

      public LocalSearchPhaseParameters makeLocalSearchPhaseParameters(IntVar objective, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder, RegularLimit limit)
    • makeLocalSearchPhaseParameters

      public LocalSearchPhaseParameters makeLocalSearchPhaseParameters(IntVar objective, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder, RegularLimit limit, LocalSearchFilterManager filter_manager)
    • makeLocalSearchPhaseParameters

      public LocalSearchPhaseParameters makeLocalSearchPhaseParameters(IntVar objective, SolutionPool pool, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder)
    • makeLocalSearchPhaseParameters

      public LocalSearchPhaseParameters makeLocalSearchPhaseParameters(IntVar objective, SolutionPool pool, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder, RegularLimit limit)
    • makeLocalSearchPhaseParameters

      public LocalSearchPhaseParameters makeLocalSearchPhaseParameters(IntVar objective, SolutionPool pool, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder, RegularLimit limit, LocalSearchFilterManager filter_manager)
    • MakeAcceptFilter

      public LocalSearchFilter MakeAcceptFilter()
      Local Search Filters
    • MakeRejectFilter

      public LocalSearchFilter MakeRejectFilter()
    • makeVariableDomainFilter

      public LocalSearchFilter makeVariableDomainFilter()
    • makeSumObjectiveFilter

      public IntVarLocalSearchFilter makeSumObjectiveFilter(IntVar[] vars, LongBinaryOperator values, int filter_enum)
    • makeSumObjectiveFilter

      public IntVarLocalSearchFilter makeSumObjectiveFilter(IntVar[] vars, IntVar[] secondary_vars, LongTernaryOperator values, int filter_enum)
    • topPeriodicCheck

      public void topPeriodicCheck()
      Performs PeriodicCheck on the top-level search; for instance, can be
      called from a nested solve to check top-level limits.
    • topProgressPercent

      public int topProgressPercent()
      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).
    • pushState

      public void pushState()
      The PushState and PopState methods manipulates the states
      of the reversible objects. They are visible only because they
      are useful to write unitary tests.
    • popState

      public void popState()
    • searchDepth

      public int searchDepth()
      Gets the search depth of the current active search. Returns -1 if
      there is no active search opened.
    • searchLeftDepth

      public int searchLeftDepth()
      Gets the search left depth of the current active search. Returns -1 if
      there is no active search opened.
    • solveDepth

      public int solveDepth()
      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.
    • rand64

      public long rand64(long size)
      Returns a random value between 0 and 'size' - 1;
    • rand32

      public int rand32(int size)
      Returns a random value between 0 and 'size' - 1;
    • reSeed

      public void reSeed(int seed)
      Reseed the solver random generator.
    • exportProfilingOverview

      public void exportProfilingOverview(String filename)
      Exports the profiling information in a human readable overview.
      The parameter profile_level used to create the solver must be
      set to true.
    • localSearchProfile

      public String localSearchProfile()
      Returns local search profiling information in a human readable format.
    • currentlyInSolve

      public boolean currentlyInSolve()
      Returns true whether the current search has been
      created using a Solve() call instead of a NewSearch one. It
      returns false if the solver is not in search at all.
    • constraints

      public int constraints()
      Counts the number of constraints that have been added
      to the solver before the search.
    • accept

      public void accept(ModelVisitor visitor)
      Accepts the given model visitor.
    • balancing_decision

      public Decision balancing_decision()
    • clear_fail_intercept

      public void clear_fail_intercept()
      Internal
    • SetUseFastLocalSearch

      public void SetUseFastLocalSearch(boolean use_fast_local_search)
      enabled for metaheuristics.
      Disables/enables fast local search.
    • UseFastLocalSearch

      public boolean UseFastLocalSearch()
      Returns true if fast local search is enabled.
    • hasName

      public boolean hasName(PropagationBaseObject object)
      Returns whether the object has been named or not.
    • registerDemon

      public Demon registerDemon(Demon demon)
      Adds a new demon and wraps it inside a DemonProfiler if necessary.
    • registerIntExpr

      public IntExpr registerIntExpr(IntExpr expr)
      Registers a new IntExpr and wraps it inside a TraceIntExpr if necessary.
    • registerIntVar

      public IntVar registerIntVar(IntVar var)
      Registers a new IntVar and wraps it inside a TraceIntVar if necessary.
    • registerIntervalVar

      public IntervalVar registerIntervalVar(IntervalVar var)
      Registers a new IntervalVar and wraps it inside a TraceIntervalVar
      if necessary.
    • cache

      public ModelCache cache()
      Returns the cache of the model.
    • instrumentsDemons

      public boolean instrumentsDemons()
      Returns whether we are instrumenting demons.
    • isProfilingEnabled

      public boolean isProfilingEnabled()
      Returns whether we are profiling the solver.
    • isLocalSearchProfilingEnabled

      public boolean isLocalSearchProfilingEnabled()
      Returns whether we are profiling local search.
    • instrumentsVariables

      public boolean instrumentsVariables()
      Returns whether we are tracing variables.
    • nameAllVariables

      public boolean nameAllVariables()
      Returns whether all variables should be named.
    • model_name

      public String model_name()
      Returns the name of the model.
    • getPropagationMonitor

      public PropagationMonitor getPropagationMonitor()
      Returns the propagation monitor.
    • addPropagationMonitor

      public void addPropagationMonitor(PropagationMonitor monitor)
      Adds the propagation monitor to the solver. This is called internally when
      a propagation monitor is passed to the Solve() or NewSearch() method.
    • getLocalSearchMonitor

      public LocalSearchMonitor getLocalSearchMonitor()
      Returns the local search monitor.
    • addLocalSearchMonitor

      public void addLocalSearchMonitor(LocalSearchMonitor monitor)
      Adds the local search monitor to the solver. This is called internally
      when a propagation monitor is passed to the Solve() or NewSearch() method.
    • GetOrCreateLocalSearchState

      public Assignment GetOrCreateLocalSearchState()
      Returns (or creates) an assignment representing the state of local search.
    • ClearLocalSearchState

      public void ClearLocalSearchState()
      Clears the local search state.
    • setTmpVector

      public void setTmpVector(long[] value)
      Unsafe temporary vector. It is used to avoid leaks in operations
      that need storage and that may fail. See IntVar::SetValues() for
      instance. It is not locked; do not use in a multi-threaded or reentrant
      setup.
    • getTmpVector

      public long[] getTmpVector()
      Unsafe temporary vector. It is used to avoid leaks in operations
      that need storage and that may fail. See IntVar::SetValues() for
      instance. It is not locked; do not use in a multi-threaded or reentrant
      setup.
    • castExpression

      public IntExpr castExpression(IntVar var)
      Internal. If the variables is the result of expr->Var(), this
      method returns expr, nullptr otherwise.
    • finishCurrentSearch

      public void finishCurrentSearch()
      Tells the solver to kill or restart the current search.
    • restartCurrentSearch

      public void restartCurrentSearch()
    • shouldFail

      public void shouldFail()
      These methods are only useful for the SWIG wrappers, which need a way
      to externally cause the Solver to fail.
    • checkFail

      public void checkFail()
    • MakeProfiledDecisionBuilderWrapper

      public DecisionBuilder MakeProfiledDecisionBuilderWrapper(DecisionBuilder db)
      Activates profiling on a decision builder.