C++ Reference: class Solver

Note: This documentation is automatically generated.

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.
Method
ABSL_DEPRECATED

Arguments: "Use the version taking absl::Duration() as argument"

ABSL_DEPRECATED

Arguments: "Use other MakeLimit() versions"

Accept

Return type: void

Arguments: ModelVisitor* const visitor

Accepts the given model visitor.

accepted_neighbors

Return type: int64_t

The number of accepted neighbors.

ActiveSearch

Return type: Search*

Returns the active search, nullptr outside search.

AddBacktrackAction

Return type: void

Arguments: Action a, bool fast

When SaveValue() is not the best way to go, one can create a reversible action that will be called upon backtrack. The "fast" parameter indicates whether we need restore all values saved through SaveValue() before calling this method.

AddCastConstraint

Return type: void

Arguments: CastConstraint* const constraint, IntVar* const target_var, IntExpr* const 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.

AddConstraint

Return type: void

Arguments: Constraint* const 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 not 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(...));

AddLocalSearchMonitor

Return type: void

Arguments: 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.

AddPropagationMonitor

Return type: void

Arguments: PropagationMonitor* const monitor

Adds the propagation monitor to the solver. This is called internally when a propagation monitor is passed to the Solve() or NewSearch() method.

balancing_decision

Return type: Decision*

branches

Return type: int64_t

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

Cache

Return type: ModelCache*

Returns the cache of the model.

CastExpression

Return type: IntExpr*

Arguments: const IntVar* const var

Internal. If the variables is the result of expr->Var(), this method returns expr, nullptr otherwise.

CheckAssignment

Return type: bool

Arguments: Assignment* const solution

Checks whether the given assignment satisfies all relevant constraints.

CheckConstraint

Return type: bool

Arguments: Constraint* const 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.

CheckFail

Return type: void

clear_fail_intercept

Return type: void

ClearLocalSearchState

Return type: void

Clears the local search state.

Compose

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db1, DecisionBuilder* const 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

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db1, DecisionBuilder* const db2, DecisionBuilder* const db3

Compose

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db1, DecisionBuilder* const db2, DecisionBuilder* const db3, DecisionBuilder* const db4

Compose

Return type: DecisionBuilder*

Arguments: const std::vector<DecisionBuilder*>& dbs

ConcatenateOperators

Return type: LocalSearchOperator*

Arguments: const std::vector<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

Return type: LocalSearchOperator*

Arguments: const std::vector<LocalSearchOperator*>& ops, bool restart

ConcatenateOperators

Return type: LocalSearchOperator*

Arguments: const std::vector<LocalSearchOperator*>& ops, std::function<int64_t(int, int)> evaluator

const_parameters

Return type: const ConstraintSolverParameters&

Read-only.

constraints

Return type: int

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

CurrentlyInSolve

Return type: bool

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.

DebugString

Return type: std::string

misc debug string.

DefaultSolverParameters

Return type: static ConstraintSolverParameters

Create a ConstraintSolverParameters proto with all the default values. TODO(user): Move to constraint_solver_parameters.h.

demon_profiler

Return type: DemonProfiler*

Access to demon profiler.

demon_runs

Return type: int64_t

Arguments: DemonPriority p

The number of demons executed during search for a given priority.

EndSearch

Return type: void

ExportProfilingOverview

Return type: void

Arguments: const std::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.

Fail

Return type: void

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

fail_stamp

Return type: uint64_t

The fail_stamp() is incremented after each backtrack.

failures

Return type: int64_t

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

filtered_neighbors

Return type: int64_t

The number of filtered neighbors (neighbors accepted by filters).

FinishCurrentSearch

Return type: void

Tells the solver to kill or restart the current search.

GetConstraintSolverStatistics

Return type: ConstraintSolverStatistics

Returns detailed cp search statistics.

GetLocalSearchMonitor

Return type: LocalSearchMonitor*

Returns the local search monitor.

GetLocalSearchStatistics

Return type: LocalSearchStatistics

Returns detailed local search statistics.

GetOrCreateLocalSearchState

Return type: Assignment*

Returns (or creates) an assignment representing the state of local search. TODO(user): Investigate if this should be moved to Search.

GetPropagationMonitor

Return type: PropagationMonitor*

Returns the propagation monitor.

HasName

Return type: bool

Arguments: const PropagationBaseObject* object

Returns whether the object has been named or not.

InstrumentsDemons

Return type: bool

Returns whether we are instrumenting demons.

InstrumentsVariables

Return type: bool

Returns whether we are tracing variables.

IntegerCastInfo

InternalSaveBooleanVarValue

Return type: friend void

Arguments: Solver* const, IntVar* const

IsBooleanVar

Return type: bool

Arguments: IntExpr* const expr, IntVar** inner_var, bool* is_negated

Returns true if expr represents either boolean_var or 1 - boolean_var. In that case, it fills inner_var and is_negated to be true if the expression is 1 - boolean_var -- equivalent to not(boolean_var).

IsLocalSearchProfilingEnabled

Return type: bool

Returns whether we are profiling local search.

IsProduct

Return type: bool

Arguments: IntExpr* const expr, IntExpr** inner_expr, int64_t* coefficient

Returns true if expr represents a product of a expr and a constant. In that case, it fills inner_expr and coefficient with these, and returns true. In the other case, it fills inner_expr with expr, coefficient with 1, and returns false.

IsProfilingEnabled

Return type: bool

Returns whether we are profiling the solver.

LocalSearchProfile

Return type: std::string

Returns local search profiling information in a human readable format. TODO(user): Merge demon and local search profiles.

MakeAbs

Return type: IntExpr*

Arguments: IntExpr* const expr

|expr|

MakeAbsEquality

Return type: Constraint*

Arguments: IntVar* const var, IntVar* const abs_var

Creates the constraint abs(var) == abs_var.

MakeAcceptFilter

Return type: LocalSearchFilter*

Local Search Filters

MakeActionDemon

Return type: Demon*

Arguments: Action action

Creates a demon from a callback.

MakeAllDifferent

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars

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

MakeAllDifferent

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, bool 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

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, int64_t escape_value

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

MakeAllowedAssignments

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const 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.

MakeAllowedAssignments

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<std::vector<int64_t> /*keep for swig*/>& raw_tuples

Compatibility layer for Python API.

MakeAllSolutionCollector

Return type: SolutionCollector*

Arguments: const Assignment* const assignment

Collect all solutions of the search.

MakeAllSolutionCollector

Return type: SolutionCollector*

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

MakeApplyBranchSelector

Return type: DecisionBuilder*

Arguments: BranchSelector bs

Creates a decision builder that will set the branch selector.

MakeAssignment

Return type: Assignment*

This method creates an empty assignment.

MakeAssignment

Return type: Assignment*

Arguments: const Assignment* const a

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

MakeAssignVariablesValues

Return type: Decision*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int64_t>& values

MakeAssignVariablesValuesOrDoNothing

Return type: Decision*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int64_t>& values

MakeAssignVariablesValuesOrFail

Return type: Decision*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int64_t>& values

MakeAssignVariableValue

Return type: Decision*

Arguments: IntVar* const var, int64_t val

Decisions.

MakeAssignVariableValueOrDoNothing

Return type: Decision*

Arguments: IntVar* const var, int64_t value

MakeAssignVariableValueOrFail

Return type: Decision*

Arguments: IntVar* const var, int64_t value

MakeAtMost

Return type: Constraint*

Arguments: std::vector<IntVar*> vars, int64_t value, int64_t max_count

|{i | vars[i] == value}| <= max_count

MakeAtSolutionCallback

Return type: SearchMonitor*

Arguments: std::function<void()> callback

MakeBestValueSolutionCollector

Return type: SolutionCollector*

Arguments: const Assignment* const assignment, bool 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).

MakeBestValueSolutionCollector

Return type: SolutionCollector*

Arguments: bool 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). The variables will need to be added later.

MakeBetweenCt

Return type: Constraint*

Arguments: IntExpr* const expr, int64_t l, int64_t u

(l <= expr <= u)

MakeBoolVar

Return type: IntVar*

Arguments: const std::string& name

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

MakeBoolVar

Return type: IntVar*

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

MakeBoolVarArray

Return type: void

Arguments: int var_count, const std::string& name, std::vector<IntVar*>* vars

This method will append the vector vars with 'var_count' boolean variables having name "name" where is the index of the variable.

MakeBoolVarArray

Return type: void

Arguments: int var_count, std::vector<IntVar*>* vars

This method will append the vector vars with 'var_count' boolean variables having no names.

MakeBoolVarArray

Return type: IntVar**

Arguments: int var_count, const std::string& name

Same but allocates an array and returns it.

MakeBranchesLimit

Return type: ABSL_MUST_USE_RESULT RegularLimit*

Arguments: int64_t branches

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

MakeCircuit

Return type: Constraint*

Arguments: const std::vector<IntVar*>& nexts

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

MakeClosureDemon

Return type: Demon*

Arguments: Closure closure

Creates a demon from a closure.

MakeConditionalExpression

Return type: IntExpr*

Arguments: IntVar* const condition, IntExpr* const expr, int64_t unperformed_value

Conditional Expr condition ? expr : unperformed_value

MakeConstantRestart

Return type: SearchMonitor*

Arguments: int frequency

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

MakeConstraintAdder

Return type: DecisionBuilder*

Arguments: Constraint* const ct

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

MakeConstraintInitialPropagateCallback

Return type: Demon*

Arguments: Constraint* const ct

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

MakeConvexPiecewiseExpr

Return type: IntExpr*

Arguments: IntExpr* expr, int64_t early_cost, int64_t early_date, int64_t late_date, int64_t late_cost

Convex piecewise function.

MakeCount

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, int64_t value, int64_t max_count

|{i | vars[i] == value}| == max_count

MakeCount

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, int64_t value, IntVar* const max_count

|{i | vars[i] == value}| == max_count

MakeCover

Return type: Constraint*

Arguments: const std::vector<IntervalVar*>& vars, IntervalVar* const 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.

MakeCumulative

Return type: Constraint*

Arguments: const std::vector<IntervalVar*>& intervals, const std::vector<int64_t>& demands, int64_t capacity, const std::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

Return type: Constraint*

Arguments: const std::vector<IntervalVar*>& intervals, const std::vector<int>& demands, int64_t capacity, const std::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

Return type: Constraint*

Arguments: const std::vector<IntervalVar*>& intervals, const std::vector<int64_t>& demands, IntVar* const capacity, const std::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

Return type: Constraint*

Arguments: const std::vector<IntervalVar*>& intervals, const std::vector<int>& demands, IntVar* const capacity, const std::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

Return type: Constraint*

Arguments: const std::vector<IntervalVar*>& intervals, const std::vector<IntVar*>& demands, int64_t capacity, const std::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

Return type: Constraint*

Arguments: const std::vector<IntervalVar*>& intervals, const std::vector<IntVar*>& demands, IntVar* const capacity, const std::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.

MakeCustomLimit

Return type: ABSL_MUST_USE_RESULT SearchLimit*

Arguments: std::function<bool()> limiter

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

MakeDecision

Return type: Decision*

Arguments: Action apply, Action refute

MakeDecisionBuilderFromAssignment

Return type: DecisionBuilder*

Arguments: Assignment* const assignment, DecisionBuilder* const db, const std::vector<IntVar*>& vars

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

MakeDefaultPhase

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars

MakeDefaultPhase

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars, const DefaultPhaseParameters& parameters

MakeDefaultRegularLimitParameters

Return type: RegularLimitParameters

Creates a regular limit proto containing default values.

MakeDefaultSolutionPool

Return type: SolutionPool*

Solution Pool.

MakeDelayedConstraintInitialPropagateCallback

Return type: Demon*

Arguments: Constraint* const ct

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

MakeDelayedPathCumul

Return type: Constraint*

Arguments: const std::vector<IntVar*>& nexts, const std::vector<IntVar*>& active, const std::vector<IntVar*>& cumuls, const std::vector<IntVar*>& transits

Delayed version of the same constraint: propagation on the nexts variables is delayed until all constraints have propagated. TODO(user): Merge with other path-cumuls constraints.

MakeDeviation

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, IntVar* const deviation_var, int64_t total_sum

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

MakeDifference

Return type: IntExpr*

Arguments: IntExpr* const left, IntExpr* const right

left - right

MakeDifference

Return type: IntExpr*

Arguments: int64_t value, IntExpr* const expr

value - expr

MakeDisjunctiveConstraint

Return type: DisjunctiveConstraint*

Arguments: const std::vector<IntervalVar*>& intervals, const std::string& name

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

MakeDistribute

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int64_t>& values, const std::vector<IntVar*>& cards

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

MakeDistribute

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int>& values, const std::vector<IntVar*>& cards

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

MakeDistribute

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<IntVar*>& cards

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

MakeDistribute

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, int64_t card_min, int64_t card_max, int64_t 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

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int64_t>& card_min, const std::vector<int64_t>& 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

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int>& card_min, const std::vector<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

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int64_t>& values, const std::vector<int64_t>& card_min, const std::vector<int64_t>& 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

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int>& values, const std::vector<int>& card_min, const std::vector<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]

MakeDiv

Return type: IntExpr*

Arguments: IntExpr* const expr, int64_t value

expr / value (integer division)

MakeDiv

Return type: IntExpr*

Arguments: IntExpr* const numerator, IntExpr* const denominator

numerator / denominator (integer division). Terms need to be positive.

MakeElement

Return type: IntExpr*

Arguments: const std::vector<int64_t>& values, IntVar* const index

values[index]

MakeElement

Return type: IntExpr*

Arguments: const std::vector<int>& values, IntVar* const index

values[index]

MakeElement

Return type: IntExpr*

Arguments: IndexEvaluator1 values, IntVar* const 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).

MakeElement

Return type: IntExpr*

Arguments: IndexEvaluator2 values, IntVar* const index1, IntVar* const index2

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

MakeElement

Return type: IntExpr*

Arguments: const std::vector<IntVar*>& vars, IntVar* const index

vars[expr]

MakeElement

Return type: IntExpr*

Arguments: Int64ToIntVar vars, int64_t range_start, int64_t range_end, IntVar* argument

vars(argument)

MakeElementEquality

Return type: Constraint*

Arguments: const std::vector<int64_t>& vals, IntVar* const index, IntVar* const target

MakeElementEquality

Return type: Constraint*

Arguments: const std::vector<int>& vals, IntVar* const index, IntVar* const target

MakeElementEquality

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, IntVar* const index, IntVar* const target

MakeElementEquality

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, IntVar* const index, int64_t target

MakeEnterSearchCallback

Return type: SearchMonitor*

Arguments: std::function<void()> callback

----- Callback-based search monitors -----

MakeEquality

Return type: Constraint*

Arguments: IntExpr* const left, IntExpr* const right

left == right

MakeEquality

Return type: Constraint*

Arguments: IntExpr* const expr, int64_t value

expr == value

MakeEquality

Return type: Constraint*

Arguments: IntExpr* const expr, int value

expr == value

MakeEquality

Return type: Constraint*

Arguments: IntervalVar* const var1, IntervalVar* const var2

This constraints states that the two interval variables are equal.

MakeExitSearchCallback

Return type: SearchMonitor*

Arguments: std::function<void()> callback

MakeFailDecision

Return type: Decision*

MakeFailuresLimit

Return type: ABSL_MUST_USE_RESULT RegularLimit*

Arguments: int64_t failures

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

MakeFalseConstraint

Return type: Constraint*

This constraint always fails.

MakeFalseConstraint

Return type: Constraint*

Arguments: const std::string& explanation

MakeFirstSolutionCollector

Return type: SolutionCollector*

Arguments: const Assignment* const assignment

Collect the first solution of the search.

MakeFirstSolutionCollector

Return type: SolutionCollector*

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

MakeFixedDurationEndSyncedOnEndIntervalVar

Return type: IntervalVar*

Arguments: IntervalVar* const interval_var, int64_t duration, int64_t 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.

MakeFixedDurationEndSyncedOnStartIntervalVar

Return type: IntervalVar*

Arguments: IntervalVar* const interval_var, int64_t duration, int64_t 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.

MakeFixedDurationIntervalVar

Return type: IntervalVar*

Arguments: int64_t start_min, int64_t start_max, int64_t duration, bool optional, const std::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

Return type: IntervalVar*

Arguments: IntVar* const start_variable, int64_t duration, const std::string& name

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

MakeFixedDurationIntervalVar

Return type: IntervalVar*

Arguments: IntVar* const start_variable, int64_t duration, IntVar* const performed_variable, const std::string& name

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

MakeFixedDurationIntervalVarArray

Return type: void

Arguments: int count, int64_t start_min, int64_t start_max, int64_t duration, bool optional, const std::string& name, std::vector<IntervalVar*>* const array

This method fills the vector with 'count' interval variables built with the corresponding parameters.

MakeFixedDurationIntervalVarArray

Return type: void

Arguments: const std::vector<IntVar*>& start_variables, int64_t duration, const std::string& name, std::vector<IntervalVar*>* const array

This method fills the vector with 'count' interval var built with the corresponding start variables.

MakeFixedDurationIntervalVarArray

Return type: void

Arguments: const std::vector<IntVar*>& start_variables, const std::vector<int64_t>& durations, const std::string& name, std::vector<IntervalVar*>* const array

This method fills the vector with interval variables built with the corresponding start variables.

MakeFixedDurationIntervalVarArray

Return type: void

Arguments: const std::vector<IntVar*>& start_variables, const std::vector<int>& durations, const std::string& name, std::vector<IntervalVar*>* const array

This method fills the vector with interval variables built with the corresponding start variables.

MakeFixedDurationIntervalVarArray

Return type: void

Arguments: const std::vector<IntVar*>& start_variables, const std::vector<int64_t>& durations, const std::vector<IntVar*>& performed_variables, const std::string& name, std::vector<IntervalVar*>* const array

This method fills the vector with interval variables built with the corresponding start and performed variables.

MakeFixedDurationIntervalVarArray

Return type: void

Arguments: const std::vector<IntVar*>& start_variables, const std::vector<int>& durations, const std::vector<IntVar*>& performed_variables, const std::string& name, std::vector<IntervalVar*>* const array

This method fills the vector with interval variables built with the corresponding start and performed variables.

MakeFixedDurationStartSyncedOnEndIntervalVar

Return type: IntervalVar*

Arguments: IntervalVar* const interval_var, int64_t duration, int64_t 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.

MakeFixedDurationStartSyncedOnStartIntervalVar

Return type: IntervalVar*

Arguments: IntervalVar* const interval_var, int64_t duration, int64_t 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.

MakeFixedInterval

Return type: IntervalVar*

Arguments: int64_t start, int64_t duration, const std::string& name

Creates a fixed and performed interval.

MakeGenericTabuSearch

Return type: SearchMonitor*

Arguments: bool maximize, IntVar* const v, int64_t step, const std::vector<IntVar*>& tabu_vars, int64_t forbid_tenure

Creates a Tabu Search based on the vars |vars|. A solution is "tabu" if all the vars in |vars| keep their value.

MakeGreater

Return type: Constraint*

Arguments: IntExpr* const left, IntExpr* const right

left > right

MakeGreater

Return type: Constraint*

Arguments: IntExpr* const expr, int64_t value

expr > value

MakeGreater

Return type: Constraint*

Arguments: IntExpr* const expr, int value

expr > value

MakeGreaterOrEqual

Return type: Constraint*

Arguments: IntExpr* const left, IntExpr* const right

left >= right

MakeGreaterOrEqual

Return type: Constraint*

Arguments: IntExpr* const expr, int64_t value

expr >= value

MakeGreaterOrEqual

Return type: Constraint*

Arguments: IntExpr* const expr, int value

expr >= value

MakeGuidedLocalSearch

Return type: SearchMonitor*

Arguments: bool maximize, IntVar* const objective, IndexEvaluator2 objective_function, int64_t step, const std::vector<IntVar*>& vars, double penalty_factor

Creates a Guided Local Search monitor. Description here: http://en.wikipedia.org/wiki/Guided_Local_Search

MakeGuidedLocalSearch

Return type: SearchMonitor*

Arguments: bool maximize, IntVar* const objective, IndexEvaluator3 objective_function, int64_t step, const std::vector<IntVar*>& vars, const std::vector<IntVar*>& secondary_vars, double penalty_factor

MakeIfThenElseCt

Return type: Constraint*

Arguments: IntVar* const condition, IntExpr* const then_expr, IntExpr* const else_expr, IntVar* const target_var

Special cases with arrays of size two.

MakeImprovementLimit

Return type: ABSL_MUST_USE_RESULT ImprovementSearchLimit*

Arguments: IntVar* objective_var, bool 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.

MakeIndexExpression

Return type: IntExpr*

Arguments: const std::vector<IntVar*>& vars, int64_t value

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

MakeIndexOfConstraint

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, IntVar* const index, int64_t 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.

MakeIndexOfFirstMaxValueConstraint

Return type: Constraint*

Arguments: IntVar* index, const std::vector<IntVar*>& vars

Creates a constraint that binds the index variable to the index of the first variable with the maximum value.

MakeIndexOfFirstMinValueConstraint

Return type: Constraint*

Arguments: IntVar* index, const std::vector<IntVar*>& vars

Creates a constraint that binds the index variable to the index of the first variable with the minimum value.

MakeIntConst

Return type: IntVar*

Arguments: int64_t val, const std::string& name

IntConst will create a constant expression.

MakeIntConst

Return type: IntVar*

Arguments: int64_t val

IntConst will create a constant expression.

MakeIntervalRelaxedMax

Return type: IntervalVar*

Arguments: IntervalVar* const 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.

MakeIntervalRelaxedMin

Return type: IntervalVar*

Arguments: IntervalVar* const 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.

MakeIntervalVar

Return type: IntervalVar*

Arguments: int64_t start_min, int64_t start_max, int64_t duration_min, int64_t duration_max, int64_t end_min, int64_t end_max, bool optional, const std::string& name

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

MakeIntervalVarArray

Return type: void

Arguments: int count, int64_t start_min, int64_t start_max, int64_t duration_min, int64_t duration_max, int64_t end_min, int64_t end_max, bool optional, const std::string& name, std::vector<IntervalVar*>* const array

This method fills the vector with 'count' interval var built with the corresponding parameters.

MakeIntervalVarRelation

Return type: Constraint*

Arguments: IntervalVar* const t, UnaryIntervalRelation r, int64_t d

This method creates a relation between an interval var and a date.

MakeIntervalVarRelation

Return type: Constraint*

Arguments: IntervalVar* const t1, BinaryIntervalRelation r, IntervalVar* const t2

This method creates a relation between two interval vars.

MakeIntervalVarRelationWithDelay

Return type: Constraint*

Arguments: IntervalVar* const t1, BinaryIntervalRelation r, IntervalVar* const t2, int64_t 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.

MakeIntVar

Return type: IntVar*

Arguments: int64_t min, int64_t max, const std::string& name

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

MakeIntVar

Return type: IntVar*

Arguments: const std::vector<int64_t>& values, const std::string& name

MakeIntVar will create a variable with the given sparse domain.

MakeIntVar

Return type: IntVar*

Arguments: const std::vector<int>& values, const std::string& name

MakeIntVar will create a variable with the given sparse domain.

MakeIntVar

Return type: IntVar*

Arguments: int64_t min, int64_t max

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

MakeIntVar

Return type: IntVar*

Arguments: const std::vector<int64_t>& values

MakeIntVar will create a variable with the given sparse domain.

MakeIntVar

Return type: IntVar*

Arguments: const std::vector<int>& values

MakeIntVar will create a variable with the given sparse domain.

MakeIntVarArray

Return type: void

Arguments: int var_count, int64_t vmin, int64_t vmax, const std::string& name, std::vector<IntVar*>* vars

This method will append the vector vars with 'var_count' variables having bounds vmin and vmax and having name "name" where is the index of the variable.

MakeIntVarArray

Return type: void

Arguments: int var_count, int64_t vmin, int64_t vmax, std::vector<IntVar*>* vars

This method will append the vector vars with 'var_count' variables having bounds vmin and vmax and having no names.

MakeIntVarArray

Return type: IntVar**

Arguments: int var_count, int64_t vmin, int64_t vmax, const std::string& name

Same but allocates an array and returns it.

MakeInversePermutationConstraint

Return type: Constraint*

Arguments: const std::vector<IntVar*>& left, const std::vector<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.

MakeIsBetweenCt

Return type: Constraint*

Arguments: IntExpr* const expr, int64_t l, int64_t u, IntVar* const b

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

MakeIsBetweenVar

Return type: IntVar*

Arguments: IntExpr* const v, int64_t l, int64_t u

MakeIsDifferentCstCt

Return type: Constraint*

Arguments: IntExpr* const var, int64_t value, IntVar* const boolvar

boolvar == (var != value)

MakeIsDifferentCstVar

Return type: IntVar*

Arguments: IntExpr* const var, int64_t value

status var of (var != value)

MakeIsDifferentCt

Return type: Constraint*

Arguments: IntExpr* const v1, IntExpr* const v2, IntVar* const b

b == (v1 != v2)

MakeIsDifferentVar

Return type: IntVar*

Arguments: IntExpr* const v1, IntExpr* const v2

status var of (v1 != v2)

MakeIsEqualCstCt

Return type: Constraint*

Arguments: IntExpr* const var, int64_t value, IntVar* const boolvar

boolvar == (var == value)

MakeIsEqualCstVar

Return type: IntVar*

Arguments: IntExpr* const var, int64_t value

status var of (var == value)

MakeIsEqualCt

Return type: Constraint*

Arguments: IntExpr* const v1, IntExpr* v2, IntVar* const b

b == (v1 == v2)

MakeIsEqualVar

Return type: IntVar*

Arguments: IntExpr* const v1, IntExpr* v2

status var of (v1 == v2)

MakeIsGreaterCstCt

Return type: Constraint*

Arguments: IntExpr* const v, int64_t c, IntVar* const b

b == (v > c)

MakeIsGreaterCstVar

Return type: IntVar*

Arguments: IntExpr* const var, int64_t value

status var of (var > value)

MakeIsGreaterCt

Return type: Constraint*

Arguments: IntExpr* const left, IntExpr* const right, IntVar* const b

b == (left > right)

MakeIsGreaterOrEqualCstCt

Return type: Constraint*

Arguments: IntExpr* const var, int64_t value, IntVar* const boolvar

boolvar == (var >= value)

MakeIsGreaterOrEqualCstVar

Return type: IntVar*

Arguments: IntExpr* const var, int64_t value

status var of (var >= value)

MakeIsGreaterOrEqualCt

Return type: Constraint*

Arguments: IntExpr* const left, IntExpr* const right, IntVar* const b

b == (left >= right)

MakeIsGreaterOrEqualVar

Return type: IntVar*

Arguments: IntExpr* const left, IntExpr* const right

status var of (left >= right)

MakeIsGreaterVar

Return type: IntVar*

Arguments: IntExpr* const left, IntExpr* const right

status var of (left > right)

MakeIsLessCstCt

Return type: Constraint*

Arguments: IntExpr* const v, int64_t c, IntVar* const b

b == (v < c)

MakeIsLessCstVar

Return type: IntVar*

Arguments: IntExpr* const var, int64_t value

status var of (var < value)

MakeIsLessCt

Return type: Constraint*

Arguments: IntExpr* const left, IntExpr* const right, IntVar* const b

b == (left < right)

MakeIsLessOrEqualCstCt

Return type: Constraint*

Arguments: IntExpr* const var, int64_t value, IntVar* const boolvar

boolvar == (var <= value)

MakeIsLessOrEqualCstVar

Return type: IntVar*

Arguments: IntExpr* const var, int64_t value

status var of (var <= value)

MakeIsLessOrEqualCt

Return type: Constraint*

Arguments: IntExpr* const left, IntExpr* const right, IntVar* const b

b == (left <= right)

MakeIsLessOrEqualVar

Return type: IntVar*

Arguments: IntExpr* const left, IntExpr* const right

status var of (left <= right)

MakeIsLessVar

Return type: IntVar*

Arguments: IntExpr* const left, IntExpr* const right

status var of (left < right)

MakeIsMemberCt

Return type: Constraint*

Arguments: IntExpr* const expr, const std::vector<int64_t>& values, IntVar* const boolvar

boolvar == (expr in set)

MakeIsMemberCt

Return type: Constraint*

Arguments: IntExpr* const expr, const std::vector<int>& values, IntVar* const boolvar

MakeIsMemberVar

Return type: IntVar*

Arguments: IntExpr* const expr, const std::vector<int64_t>& values

MakeIsMemberVar

Return type: IntVar*

Arguments: IntExpr* const expr, const std::vector<int>& values

MakeLastSolutionCollector

Return type: SolutionCollector*

Arguments: const Assignment* const assignment

Collect the last solution of the search.

MakeLastSolutionCollector

Return type: SolutionCollector*

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

MakeLess

Return type: Constraint*

Arguments: IntExpr* const left, IntExpr* const right

left < right

MakeLess

Return type: Constraint*

Arguments: IntExpr* const expr, int64_t value

expr < value

MakeLess

Return type: Constraint*

Arguments: IntExpr* const expr, int value

expr < value

MakeLessOrEqual

Return type: Constraint*

Arguments: IntExpr* const left, IntExpr* const right

left <= right

MakeLessOrEqual

Return type: Constraint*

Arguments: IntExpr* const expr, int64_t value

expr <= value

MakeLessOrEqual

Return type: Constraint*

Arguments: IntExpr* const expr, int value

expr <= value

MakeLexicalLess

Return type: Constraint*

Arguments: const std::vector<IntVar*>& left, const std::vector<IntVar*>& right

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

MakeLexicalLessOrEqual

Return type: Constraint*

Arguments: const std::vector<IntVar*>& left, const std::vector<IntVar*>& right

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

MakeLimit

Return type: ABSL_MUST_USE_RESULT RegularLimit*

Arguments: absl::Duration time, int64_t branches, int64_t failures, int64_t solutions, bool smart_time_check = false, bool cumulative = false

Limits the search with the 'time', 'branches', 'failures' and 'solutions' limits. 'smart_time_check' reduces the calls to the wall timer by estimating the number of remaining calls, and 'cumulative' means that the limit applies cumulatively, instead of search-by-search.

MakeLimit

Return type: ABSL_MUST_USE_RESULT RegularLimit*

Arguments: const RegularLimitParameters& proto

Creates a search limit from its protobuf description

MakeLimit

Return type: ABSL_MUST_USE_RESULT RegularLimit*

Arguments: int64_t time, int64_t branches, int64_t failures, int64_t solutions, bool smart_time_check = false, bool cumulative = false

MakeLimit

Return type: ABSL_MUST_USE_RESULT SearchLimit*

Arguments: SearchLimit* const limit_1, SearchLimit* const 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.

MakeLocalSearchPhase

Return type: DecisionBuilder*

Arguments: Assignment* const assignment, LocalSearchPhaseParameters* const parameters

MakeLocalSearchPhase

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars, DecisionBuilder* const first_solution, LocalSearchPhaseParameters* const parameters

MakeLocalSearchPhase

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars, DecisionBuilder* const first_solution, DecisionBuilder* const first_solution_sub_decision_builder, LocalSearchPhaseParameters* const parameters

Variant with a sub_decison_builder specific to the first solution.

MakeLocalSearchPhase

Return type: DecisionBuilder*

Arguments: const std::vector<SequenceVar*>& vars, DecisionBuilder* const first_solution, LocalSearchPhaseParameters* const parameters

MakeLocalSearchPhaseParameters

Return type: LocalSearchPhaseParameters*

Arguments: IntVar* objective, LocalSearchOperator* const ls_operator, DecisionBuilder* const sub_decision_builder

Local Search Phase Parameters

MakeLocalSearchPhaseParameters

Return type: LocalSearchPhaseParameters*

Arguments: IntVar* objective, LocalSearchOperator* const ls_operator, DecisionBuilder* const sub_decision_builder, RegularLimit* const limit

MakeLocalSearchPhaseParameters

Return type: LocalSearchPhaseParameters*

Arguments: IntVar* objective, LocalSearchOperator* const ls_operator, DecisionBuilder* const sub_decision_builder, RegularLimit* const limit, LocalSearchFilterManager* filter_manager

MakeLocalSearchPhaseParameters

Return type: LocalSearchPhaseParameters*

Arguments: IntVar* objective, SolutionPool* const pool, LocalSearchOperator* const ls_operator, DecisionBuilder* const sub_decision_builder

MakeLocalSearchPhaseParameters

Return type: LocalSearchPhaseParameters*

Arguments: IntVar* objective, SolutionPool* const pool, LocalSearchOperator* const ls_operator, DecisionBuilder* const sub_decision_builder, RegularLimit* const limit

MakeLocalSearchPhaseParameters

Return type: LocalSearchPhaseParameters*

Arguments: IntVar* objective, SolutionPool* const pool, LocalSearchOperator* const ls_operator, DecisionBuilder* const sub_decision_builder, RegularLimit* const limit, LocalSearchFilterManager* filter_manager

MakeLubyRestart

Return type: SearchMonitor*

Arguments: 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...).

MakeMapDomain

Return type: Constraint*

Arguments: IntVar* const var, const std::vector<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);

MakeMax

Return type: IntExpr*

Arguments: const std::vector<IntVar*>& vars

std::max(vars)

MakeMax

Return type: IntExpr*

Arguments: IntExpr* const left, IntExpr* const right

std::max(left, right)

MakeMax

Return type: IntExpr*

Arguments: IntExpr* const expr, int64_t value

std::max(expr, value)

MakeMax

Return type: IntExpr*

Arguments: IntExpr* const expr, int value

std::max(expr, value)

MakeMaxEquality

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, IntVar* const max_var

MakeMaximize

Return type: OptimizeVar*

Arguments: IntVar* const v, int64_t step

Creates a maximization objective.

MakeMemberCt

Return type: Constraint*

Arguments: IntExpr* const expr, const std::vector<int64_t>& values

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

MakeMemberCt

Return type: Constraint*

Arguments: IntExpr* const expr, const std::vector<int>& values

MakeMin

Return type: IntExpr*

Arguments: const std::vector<IntVar*>& vars

std::min(vars)

MakeMin

Return type: IntExpr*

Arguments: IntExpr* const left, IntExpr* const right

std::min (left, right)

MakeMin

Return type: IntExpr*

Arguments: IntExpr* const expr, int64_t value

std::min(expr, value)

MakeMin

Return type: IntExpr*

Arguments: IntExpr* const expr, int value

std::min(expr, value)

MakeMinEquality

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, IntVar* const min_var

MakeMinimize

Return type: OptimizeVar*

Arguments: IntVar* const v, int64_t step

Creates a minimization objective.

MakeMirrorInterval

Return type: IntervalVar*

Arguments: IntervalVar* const 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.

MakeModulo

Return type: IntExpr*

Arguments: IntExpr* const x, int64_t mod

Modulo expression x % mod (with the python convention for modulo).

MakeModulo

Return type: IntExpr*

Arguments: IntExpr* const x, IntExpr* const mod

Modulo expression x % mod (with the python convention for modulo).

MakeMonotonicElement

Return type: IntExpr*

Arguments: IndexEvaluator1 values, bool increasing, IntVar* const 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.

MakeMoveTowardTargetOperator

Return type: LocalSearchOperator*

Arguments: const 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

Return type: LocalSearchOperator*

Arguments: const std::vector<IntVar*>& variables, const std::vector<int64_t>& 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.

MakeNBestValueSolutionCollector

Return type: SolutionCollector*

Arguments: const Assignment* const assignment, int solution_count, bool 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

Return type: SolutionCollector*

Arguments: int solution_count, bool maximize

MakeNeighborhoodLimit

Return type: LocalSearchOperator*

Arguments: LocalSearchOperator* const op, int64_t 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.

MakeNestedOptimize

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db, Assignment* const solution, bool maximize, int64_t 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

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db, Assignment* const solution, bool maximize, int64_t step, SearchMonitor* const monitor1

MakeNestedOptimize

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db, Assignment* const solution, bool maximize, int64_t step, SearchMonitor* const monitor1, SearchMonitor* const monitor2

MakeNestedOptimize

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db, Assignment* const solution, bool maximize, int64_t step, SearchMonitor* const monitor1, SearchMonitor* const monitor2, SearchMonitor* const monitor3

MakeNestedOptimize

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db, Assignment* const solution, bool maximize, int64_t step, SearchMonitor* const monitor1, SearchMonitor* const monitor2, SearchMonitor* const monitor3, SearchMonitor* const monitor4

MakeNestedOptimize

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db, Assignment* const solution, bool maximize, int64_t step, const std::vector<SearchMonitor*>& monitors

MakeNoCycle

Return type: Constraint*

Arguments: const std::vector<IntVar*>& nexts, const std::vector<IntVar*>& active, IndexFilter1 sink_handler = nullptr

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

Return type: Constraint*

Arguments: const std::vector<IntVar*>& nexts, const std::vector<IntVar*>& active, IndexFilter1 sink_handler, bool assume_paths

MakeNonEquality

Return type: Constraint*

Arguments: IntExpr* const left, IntExpr* const right

left != right

MakeNonEquality

Return type: Constraint*

Arguments: IntExpr* const expr, int64_t value

expr != value

MakeNonEquality

Return type: Constraint*

Arguments: IntExpr* const expr, int value

expr != value

MakeNonOverlappingBoxesConstraint

Return type: Constraint*

Arguments: const std::vector<IntVar*>& x_vars, const std::vector<IntVar*>& y_vars, const std::vector<IntVar*>& x_size, const std::vector<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

Return type: Constraint*

Arguments: const std::vector<IntVar*>& x_vars, const std::vector<IntVar*>& y_vars, const std::vector<int64_t>& x_size, const std::vector<int64_t>& y_size

MakeNonOverlappingBoxesConstraint

Return type: Constraint*

Arguments: const std::vector<IntVar*>& x_vars, const std::vector<IntVar*>& y_vars, const std::vector<int>& x_size, const std::vector<int>& y_size

MakeNonOverlappingNonStrictBoxesConstraint

Return type: Constraint*

Arguments: const std::vector<IntVar*>& x_vars, const std::vector<IntVar*>& y_vars, const std::vector<IntVar*>& x_size, const std::vector<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

Return type: Constraint*

Arguments: const std::vector<IntVar*>& x_vars, const std::vector<IntVar*>& y_vars, const std::vector<int64_t>& x_size, const std::vector<int64_t>& y_size

MakeNonOverlappingNonStrictBoxesConstraint

Return type: Constraint*

Arguments: const std::vector<IntVar*>& x_vars, const std::vector<IntVar*>& y_vars, const std::vector<int>& x_size, const std::vector<int>& y_size

MakeNotBetweenCt

Return type: Constraint*

Arguments: IntExpr* const expr, int64_t l, int64_t 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.

MakeNotMemberCt

Return type: Constraint*

Arguments: IntExpr* const expr, const std::vector<int64_t>& values

expr not in set.

MakeNotMemberCt

Return type: Constraint*

Arguments: IntExpr* const expr, const std::vector<int>& values

MakeNotMemberCt

Return type: Constraint*

Arguments: IntExpr* const expr, std::vector<int64_t> starts, std::vector<int64_t> ends

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

MakeNotMemberCt

Return type: Constraint*

Arguments: IntExpr* const expr, std::vector<int> starts, std::vector<int> ends

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

MakeNotMemberCt

Return type: Constraint*

Arguments: IntExpr* expr, SortedDisjointIntervalList intervals

expr should not be in the list of forbidden intervals.

MakeNullIntersect

Return type: Constraint*

Arguments: const std::vector<IntVar*>& first_vars, const std::vector<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

Return type: Constraint*

Arguments: const std::vector<IntVar*>& first_vars, const std::vector<IntVar*>& second_vars, int64_t 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.

MakeOperator

Return type: LocalSearchOperator*

Arguments: const std::vector<IntVar*>& vars, LocalSearchOperators op

Local Search Operators.

MakeOperator

Return type: LocalSearchOperator*

Arguments: const std::vector<IntVar*>& vars, const std::vector<IntVar*>& secondary_vars, LocalSearchOperators op

MakeOperator

Return type: LocalSearchOperator*

Arguments: const std::vector<IntVar*>& vars, IndexEvaluator3 evaluator, EvaluatorLocalSearchOperators op

TODO(user): Make the callback an IndexEvaluator2 when there are no secondary variables.

MakeOperator

Return type: LocalSearchOperator*

Arguments: const std::vector<IntVar*>& vars, const std::vector<IntVar*>& secondary_vars, IndexEvaluator3 evaluator, EvaluatorLocalSearchOperators op

MakeOpposite

Return type: IntExpr*

Arguments: IntExpr* const expr

-expr

MakeOptimize

Return type: OptimizeVar*

Arguments: bool maximize, IntVar* const v, int64_t step

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

MakePack

Return type: Pack*

Arguments: const std::vector<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.

MakePathConnected

Return type: Constraint*

Arguments: std::vector<IntVar*> nexts, std::vector<int64_t> sources, std::vector<int64_t> sinks, std::vector<IntVar*> status

Constraint enforcing that status[i] is true iff there's a path defined on next variables from sources[i] to sinks[i]. TODO(user): Only does checking on WhenBound events on next variables. Check whether more propagation is needed.

MakePathCumul

Return type: Constraint*

Arguments: const std::vector<IntVar*>& nexts, const std::vector<IntVar*>& active, const std::vector<IntVar*>& cumuls, const std::vector<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.

MakePathCumul

Return type: Constraint*

Arguments: const std::vector<IntVar*>& nexts, const std::vector<IntVar*>& active, const std::vector<IntVar*>& cumuls, IndexEvaluator2 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

Return type: Constraint*

Arguments: const std::vector<IntVar*>& nexts, const std::vector<IntVar*>& active, const std::vector<IntVar*>& cumuls, const std::vector<IntVar*>& slacks, IndexEvaluator2 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.

MakePathPrecedenceConstraint

Return type: Constraint*

Arguments: std::vector<IntVar*> nexts, const std::vector<std::pair<int, int>>& precedences

Constraint enforcing, for each pair (i,j) in precedences, i to be before j in paths defined by next variables. TODO(user): This constraint does not make holes in variable domains; the implementation can easily be modified to do that; evaluate the impact on models solved with local search.

MakePathPrecedenceConstraint

Return type: Constraint*

Arguments: std::vector<IntVar*> nexts, const std::vector<std::pair<int, int>>& precedences, const std::vector<int>& lifo_path_starts, const std::vector<int>& fifo_path_starts

Same as MakePathPrecedenceConstraint but ensures precedence pairs on some paths follow a LIFO or FIFO order. LIFO order: given 2 pairs (a,b) and (c,d), if a is before c on the path then d must be before b or b must be before c. FIFO order: given 2 pairs (a,b) and (c,d), if a is before c on the path then b must be before d. LIFO (resp. FIFO) orders are enforced only on paths starting by indices in lifo_path_starts (resp. fifo_path_start).

MakePathTransitPrecedenceConstraint

Return type: Constraint*

Arguments: std::vector<IntVar*> nexts, std::vector<IntVar*> transits, const std::vector<std::pair<int, int>>& precedences

Same as MakePathPrecedenceConstraint but will force i to be before j if the sum of transits on the path from i to j is strictly positive.

MakePhase

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars, IntVarStrategy var_str, IntValueStrategy val_str

Phases on IntVar arrays. TODO(user): name each of them differently, and document them (and do that for all other functions that have several homonyms in this .h).

MakePhase

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars, IndexEvaluator1 var_evaluator, IntValueStrategy val_str

MakePhase

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars, IntVarStrategy var_str, IndexEvaluator2 value_evaluator

MakePhase

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars, IntVarStrategy var_str, VariableValueComparator 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

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars, IndexEvaluator1 var_evaluator, IndexEvaluator2 value_evaluator

MakePhase

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars, IntVarStrategy var_str, IndexEvaluator2 value_evaluator, IndexEvaluator1 tie_breaker

MakePhase

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars, IndexEvaluator1 var_evaluator, IndexEvaluator2 value_evaluator, IndexEvaluator1 tie_breaker

MakePhase

Return type: DecisionBuilder*

Arguments: IntVar* const v0, IntVarStrategy var_str, IntValueStrategy val_str

Shortcuts for small arrays.

MakePhase

Return type: DecisionBuilder*

Arguments: IntVar* const v0, IntVar* const v1, IntVarStrategy var_str, IntValueStrategy val_str

MakePhase

Return type: DecisionBuilder*

Arguments: IntVar* const v0, IntVar* const v1, IntVar* const v2, IntVarStrategy var_str, IntValueStrategy val_str

MakePhase

Return type: DecisionBuilder*

Arguments: IntVar* const v0, IntVar* const v1, IntVar* const v2, IntVar* const v3, IntVarStrategy var_str, IntValueStrategy val_str

MakePhase

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars, IndexEvaluator2 eval, EvaluatorStrategy 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

Return type: DecisionBuilder*

Arguments: const std::vector<IntVar*>& vars, IndexEvaluator2 eval, IndexEvaluator1 tie_breaker, EvaluatorStrategy 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

Return type: DecisionBuilder*

Arguments: const std::vector<IntervalVar*>& intervals, IntervalStrategy str

Scheduling phases.

MakePhase

Return type: DecisionBuilder*

Arguments: const std::vector<SequenceVar*>& sequences, SequenceStrategy str

MakePiecewiseLinearExpr

Return type: IntExpr*

Arguments: IntExpr* expr, const PiecewiseLinearFunction& f

MakePower

Return type: IntExpr*

Arguments: IntExpr* const expr, int64_t n

expr ^ n (n > 0)

MakePrintModelVisitor

Return type: ModelVisitor*

Prints the model.

MakeProd

Return type: IntExpr*

Arguments: IntExpr* const left, IntExpr* const right

left * right

MakeProd

Return type: IntExpr*

Arguments: IntExpr* const expr, int64_t value

expr * value

MakeProfiledDecisionBuilderWrapper

Return type: DecisionBuilder*

Arguments: DecisionBuilder* db

Activates profiling on a decision builder.

MakeRandomLnsOperator

Return type: LocalSearchOperator*

Arguments: const std::vector<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

Return type: LocalSearchOperator*

Arguments: const std::vector<IntVar*>& vars, int number_of_variables, int32_t seed

MakeRankFirstInterval

Return type: Decision*

Arguments: SequenceVar* const sequence, int index

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

MakeRankLastInterval

Return type: Decision*

Arguments: SequenceVar* const sequence, int index

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

MakeRejectFilter

Return type: LocalSearchFilter*

MakeRestoreAssignment

Return type: DecisionBuilder*

Arguments: Assignment* assignment

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

MakeScalProd

Return type: IntExpr*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int64_t>& coefs

scalar product

MakeScalProd

Return type: IntExpr*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int>& coefs

scalar product

MakeScalProdEquality

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int64_t>& coefficients, int64_t cst

MakeScalProdEquality

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int>& coefficients, int64_t cst

MakeScalProdEquality

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int64_t>& coefficients, IntVar* const target

MakeScalProdEquality

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int>& coefficients, IntVar* const target

MakeScalProdGreaterOrEqual

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int64_t>& coeffs, int64_t cst

MakeScalProdGreaterOrEqual

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int>& coeffs, int64_t cst

MakeScalProdLessOrEqual

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int64_t>& coefficients, int64_t cst

MakeScalProdLessOrEqual

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<int>& coefficients, int64_t cst

MakeScheduleOrExpedite

Return type: Decision*

Arguments: IntervalVar* const var, int64_t est, int64_t* const 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.

MakeScheduleOrPostpone

Return type: Decision*

Arguments: IntervalVar* const var, int64_t est, int64_t* const 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.

MakeSearchLog

Return type: SearchMonitor*

Arguments: int branch_period

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

MakeSearchLog

Return type: SearchMonitor*

Arguments: int branch_period, IntVar* const var

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

MakeSearchLog

Return type: SearchMonitor*

Arguments: int branch_period, std::function<std::string()> display_callback

At each solution, this monitor will also display result of @p display_callback.

MakeSearchLog

Return type: SearchMonitor*

Arguments: int branch_period, IntVar* var, std::function<std::string()> display_callback

At each solution, this monitor will display the 'var' value and the result of @p display_callback.

MakeSearchLog

Return type: SearchMonitor*

Arguments: int branch_period, OptimizeVar* const opt_var

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

MakeSearchLog

Return type: SearchMonitor*

Arguments: int branch_period, OptimizeVar* const opt_var, std::function<std::string()> display_callback

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

MakeSearchLog

Return type: SearchMonitor*

Arguments: SearchLogParameters parameters

MakeSearchTrace

Return type: SearchMonitor*

Arguments: const std::string& prefix

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

MakeSemiContinuousExpr

Return type: IntExpr*

Arguments: IntExpr* const expr, int64_t fixed_charge, int64_t step

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

MakeSimulatedAnnealing

Return type: SearchMonitor*

Arguments: bool maximize, IntVar* const v, int64_t step, int64_t initial_temperature

Creates a Simulated Annealing monitor. TODO(user): document behavior

MakeSolutionsLimit

Return type: ABSL_MUST_USE_RESULT RegularLimit*

Arguments: int64_t solutions

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

MakeSolveOnce

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const 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

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db, SearchMonitor* const monitor1

MakeSolveOnce

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db, SearchMonitor* const monitor1, SearchMonitor* const monitor2

MakeSolveOnce

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db, SearchMonitor* const monitor1, SearchMonitor* const monitor2, SearchMonitor* const monitor3

MakeSolveOnce

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db, SearchMonitor* const monitor1, SearchMonitor* const monitor2, SearchMonitor* const monitor3, SearchMonitor* const monitor4

MakeSolveOnce

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db, const std::vector<SearchMonitor*>& monitors

MakeSortingConstraint

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<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

MakeSplitVariableDomain

Return type: Decision*

Arguments: IntVar* const var, int64_t val, bool start_with_lower_half

MakeSquare

Return type: IntExpr*

Arguments: IntExpr* const expr

expr * expr

MakeStatisticsModelVisitor

Return type: ModelVisitor*

Displays some nice statistics on the model.

MakeStoreAssignment

Return type: DecisionBuilder*

Arguments: Assignment* assignment

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

MakeStrictDisjunctiveConstraint

Return type: DisjunctiveConstraint*

Arguments: const std::vector<IntervalVar*>& intervals, const std::string& name

This constraint forces all interval vars into an non-overlapping sequence. Intervals with zero durations cannot overlap with over intervals.

MakeSubCircuit

Return type: Constraint*

Arguments: const std::vector<IntVar*>& nexts

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

MakeSum

Return type: IntExpr*

Arguments: IntExpr* const left, IntExpr* const right

left + right.

MakeSum

Return type: IntExpr*

Arguments: IntExpr* const expr, int64_t value

expr + value.

MakeSum

Return type: IntExpr*

Arguments: const std::vector<IntVar*>& vars

sum of all vars.

MakeSumEquality

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, int64_t cst

MakeSumEquality

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, IntVar* const var

MakeSumGreaterOrEqual

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, int64_t cst

MakeSumLessOrEqual

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, int64_t cst

Variation on arrays.

MakeSumObjectiveFilter

Return type: IntVarLocalSearchFilter*

Arguments: const std::vector<IntVar*>& vars, IndexEvaluator2 values, Solver::LocalSearchFilterBound filter_enum

MakeSumObjectiveFilter

Return type: IntVarLocalSearchFilter*

Arguments: const std::vector<IntVar*>& vars, const std::vector<IntVar*>& secondary_vars, IndexEvaluator3 values, Solver::LocalSearchFilterBound filter_enum

MakeSymmetryManager

Return type: SearchMonitor*

Arguments: const std::vector<SymmetryBreaker*>& visitors

Symmetry Breaking.

MakeSymmetryManager

Return type: SearchMonitor*

Arguments: SymmetryBreaker* const v1

MakeSymmetryManager

Return type: SearchMonitor*

Arguments: SymmetryBreaker* const v1, SymmetryBreaker* const v2

MakeSymmetryManager

Return type: SearchMonitor*

Arguments: SymmetryBreaker* const v1, SymmetryBreaker* const v2, SymmetryBreaker* const v3

MakeSymmetryManager

Return type: SearchMonitor*

Arguments: SymmetryBreaker* const v1, SymmetryBreaker* const v2, SymmetryBreaker* const v3, SymmetryBreaker* const v4

MakeTabuSearch

Return type: SearchMonitor*

Arguments: bool maximize, IntVar* const v, int64_t step, const std::vector<IntVar*>& vars, int64_t keep_tenure, int64_t forbid_tenure, double tabu_factor

MakeTemporalDisjunction

Return type: Constraint*

Arguments: IntervalVar* const t1, IntervalVar* const t2, IntVar* const 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

Return type: Constraint*

Arguments: IntervalVar* const t1, IntervalVar* const t2

This constraint implements a temporal disjunction between two interval vars.

MakeTimeLimit

Return type: ABSL_MUST_USE_RESULT RegularLimit*

Arguments: absl::Duration time

Creates a search limit that constrains the running time.

MakeTimeLimit

Return type: ABSL_MUST_USE_RESULT RegularLimit*

Arguments: int64_t time_in_ms

MakeTransitionConstraint

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const IntTupleSet& transition_table, int64_t initial_state, const std::vector<int64_t>& 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

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const IntTupleSet& transition_table, int64_t initial_state, const std::vector<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.

MakeTransitionConstraint

Return type: Constraint*

Arguments: const std::vector<IntVar*>& vars, const std::vector<std::vector<int64_t> /*keep for swig*/>& raw_transitions, int64_t initial_state, const std::vector<int>& final_states

MakeTrueConstraint

Return type: Constraint*

This constraint always succeeds.

MakeVariableDegreeVisitor

Return type: ModelVisitor*

Arguments: absl::flat_hash_map<const IntVar*, int>* const map

Compute the number of constraints a variable is attached to.

MakeVariableDomainFilter

Return type: LocalSearchFilter*

MakeVariableGreaterOrEqualValue

Return type: Decision*

Arguments: IntVar* const var, int64_t value

MakeVariableLessOrEqualValue

Return type: Decision*

Arguments: IntVar* const var, int64_t value

MakeWeightedMaximize

Return type: OptimizeVar*

Arguments: const std::vector<IntVar*>& sub_objectives, const std::vector<int64_t>& weights, int64_t step

Creates a maximization weigthed objective.

MakeWeightedMaximize

Return type: OptimizeVar*

Arguments: const std::vector<IntVar*>& sub_objectives, const std::vector<int>& weights, int64_t step

Creates a maximization weigthed objective.

MakeWeightedMinimize

Return type: OptimizeVar*

Arguments: const std::vector<IntVar*>& sub_objectives, const std::vector<int64_t>& weights, int64_t step

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

MakeWeightedMinimize

Return type: OptimizeVar*

Arguments: const std::vector<IntVar*>& sub_objectives, const std::vector<int>& weights, int64_t step

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

MakeWeightedOptimize

Return type: OptimizeVar*

Arguments: bool maximize, const std::vector<IntVar*>& sub_objectives, const std::vector<int64_t>& weights, int64_t step

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

MakeWeightedOptimize

Return type: OptimizeVar*

Arguments: bool maximize, const std::vector<IntVar*>& sub_objectives, const std::vector<int>& weights, int64_t step

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

MemoryUsage

Return type: static int64_t

Current memory usage in bytes

model_name

Return type: std::string

Returns the name of the model.

MultiArmedBanditConcatenateOperators

Return type: LocalSearchOperator*

Arguments: const std::vector<LocalSearchOperator*>& ops, double memory_coefficient, double exploration_coefficient, bool 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.

NameAllVariables

Return type: bool

Returns whether all variables should be named.

neighbors

Return type: int64_t

The number of neighbors created.

NewSearch

Return type: void

Arguments: DecisionBuilder* const db, const std::vector<SearchMonitor*>& monitors

NewSearch

Return type: void

Arguments: DecisionBuilder* const db

NewSearch

Return type: void

Arguments: DecisionBuilder* const db, SearchMonitor* const m1

NewSearch

Return type: void

Arguments: DecisionBuilder* const db, SearchMonitor* const m1, SearchMonitor* const m2

NewSearch

Return type: void

Arguments: DecisionBuilder* const db, SearchMonitor* const m1, SearchMonitor* const m2, SearchMonitor* const m3

NewSearch

Return type: void

Arguments: DecisionBuilder* const db, SearchMonitor* const m1, SearchMonitor* const m2, SearchMonitor* const m3, SearchMonitor* const m4

NextSolution

Return type: bool

Now

Return type: absl::Time

The 'absolute time' as seen by the solver. Unless a user-provided clock was injected via SetClock() (eg. for unit tests), this is a real walltime, shifted so that it was 0 at construction. All so-called "walltime" limits are relative to this time.

optimization_direction

Return type: OptimizationDirection

The direction of optimization, getter and setter.

parameters

Return type: ConstraintSolverParameters

Stored Parameters.

PopState

Return type: void

PushState

Return type: void

The PushState and PopState methods manipulates the states of the reversible objects. They are visible only because they are useful to write unitary tests.

Rand32

Return type: int32_t

Arguments: int32_t size

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

Rand64

Return type: int64_t

Arguments: int64_t size

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

RandomConcatenateOperators

Return type: LocalSearchOperator*

Arguments: const std::vector<LocalSearchOperator*>& ops

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

RandomConcatenateOperators

Return type: LocalSearchOperator*

Arguments: const std::vector<LocalSearchOperator*>& ops, int32_t 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.

RegisterDemon

Return type: Demon*

Arguments: Demon* const demon

Adds a new demon and wraps it inside a DemonProfiler if necessary.

RegisterIntervalVar

Return type: IntervalVar*

Arguments: IntervalVar* const var

Registers a new IntervalVar and wraps it inside a TraceIntervalVar if necessary.

RegisterIntExpr

Return type: IntExpr*

Arguments: IntExpr* const expr

Registers a new IntExpr and wraps it inside a TraceIntExpr if necessary.

RegisterIntVar

Return type: IntVar*

Arguments: IntVar* const var

Registers a new IntVar and wraps it inside a TraceIntVar if necessary.

ReSeed

Return type: void

Arguments: int32_t seed

Reseed the solver random generator.

RestartCurrentSearch

Return type: void

RestartSearch

Return type: void

RevAlloc

Return type: T*

Arguments: T* object

RevAllocArray

Return type: T*

Arguments: T* object

SaveAndAdd

Return type: void

Arguments: T* adr, T val

SaveAndSetValue

Return type: void

Arguments: T* adr, T val

SaveValue

Return type: void

Arguments: T* o

SearchContext

Return type: std::string

SearchContext

Return type: std::string

Arguments: const Search* search

SearchDepth

Return type: int

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

SearchLeftDepth

Return type: int

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

set_fail_intercept

Return type: void

Arguments: std::function<void()> fail_intercept

set_optimization_direction

Return type: void

Arguments: OptimizationDirection direction

SetBranchSelector

Return type: void

Arguments: BranchSelector bs

Sets the given branch selector on the current active search.

SetSearchContext

Return type: void

Arguments: Search* search, const std::string& search_context

SetUseFastLocalSearch

Return type: void

Arguments: bool use_fast_local_search

TODO(user): Get rid of the following methods once fast local search is enabled for metaheuristics. Disables/enables fast local search.

ShouldFail

Return type: void

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

solutions

Return type: int64_t

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

Solve

Return type: bool

Arguments: DecisionBuilder* const db, const std::vector<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(). @param db The decision builder that will generate the search tree. @param monitors A vector of search monitors that will be notified of various events during the search. In their reaction to these events, such monitors may influence the search.

Solve

Return type: bool

Arguments: DecisionBuilder* const db

Solve

Return type: bool

Arguments: DecisionBuilder* const db, SearchMonitor* const m1

Solve

Return type: bool

Arguments: DecisionBuilder* const db, SearchMonitor* const m1, SearchMonitor* const m2

Solve

Return type: bool

Arguments: DecisionBuilder* const db, SearchMonitor* const m1, SearchMonitor* const m2, SearchMonitor* const m3

Solve

Return type: bool

Arguments: DecisionBuilder* const db, SearchMonitor* const m1, SearchMonitor* const m2, SearchMonitor* const m3, SearchMonitor* const m4

SolveAndCommit

Return type: bool

Arguments: DecisionBuilder* const db, const std::vector<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

Return type: bool

Arguments: DecisionBuilder* const db

SolveAndCommit

Return type: bool

Arguments: DecisionBuilder* const db, SearchMonitor* const m1

SolveAndCommit

Return type: bool

Arguments: DecisionBuilder* const db, SearchMonitor* const m1, SearchMonitor* const m2

SolveAndCommit

Return type: bool

Arguments: DecisionBuilder* const db, SearchMonitor* const m1, SearchMonitor* const m2, SearchMonitor* const m3

SolveDepth

Return type: int

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.

Solver

Return type: explicit

Arguments: const std::string& name

Solver API

Solver

Arguments: const std::string& name, const ConstraintSolverParameters& parameters

~Solver

stamp

Return type: uint64_t

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.

state

Return type: SolverState

State of the solver.

TopPeriodicCheck

Return type: void

Performs PeriodicCheck on the top-level search; for instance, can be called from a nested solve to check top-level limits.

TopProgressPercent

Return type: int

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

Try

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db1, DecisionBuilder* const 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. TODO(user): The search tree can be balanced by using binary "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.

Try

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db1, DecisionBuilder* const db2, DecisionBuilder* const db3

Try

Return type: DecisionBuilder*

Arguments: DecisionBuilder* const db1, DecisionBuilder* const db2, DecisionBuilder* const db3, DecisionBuilder* const db4

Try

Return type: DecisionBuilder*

Arguments: const std::vector<DecisionBuilder*>& dbs

unchecked_solutions

Return type: int64_t

The number of unchecked solutions found by local search.

UseFastLocalSearch

Return type: bool

Returns true if fast local search is enabled.

wall_time

Return type: int64_t

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