Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::Solver Class Reference

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

#include <constraint_solver.h>

Classes

struct  IntegerCastInfo
 
struct  PathEnergyCostConstraintSpecification
 
struct  SearchLogParameters
 Creates a search monitor from logging parameters. More...
 

Public Types

enum  IntVarStrategy {
  INT_VAR_DEFAULT , INT_VAR_SIMPLE , CHOOSE_FIRST_UNBOUND , CHOOSE_RANDOM ,
  CHOOSE_MIN_SIZE_LOWEST_MIN , CHOOSE_MIN_SIZE_HIGHEST_MIN , CHOOSE_MIN_SIZE_LOWEST_MAX , CHOOSE_MIN_SIZE_HIGHEST_MAX ,
  CHOOSE_LOWEST_MIN , CHOOSE_HIGHEST_MAX , CHOOSE_MIN_SIZE , CHOOSE_MAX_SIZE ,
  CHOOSE_MAX_REGRET_ON_MIN , CHOOSE_PATH
}
 
enum  IntValueStrategy {
  INT_VALUE_DEFAULT , INT_VALUE_SIMPLE , ASSIGN_MIN_VALUE , ASSIGN_MAX_VALUE ,
  ASSIGN_RANDOM_VALUE , ASSIGN_CENTER_VALUE , SPLIT_LOWER_HALF , SPLIT_UPPER_HALF
}
 
enum  EvaluatorStrategy { CHOOSE_STATIC_GLOBAL_BEST , CHOOSE_DYNAMIC_GLOBAL_BEST }
 
enum  SequenceStrategy { SEQUENCE_DEFAULT , SEQUENCE_SIMPLE , CHOOSE_MIN_SLACK_RANK_FORWARD , CHOOSE_RANDOM_RANK_FORWARD }
 Used for scheduling. Not yet implemented. More...
 
enum  IntervalStrategy { INTERVAL_DEFAULT , INTERVAL_SIMPLE , INTERVAL_SET_TIMES_FORWARD , INTERVAL_SET_TIMES_BACKWARD }
 
enum  LocalSearchOperators {
  TWOOPT , OROPT , RELOCATE , EXCHANGE ,
  CROSS , MAKEACTIVE , MAKEINACTIVE , MAKECHAININACTIVE ,
  SWAPACTIVE , EXTENDEDSWAPACTIVE , PATHLNS , FULLPATHLNS ,
  UNACTIVELNS , INCREMENT , DECREMENT , SIMPLELNS
}
 
enum  EvaluatorLocalSearchOperators { LK , TSPOPT , TSPLNS }
 
enum  LocalSearchFilterBound { GE , LE , EQ }
 
enum  DemonPriority { DELAYED_PRIORITY = 0 , VAR_PRIORITY = 1 , NORMAL_PRIORITY = 2 }
 
enum  BinaryIntervalRelation {
  ENDS_AFTER_END , ENDS_AFTER_START , ENDS_AT_END , ENDS_AT_START ,
  STARTS_AFTER_END , STARTS_AFTER_START , STARTS_AT_END , STARTS_AT_START ,
  STAYS_IN_SYNC
}
 
enum  UnaryIntervalRelation {
  ENDS_AFTER , ENDS_AT , ENDS_BEFORE , STARTS_AFTER ,
  STARTS_AT , STARTS_BEFORE , CROSS_DATE , AVOID_DATE
}
 
enum  DecisionModification {
  NO_CHANGE , KEEP_LEFT , KEEP_RIGHT , KILL_BOTH ,
  SWITCH_BRANCHES
}
 
enum  MarkerType { SENTINEL , SIMPLE_MARKER , CHOICE_POINT , REVERSIBLE_ACTION }
 
enum  SolverState {
  OUTSIDE_SEARCH , IN_ROOT_NODE , IN_SEARCH , AT_SOLUTION ,
  NO_MORE_SOLUTIONS , PROBLEM_INFEASIBLE
}
 This enum represents the state of the solver w.r.t. the search. More...
 
enum  OptimizationDirection { NOT_SET , MAXIMIZATION , MINIMIZATION }
 Optimization directions. More...
 
enum class  MonitorEvent : int {
  kEnterSearch = 0 , kRestartSearch , kExitSearch , kBeginNextDecision ,
  kEndNextDecision , kApplyDecision , kRefuteDecision , kAfterDecision ,
  kBeginFail , kEndFail , kBeginInitialPropagation , kEndInitialPropagation ,
  kAcceptSolution , kAtSolution , kNoMoreSolutions , kLocalOptimum ,
  kAcceptDelta , kAcceptNeighbor , kAcceptUncheckedNeighbor , kIsUncheckedSolutionLimitReached ,
  kPeriodicCheck , kProgressPercent , kAccept , kLast
}
 Search monitor events. More...
 
typedef std::function< int64_t(int64_t)> IndexEvaluator1
 Callback typedefs.
 
typedef std::function< int64_t(int64_t, int64_t)> IndexEvaluator2
 
typedef std::function< int64_t(int64_t, int64_t, int64_t)> IndexEvaluator3
 
typedef std::function< bool(int64_t)> IndexFilter1
 
typedef std::function< IntVar *(int64_t)> Int64ToIntVar
 
typedef std::function< int64_t(Solver *solver, const std::vector< IntVar * > &vars, int64_t first_unbound, int64_t last_unbound)> VariableIndexSelector
 
typedef std::function< int64_t(const IntVar *v, int64_t id)> VariableValueSelector
 
typedef std::function< bool(int64_t, int64_t, int64_t)> VariableValueComparator
 
typedef std::function< DecisionModification()> BranchSelector
 
typedef std::function< void(Solver *)> Action
 
typedef std::function< void()> Closure
 

Public Member Functions

 Solver (const std::string &name)
 Solver API.
 
 Solver (const std::string &name, const ConstraintSolverParameters &parameters)
 
 Solver (const Solver &)=delete
 This type is neither copyable nor movable.
 
Solveroperator= (const Solver &)=delete
 
 ~Solver ()
 
ConstraintSolverParameters parameters () const
 Stored Parameters.
 
const ConstraintSolverParameters & const_parameters () const
 Read-only.
 
template<class T >
void SaveValue (T *o)
 reversibility
 
template<typename T >
T * RevAlloc (T *object)
 
template<typename T >
T * RevAllocArray (T *object)
 
void AddConstraint (Constraint *c)
 
void AddCastConstraint (CastConstraint *constraint, IntVar *target_var, IntExpr *expr)
 
bool SolveAndCommit (DecisionBuilder *db, const std::vector< SearchMonitor * > &monitors)
 
bool SolveAndCommit (DecisionBuilder *db)
 
bool SolveAndCommit (DecisionBuilder *db, SearchMonitor *m1)
 
bool SolveAndCommit (DecisionBuilder *db, SearchMonitor *m1, SearchMonitor *m2)
 
bool SolveAndCommit (DecisionBuilder *db, SearchMonitor *m1, SearchMonitor *m2, SearchMonitor *m3)
 
bool CheckAssignment (Assignment *solution)
 Checks whether the given assignment satisfies all relevant constraints.
 
bool CheckConstraint (Constraint *ct)
 
SolverState state () const
 State of the solver.
 
void Fail ()
 Abandon the current branch in the search tree. A backtrack will follow.
 
void AddBacktrackAction (Action a, bool fast)
 
std::string DebugString () const
 !defined(SWIG)
 
absl::Time Now () const
 
int64_t wall_time () const
 
int64_t branches () const
 The number of branches explored since the creation of the solver.
 
int64_t solutions () const
 The number of solutions found since the start of the search.
 
int64_t unchecked_solutions () const
 The number of unchecked solutions found by local search.
 
int64_t demon_runs (DemonPriority p) const
 The number of demons executed during search for a given priority.
 
int64_t failures () const
 The number of failures encountered since the creation of the solver.
 
int64_t neighbors () const
 The number of neighbors created.
 
void ClearNeighbors ()
 
void IncrementNeighbors ()
 
int64_t filtered_neighbors () const
 The number of filtered neighbors (neighbors accepted by filters).
 
int64_t accepted_neighbors () const
 The number of accepted neighbors.
 
uint64_t stamp () const
 
uint64_t fail_stamp () const
 The fail_stamp() is incremented after each backtrack.
 
void set_context (absl::string_view context)
 Sets the current context of the search.
 
const std::string & context () const
 Gets the current context of the search.
 
OptimizationDirection optimization_direction () const
 The direction of optimization, getter and setter.
 
void set_optimization_direction (OptimizationDirection direction)
 
IntVarMakeIntVar (int64_t min, int64_t max, const std::string &name)
 --— Int Variables and Constants --—
 
IntVarMakeIntVar (const std::vector< int64_t > &values, const std::string &name)
 MakeIntVar will create a variable with the given sparse domain.
 
IntVarMakeIntVar (const std::vector< int > &values, const std::string &name)
 MakeIntVar will create a variable with the given sparse domain.
 
IntVarMakeIntVar (int64_t min, int64_t max)
 MakeIntVar will create the best range based int var for the bounds given.
 
IntVarMakeIntVar (const std::vector< int64_t > &values)
 MakeIntVar will create a variable with the given sparse domain.
 
IntVarMakeIntVar (const std::vector< int > &values)
 MakeIntVar will create a variable with the given sparse domain.
 
IntVarMakeBoolVar (const std::string &name)
 MakeBoolVar will create a variable with a {0, 1} domain.
 
IntVarMakeBoolVar ()
 MakeBoolVar will create a variable with a {0, 1} domain.
 
IntVarMakeIntConst (int64_t val, const std::string &name)
 IntConst will create a constant expression.
 
IntVarMakeIntConst (int64_t val)
 IntConst will create a constant expression.
 
void MakeIntVarArray (int var_count, int64_t vmin, int64_t vmax, const std::string &name, std::vector< IntVar * > *vars)
 
void MakeIntVarArray (int var_count, int64_t vmin, int64_t vmax, std::vector< IntVar * > *vars)
 
IntVar ** MakeIntVarArray (int var_count, int64_t vmin, int64_t vmax, const std::string &name)
 Same but allocates an array and returns it.
 
void MakeBoolVarArray (int var_count, const std::string &name, std::vector< IntVar * > *vars)
 
void MakeBoolVarArray (int var_count, std::vector< IntVar * > *vars)
 
IntVar ** MakeBoolVarArray (int var_count, const std::string &name)
 Same but allocates an array and returns it.
 
IntExprMakeSum (IntExpr *left, IntExpr *right)
 --— Integer Expressions --—
 
IntExprMakeSum (IntExpr *expr, int64_t value)
 expr + value.
 
IntExprMakeSum (const std::vector< IntVar * > &vars)
 sum of all vars.
 
IntExprMakeScalProd (const std::vector< IntVar * > &vars, const std::vector< int64_t > &coefs)
 scalar product
 
IntExprMakeScalProd (const std::vector< IntVar * > &vars, const std::vector< int > &coefs)
 scalar product
 
IntExprMakeDifference (IntExpr *left, IntExpr *right)
 left - right
 
IntExprMakeDifference (int64_t value, IntExpr *expr)
 value - expr
 
IntExprMakeOpposite (IntExpr *expr)
 -expr
 
IntExprMakeProd (IntExpr *left, IntExpr *right)
 left * right
 
IntExprMakeProd (IntExpr *expr, int64_t value)
 expr * value
 
IntExprMakeDiv (IntExpr *expr, int64_t value)
 expr / value (integer division)
 
IntExprMakeDiv (IntExpr *numerator, IntExpr *denominator)
 numerator / denominator (integer division). Terms need to be positive.
 
IntExprMakeAbs (IntExpr *expr)
 expr
 
IntExprMakeSquare (IntExpr *expr)
 expr * expr
 
IntExprMakePower (IntExpr *expr, int64_t n)
 expr ^ n (n > 0)
 
IntExprMakeElement (const std::vector< int64_t > &values, IntVar *index)
 values[index]
 
IntExprMakeElement (const std::vector< int > &values, IntVar *index)
 values[index]
 
IntExprMakeElement (IndexEvaluator1 values, IntVar *index)
 
IntExprMakeMonotonicElement (IndexEvaluator1 values, bool increasing, IntVar *index)
 
IntExprMakeElement (IndexEvaluator2 values, IntVar *index1, IntVar *index2)
 2D version of function-based element expression, values(expr1, expr2).
 
IntExprMakeElement (const std::vector< IntVar * > &vars, IntVar *index)
 vars[expr]
 
IntExprMakeElement (Int64ToIntVar vars, int64_t range_start, int64_t range_end, IntVar *argument)
 vars(argument)
 
template<typename F >
ConstraintMakeLightElement (F values, IntVar *const var, IntVar *const index, std::function< bool()> deep_serialize=nullptr)
 
template<typename F >
ConstraintMakeLightElement (F values, IntVar *const var, IntVar *const index1, IntVar *const index2, std::function< bool()> deep_serialize=nullptr)
 
IntExprMakeIndexExpression (const std::vector< IntVar * > &vars, int64_t value)
 
ConstraintMakeIfThenElseCt (IntVar *condition, IntExpr *then_expr, IntExpr *else_expr, IntVar *target_var)
 Special cases with arrays of size two.
 
IntExprMakeMin (const std::vector< IntVar * > &vars)
 std::min(vars)
 
IntExprMakeMin (IntExpr *left, IntExpr *right)
 std::min (left, right)
 
IntExprMakeMin (IntExpr *expr, int64_t value)
 std::min(expr, value)
 
IntExprMakeMin (IntExpr *expr, int value)
 std::min(expr, value)
 
IntExprMakeMax (const std::vector< IntVar * > &vars)
 std::max(vars)
 
IntExprMakeMax (IntExpr *left, IntExpr *right)
 std::max(left, right)
 
IntExprMakeMax (IntExpr *expr, int64_t value)
 std::max(expr, value)
 
IntExprMakeMax (IntExpr *expr, int value)
 std::max(expr, value)
 
IntExprMakeConvexPiecewiseExpr (IntExpr *expr, int64_t early_cost, int64_t early_date, int64_t late_date, int64_t late_cost)
 Convex piecewise function.
 
IntExprMakeSemiContinuousExpr (IntExpr *expr, int64_t fixed_charge, int64_t step)
 
IntExprMakePiecewiseLinearExpr (IntExpr *expr, const PiecewiseLinearFunction &f)
 
IntExprMakeModulo (IntExpr *x, int64_t mod)
 Modulo expression x % mod (with the python convention for modulo).
 
IntExprMakeModulo (IntExpr *x, IntExpr *mod)
 Modulo expression x % mod (with the python convention for modulo).
 
IntExprMakeConditionalExpression (IntVar *condition, IntExpr *expr, int64_t unperformed_value)
 Conditional Expr condition ? expr : unperformed_value.
 
ConstraintMakeTrueConstraint ()
 This constraint always succeeds.
 
ConstraintMakeFalseConstraint ()
 This constraint always fails.
 
ConstraintMakeFalseConstraint (const std::string &explanation)
 
ConstraintMakeIsEqualCstCt (IntExpr *var, int64_t value, IntVar *boolvar)
 boolvar == (var == value)
 
IntVarMakeIsEqualCstVar (IntExpr *var, int64_t value)
 status var of (var == value)
 
ConstraintMakeIsEqualCt (IntExpr *v1, IntExpr *v2, IntVar *b)
 b == (v1 == v2)
 
IntVarMakeIsEqualVar (IntExpr *v1, IntExpr *v2)
 status var of (v1 == v2)
 
ConstraintMakeEquality (IntExpr *left, IntExpr *right)
 left == right
 
ConstraintMakeEquality (IntExpr *expr, int64_t value)
 expr == value
 
ConstraintMakeEquality (IntExpr *expr, int value)
 expr == value
 
ConstraintMakeIsDifferentCstCt (IntExpr *var, int64_t value, IntVar *boolvar)
 boolvar == (var != value)
 
IntVarMakeIsDifferentCstVar (IntExpr *var, int64_t value)
 status var of (var != value)
 
IntVarMakeIsDifferentVar (IntExpr *v1, IntExpr *v2)
 status var of (v1 != v2)
 
ConstraintMakeIsDifferentCt (IntExpr *v1, IntExpr *v2, IntVar *b)
 b == (v1 != v2)
 
ConstraintMakeNonEquality (IntExpr *left, IntExpr *right)
 left != right
 
ConstraintMakeNonEquality (IntExpr *expr, int64_t value)
 expr != value
 
ConstraintMakeNonEquality (IntExpr *expr, int value)
 expr != value
 
ConstraintMakeIsLessOrEqualCstCt (IntExpr *var, int64_t value, IntVar *boolvar)
 boolvar == (var <= value)
 
IntVarMakeIsLessOrEqualCstVar (IntExpr *var, int64_t value)
 status var of (var <= value)
 
IntVarMakeIsLessOrEqualVar (IntExpr *left, IntExpr *right)
 status var of (left <= right)
 
ConstraintMakeIsLessOrEqualCt (IntExpr *left, IntExpr *right, IntVar *b)
 b == (left <= right)
 
ConstraintMakeLessOrEqual (IntExpr *left, IntExpr *right)
 left <= right
 
ConstraintMakeLessOrEqual (IntExpr *expr, int64_t value)
 expr <= value
 
ConstraintMakeLessOrEqual (IntExpr *expr, int value)
 expr <= value
 
ConstraintMakeIsGreaterOrEqualCstCt (IntExpr *var, int64_t value, IntVar *boolvar)
 boolvar == (var >= value)
 
IntVarMakeIsGreaterOrEqualCstVar (IntExpr *var, int64_t value)
 status var of (var >= value)
 
IntVarMakeIsGreaterOrEqualVar (IntExpr *left, IntExpr *right)
 status var of (left >= right)
 
ConstraintMakeIsGreaterOrEqualCt (IntExpr *left, IntExpr *right, IntVar *b)
 b == (left >= right)
 
ConstraintMakeGreaterOrEqual (IntExpr *left, IntExpr *right)
 left >= right
 
ConstraintMakeGreaterOrEqual (IntExpr *expr, int64_t value)
 expr >= value
 
ConstraintMakeGreaterOrEqual (IntExpr *expr, int value)
 expr >= value
 
ConstraintMakeIsGreaterCstCt (IntExpr *v, int64_t c, IntVar *b)
 b == (v > c)
 
IntVarMakeIsGreaterCstVar (IntExpr *var, int64_t value)
 status var of (var > value)
 
IntVarMakeIsGreaterVar (IntExpr *left, IntExpr *right)
 status var of (left > right)
 
ConstraintMakeIsGreaterCt (IntExpr *left, IntExpr *right, IntVar *b)
 b == (left > right)
 
ConstraintMakeGreater (IntExpr *left, IntExpr *right)
 left > right
 
ConstraintMakeGreater (IntExpr *expr, int64_t value)
 expr > value
 
ConstraintMakeGreater (IntExpr *expr, int value)
 expr > value
 
ConstraintMakeIsLessCstCt (IntExpr *v, int64_t c, IntVar *b)
 b == (v < c)
 
IntVarMakeIsLessCstVar (IntExpr *var, int64_t value)
 status var of (var < value)
 
IntVarMakeIsLessVar (IntExpr *left, IntExpr *right)
 status var of (left < right)
 
ConstraintMakeIsLessCt (IntExpr *left, IntExpr *right, IntVar *b)
 b == (left < right)
 
ConstraintMakeLess (IntExpr *left, IntExpr *right)
 left < right
 
ConstraintMakeLess (IntExpr *expr, int64_t value)
 expr < value
 
ConstraintMakeLess (IntExpr *expr, int value)
 expr < value
 
ConstraintMakeSumLessOrEqual (const std::vector< IntVar * > &vars, int64_t cst)
 Variation on arrays.
 
ConstraintMakeSumGreaterOrEqual (const std::vector< IntVar * > &vars, int64_t cst)
 
ConstraintMakeSumEquality (const std::vector< IntVar * > &vars, int64_t cst)
 
ConstraintMakeSumEquality (const std::vector< IntVar * > &vars, IntVar *var)
 
ConstraintMakeScalProdEquality (const std::vector< IntVar * > &vars, const std::vector< int64_t > &coefficients, int64_t cst)
 
ConstraintMakeScalProdEquality (const std::vector< IntVar * > &vars, const std::vector< int > &coefficients, int64_t cst)
 
ConstraintMakeScalProdEquality (const std::vector< IntVar * > &vars, const std::vector< int64_t > &coefficients, IntVar *target)
 
ConstraintMakeScalProdEquality (const std::vector< IntVar * > &vars, const std::vector< int > &coefficients, IntVar *target)
 
ConstraintMakeScalProdGreaterOrEqual (const std::vector< IntVar * > &vars, const std::vector< int64_t > &coeffs, int64_t cst)
 
ConstraintMakeScalProdGreaterOrEqual (const std::vector< IntVar * > &vars, const std::vector< int > &coeffs, int64_t cst)
 
ConstraintMakeScalProdLessOrEqual (const std::vector< IntVar * > &vars, const std::vector< int64_t > &coefficients, int64_t cst)
 
ConstraintMakeScalProdLessOrEqual (const std::vector< IntVar * > &vars, const std::vector< int > &coefficients, int64_t cst)
 
ConstraintMakeMinEquality (const std::vector< IntVar * > &vars, IntVar *min_var)
 
ConstraintMakeMaxEquality (const std::vector< IntVar * > &vars, IntVar *max_var)
 
ConstraintMakeElementEquality (const std::vector< int64_t > &vals, IntVar *index, IntVar *target)
 
ConstraintMakeElementEquality (const std::vector< int > &vals, IntVar *index, IntVar *target)
 
ConstraintMakeElementEquality (const std::vector< IntVar * > &vars, IntVar *index, IntVar *target)
 
ConstraintMakeElementEquality (const std::vector< IntVar * > &vars, IntVar *index, int64_t target)
 
ConstraintMakeAbsEquality (IntVar *var, IntVar *abs_var)
 Creates the constraint abs(var) == abs_var.
 
ConstraintMakeIndexOfConstraint (const std::vector< IntVar * > &vars, IntVar *index, int64_t target)
 
DemonMakeConstraintInitialPropagateCallback (Constraint *ct)
 
DemonMakeDelayedConstraintInitialPropagateCallback (Constraint *ct)
 
DemonMakeActionDemon (Action action)
 Creates a demon from a callback.
 
DemonMakeClosureDemon (Closure closure)
 Creates a demon from a closure.
 
ConstraintMakeBetweenCt (IntExpr *expr, int64_t l, int64_t u)
 --— Between and related constraints --—
 
ConstraintMakeNotBetweenCt (IntExpr *expr, int64_t l, int64_t u)
 
ConstraintMakeIsBetweenCt (IntExpr *expr, int64_t l, int64_t u, IntVar *b)
 b == (l <= expr <= u)
 
IntVarMakeIsBetweenVar (IntExpr *v, int64_t l, int64_t u)
 
ConstraintMakeMemberCt (IntExpr *expr, const std::vector< int64_t > &values)
 --— Member and related constraints --—
 
ConstraintMakeMemberCt (IntExpr *expr, const std::vector< int > &values)
 
ConstraintMakeNotMemberCt (IntExpr *expr, const std::vector< int64_t > &values)
 expr not in set.
 
ConstraintMakeNotMemberCt (IntExpr *expr, const std::vector< int > &values)
 
ConstraintMakeNotMemberCt (IntExpr *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]].
 
ConstraintMakeNotMemberCt (IntExpr *expr, std::vector< int > starts, std::vector< int > ends)
 expr should not be in the list of forbidden intervals [start[i]..end[i]].
 
ConstraintMakeNotMemberCt (IntExpr *expr, SortedDisjointIntervalList intervals)
 expr should not be in the list of forbidden intervals.
 
ConstraintMakeIsMemberCt (IntExpr *expr, const std::vector< int64_t > &values, IntVar *boolvar)
 boolvar == (expr in set)
 
ConstraintMakeIsMemberCt (IntExpr *expr, const std::vector< int > &values, IntVar *boolvar)
 
IntVarMakeIsMemberVar (IntExpr *expr, const std::vector< int64_t > &values)
 
IntVarMakeIsMemberVar (IntExpr *expr, const std::vector< int > &values)
 
ConstraintMakeAtMost (std::vector< IntVar * > vars, int64_t value, int64_t max_count)
 |{i | vars[i] == value}| <= max_count
 
ConstraintMakeCount (const std::vector< IntVar * > &vars, int64_t value, int64_t max_count)
 |{i | vars[i] == value}| == max_count
 
ConstraintMakeCount (const std::vector< IntVar * > &vars, int64_t value, IntVar *max_count)
 |{i | vars[i] == value}| == max_count
 
ConstraintMakeDistribute (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].
 
ConstraintMakeDistribute (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].
 
ConstraintMakeDistribute (const std::vector< IntVar * > &vars, const std::vector< IntVar * > &cards)
 Aggregated version of count: |{i | v[i] == j}| == cards[j].
 
ConstraintMakeDistribute (const std::vector< IntVar * > &vars, int64_t card_min, int64_t card_max, int64_t card_size)
 
ConstraintMakeDistribute (const std::vector< IntVar * > &vars, const std::vector< int64_t > &card_min, const std::vector< int64_t > &card_max)
 
ConstraintMakeDistribute (const std::vector< IntVar * > &vars, const std::vector< int > &card_min, const std::vector< int > &card_max)
 
ConstraintMakeDistribute (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)
 
ConstraintMakeDistribute (const std::vector< IntVar * > &vars, const std::vector< int > &values, const std::vector< int > &card_min, const std::vector< int > &card_max)
 
ConstraintMakeDeviation (const std::vector< IntVar * > &vars, IntVar *deviation_var, int64_t total_sum)
 
ConstraintMakeAllDifferent (const std::vector< IntVar * > &vars)
 
ConstraintMakeAllDifferent (const std::vector< IntVar * > &vars, bool stronger_propagation)
 
ConstraintMakeAllDifferentExcept (const std::vector< IntVar * > &vars, int64_t escape_value)
 
ConstraintMakeSortingConstraint (const std::vector< IntVar * > &vars, const std::vector< IntVar * > &sorted)
 
ConstraintMakeLexicalLess (const std::vector< IntVar * > &left, const std::vector< IntVar * > &right)
 
ConstraintMakeLexicalLessOrEqual (const std::vector< IntVar * > &left, const std::vector< IntVar * > &right)
 
ConstraintMakeLexicalLessOrEqualWithOffsets (std::vector< IntVar * > left, std::vector< IntVar * > right, std::vector< int64_t > offsets)
 
ConstraintMakeIsLexicalLessOrEqualWithOffsetsCt (std::vector< IntVar * > left, std::vector< IntVar * > right, std::vector< int64_t > offsets, IntVar *boolvar)
 Semi-reified version of the above: boolvar -> LexLE(left, right, offsets).
 
ConstraintMakeInversePermutationConstraint (const std::vector< IntVar * > &left, const std::vector< IntVar * > &right)
 
ConstraintMakeIndexOfFirstMaxValueConstraint (IntVar *index, const std::vector< IntVar * > &vars)
 
ConstraintMakeIndexOfFirstMinValueConstraint (IntVar *index, const std::vector< IntVar * > &vars)
 
ConstraintMakeNullIntersect (const std::vector< IntVar * > &first_vars, const std::vector< IntVar * > &second_vars)
 
ConstraintMakeNullIntersectExcept (const std::vector< IntVar * > &first_vars, const std::vector< IntVar * > &second_vars, int64_t escape_value)
 
ConstraintMakeNoCycle (const std::vector< IntVar * > &nexts, const std::vector< IntVar * > &active, IndexFilter1 sink_handler=nullptr)
 
ConstraintMakeNoCycle (const std::vector< IntVar * > &nexts, const std::vector< IntVar * > &active, IndexFilter1 sink_handler, bool assume_paths)
 
ConstraintMakeCircuit (const std::vector< IntVar * > &nexts)
 Force the "nexts" variable to create a complete Hamiltonian path.
 
ConstraintMakeSubCircuit (const std::vector< IntVar * > &nexts)
 
ConstraintMakePathCumul (const std::vector< IntVar * > &nexts, const std::vector< IntVar * > &active, const std::vector< IntVar * > &cumuls, const std::vector< IntVar * > &transits)
 
ConstraintMakeDelayedPathCumul (const std::vector< IntVar * > &nexts, const std::vector< IntVar * > &active, const std::vector< IntVar * > &cumuls, const std::vector< IntVar * > &transits)
 
ConstraintMakePathCumul (const std::vector< IntVar * > &nexts, const std::vector< IntVar * > &active, const std::vector< IntVar * > &cumuls, IndexEvaluator2 transit_evaluator)
 
ConstraintMakePathCumul (const std::vector< IntVar * > &nexts, const std::vector< IntVar * > &active, const std::vector< IntVar * > &cumuls, const std::vector< IntVar * > &slacks, IndexEvaluator2 transit_evaluator)
 
ConstraintMakePathConnected (std::vector< IntVar * > nexts, std::vector< int64_t > sources, std::vector< int64_t > sinks, std::vector< IntVar * > status)
 
ConstraintMakePathPrecedenceConstraint (std::vector< IntVar * > nexts, const std::vector< std::pair< int, int > > &precedences)
 
ConstraintMakePathPrecedenceConstraint (std::vector< IntVar * > nexts, const std::vector< std::pair< int, int > > &precedences, absl::Span< const int > lifo_path_starts, absl::Span< const int > fifo_path_starts)
 
ConstraintMakePathTransitPrecedenceConstraint (std::vector< IntVar * > nexts, std::vector< IntVar * > transits, const std::vector< std::pair< int, int > > &precedences)
 
ConstraintMakePathEnergyCostConstraint (PathEnergyCostConstraintSpecification specification)
 
ConstraintMakeMapDomain (IntVar *var, const std::vector< IntVar * > &actives)
 
ConstraintMakeAllowedAssignments (const std::vector< IntVar * > &vars, const IntTupleSet &tuples)
 ------— API -------—
 
ConstraintMakeTransitionConstraint (const std::vector< IntVar * > &vars, const IntTupleSet &transition_table, int64_t initial_state, const std::vector< int64_t > &final_states)
 
ConstraintMakeTransitionConstraint (const std::vector< IntVar * > &vars, const IntTupleSet &transition_table, int64_t initial_state, const std::vector< int > &final_states)
 
ConstraintMakeNonOverlappingBoxesConstraint (const std::vector< IntVar * > &x_vars, const std::vector< IntVar * > &y_vars, const std::vector< IntVar * > &x_size, const std::vector< IntVar * > &y_size)
 
ConstraintMakeNonOverlappingBoxesConstraint (const std::vector< IntVar * > &x_vars, const std::vector< IntVar * > &y_vars, absl::Span< const int64_t > x_size, absl::Span< const int64_t > y_size)
 
ConstraintMakeNonOverlappingBoxesConstraint (const std::vector< IntVar * > &x_vars, const std::vector< IntVar * > &y_vars, absl::Span< const int > x_size, absl::Span< const int > y_size)
 
ConstraintMakeNonOverlappingNonStrictBoxesConstraint (const std::vector< IntVar * > &x_vars, const std::vector< IntVar * > &y_vars, const std::vector< IntVar * > &x_size, const std::vector< IntVar * > &y_size)
 
ConstraintMakeNonOverlappingNonStrictBoxesConstraint (const std::vector< IntVar * > &x_vars, const std::vector< IntVar * > &y_vars, absl::Span< const int64_t > x_size, absl::Span< const int64_t > y_size)
 
ConstraintMakeNonOverlappingNonStrictBoxesConstraint (const std::vector< IntVar * > &x_vars, const std::vector< IntVar * > &y_vars, absl::Span< const int > x_size, absl::Span< const int > y_size)
 
PackMakePack (const std::vector< IntVar * > &vars, int number_of_bins)
 
IntervalVarMakeFixedDurationIntervalVar (int64_t start_min, int64_t start_max, int64_t duration, bool optional, const std::string &name)
 
void MakeFixedDurationIntervalVarArray (int count, int64_t start_min, int64_t start_max, int64_t duration, bool optional, absl::string_view name, std::vector< IntervalVar * > *array)
 
IntervalVarMakeFixedDurationIntervalVar (IntVar *start_variable, int64_t duration, const std::string &name)
 
IntervalVarMakeFixedDurationIntervalVar (IntVar *start_variable, int64_t duration, IntVar *performed_variable, const std::string &name)
 
void MakeFixedDurationIntervalVarArray (const std::vector< IntVar * > &start_variables, int64_t duration, absl::string_view name, std::vector< IntervalVar * > *array)
 
void MakeFixedDurationIntervalVarArray (const std::vector< IntVar * > &start_variables, absl::Span< const int64_t > durations, absl::string_view name, std::vector< IntervalVar * > *array)
 
void MakeFixedDurationIntervalVarArray (const std::vector< IntVar * > &start_variables, absl::Span< const int > durations, absl::string_view name, std::vector< IntervalVar * > *array)
 
void MakeFixedDurationIntervalVarArray (const std::vector< IntVar * > &start_variables, absl::Span< const int64_t > durations, const std::vector< IntVar * > &performed_variables, absl::string_view name, std::vector< IntervalVar * > *array)
 
void MakeFixedDurationIntervalVarArray (const std::vector< IntVar * > &start_variables, absl::Span< const int > durations, const std::vector< IntVar * > &performed_variables, absl::string_view name, std::vector< IntervalVar * > *array)
 
IntervalVarMakeFixedInterval (int64_t start, int64_t duration, const std::string &name)
 Creates a fixed and performed interval.
 
IntervalVarMakeIntervalVar (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)
 Variable Duration Interval Var.
 
void MakeIntervalVarArray (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, absl::string_view name, std::vector< IntervalVar * > *array)
 
IntervalVarMakeMirrorInterval (IntervalVar *interval_var)
 --— API --—
 
IntervalVarMakeFixedDurationStartSyncedOnStartIntervalVar (IntervalVar *interval_var, int64_t duration, int64_t offset)
 Synced Interval Vars.
 
IntervalVarMakeFixedDurationStartSyncedOnEndIntervalVar (IntervalVar *interval_var, int64_t duration, int64_t offset)
 
IntervalVarMakeFixedDurationEndSyncedOnStartIntervalVar (IntervalVar *interval_var, int64_t duration, int64_t offset)
 
IntervalVarMakeFixedDurationEndSyncedOnEndIntervalVar (IntervalVar *interval_var, int64_t duration, int64_t offset)
 
IntervalVarMakeIntervalRelaxedMin (IntervalVar *interval_var)
 
IntervalVarMakeIntervalRelaxedMax (IntervalVar *interval_var)
 
ConstraintMakeIntervalVarRelation (IntervalVar *t, UnaryIntervalRelation r, int64_t d)
 
ConstraintMakeIntervalVarRelation (IntervalVar *t1, BinaryIntervalRelation r, IntervalVar *t2)
 This method creates a relation between two interval vars.
 
ConstraintMakeIntervalVarRelationWithDelay (IntervalVar *t1, BinaryIntervalRelation r, IntervalVar *t2, int64_t delay)
 
ConstraintMakeTemporalDisjunction (IntervalVar *t1, IntervalVar *t2, IntVar *alt)
 
ConstraintMakeTemporalDisjunction (IntervalVar *t1, IntervalVar *t2)
 
DisjunctiveConstraintMakeDisjunctiveConstraint (const std::vector< IntervalVar * > &intervals, const std::string &name)
 -------— Factory methods -------—
 
DisjunctiveConstraintMakeStrictDisjunctiveConstraint (const std::vector< IntervalVar * > &intervals, const std::string &name)
 
ConstraintMakeCumulative (const std::vector< IntervalVar * > &intervals, const std::vector< int64_t > &demands, int64_t capacity, const std::string &name)
 Demands are constant.
 
ConstraintMakeCumulative (const std::vector< IntervalVar * > &intervals, const std::vector< int > &demands, int64_t capacity, const std::string &name)
 
ConstraintMakeCumulative (const std::vector< IntervalVar * > &intervals, const std::vector< int64_t > &demands, IntVar *capacity, absl::string_view name)
 
ConstraintMakeCumulative (const std::vector< IntervalVar * > &intervals, const std::vector< int > &demands, IntVar *capacity, const std::string &name)
 
ConstraintMakeCumulative (const std::vector< IntervalVar * > &intervals, const std::vector< IntVar * > &demands, int64_t capacity, const std::string &name)
 Demands should be positive.
 
ConstraintMakeCumulative (const std::vector< IntervalVar * > &intervals, const std::vector< IntVar * > &demands, IntVar *capacity, const std::string &name)
 Demands should be positive.
 
ConstraintMakeCover (const std::vector< IntervalVar * > &vars, IntervalVar *target_var)
 
ConstraintMakeEquality (IntervalVar *var1, IntervalVar *var2)
 This constraints states that the two interval variables are equal.
 
AssignmentMakeAssignment ()
 This method creates an empty assignment.
 
AssignmentMakeAssignment (const Assignment *a)
 This method creates an assignment which is a copy of 'a'.
 
SolutionCollectorMakeFirstSolutionCollector (const Assignment *assignment)
 Collect the first solution of the search.
 
SolutionCollectorMakeFirstSolutionCollector ()
 
SolutionCollectorMakeLastSolutionCollector (const Assignment *assignment)
 Collect the last solution of the search.
 
SolutionCollectorMakeLastSolutionCollector ()
 
SolutionCollectorMakeBestValueSolutionCollector (const Assignment *assignment, bool maximize)
 
SolutionCollectorMakeBestLexicographicValueSolutionCollector (const Assignment *assignment, std::vector< bool > maximize)
 
SolutionCollectorMakeBestValueSolutionCollector (bool maximize)
 
SolutionCollectorMakeBestLexicographicValueSolutionCollector (std::vector< bool > maximize)
 
SolutionCollectorMakeNBestValueSolutionCollector (const Assignment *assignment, int solution_count, bool maximize)
 
SolutionCollectorMakeNBestValueSolutionCollector (int solution_count, bool maximize)
 
SolutionCollectorMakeNBestLexicographicValueSolutionCollector (const Assignment *assignment, int solution_count, std::vector< bool > maximize)
 
SolutionCollectorMakeNBestLexicographicValueSolutionCollector (int solution_count, std::vector< bool > maximize)
 
SolutionCollectorMakeAllSolutionCollector (const Assignment *assignment)
 Collect all solutions of the search.
 
SolutionCollectorMakeAllSolutionCollector ()
 
OptimizeVarMakeMinimize (IntVar *v, int64_t step)
 Creates a minimization objective.
 
OptimizeVarMakeMaximize (IntVar *v, int64_t step)
 Creates a maximization objective.
 
OptimizeVarMakeOptimize (bool maximize, IntVar *v, int64_t step)
 Creates a objective with a given sense (true = maximization).
 
OptimizeVarMakeWeightedMinimize (const std::vector< IntVar * > &sub_objectives, const std::vector< int64_t > &weights, int64_t step)
 
OptimizeVarMakeWeightedMinimize (const std::vector< IntVar * > &sub_objectives, const std::vector< int > &weights, int64_t step)
 
OptimizeVarMakeWeightedMaximize (const std::vector< IntVar * > &sub_objectives, const std::vector< int64_t > &weights, int64_t step)
 Creates a maximization weigthed objective.
 
OptimizeVarMakeWeightedMaximize (const std::vector< IntVar * > &sub_objectives, const std::vector< int > &weights, int64_t step)
 Creates a maximization weigthed objective.
 
OptimizeVarMakeWeightedOptimize (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).
 
OptimizeVarMakeWeightedOptimize (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).
 
OptimizeVarMakeLexicographicOptimize (std::vector< bool > maximize, std::vector< IntVar * > variables, std::vector< int64_t > steps)
 
ObjectiveMonitorMakeTabuSearch (bool maximize, IntVar *objective, int64_t step, const std::vector< IntVar * > &vars, int64_t keep_tenure, int64_t forbid_tenure, double tabu_factor)
 MetaHeuristics which try to get the search out of local optima.
 
ObjectiveMonitorMakeLexicographicTabuSearch (const std::vector< bool > &maximize, std::vector< IntVar * > objectives, std::vector< int64_t > steps, const std::vector< IntVar * > &vars, int64_t keep_tenure, int64_t forbid_tenure, double tabu_factor)
 
ObjectiveMonitorMakeGenericTabuSearch (bool maximize, IntVar *v, int64_t step, const std::vector< IntVar * > &tabu_vars, int64_t forbid_tenure)
 
ObjectiveMonitorMakeSimulatedAnnealing (bool maximize, IntVar *v, int64_t step, int64_t initial_temperature)
 
ObjectiveMonitorMakeLexicographicSimulatedAnnealing (const std::vector< bool > &maximize, std::vector< IntVar * > vars, std::vector< int64_t > steps, std::vector< int64_t > initial_temperatures)
 
ObjectiveMonitorMakeGuidedLocalSearch (bool maximize, IntVar *objective, IndexEvaluator2 objective_function, int64_t step, const std::vector< IntVar * > &vars, double penalty_factor, bool reset_penalties_on_new_best_solution=false)
 
ObjectiveMonitorMakeGuidedLocalSearch (bool maximize, IntVar *objective, IndexEvaluator3 objective_function, int64_t step, const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, double penalty_factor, bool reset_penalties_on_new_best_solution=false)
 
SearchMonitorMakeLubyRestart (int scale_factor)
 
SearchMonitorMakeConstantRestart (int frequency)
 
ABSL_MUST_USE_RESULT RegularLimitMakeTimeLimit (absl::Duration time)
 Creates a search limit that constrains the running time.
 
ABSL_MUST_USE_RESULT RegularLimitMakeTimeLimit (int64_t time_in_ms)
 
ABSL_MUST_USE_RESULT RegularLimitMakeBranchesLimit (int64_t branches)
 
ABSL_MUST_USE_RESULT RegularLimitMakeFailuresLimit (int64_t failures)
 
ABSL_MUST_USE_RESULT RegularLimitMakeSolutionsLimit (int64_t solutions)
 
ABSL_MUST_USE_RESULT RegularLimitMakeLimit (absl::Duration time, int64_t branches, int64_t failures, int64_t solutions, bool smart_time_check=false, bool cumulative=false)
 
ABSL_MUST_USE_RESULT RegularLimitMakeLimit (const RegularLimitParameters &proto)
 Creates a search limit from its protobuf description.
 
ABSL_MUST_USE_RESULT RegularLimitMakeLimit (int64_t time, int64_t branches, int64_t failures, int64_t solutions, bool smart_time_check=false, bool cumulative=false)
 
RegularLimitParameters MakeDefaultRegularLimitParameters () const
 Creates a regular limit proto containing default values.
 
ABSL_MUST_USE_RESULT SearchLimitMakeLimit (SearchLimit *limit_1, SearchLimit *limit_2)
 
ABSL_MUST_USE_RESULT ImprovementSearchLimitMakeImprovementLimit (IntVar *objective_var, bool maximize, double objective_scaling_factor, double objective_offset, double improvement_rate_coefficient, int improvement_rate_solutions_distance)
 
ABSL_MUST_USE_RESULT ImprovementSearchLimitMakeLexicographicImprovementLimit (std::vector< IntVar * > objective_vars, std::vector< bool > maximize, std::vector< double > objective_scaling_factors, std::vector< double > objective_offsets, double improvement_rate_coefficient, int improvement_rate_solutions_distance)
 
ABSL_MUST_USE_RESULT SearchLimitMakeCustomLimit (std::function< bool()> limiter)
 
SearchMonitorMakeSearchLog (int branch_period)
 
SearchMonitorMakeSearchLog (int branch_period, IntVar *var)
 At each solution, this monitor also display the var value.
 
SearchMonitorMakeSearchLog (int branch_period, std::function< std::string()> display_callback)
 
SearchMonitorMakeSearchLog (int branch_period, IntVar *var, std::function< std::string()> display_callback)
 
SearchMonitorMakeSearchLog (int branch_period, std::vector< IntVar * > vars, std::function< std::string()> display_callback)
 
SearchMonitorMakeSearchLog (int branch_period, OptimizeVar *opt_var)
 
SearchMonitorMakeSearchLog (int branch_period, OptimizeVar *opt_var, std::function< std::string()> display_callback)
 
SearchMonitorMakeSearchLog (SearchLogParameters parameters)
 
SearchMonitorMakeSearchTrace (const std::string &prefix)
 
SearchMonitorMakeEnterSearchCallback (std::function< void()> callback)
 --— Callback-based search monitors --—
 
SearchMonitorMakeExitSearchCallback (std::function< void()> callback)
 
SearchMonitorMakeAtSolutionCallback (std::function< void()> callback)
 
ModelVisitorMakePrintModelVisitor ()
 Prints the model.
 
ModelVisitorMakeStatisticsModelVisitor ()
 Displays some nice statistics on the model.
 
ModelVisitorMakeVariableDegreeVisitor (absl::flat_hash_map< const IntVar *, int > *map)
 Compute the number of constraints a variable is attached to.
 
SearchMonitorMakeSymmetryManager (const std::vector< SymmetryBreaker * > &visitors)
 Symmetry Breaking.
 
SearchMonitorMakeSymmetryManager (SymmetryBreaker *v1)
 
SearchMonitorMakeSymmetryManager (SymmetryBreaker *v1, SymmetryBreaker *v2)
 
SearchMonitorMakeSymmetryManager (SymmetryBreaker *v1, SymmetryBreaker *v2, SymmetryBreaker *v3)
 
SearchMonitorMakeSymmetryManager (SymmetryBreaker *v1, SymmetryBreaker *v2, SymmetryBreaker *v3, SymmetryBreaker *v4)
 
DecisionMakeAssignVariableValue (IntVar *var, int64_t val)
 Decisions.
 
DecisionMakeVariableLessOrEqualValue (IntVar *var, int64_t value)
 
DecisionMakeVariableGreaterOrEqualValue (IntVar *var, int64_t value)
 
DecisionMakeSplitVariableDomain (IntVar *var, int64_t val, bool start_with_lower_half)
 
DecisionMakeAssignVariableValueOrFail (IntVar *var, int64_t value)
 
DecisionMakeAssignVariableValueOrDoNothing (IntVar *var, int64_t value)
 
DecisionMakeAssignVariablesValues (const std::vector< IntVar * > &vars, const std::vector< int64_t > &values)
 
DecisionMakeAssignVariablesValuesOrDoNothing (const std::vector< IntVar * > &vars, const std::vector< int64_t > &values)
 
DecisionMakeAssignVariablesValuesOrFail (const std::vector< IntVar * > &vars, const std::vector< int64_t > &values)
 
DecisionMakeFailDecision ()
 
DecisionMakeDecision (Action apply, Action refute)
 
DecisionBuilderCompose (DecisionBuilder *db1, DecisionBuilder *db2)
 
DecisionBuilderCompose (DecisionBuilder *db1, DecisionBuilder *db2, DecisionBuilder *db3)
 
DecisionBuilderCompose (DecisionBuilder *db1, DecisionBuilder *db2, DecisionBuilder *db3, DecisionBuilder *db4)
 
DecisionBuilderCompose (const std::vector< DecisionBuilder * > &dbs)
 
DecisionBuilderTry (DecisionBuilder *db1, DecisionBuilder *db2)
 
DecisionBuilderTry (DecisionBuilder *db1, DecisionBuilder *db2, DecisionBuilder *db3)
 
DecisionBuilderTry (DecisionBuilder *db1, DecisionBuilder *db2, DecisionBuilder *db3, DecisionBuilder *db4)
 
DecisionBuilderTry (const std::vector< DecisionBuilder * > &dbs)
 
DecisionBuilderMakePhase (const std::vector< IntVar * > &vars, IntVarStrategy var_str, IntValueStrategy val_str)
 
DecisionBuilderMakePhase (const std::vector< IntVar * > &vars, IndexEvaluator1 var_evaluator, IntValueStrategy val_str)
 
DecisionBuilderMakePhase (const std::vector< IntVar * > &vars, IntVarStrategy var_str, IndexEvaluator2 value_evaluator)
 
DecisionBuilderMakePhase (const std::vector< IntVar * > &vars, IntVarStrategy var_str, VariableValueComparator var_val1_val2_comparator)
 
DecisionBuilderMakePhase (const std::vector< IntVar * > &vars, IndexEvaluator1 var_evaluator, IndexEvaluator2 value_evaluator)
 
DecisionBuilderMakePhase (const std::vector< IntVar * > &vars, IntVarStrategy var_str, IndexEvaluator2 value_evaluator, IndexEvaluator1 tie_breaker)
 
DecisionBuilderMakePhase (const std::vector< IntVar * > &vars, IndexEvaluator1 var_evaluator, IndexEvaluator2 value_evaluator, IndexEvaluator1 tie_breaker)
 
DecisionBuilderMakeDefaultPhase (const std::vector< IntVar * > &vars)
 
DecisionBuilderMakeDefaultPhase (const std::vector< IntVar * > &vars, const DefaultPhaseParameters &parameters)
 
DecisionBuilderMakePhase (IntVar *v0, IntVarStrategy var_str, IntValueStrategy val_str)
 Shortcuts for small arrays.
 
DecisionBuilderMakePhase (IntVar *v0, IntVar *v1, IntVarStrategy var_str, IntValueStrategy val_str)
 
DecisionBuilderMakePhase (IntVar *v0, IntVar *v1, IntVar *v2, IntVarStrategy var_str, IntValueStrategy val_str)
 
DecisionBuilderMakePhase (IntVar *v0, IntVar *v1, IntVar *v2, IntVar *v3, IntVarStrategy var_str, IntValueStrategy val_str)
 
DecisionMakeScheduleOrPostpone (IntervalVar *var, int64_t est, int64_t *marker)
 
DecisionMakeScheduleOrExpedite (IntervalVar *var, int64_t est, int64_t *marker)
 
DecisionMakeRankFirstInterval (SequenceVar *sequence, int index)
 
DecisionMakeRankLastInterval (SequenceVar *sequence, int index)
 
DecisionBuilderMakePhase (const std::vector< IntVar * > &vars, IndexEvaluator2 eval, EvaluatorStrategy str)
 
DecisionBuilderMakePhase (const std::vector< IntVar * > &vars, IndexEvaluator2 eval, IndexEvaluator1 tie_breaker, EvaluatorStrategy str)
 
DecisionBuilderMakePhase (const std::vector< IntervalVar * > &intervals, IntervalStrategy str)
 Scheduling phases.
 
DecisionBuilderMakePhase (const std::vector< SequenceVar * > &sequences, SequenceStrategy str)
 
DecisionBuilderMakeDecisionBuilderFromAssignment (Assignment *assignment, DecisionBuilder *db, const std::vector< IntVar * > &vars)
 
DecisionBuilderMakeConstraintAdder (Constraint *ct)
 
DecisionBuilderMakeSolveOnce (DecisionBuilder *db)
 
DecisionBuilderMakeSolveOnce (DecisionBuilder *db, SearchMonitor *monitor1)
 
DecisionBuilderMakeSolveOnce (DecisionBuilder *db, SearchMonitor *monitor1, SearchMonitor *monitor2)
 
DecisionBuilderMakeSolveOnce (DecisionBuilder *db, SearchMonitor *monitor1, SearchMonitor *monitor2, SearchMonitor *monitor3)
 
DecisionBuilderMakeSolveOnce (DecisionBuilder *db, SearchMonitor *monitor1, SearchMonitor *monitor2, SearchMonitor *monitor3, SearchMonitor *monitor4)
 
DecisionBuilderMakeSolveOnce (DecisionBuilder *db, const std::vector< SearchMonitor * > &monitors)
 
DecisionBuilderMakeNestedOptimize (DecisionBuilder *db, Assignment *solution, bool maximize, int64_t step)
 
DecisionBuilderMakeNestedOptimize (DecisionBuilder *db, Assignment *solution, bool maximize, int64_t step, SearchMonitor *monitor1)
 
DecisionBuilderMakeNestedOptimize (DecisionBuilder *db, Assignment *solution, bool maximize, int64_t step, SearchMonitor *monitor1, SearchMonitor *monitor2)
 
DecisionBuilderMakeNestedOptimize (DecisionBuilder *db, Assignment *solution, bool maximize, int64_t step, SearchMonitor *monitor1, SearchMonitor *monitor2, SearchMonitor *monitor3)
 
DecisionBuilderMakeNestedOptimize (DecisionBuilder *db, Assignment *solution, bool maximize, int64_t step, SearchMonitor *monitor1, SearchMonitor *monitor2, SearchMonitor *monitor3, SearchMonitor *monitor4)
 
DecisionBuilderMakeNestedOptimize (DecisionBuilder *db, Assignment *solution, bool maximize, int64_t step, const std::vector< SearchMonitor * > &monitors)
 
DecisionBuilderMakeRestoreAssignment (Assignment *assignment)
 
DecisionBuilderMakeStoreAssignment (Assignment *assignment)
 
LocalSearchOperatorMakeOperator (const std::vector< IntVar * > &vars, LocalSearchOperators op, std::function< const std::vector< int > &(int, int)> get_neighbors=nullptr)
 Local Search Operators.
 
LocalSearchOperatorMakeOperator (const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, LocalSearchOperators op, std::function< const std::vector< int > &(int, int)> get_neighbors=nullptr)
 
LocalSearchOperatorMakeOperator (const std::vector< IntVar * > &vars, IndexEvaluator3 evaluator, EvaluatorLocalSearchOperators op)
 
LocalSearchOperatorMakeOperator (const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, IndexEvaluator3 evaluator, EvaluatorLocalSearchOperators op)
 
LocalSearchOperatorMakeRandomLnsOperator (const std::vector< IntVar * > &vars, int number_of_variables)
 
LocalSearchOperatorMakeRandomLnsOperator (const std::vector< IntVar * > &vars, int number_of_variables, int32_t seed)
 
LocalSearchOperatorMakeMoveTowardTargetOperator (const Assignment &target)
 
LocalSearchOperatorMakeMoveTowardTargetOperator (const std::vector< IntVar * > &variables, const std::vector< int64_t > &target_values)
 
LocalSearchOperatorConcatenateOperators (const std::vector< LocalSearchOperator * > &ops)
 
LocalSearchOperatorConcatenateOperators (const std::vector< LocalSearchOperator * > &ops, bool restart)
 
LocalSearchOperatorConcatenateOperators (const std::vector< LocalSearchOperator * > &ops, std::function< int64_t(int, int)> evaluator)
 
LocalSearchOperatorRandomConcatenateOperators (const std::vector< LocalSearchOperator * > &ops)
 
LocalSearchOperatorRandomConcatenateOperators (const std::vector< LocalSearchOperator * > &ops, int32_t seed)
 
LocalSearchOperatorMultiArmedBanditConcatenateOperators (const std::vector< LocalSearchOperator * > &ops, double memory_coefficient, double exploration_coefficient, bool maximize)
 
LocalSearchOperatorMakeNeighborhoodLimit (LocalSearchOperator *op, int64_t limit)
 
DecisionBuilderMakeLocalSearchPhase (Assignment *assignment, LocalSearchPhaseParameters *parameters)
 
DecisionBuilderMakeLocalSearchPhase (const std::vector< IntVar * > &vars, DecisionBuilder *first_solution, LocalSearchPhaseParameters *parameters)
 
DecisionBuilderMakeLocalSearchPhase (const std::vector< IntVar * > &vars, DecisionBuilder *first_solution, DecisionBuilder *first_solution_sub_decision_builder, LocalSearchPhaseParameters *parameters)
 Variant with a sub_decison_builder specific to the first solution.
 
DecisionBuilderMakeLocalSearchPhase (const std::vector< SequenceVar * > &vars, DecisionBuilder *first_solution, LocalSearchPhaseParameters *parameters)
 
AssignmentRunUncheckedLocalSearch (const Assignment *initial_solution, LocalSearchFilterManager *filter_manager, LocalSearchOperator *ls_operator, const std::vector< SearchMonitor * > &monitors, RegularLimit *limit, absl::flat_hash_set< IntVar * > *touched=nullptr)
 
SolutionPoolMakeDefaultSolutionPool ()
 Solution Pool.
 
LocalSearchPhaseParametersMakeLocalSearchPhaseParameters (IntVar *objective, LocalSearchOperator *ls_operator, DecisionBuilder *sub_decision_builder)
 Local Search Phase Parameters.
 
LocalSearchPhaseParametersMakeLocalSearchPhaseParameters (IntVar *objective, LocalSearchOperator *ls_operator, DecisionBuilder *sub_decision_builder, RegularLimit *limit)
 
LocalSearchPhaseParametersMakeLocalSearchPhaseParameters (IntVar *objective, LocalSearchOperator *ls_operator, DecisionBuilder *sub_decision_builder, RegularLimit *limit, LocalSearchFilterManager *filter_manager)
 
LocalSearchPhaseParametersMakeLocalSearchPhaseParameters (IntVar *objective, SolutionPool *pool, LocalSearchOperator *ls_operator, DecisionBuilder *sub_decision_builder)
 
LocalSearchPhaseParametersMakeLocalSearchPhaseParameters (IntVar *objective, SolutionPool *pool, LocalSearchOperator *ls_operator, DecisionBuilder *sub_decision_builder, RegularLimit *limit)
 
LocalSearchPhaseParametersMakeLocalSearchPhaseParameters (IntVar *objective, SolutionPool *pool, LocalSearchOperator *ls_operator, DecisionBuilder *sub_decision_builder, RegularLimit *limit, LocalSearchFilterManager *filter_manager)
 
LocalSearchFilterMakeAcceptFilter ()
 Local Search Filters.
 
LocalSearchFilterMakeRejectFilter ()
 
LocalSearchFilterMakeVariableDomainFilter ()
 
IntVarLocalSearchFilterMakeSumObjectiveFilter (const std::vector< IntVar * > &vars, IndexEvaluator2 values, Solver::LocalSearchFilterBound filter_enum)
 
IntVarLocalSearchFilterMakeSumObjectiveFilter (const std::vector< IntVar * > &vars, const std::vector< IntVar * > &secondary_vars, IndexEvaluator3 values, Solver::LocalSearchFilterBound filter_enum)
 
void TopPeriodicCheck ()
 
int TopProgressPercent ()
 
void PushState ()
 
void PopState ()
 
int SearchDepth () const
 
int SearchLeftDepth () const
 
int SolveDepth () const
 
void SetBranchSelector (BranchSelector bs)
 Sets the given branch selector on the current active search.
 
DecisionBuilderMakeApplyBranchSelector (BranchSelector bs)
 Creates a decision builder that will set the branch selector.
 
template<class T >
void SaveAndSetValue (T *adr, T val)
 All-in-one SaveAndSetValue.
 
template<class T >
void SaveAndAdd (T *adr, T val)
 All-in-one SaveAndAdd_value.
 
int64_t Rand64 (int64_t size)
 Returns a random value between 0 and 'size' - 1;.
 
int32_t Rand32 (int32_t size)
 Returns a random value between 0 and 'size' - 1;.
 
void ReSeed (int32_t seed)
 Reseed the solver random generator.
 
void ExportProfilingOverview (const std::string &filename)
 
std::string LocalSearchProfile () const
 
ConstraintSolverStatistics GetConstraintSolverStatistics () const
 Returns detailed cp search statistics.
 
LocalSearchStatistics GetLocalSearchStatistics () const
 Returns detailed local search statistics.
 
bool CurrentlyInSolve () const
 
int constraints () const
 
void Accept (ModelVisitor *visitor) const
 Accepts the given model visitor.
 
Decisionbalancing_decision () const
 
void set_fail_intercept (std::function< void()> fail_intercept)
 Internal.
 
void clear_fail_intercept ()
 
DemonProfilerdemon_profiler () const
 Access to demon profiler.
 
void SetUseFastLocalSearch (bool use_fast_local_search)
 
bool UseFastLocalSearch () const
 Returns true if fast local search is enabled.
 
bool HasName (const PropagationBaseObject *object) const
 Returns whether the object has been named or not.
 
DemonRegisterDemon (Demon *demon)
 Adds a new demon and wraps it inside a DemonProfiler if necessary.
 
IntExprRegisterIntExpr (IntExpr *expr)
 Registers a new IntExpr and wraps it inside a TraceIntExpr if necessary.
 
IntVarRegisterIntVar (IntVar *var)
 Registers a new IntVar and wraps it inside a TraceIntVar if necessary.
 
IntervalVarRegisterIntervalVar (IntervalVar *var)
 
SearchActiveSearch () const
 Returns the active search, nullptr outside search.
 
ModelCacheCache () const
 Returns the cache of the model.
 
bool InstrumentsDemons () const
 Returns whether we are instrumenting demons.
 
bool IsProfilingEnabled () const
 Returns whether we are profiling the solver.
 
bool IsLocalSearchProfilingEnabled () const
 Returns whether we are profiling local search.
 
bool InstrumentsVariables () const
 Returns whether we are tracing variables.
 
bool NameAllVariables () const
 Returns whether all variables should be named.
 
std::string model_name () const
 Returns the name of the model.
 
PropagationMonitorGetPropagationMonitor () const
 Returns the propagation monitor.
 
void AddPropagationMonitor (PropagationMonitor *monitor)
 
LocalSearchMonitorGetLocalSearchMonitor () const
 Returns the local search monitor.
 
void AddLocalSearchMonitor (LocalSearchMonitor *monitor)
 
void SetSearchContext (Search *search, absl::string_view search_context)
 
std::string SearchContext () const
 
std::string SearchContext (const Search *search) const
 
AssignmentGetOrCreateLocalSearchState ()
 
void ClearLocalSearchState ()
 Clears the local search state.
 
bool IsBooleanVar (IntExpr *expr, IntVar **inner_var, bool *is_negated) const
 
bool IsProduct (IntExpr *expr, IntExpr **inner_expr, int64_t *coefficient)
 
IntExprCastExpression (const IntVar *var) const
 !defined(SWIG)
 
void FinishCurrentSearch ()
 Tells the solver to kill or restart the current search.
 
void RestartCurrentSearch ()
 
void ShouldFail ()
 
void CheckFail ()
 
DecisionBuilderMakeProfiledDecisionBuilderWrapper (DecisionBuilder *db)
 Activates profiling on a decision builder.
 
bool Solve (DecisionBuilder *db, const std::vector< SearchMonitor * > &monitors)
 
bool Solve (DecisionBuilder *db)
 
bool Solve (DecisionBuilder *db, SearchMonitor *m1)
 
bool Solve (DecisionBuilder *db, SearchMonitor *m1, SearchMonitor *m2)
 
bool Solve (DecisionBuilder *db, SearchMonitor *m1, SearchMonitor *m2, SearchMonitor *m3)
 
bool Solve (DecisionBuilder *db, SearchMonitor *m1, SearchMonitor *m2, SearchMonitor *m3, SearchMonitor *m4)
 
void NewSearch (DecisionBuilder *db, const std::vector< SearchMonitor * > &monitors)
 Opens a new top level search.
 
void NewSearch (DecisionBuilder *db)
 
void NewSearch (DecisionBuilder *db, SearchMonitor *m1)
 
void NewSearch (DecisionBuilder *db, SearchMonitor *m1, SearchMonitor *m2)
 
void NewSearch (DecisionBuilder *db, SearchMonitor *m1, SearchMonitor *m2, SearchMonitor *m3)
 
void NewSearch (DecisionBuilder *db, SearchMonitor *m1, SearchMonitor *m2, SearchMonitor *m3, SearchMonitor *m4)
 
bool NextSolution ()
 Search for the next solution in the search tree.
 
void RestartSearch ()
 
void EndSearch ()
 

Static Public Member Functions

static ConstraintSolverParameters DefaultSolverParameters ()
 --— ConstraintSolverParameters --—
 
static int64_t MemoryUsage ()
 Current memory usage in bytes.
 

Public Attributes

std::vector< int64_t > tmp_vector_
 

Static Public Attributes

static constexpr int kNumPriorities = 3
 Number of priorities for demons.
 

Friends

class BaseIntExpr
 
class Constraint
 
class DemonProfiler
 
class FindOneNeighbor
 
class IntVar
 
class PropagationBaseObject
 
class Queue
 
class SearchMonitor
 
class SearchLimit
 
class RoutingModel
 
class LocalSearch
 
class LocalSearchProfiler
 
template<class >
class SimpleRevFIFO
 
template<class K , class V >
class RevImmutableMultiMap
 
void InternalSaveBooleanVarValue (Solver *solver, IntVar *var)
 

Detailed Description

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

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.

Definition at line 266 of file constraint_solver.h.

Member Typedef Documentation

◆ Action

Todo
(user): wrap in swig.

Definition at line 807 of file constraint_solver.h.

◆ BranchSelector

◆ Closure

std::function<void()> operations_research::Solver::Closure

Definition at line 808 of file constraint_solver.h.

◆ IndexEvaluator1

std::function<int64_t(int64_t)> operations_research::Solver::IndexEvaluator1

Callback typedefs.

Definition at line 788 of file constraint_solver.h.

◆ IndexEvaluator2

std::function<int64_t(int64_t, int64_t)> operations_research::Solver::IndexEvaluator2

Definition at line 789 of file constraint_solver.h.

◆ IndexEvaluator3

std::function<int64_t(int64_t, int64_t, int64_t)> operations_research::Solver::IndexEvaluator3

Definition at line 790 of file constraint_solver.h.

◆ IndexFilter1

std::function<bool(int64_t)> operations_research::Solver::IndexFilter1

Definition at line 792 of file constraint_solver.h.

◆ Int64ToIntVar

Definition at line 794 of file constraint_solver.h.

◆ VariableIndexSelector

std::function<int64_t(Solver* solver, const std::vector<IntVar*>& vars, int64_t first_unbound, int64_t last_unbound)> operations_research::Solver::VariableIndexSelector

Definition at line 799 of file constraint_solver.h.

◆ VariableValueComparator

std::function<bool(int64_t, int64_t, int64_t)> operations_research::Solver::VariableValueComparator

Definition at line 804 of file constraint_solver.h.

◆ VariableValueSelector

std::function<int64_t(const IntVar* v, int64_t id)> operations_research::Solver::VariableValueSelector

Definition at line 802 of file constraint_solver.h.

Member Enumeration Documentation

◆ BinaryIntervalRelation

This enum is used in Solver::MakeIntervalVarRelation to specify the temporal relation between the two intervals t1 and t2.

Enumerator
ENDS_AFTER_END 

t1 ends after t2 end, i.e. End(t1) >= End(t2) + delay.

ENDS_AFTER_START 

t1 ends after t2 start, i.e. End(t1) >= Start(t2) + delay.

ENDS_AT_END 

t1 ends at t2 end, i.e. End(t1) == End(t2) + delay.

ENDS_AT_START 

t1 ends at t2 start, i.e. End(t1) == Start(t2) + delay.

STARTS_AFTER_END 

t1 starts after t2 end, i.e. Start(t1) >= End(t2) + delay.

STARTS_AFTER_START 

t1 starts after t2 start, i.e. Start(t1) >= Start(t2) + delay.

STARTS_AT_END 

t1 starts at t2 end, i.e. Start(t1) == End(t2) + delay.

STARTS_AT_START 

t1 starts at t2 start, i.e. Start(t1) == Start(t2) + delay.

STAYS_IN_SYNC 

STARTS_AT_START and ENDS_AT_END at the same time. t1 starts at t2 start, i.e. Start(t1) == Start(t2) + delay. t1 ends at t2 end, i.e. End(t1) == End(t2).

Definition at line 641 of file constraint_solver.h.

◆ DecisionModification

The Solver is responsible for creating the search tree. Thanks to the DecisionBuilder, it creates a new decision with two branches at each node: left and right. The DecisionModification enum is used to specify how the branch selector should behave.

Enumerator
NO_CHANGE 

Keeps the default behavior, i.e. apply left branch first, and then right branch in case of backtracking.

KEEP_LEFT 

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

KEEP_RIGHT 

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

KILL_BOTH 

Backtracks to the previous decisions, i.e. left and right branches are not applied.

SWITCH_BRANCHES 

Applies right branch first. Left branch will be applied in case of backtracking.

Definition at line 709 of file constraint_solver.h.

◆ DemonPriority

This enum represents the three possible priorities for a demon in the Solver queue.

Note
this is for advanced users only.
Enumerator
DELAYED_PRIORITY 

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

VAR_PRIORITY 

VAR_PRIORITY is between DELAYED_PRIORITY and NORMAL_PRIORITY.

NORMAL_PRIORITY 

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

Definition at line 627 of file constraint_solver.h.

◆ EvaluatorLocalSearchOperators

This enum is used in Solver::MakeOperator associated with an evaluator to specify the neighborhood to create.

Enumerator
LK 

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

TSPOPT 

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

TSPLNS 

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

Definition at line 586 of file constraint_solver.h.

◆ EvaluatorStrategy

This enum is used by Solver::MakePhase to specify how to select variables and values during the search. In Solver::MakePhase(const std::vector<IntVar*>&, IntVarStrategy, IntValueStrategy), variables are selected first, and then the associated value. In Solver::MakePhase(const std::vector<IntVar*>& vars, IndexEvaluator2, EvaluatorStrategy), the selection is done scanning every pair <variable, possible value>. The next selected pair is then the best among all possibilities, i.e. the pair with the smallest evaluation. As this is costly, two options are offered: static or dynamic evaluation.

Enumerator
CHOOSE_STATIC_GLOBAL_BEST 

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

CHOOSE_DYNAMIC_GLOBAL_BEST 

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

Definition at line 408 of file constraint_solver.h.

◆ IntervalStrategy

This enum describes the straregy used to select the next interval variable and its value to be fixed.

Enumerator
INTERVAL_DEFAULT 

The default is INTERVAL_SET_TIMES_FORWARD.

INTERVAL_SIMPLE 

The simple is INTERVAL_SET_TIMES_FORWARD.

INTERVAL_SET_TIMES_FORWARD 

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

INTERVAL_SET_TIMES_BACKWARD 

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

Definition at line 432 of file constraint_solver.h.

◆ IntValueStrategy

Todo
(user): add HIGHEST_MIN and LOWEST_MAX.

This enum describes the strategy used to select the next variable value to set.

Enumerator
INT_VALUE_DEFAULT 

The default behavior is ASSIGN_MIN_VALUE.

INT_VALUE_SIMPLE 

The simple selection is ASSIGN_MIN_VALUE.

ASSIGN_MIN_VALUE 

Selects the min value of the selected variable.

ASSIGN_MAX_VALUE 

Selects the max value of the selected variable.

ASSIGN_RANDOM_VALUE 

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

ASSIGN_CENTER_VALUE 

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

SPLIT_LOWER_HALF 

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

SPLIT_UPPER_HALF 

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

Definition at line 368 of file constraint_solver.h.

◆ IntVarStrategy

This enum describes the strategy used to select the next branching variable at each node during the search.

Enumerator
INT_VAR_DEFAULT 

The default behavior is CHOOSE_FIRST_UNBOUND.

INT_VAR_SIMPLE 

The simple selection is CHOOSE_FIRST_UNBOUND.

CHOOSE_FIRST_UNBOUND 

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

CHOOSE_RANDOM 

Randomly select one of the remaining unbound variables.

CHOOSE_MIN_SIZE_LOWEST_MIN 

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

CHOOSE_MIN_SIZE_HIGHEST_MIN 

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

CHOOSE_MIN_SIZE_LOWEST_MAX 

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

CHOOSE_MIN_SIZE_HIGHEST_MAX 

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

CHOOSE_LOWEST_MIN 

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

CHOOSE_HIGHEST_MAX 

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

CHOOSE_MIN_SIZE 

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

CHOOSE_MAX_SIZE 

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

CHOOSE_MAX_REGRET_ON_MIN 

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

CHOOSE_PATH 

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

Definition at line 287 of file constraint_solver.h.

◆ LocalSearchFilterBound

This enum is used in Solver::MakeLocalSearchObjectiveFilter. It specifies the behavior of the objective filter to create. The goal is to define under which condition a move is accepted based on the current objective value.

Enumerator
GE 

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

LE 

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

EQ 

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

Definition at line 614 of file constraint_solver.h.

◆ LocalSearchOperators

This enum is used in Solver::MakeOperator to specify the neighborhood to create.

Enumerator
TWOOPT 

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

OROPT 

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

RELOCATE 

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

EXCHANGE 

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

CROSS 

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

MAKEACTIVE 

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

MAKEINACTIVE 

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

MAKECHAININACTIVE 

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

SWAPACTIVE 

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

EXTENDEDSWAPACTIVE 

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

PATHLNS 

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

Note
the two sub-chains can be part of the same path; they even may overlap.
FULLPATHLNS 

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

UNACTIVELNS 

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

INCREMENT 

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

DECREMENT 

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

SIMPLELNS 

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

Definition at line 447 of file constraint_solver.h.

◆ MarkerType

This enum is used internally in private methods Solver::PushState and Solver::PopState to tag states in the search tree.

Enumerator
SENTINEL 
SIMPLE_MARKER 
CHOICE_POINT 
REVERSIBLE_ACTION 

Definition at line 735 of file constraint_solver.h.

◆ MonitorEvent

Search monitor events.

Enumerator
kEnterSearch 
kRestartSearch 
kExitSearch 
kBeginNextDecision 
kEndNextDecision 
kApplyDecision 
kRefuteDecision 
kAfterDecision 
kBeginFail 
kEndFail 
kBeginInitialPropagation 
kEndInitialPropagation 
kAcceptSolution 
kAtSolution 
kNoMoreSolutions 
kLocalOptimum 
kAcceptDelta 
kAcceptNeighbor 
kAcceptUncheckedNeighbor 
kIsUncheckedSolutionLimitReached 
kPeriodicCheck 
kProgressPercent 
kAccept 
kLast 

Dummy event whose underlying int is the number of MonitorEvent enums.

Definition at line 758 of file constraint_solver.h.

◆ OptimizationDirection

Optimization directions.

Enumerator
NOT_SET 
MAXIMIZATION 
MINIMIZATION 

Definition at line 754 of file constraint_solver.h.

◆ SequenceStrategy

Used for scheduling. Not yet implemented.

Enumerator
SEQUENCE_DEFAULT 
SEQUENCE_SIMPLE 
CHOOSE_MIN_SLACK_RANK_FORWARD 
CHOOSE_RANDOM_RANK_FORWARD 

Definition at line 423 of file constraint_solver.h.

◆ SolverState

This enum represents the state of the solver w.r.t. the search.

Enumerator
OUTSIDE_SEARCH 

Before search, after search.

IN_ROOT_NODE 

Executing the root node.

IN_SEARCH 

Executing the search code.

AT_SOLUTION 

After successful NextSolution and before EndSearch.

NO_MORE_SOLUTIONS 

After failed NextSolution and before EndSearch.

PROBLEM_INFEASIBLE 

After search, the model is infeasible.

Definition at line 738 of file constraint_solver.h.

◆ UnaryIntervalRelation

This enum is used in Solver::MakeIntervalVarRelation to specify the temporal relation between an interval t and an integer d.

Enumerator
ENDS_AFTER 

t ends after d, i.e. End(t) >= d.

ENDS_AT 

t ends at d, i.e. End(t) == d.

ENDS_BEFORE 

t ends before d, i.e. End(t) <= d.

STARTS_AFTER 

t starts after d, i.e. Start(t) >= d.

STARTS_AT 

t starts at d, i.e. Start(t) == d.

STARTS_BEFORE 

t starts before d, i.e. Start(t) <= d.

CROSS_DATE 

STARTS_BEFORE and ENDS_AFTER at the same time, i.e. d is in t. t starts before d, i.e. Start(t) <= d. t ends after d, i.e. End(t) >= d.

AVOID_DATE 

STARTS_AFTER or ENDS_BEFORE, i.e. d is not in t. t starts after d, i.e. Start(t) >= d. t ends before d, i.e. End(t) <= d.

Definition at line 674 of file constraint_solver.h.

Constructor & Destructor Documentation

◆ Solver() [1/3]

operations_research::Solver::Solver ( const std::string & name)
explicit

Solver API.

Definition at line 1448 of file constraint_solver.cc.

◆ Solver() [2/3]

operations_research::Solver::Solver ( const std::string & name,
const ConstraintSolverParameters & parameters )

Definition at line 1437 of file constraint_solver.cc.

◆ Solver() [3/3]

operations_research::Solver::Solver ( const Solver & )
delete

This type is neither copyable nor movable.

◆ ~Solver()

operations_research::Solver::~Solver ( )

solver destructor called with searches open.

Not popping a SENTINEL in Solver destructor.

Not popping initial SENTINEL in Solver destructor.

Definition at line 1502 of file constraint_solver.cc.

Member Function Documentation

◆ Accept()

void operations_research::Solver::Accept ( ModelVisitor * visitor) const

Accepts the given model visitor.

Definition at line 1726 of file constraint_solver.cc.

◆ accepted_neighbors()

int64_t operations_research::Solver::accepted_neighbors ( ) const
inline

The number of accepted neighbors.

Definition at line 1081 of file constraint_solver.h.

◆ ActiveSearch()

Search * operations_research::Solver::ActiveSearch ( ) const

Returns the active search, nullptr outside search.

Definition at line 1155 of file constraint_solver.cc.

◆ AddBacktrackAction()

void operations_research::Solver::AddBacktrackAction ( 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.

Definition at line 1622 of file constraint_solver.cc.

◆ AddCastConstraint()

void operations_research::Solver::AddCastConstraint ( CastConstraint * constraint,
IntVar * target_var,
IntExpr * expr )

Adds 'constraint' to the solver and marks it as a cast constraint, that is, a constraint created calling Var() on an expression. This is used internally.

Definition at line 1714 of file constraint_solver.cc.

◆ AddConstraint()

void operations_research::Solver::AddConstraint ( Constraint * c)

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

  • the most common use case is modeling: the given constraint is really part of the problem that the user is trying to solve. In this use case, AddConstraint is called outside of search (i.e., with state() == OUTSIDE_SEARCH). Most users should only use AddConstraint in this way. In this case, the constraint will belong to the model forever: it cannot be removed by backtracking.
  • a rarer use case is that 'c' is not a real constraint of the model. It may be a constraint generated by a branching decision (a constraint whose goal is to restrict the search space), a symmetry breaking constraint (a constraint that does restrict the search space, but in a way that cannot have an impact on the quality of the solutions in the subtree), or an inferred constraint that, while having no semantic value to the model (it does not restrict the set of solutions), is worth having because we believe it may strengthen the propagation. In these cases, it happens that the constraint is added during the search (i.e., with state() == IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is added during a search, it applies only to the subtree of the search tree rooted at the current node, and will be automatically removed by backtracking. This method does not take ownership of the constraint. If the constraint has been created by any factory method (Solver::MakeXXX), it will automatically be deleted. However, power users who implement their own constraints should do: solver.AddConstraint(solver.RevAlloc(new MyConstraint(...));

Definition at line 1690 of file constraint_solver.cc.

◆ AddLocalSearchMonitor()

void operations_research::Solver::AddLocalSearchMonitor ( LocalSearchMonitor * monitor)

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

Definition at line 3231 of file constraint_solver.cc.

◆ AddPropagationMonitor()

void operations_research::Solver::AddPropagationMonitor ( PropagationMonitor * monitor)

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

Todo
(user): Check solver state?

Definition at line 3153 of file constraint_solver.cc.

◆ balancing_decision()

Decision * operations_research::Solver::balancing_decision ( ) const
inline

Definition at line 3076 of file constraint_solver.h.

◆ branches()

int64_t operations_research::Solver::branches ( ) const
inline

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

Definition at line 1055 of file constraint_solver.h.

◆ Cache()

ModelCache * operations_research::Solver::Cache ( ) const

Returns the cache of the model.

Definition at line 850 of file model_cache.cc.

◆ CastExpression()

IntExpr * operations_research::Solver::CastExpression ( const IntVar * var) const

!defined(SWIG)

--— Cast Expression --—

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

Definition at line 2427 of file constraint_solver.cc.

◆ CheckAssignment()

bool operations_research::Solver::CheckAssignment ( Assignment * solution)

Checks whether the given assignment satisfies all relevant constraints.

Check state and go to OUTSIDE_SEARCH.

Push monitors and enter search.

Push sentinel and set decision builder.

Definition at line 2293 of file constraint_solver.cc.

◆ CheckConstraint()

bool operations_research::Solver::CheckConstraint ( Constraint * ct)

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

Definition at line 2372 of file constraint_solver.cc.

◆ CheckFail()

void operations_research::Solver::CheckFail ( )
inline

Definition at line 3192 of file constraint_solver.h.

◆ clear_fail_intercept()

void operations_research::Solver::clear_fail_intercept ( )
inline

Definition at line 3084 of file constraint_solver.h.

◆ ClearLocalSearchState()

void operations_research::Solver::ClearLocalSearchState ( )
inline

Clears the local search state.

Definition at line 3140 of file constraint_solver.h.

◆ ClearNeighbors()

void operations_research::Solver::ClearNeighbors ( )
inline

Manipulate neighbors count; to be used for testing purposes only.

Todo
(user): Find a workaround to avoid exposing this.

Definition at line 1074 of file constraint_solver.h.

◆ Compose() [1/4]

DecisionBuilder * operations_research::Solver::Compose ( const std::vector< DecisionBuilder * > & dbs)

Definition at line 639 of file search.cc.

◆ Compose() [2/4]

DecisionBuilder * operations_research::Solver::Compose ( DecisionBuilder * db1,
DecisionBuilder * db2 )

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

Definition at line 609 of file search.cc.

◆ Compose() [3/4]

DecisionBuilder * operations_research::Solver::Compose ( DecisionBuilder * db1,
DecisionBuilder * db2,
DecisionBuilder * db3 )

Definition at line 617 of file search.cc.

◆ Compose() [4/4]

DecisionBuilder * operations_research::Solver::Compose ( DecisionBuilder * db1,
DecisionBuilder * db2,
DecisionBuilder * db3,
DecisionBuilder * db4 )

Definition at line 627 of file search.cc.

◆ ConcatenateOperators() [1/3]

LocalSearchOperator * operations_research::Solver::ConcatenateOperators ( 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].

Definition at line 2161 of file local_search.cc.

◆ ConcatenateOperators() [2/3]

LocalSearchOperator * operations_research::Solver::ConcatenateOperators ( const std::vector< LocalSearchOperator * > & ops,
bool restart )

Definition at line 2166 of file local_search.cc.

◆ ConcatenateOperators() [3/3]

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

Definition at line 2178 of file local_search.cc.

◆ const_parameters()

const ConstraintSolverParameters & operations_research::Solver::const_parameters ( ) const
inline

Read-only.

Definition at line 825 of file constraint_solver.h.

◆ constraints()

int operations_research::Solver::constraints ( ) const
inline

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

Definition at line 3071 of file constraint_solver.h.

◆ context()

const std::string & operations_research::Solver::context ( ) const
inline

Gets the current context of the search.

Definition at line 1094 of file constraint_solver.h.

◆ CurrentlyInSolve()

bool operations_research::Solver::CurrentlyInSolve ( ) const

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.

Definition at line 1779 of file constraint_solver.cc.

◆ DebugString()

std::string operations_research::Solver::DebugString ( ) const

!defined(SWIG)

misc debug string.

Definition at line 1518 of file constraint_solver.cc.

◆ DefaultSolverParameters()

ConstraintSolverParameters operations_research::Solver::DefaultSolverParameters ( )
static

--— ConstraintSolverParameters --—

Create a ConstraintSolverParameters proto with all the default values.

Todo
(user): Move to constraint_solver_parameters.h.

Definition at line 129 of file constraint_solver.cc.

◆ demon_profiler()

DemonProfiler * operations_research::Solver::demon_profiler ( ) const
inline

Access to demon profiler.

Definition at line 3086 of file constraint_solver.h.

◆ demon_runs()

int64_t operations_research::Solver::demon_runs ( DemonPriority p) const
inline

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

Definition at line 1064 of file constraint_solver.h.

◆ EndSearch()

void operations_research::Solver::EndSearch ( )

Restores the state.

Checks if we want to export the profile info.

Definition at line 2262 of file constraint_solver.cc.

◆ ExportProfilingOverview()

void operations_research::Solver::ExportProfilingOverview ( 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.

Definition at line 435 of file demon_profiler.cc.

◆ Fail()

void operations_research::Solver::Fail ( )

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

Definition at line 2406 of file constraint_solver.cc.

◆ fail_stamp()

uint64_t operations_research::Solver::fail_stamp ( ) const

The fail_stamp() is incremented after each backtrack.

Definition at line 1678 of file constraint_solver.cc.

◆ failures()

int64_t operations_research::Solver::failures ( ) const
inline

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

Definition at line 1067 of file constraint_solver.h.

◆ filtered_neighbors()

int64_t operations_research::Solver::filtered_neighbors ( ) const
inline

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

Definition at line 1078 of file constraint_solver.h.

◆ FinishCurrentSearch()

void operations_research::Solver::FinishCurrentSearch ( )

Tells the solver to kill or restart the current search.

Definition at line 2417 of file constraint_solver.cc.

◆ GetConstraintSolverStatistics()

ConstraintSolverStatistics operations_research::Solver::GetConstraintSolverStatistics ( ) const

Returns detailed cp search statistics.

Definition at line 1579 of file constraint_solver.cc.

◆ GetLocalSearchMonitor()

LocalSearchMonitor * operations_research::Solver::GetLocalSearchMonitor ( ) const

Returns the local search monitor.

Definition at line 3237 of file constraint_solver.cc.

◆ GetLocalSearchStatistics()

LocalSearchStatistics operations_research::Solver::GetLocalSearchStatistics ( ) const

Returns detailed local search statistics.

Definition at line 4598 of file local_search.cc.

◆ GetOrCreateLocalSearchState()

Assignment * operations_research::Solver::GetOrCreateLocalSearchState ( )

Returns (or creates) an assignment representing the state of local search.

Todo
(user): Investigate if this should be moved to Search.

Definition at line 3254 of file constraint_solver.cc.

◆ GetPropagationMonitor()

PropagationMonitor * operations_research::Solver::GetPropagationMonitor ( ) const

Returns the propagation monitor.

Definition at line 3158 of file constraint_solver.cc.

◆ HasName()

bool operations_research::Solver::HasName ( const PropagationBaseObject * object) const

Returns whether the object has been named or not.

Definition at line 2475 of file constraint_solver.cc.

◆ IncrementNeighbors()

void operations_research::Solver::IncrementNeighbors ( )
inline

Definition at line 1075 of file constraint_solver.h.

◆ InstrumentsDemons()

bool operations_research::Solver::InstrumentsDemons ( ) const

Returns whether we are instrumenting demons.

Todo
(user): remove this complex logic. We need the double test because parameters are set too late when using python in the open source. This is the cheapest work-around.

Definition at line 180 of file constraint_solver.cc.

◆ InstrumentsVariables()

bool operations_research::Solver::InstrumentsVariables ( ) const

Returns whether we are tracing variables.

Definition at line 194 of file constraint_solver.cc.

◆ IsBooleanVar()

bool operations_research::Solver::IsBooleanVar ( IntExpr * expr,
IntVar ** inner_var,
bool * is_negated ) const

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

Definition at line 7508 of file expressions.cc.

◆ IsLocalSearchProfilingEnabled()

bool operations_research::Solver::IsLocalSearchProfilingEnabled ( ) const

Returns whether we are profiling local search.

Definition at line 189 of file constraint_solver.cc.

◆ IsProduct()

bool operations_research::Solver::IsProduct ( IntExpr * 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.

Definition at line 7526 of file expressions.cc.

◆ IsProfilingEnabled()

bool operations_research::Solver::IsProfilingEnabled ( ) const

Returns whether we are profiling the solver.

Definition at line 184 of file constraint_solver.cc.

◆ LocalSearchProfile()

std::string operations_research::Solver::LocalSearchProfile ( ) const

Returns local search profiling information in a human readable format.

Todo
(user): Merge demon and local search profiles.

Definition at line 4591 of file local_search.cc.

◆ MakeAbs()

IntExpr * operations_research::Solver::MakeAbs ( IntExpr * expr)

expr

Definition at line 7049 of file expressions.cc.

◆ MakeAbsEquality()

Constraint * operations_research::Solver::MakeAbsEquality ( IntVar * var,
IntVar * abs_var )

Creates the constraint abs(var) == abs_var.

Definition at line 7042 of file expressions.cc.

◆ MakeAcceptFilter()

LocalSearchFilter * operations_research::Solver::MakeAcceptFilter ( )

Local Search Filters.

Definition at line 2634 of file local_search.cc.

◆ MakeActionDemon()

Demon * operations_research::Solver::MakeActionDemon ( Solver::Action action)

Creates a demon from a callback.

--— API --—

Definition at line 522 of file constraints.cc.

◆ MakeAllDifferent() [1/2]

Constraint * operations_research::Solver::MakeAllDifferent ( const std::vector< IntVar * > & vars)

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

Definition at line 694 of file alldiff_cst.cc.

◆ MakeAllDifferent() [2/2]

Constraint * operations_research::Solver::MakeAllDifferent ( 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.

Definition at line 698 of file alldiff_cst.cc.

◆ MakeAllDifferentExcept()

Constraint * operations_research::Solver::MakeAllDifferentExcept ( const std::vector< IntVar * > & vars,
int64_t escape_value )

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

Definition at line 724 of file alldiff_cst.cc.

◆ MakeAllowedAssignments()

Constraint * operations_research::Solver::MakeAllowedAssignments ( const std::vector< IntVar * > & vars,
const IntTupleSet & tuples )

------— API -------—

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.

Definition at line 1259 of file table.cc.

◆ MakeAllSolutionCollector() [1/2]

SolutionCollector * operations_research::Solver::MakeAllSolutionCollector ( )

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

Definition at line 2942 of file search.cc.

◆ MakeAllSolutionCollector() [2/2]

SolutionCollector * operations_research::Solver::MakeAllSolutionCollector ( const Assignment * assignment)

Collect all solutions of the search.

Definition at line 2937 of file search.cc.

◆ MakeApplyBranchSelector()

DecisionBuilder * operations_research::Solver::MakeApplyBranchSelector ( BranchSelector bs)

Creates a decision builder that will set the branch selector.

Definition at line 1195 of file constraint_solver.cc.

◆ MakeAssignment() [1/2]

Assignment * operations_research::Solver::MakeAssignment ( )

This method creates an empty assignment.

Definition at line 969 of file assignment.cc.

◆ MakeAssignment() [2/2]

Assignment * operations_research::Solver::MakeAssignment ( const Assignment * a)

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

Definition at line 971 of file assignment.cc.

◆ MakeAssignVariablesValues()

Decision * operations_research::Solver::MakeAssignVariablesValues ( const std::vector< IntVar * > & vars,
const std::vector< int64_t > & values )

Definition at line 1846 of file search.cc.

◆ MakeAssignVariablesValuesOrDoNothing()

Decision * operations_research::Solver::MakeAssignVariablesValuesOrDoNothing ( const std::vector< IntVar * > & vars,
const std::vector< int64_t > & values )

Definition at line 1854 of file search.cc.

◆ MakeAssignVariablesValuesOrFail()

Decision * operations_research::Solver::MakeAssignVariablesValuesOrFail ( const std::vector< IntVar * > & vars,
const std::vector< int64_t > & values )

Definition at line 1861 of file search.cc.

◆ MakeAssignVariableValue()

Decision * operations_research::Solver::MakeAssignVariableValue ( IntVar * var,
int64_t val )

Decisions.

Definition at line 1616 of file search.cc.

◆ MakeAssignVariableValueOrDoNothing()

Decision * operations_research::Solver::MakeAssignVariableValueOrDoNothing ( IntVar * var,
int64_t value )

Definition at line 1683 of file search.cc.

◆ MakeAssignVariableValueOrFail()

Decision * operations_research::Solver::MakeAssignVariableValueOrFail ( IntVar * var,
int64_t value )

Definition at line 1654 of file search.cc.

◆ MakeAtMost()

Constraint * operations_research::Solver::MakeAtMost ( std::vector< IntVar * > vars,
int64_t value,
int64_t max_count )

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

--— Factory --—

Definition at line 957 of file count_cst.cc.

◆ MakeAtSolutionCallback()

SearchMonitor * operations_research::Solver::MakeAtSolutionCallback ( std::function< void()> callback)

Definition at line 465 of file search.cc.

◆ MakeBestLexicographicValueSolutionCollector() [1/2]

SolutionCollector * operations_research::Solver::MakeBestLexicographicValueSolutionCollector ( const Assignment * assignment,
std::vector< bool > maximize )

Same as above, but supporting lexicographic objectives; 'maximize' specifies the optimization direction for each objective in 'assignment'.

Definition at line 2737 of file search.cc.

◆ MakeBestLexicographicValueSolutionCollector() [2/2]

SolutionCollector * operations_research::Solver::MakeBestLexicographicValueSolutionCollector ( std::vector< bool > maximize)

Same as above, but supporting lexicographic objectives; 'maximize' specifies the optimization direction for each objective.

Definition at line 2747 of file search.cc.

◆ MakeBestValueSolutionCollector() [1/2]

SolutionCollector * operations_research::Solver::MakeBestValueSolutionCollector ( bool maximize)

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

Definition at line 2743 of file search.cc.

◆ MakeBestValueSolutionCollector() [2/2]

SolutionCollector * operations_research::Solver::MakeBestValueSolutionCollector ( const Assignment * 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).

Definition at line 2732 of file search.cc.

◆ MakeBetweenCt()

Constraint * operations_research::Solver::MakeBetweenCt ( IntExpr * expr,
int64_t l,
int64_t u )

--— Between and related constraints --—

(l <= expr <= u)

Catch empty and singleton intervals.

Catch the trivial cases first.

Catch one-sided constraints.

Simplify the common factor, if any.

No further reduction is possible.

Definition at line 929 of file expr_cst.cc.

◆ MakeBoolVar() [1/2]

IntVar * operations_research::Solver::MakeBoolVar ( )

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

Definition at line 6444 of file expressions.cc.

◆ MakeBoolVar() [2/2]

IntVar * operations_research::Solver::MakeBoolVar ( const std::string & name)

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

Definition at line 6440 of file expressions.cc.

◆ MakeBoolVarArray() [1/3]

IntVar ** operations_research::Solver::MakeBoolVarArray ( int var_count,
const std::string & name )

Same but allocates an array and returns it.

Definition at line 6581 of file expressions.cc.

◆ MakeBoolVarArray() [2/3]

void operations_research::Solver::MakeBoolVarArray ( 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<i>" where is the index of the variable.

Definition at line 6568 of file expressions.cc.

◆ MakeBoolVarArray() [3/3]

void operations_research::Solver::MakeBoolVarArray ( int var_count,
std::vector< IntVar * > * vars )

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

Definition at line 6575 of file expressions.cc.

◆ MakeBranchesLimit()

RegularLimit * operations_research::Solver::MakeBranchesLimit ( int64_t branches)

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

Definition at line 4508 of file search.cc.

◆ MakeCircuit()

Constraint * operations_research::Solver::MakeCircuit ( const std::vector< IntVar * > & nexts)

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

Todo
(user): Merge NoCycle and Circuit.

Definition at line 640 of file graph_constraints.cc.

◆ MakeClosureDemon()

Demon * operations_research::Solver::MakeClosureDemon ( Solver::Closure closure)

Creates a demon from a closure.

!defined(SWIG)

Definition at line 526 of file constraints.cc.

◆ MakeConditionalExpression()

IntExpr * operations_research::Solver::MakeConditionalExpression ( IntVar * condition,
IntExpr * expr,
int64_t unperformed_value )

Conditional Expr condition ? expr : unperformed_value.

--— Conditional Expression --—

Definition at line 7281 of file expressions.cc.

◆ MakeConstantRestart()

SearchMonitor * operations_research::Solver::MakeConstantRestart ( int frequency)

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

Definition at line 5154 of file search.cc.

◆ MakeConstraintAdder()

DecisionBuilder * operations_research::Solver::MakeConstraintAdder ( Constraint * ct)

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

Definition at line 2368 of file constraint_solver.cc.

◆ MakeConstraintInitialPropagateCallback()

Demon * operations_research::Solver::MakeConstraintInitialPropagateCallback ( Constraint * ct)

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

Definition at line 37 of file constraints.cc.

◆ MakeConvexPiecewiseExpr()

IntExpr * operations_research::Solver::MakeConvexPiecewiseExpr ( IntExpr * expr,
int64_t early_cost,
int64_t early_date,
int64_t late_date,
int64_t late_cost )

Convex piecewise function.

Definition at line 7194 of file expressions.cc.

◆ MakeCount() [1/2]

Constraint * operations_research::Solver::MakeCount ( const std::vector< IntVar * > & vars,
int64_t value,
int64_t max_count )

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

Definition at line 33 of file count_cst.cc.

◆ MakeCount() [2/2]

Constraint * operations_research::Solver::MakeCount ( const std::vector< IntVar * > & vars,
int64_t value,
IntVar * max_count )

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

Definition at line 48 of file count_cst.cc.

◆ MakeCover()

Constraint * operations_research::Solver::MakeCover ( const std::vector< IntervalVar * > & vars,
IntervalVar * target_var )

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

Definition at line 588 of file sched_constraints.cc.

◆ MakeCumulative() [1/6]

Constraint * operations_research::Solver::MakeCumulative ( 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.

Definition at line 2634 of file resource.cc.

◆ MakeCumulative() [2/6]

Constraint * operations_research::Solver::MakeCumulative ( const std::vector< IntervalVar * > & intervals,
const std::vector< int > & demands,
IntVar * 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.

Definition at line 2652 of file resource.cc.

◆ MakeCumulative() [3/6]

Constraint * operations_research::Solver::MakeCumulative ( const std::vector< IntervalVar * > & intervals,
const std::vector< int64_t > & demands,
int64_t capacity,
const std::string & name )

Demands are constant.

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.

Definition at line 2620 of file resource.cc.

◆ MakeCumulative() [4/6]

Constraint * operations_research::Solver::MakeCumulative ( const std::vector< IntervalVar * > & intervals,
const std::vector< int64_t > & demands,
IntVar * capacity,
absl::string_view 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.

Definition at line 2640 of file resource.cc.

◆ MakeCumulative() [5/6]

Constraint * operations_research::Solver::MakeCumulative ( const std::vector< IntervalVar * > & intervals,
const std::vector< IntVar * > & demands,
int64_t capacity,
const std::string & name )

Demands should be positive.

Demands are variable.

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.

Definition at line 2661 of file resource.cc.

◆ MakeCumulative() [6/6]

Constraint * operations_research::Solver::MakeCumulative ( const std::vector< IntervalVar * > & intervals,
const std::vector< IntVar * > & demands,
IntVar * capacity,
const std::string & name )

Demands should be positive.

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.

Definition at line 2679 of file resource.cc.

◆ MakeCustomLimit()

SearchLimit * operations_research::Solver::MakeCustomLimit ( 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.

Definition at line 4844 of file search.cc.

◆ MakeDecision()

Decision * operations_research::Solver::MakeDecision ( Action apply,
Action refute )

Definition at line 667 of file search.cc.

◆ MakeDecisionBuilderFromAssignment()

DecisionBuilder * operations_research::Solver::MakeDecisionBuilderFromAssignment ( Assignment * assignment,
DecisionBuilder * 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'.

Definition at line 2303 of file search.cc.

◆ MakeDefaultPhase() [1/2]

DecisionBuilder * operations_research::Solver::MakeDefaultPhase ( const std::vector< IntVar * > & vars)

Definition at line 1126 of file default_search.cc.

◆ MakeDefaultPhase() [2/2]

DecisionBuilder * operations_research::Solver::MakeDefaultPhase ( const std::vector< IntVar * > & vars,
const DefaultPhaseParameters & parameters )

Definition at line 1131 of file default_search.cc.

◆ MakeDefaultRegularLimitParameters()

RegularLimitParameters operations_research::Solver::MakeDefaultRegularLimitParameters ( ) const

Creates a regular limit proto containing default values.

Definition at line 4551 of file search.cc.

◆ MakeDefaultSolutionPool()

SolutionPool * operations_research::Solver::MakeDefaultSolutionPool ( )

Solution Pool.

Definition at line 5562 of file local_search.cc.

◆ MakeDelayedConstraintInitialPropagateCallback()

Demon * operations_research::Solver::MakeDelayedConstraintInitialPropagateCallback ( Constraint * ct)

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

Definition at line 42 of file constraints.cc.

◆ MakeDelayedPathCumul()

Constraint * operations_research::Solver::MakeDelayedPathCumul ( 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.

Definition at line 1328 of file graph_constraints.cc.

◆ MakeDeviation()

Constraint * operations_research::Solver::MakeDeviation ( const std::vector< IntVar * > & vars,
IntVar * 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

Definition at line 414 of file deviation.cc.

◆ MakeDifference() [1/2]

IntExpr * operations_research::Solver::MakeDifference ( int64_t value,
IntExpr * expr )

value - expr

Warning
this is 'value - expr'.

Definition at line 6739 of file expressions.cc.

◆ MakeDifference() [2/2]

IntExpr * operations_research::Solver::MakeDifference ( IntExpr * left,
IntExpr * right )

left - right

Definition at line 6699 of file expressions.cc.

◆ MakeDisjunctiveConstraint()

DisjunctiveConstraint * operations_research::Solver::MakeDisjunctiveConstraint ( const std::vector< IntervalVar * > & intervals,
const std::string & name )

-------— Factory methods -------—

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

Definition at line 2608 of file resource.cc.

◆ MakeDistribute() [1/8]

Constraint * operations_research::Solver::MakeDistribute ( 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]

Definition at line 1054 of file count_cst.cc.

◆ MakeDistribute() [2/8]

Constraint * operations_research::Solver::MakeDistribute ( 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]

Definition at line 1077 of file count_cst.cc.

◆ MakeDistribute() [3/8]

Constraint * operations_research::Solver::MakeDistribute ( 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].

Definition at line 995 of file count_cst.cc.

◆ MakeDistribute() [4/8]

Constraint * operations_research::Solver::MakeDistribute ( 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]

Definition at line 1034 of file count_cst.cc.

◆ MakeDistribute() [5/8]

Constraint * operations_research::Solver::MakeDistribute ( 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]

Definition at line 1060 of file count_cst.cc.

◆ MakeDistribute() [6/8]

Constraint * operations_research::Solver::MakeDistribute ( 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].

Todo
(user) : we can sort values (and cards) before doing the test.

Definition at line 966 of file count_cst.cc.

◆ MakeDistribute() [7/8]

Constraint * operations_research::Solver::MakeDistribute ( const std::vector< IntVar * > & vars,
const std::vector< IntVar * > & cards )

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

Definition at line 1001 of file count_cst.cc.

◆ MakeDistribute() [8/8]

Constraint * operations_research::Solver::MakeDistribute ( 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

Definition at line 1015 of file count_cst.cc.

◆ MakeDiv() [1/2]

IntExpr * operations_research::Solver::MakeDiv ( IntExpr * expr,
int64_t value )

expr / value (integer division)

Todo
(user) : implement special case.

Definition at line 7021 of file expressions.cc.

◆ MakeDiv() [2/2]

IntExpr * operations_research::Solver::MakeDiv ( IntExpr * numerator,
IntExpr * denominator )

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

Definition at line 6983 of file expressions.cc.

◆ MakeElement() [1/6]

IntExpr * operations_research::Solver::MakeElement ( const std::vector< int > & values,
IntVar * index )

values[index]

Definition at line 668 of file element.cc.

◆ MakeElement() [2/6]

IntExpr * operations_research::Solver::MakeElement ( const std::vector< int64_t > & values,
IntVar * index )

values[index]

Definition at line 658 of file element.cc.

◆ MakeElement() [3/6]

IntExpr * operations_research::Solver::MakeElement ( const std::vector< IntVar * > & vars,
IntVar * index )

vars[expr]

Let's get the index between 0 and 1.

Definition at line 1617 of file element.cc.

◆ MakeElement() [4/6]

IntExpr * operations_research::Solver::MakeElement ( Solver::IndexEvaluator1 values,
IntVar * index )

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

Definition at line 862 of file element.cc.

◆ MakeElement() [5/6]

IntExpr * operations_research::Solver::MakeElement ( Solver::IndexEvaluator2 values,
IntVar * index1,
IntVar * index2 )

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

Definition at line 1114 of file element.cc.

◆ MakeElement() [6/6]

IntExpr * operations_research::Solver::MakeElement ( Int64ToIntVar vars,
int64_t range_start,
int64_t range_end,
IntVar * argument )

vars(argument)

Definition at line 1664 of file element.cc.

◆ MakeElementEquality() [1/4]

Constraint * operations_research::Solver::MakeElementEquality ( const std::vector< int > & vals,
IntVar * index,
IntVar * target )

Definition at line 1687 of file element.cc.

◆ MakeElementEquality() [2/4]

Constraint * operations_research::Solver::MakeElementEquality ( const std::vector< int64_t > & vals,
IntVar * index,
IntVar * target )

Definition at line 1681 of file element.cc.

◆ MakeElementEquality() [3/4]

Constraint * operations_research::Solver::MakeElementEquality ( const std::vector< IntVar * > & vars,
IntVar * index,
int64_t target )

Definition at line 1720 of file element.cc.

◆ MakeElementEquality() [4/4]

Constraint * operations_research::Solver::MakeElementEquality ( const std::vector< IntVar * > & vars,
IntVar * index,
IntVar * target )

Definition at line 1693 of file element.cc.

◆ MakeEnterSearchCallback()

SearchMonitor * operations_research::Solver::MakeEnterSearchCallback ( std::function< void()> callback)

--— Callback-based search monitors --—

Definition at line 490 of file search.cc.

◆ MakeEquality() [1/4]

Constraint * operations_research::Solver::MakeEquality ( IntervalVar * var1,
IntervalVar * var2 )

This constraints states that the two interval variables are equal.

Definition at line 598 of file sched_constraints.cc.

◆ MakeEquality() [2/4]

Constraint * operations_research::Solver::MakeEquality ( IntExpr * expr,
int value )

expr == value

Definition at line 104 of file expr_cst.cc.

◆ MakeEquality() [3/4]

Constraint * operations_research::Solver::MakeEquality ( IntExpr * expr,
int64_t value )

expr == value

Definition at line 89 of file expr_cst.cc.

◆ MakeEquality() [4/4]

Constraint * operations_research::Solver::MakeEquality ( IntExpr * left,
IntExpr * right )

left == right

Definition at line 518 of file range_cst.cc.

◆ MakeExitSearchCallback()

SearchMonitor * operations_research::Solver::MakeExitSearchCallback ( std::function< void()> callback)

Definition at line 515 of file search.cc.

◆ MakeFailDecision()

Decision * operations_research::Solver::MakeFailDecision ( )

Definition at line 1410 of file constraint_solver.cc.

◆ MakeFailuresLimit()

RegularLimit * operations_research::Solver::MakeFailuresLimit ( int64_t failures)

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

Definition at line 4515 of file search.cc.

◆ MakeFalseConstraint() [1/2]

Constraint * operations_research::Solver::MakeFalseConstraint ( )

This constraint always fails.

Definition at line 535 of file constraints.cc.

◆ MakeFalseConstraint() [2/2]

Constraint * operations_research::Solver::MakeFalseConstraint ( const std::string & explanation)

Definition at line 539 of file constraints.cc.

◆ MakeFirstSolutionCollector() [1/2]

SolutionCollector * operations_research::Solver::MakeFirstSolutionCollector ( )

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

Definition at line 2584 of file search.cc.

◆ MakeFirstSolutionCollector() [2/2]

SolutionCollector * operations_research::Solver::MakeFirstSolutionCollector ( const Assignment * assignment)

Collect the first solution of the search.

Definition at line 2579 of file search.cc.

◆ MakeFixedDurationEndSyncedOnEndIntervalVar()

IntervalVar * operations_research::Solver::MakeFixedDurationEndSyncedOnEndIntervalVar ( IntervalVar * 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.

Definition at line 2464 of file interval.cc.

◆ MakeFixedDurationEndSyncedOnStartIntervalVar()

IntervalVar * operations_research::Solver::MakeFixedDurationEndSyncedOnStartIntervalVar ( IntervalVar * 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.

Definition at line 2457 of file interval.cc.

◆ MakeFixedDurationIntervalVar() [1/3]

IntervalVar * operations_research::Solver::MakeFixedDurationIntervalVar ( 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.

Definition at line 2284 of file interval.cc.

◆ MakeFixedDurationIntervalVar() [2/3]

IntervalVar * operations_research::Solver::MakeFixedDurationIntervalVar ( IntVar * 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.

Definition at line 2312 of file interval.cc.

◆ MakeFixedDurationIntervalVar() [3/3]

IntervalVar * operations_research::Solver::MakeFixedDurationIntervalVar ( IntVar * start_variable,
int64_t duration,
IntVar * performed_variable,
const std::string & name )

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

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

Definition at line 2323 of file interval.cc.

◆ MakeFixedDurationIntervalVarArray() [1/6]

void operations_research::Solver::MakeFixedDurationIntervalVarArray ( const std::vector< IntVar * > & start_variables,
absl::Span< const int > durations,
absl::string_view name,
std::vector< IntervalVar * > * array )

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

Definition at line 2372 of file interval.cc.

◆ MakeFixedDurationIntervalVarArray() [2/6]

void operations_research::Solver::MakeFixedDurationIntervalVarArray ( const std::vector< IntVar * > & start_variables,
absl::Span< const int > durations,
const std::vector< IntVar * > & performed_variables,
absl::string_view name,
std::vector< IntervalVar * > * array )

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

Definition at line 2386 of file interval.cc.

◆ MakeFixedDurationIntervalVarArray() [3/6]

void operations_research::Solver::MakeFixedDurationIntervalVarArray ( const std::vector< IntVar * > & start_variables,
absl::Span< const int64_t > durations,
absl::string_view name,
std::vector< IntervalVar * > * array )

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

Definition at line 2358 of file interval.cc.

◆ MakeFixedDurationIntervalVarArray() [4/6]

void operations_research::Solver::MakeFixedDurationIntervalVarArray ( const std::vector< IntVar * > & start_variables,
absl::Span< const int64_t > durations,
const std::vector< IntVar * > & performed_variables,
absl::string_view name,
std::vector< IntervalVar * > * array )

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

Definition at line 2400 of file interval.cc.

◆ MakeFixedDurationIntervalVarArray() [5/6]

void operations_research::Solver::MakeFixedDurationIntervalVarArray ( const std::vector< IntVar * > & start_variables,
int64_t duration,
absl::string_view name,
std::vector< IntervalVar * > * array )

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

Definition at line 2344 of file interval.cc.

◆ MakeFixedDurationIntervalVarArray() [6/6]

void operations_research::Solver::MakeFixedDurationIntervalVarArray ( int count,
int64_t start_min,
int64_t start_max,
int64_t duration,
bool optional,
absl::string_view name,
std::vector< IntervalVar * > * array )

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

Definition at line 2299 of file interval.cc.

◆ MakeFixedDurationStartSyncedOnEndIntervalVar()

IntervalVar * operations_research::Solver::MakeFixedDurationStartSyncedOnEndIntervalVar ( IntervalVar * 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.

Definition at line 2450 of file interval.cc.

◆ MakeFixedDurationStartSyncedOnStartIntervalVar()

IntervalVar * operations_research::Solver::MakeFixedDurationStartSyncedOnStartIntervalVar ( IntervalVar * interval_var,
int64_t duration,
int64_t offset )

Synced Interval Vars.

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.

Definition at line 2443 of file interval.cc.

◆ MakeFixedInterval()

IntervalVar * operations_research::Solver::MakeFixedInterval ( int64_t start,
int64_t duration,
const std::string & name )

Creates a fixed and performed interval.

Definition at line 2279 of file interval.cc.

◆ MakeGenericTabuSearch()

ObjectiveMonitor * operations_research::Solver::MakeGenericTabuSearch ( bool maximize,
IntVar * 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.

Definition at line 3549 of file search.cc.

◆ MakeGreater() [1/3]

Constraint * operations_research::Solver::MakeGreater ( IntExpr * expr,
int value )

expr > value

Definition at line 207 of file expr_cst.cc.

◆ MakeGreater() [2/3]

Constraint * operations_research::Solver::MakeGreater ( IntExpr * expr,
int64_t value )

expr > value

Definition at line 196 of file expr_cst.cc.

◆ MakeGreater() [3/3]

Constraint * operations_research::Solver::MakeGreater ( IntExpr * left,
IntExpr * right )

left > right

Definition at line 566 of file range_cst.cc.

◆ MakeGreaterOrEqual() [1/3]

Constraint * operations_research::Solver::MakeGreaterOrEqual ( IntExpr * expr,
int value )

expr >= value

Definition at line 185 of file expr_cst.cc.

◆ MakeGreaterOrEqual() [2/3]

Constraint * operations_research::Solver::MakeGreaterOrEqual ( IntExpr * expr,
int64_t value )

expr >= value

Definition at line 174 of file expr_cst.cc.

◆ MakeGreaterOrEqual() [3/3]

Constraint * operations_research::Solver::MakeGreaterOrEqual ( IntExpr * left,
IntExpr * right )

left >= right

Definition at line 548 of file range_cst.cc.

◆ MakeGuidedLocalSearch() [1/2]

ObjectiveMonitor * operations_research::Solver::MakeGuidedLocalSearch ( bool maximize,
IntVar * objective,
Solver::IndexEvaluator2 objective_function,
int64_t step,
const std::vector< IntVar * > & vars,
double penalty_factor,
bool reset_penalties_on_new_best_solution = false )

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

Definition at line 4269 of file search.cc.

◆ MakeGuidedLocalSearch() [2/2]

ObjectiveMonitor * operations_research::Solver::MakeGuidedLocalSearch ( bool maximize,
IntVar * objective,
Solver::IndexEvaluator3 objective_function,
int64_t step,
const std::vector< IntVar * > & vars,
const std::vector< IntVar * > & secondary_vars,
double penalty_factor,
bool reset_penalties_on_new_best_solution = false )

Definition at line 4286 of file search.cc.

◆ MakeIfThenElseCt()

Constraint * operations_research::Solver::MakeIfThenElseCt ( IntVar * condition,
IntExpr * then_expr,
IntExpr * else_expr,
IntVar * target_var )

Special cases with arrays of size two.

Definition at line 1609 of file element.cc.

◆ MakeImprovementLimit()

ImprovementSearchLimit * operations_research::Solver::MakeImprovementLimit ( 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.

Definition at line 4721 of file search.cc.

◆ MakeIndexExpression()

IntExpr * operations_research::Solver::MakeIndexExpression ( const std::vector< IntVar * > & vars,
int64_t value )

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

Definition at line 1759 of file element.cc.

◆ MakeIndexOfConstraint()

Constraint * operations_research::Solver::MakeIndexOfConstraint ( const std::vector< IntVar * > & vars,
IntVar * 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.

Definition at line 1744 of file element.cc.

◆ MakeIndexOfFirstMaxValueConstraint()

Constraint * operations_research::Solver::MakeIndexOfFirstMaxValueConstraint ( 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.

Definition at line 598 of file constraints.cc.

◆ MakeIndexOfFirstMinValueConstraint()

Constraint * operations_research::Solver::MakeIndexOfFirstMinValueConstraint ( 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.

Definition at line 603 of file constraints.cc.

◆ MakeIntConst() [1/2]

IntVar * operations_research::Solver::MakeIntConst ( int64_t val)

IntConst will create a constant expression.

Definition at line 6523 of file expressions.cc.

◆ MakeIntConst() [2/2]

IntVar * operations_research::Solver::MakeIntConst ( int64_t val,
const std::string & name )

IntConst will create a constant expression.

If IntConst is going to be named after its creation, cp_share_int_consts should be set to false otherwise names can potentially be overwritten.

Definition at line 6512 of file expressions.cc.

◆ MakeIntervalRelaxedMax()

IntervalVar * operations_research::Solver::MakeIntervalRelaxedMax ( IntervalVar * interval_var)

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

  • When the underlying must be performed, the returned interval variable behaves exactly as the underlying;
  • When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the max side;
  • When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides. This is very useful for implementing propagators that may only modify the start min or end min.

Definition at line 2254 of file interval.cc.

◆ MakeIntervalRelaxedMin()

IntervalVar * operations_research::Solver::MakeIntervalRelaxedMin ( IntervalVar * interval_var)

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

  • When the underlying must be performed, the returned interval variable behaves exactly as the underlying;
  • When the underlying may or may not be performed, the returned interval variable behaves like the underlying, except that it is unbounded on the min side;
  • When the underlying cannot be performed, the returned interval variable is of duration 0 and must be performed in an interval unbounded on both sides. This is very useful to implement propagators that may only modify the start max or end max.

Definition at line 2263 of file interval.cc.

◆ MakeIntervalVar()

IntervalVar * operations_research::Solver::MakeIntervalVar ( 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 )

Variable Duration Interval Var.

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

Definition at line 2416 of file interval.cc.

◆ MakeIntervalVarArray()

void operations_research::Solver::MakeIntervalVarArray ( 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,
absl::string_view name,
std::vector< IntervalVar * > * array )

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

Definition at line 2425 of file interval.cc.

◆ MakeIntervalVarRelation() [1/2]

Constraint * operations_research::Solver::MakeIntervalVarRelation ( IntervalVar * t,
Solver::UnaryIntervalRelation r,
int64_t d )

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

Definition at line 112 of file timetabling.cc.

◆ MakeIntervalVarRelation() [2/2]

Constraint * operations_research::Solver::MakeIntervalVarRelation ( IntervalVar * t1,
Solver::BinaryIntervalRelation r,
IntervalVar * t2 )

This method creates a relation between two interval vars.

Definition at line 231 of file timetabling.cc.

◆ MakeIntervalVarRelationWithDelay()

Constraint * operations_research::Solver::MakeIntervalVarRelationWithDelay ( IntervalVar * t1,
Solver::BinaryIntervalRelation r,
IntervalVar * 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.

Definition at line 237 of file timetabling.cc.

◆ MakeIntVar() [1/6]

IntVar * operations_research::Solver::MakeIntVar ( const std::vector< int > & values)

MakeIntVar will create a variable with the given sparse domain.

Definition at line 6508 of file expressions.cc.

◆ MakeIntVar() [2/6]

IntVar * operations_research::Solver::MakeIntVar ( const std::vector< int > & values,
const std::string & name )

MakeIntVar will create a variable with the given sparse domain.

Definition at line 6503 of file expressions.cc.

◆ MakeIntVar() [3/6]

IntVar * operations_research::Solver::MakeIntVar ( const std::vector< int64_t > & values)

MakeIntVar will create a variable with the given sparse domain.

Definition at line 6499 of file expressions.cc.

◆ MakeIntVar() [4/6]

IntVar * operations_research::Solver::MakeIntVar ( const std::vector< int64_t > & values,
const std::string & name )

MakeIntVar will create a variable with the given sparse domain.

Fast-track the case where we have a single value.

Sort and remove duplicates.

Case when we have a single value, after clean-up.

Case when the values are a dense interval of integers.

Compute the GCD: if it's not 1, we can express the variable's domain as the product of the GCD and of a domain with smaller values.

If it's 1, though, we can't do anything special, so we immediately return a new DomainIntVar.

Catch the case where the divided values are a dense set of integers.

Definition at line 6448 of file expressions.cc.

◆ MakeIntVar() [5/6]

IntVar * operations_research::Solver::MakeIntVar ( int64_t min,
int64_t max )

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

Definition at line 6436 of file expressions.cc.

◆ MakeIntVar() [6/6]

IntVar * operations_research::Solver::MakeIntVar ( int64_t min,
int64_t max,
const std::string & name )

--— Int Variables and Constants --—

--— API --—

All factories (MakeXXX methods) encapsulate creation of objects through RevAlloc(). Hence, the Solver used for allocating the returned object will retain ownership of the allocated memory. Destructors are called upon backtrack, or when the Solver is itself destructed. MakeIntVar will create the best range based int var for the bounds given.

Definition at line 6420 of file expressions.cc.

◆ MakeIntVarArray() [1/3]

IntVar ** operations_research::Solver::MakeIntVarArray ( int var_count,
int64_t vmin,
int64_t vmax,
const std::string & name )

Same but allocates an array and returns it.

Definition at line 6559 of file expressions.cc.

◆ MakeIntVarArray() [2/3]

void operations_research::Solver::MakeIntVarArray ( 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<i>" where is the index of the variable.

Definition at line 6544 of file expressions.cc.

◆ MakeIntVarArray() [3/3]

void operations_research::Solver::MakeIntVarArray ( 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.

Definition at line 6552 of file expressions.cc.

◆ MakeInversePermutationConstraint()

Constraint * operations_research::Solver::MakeInversePermutationConstraint ( 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.

Definition at line 593 of file constraints.cc.

◆ MakeIsBetweenCt()

Constraint * operations_research::Solver::MakeIsBetweenCt ( IntExpr * expr,
int64_t l,
int64_t u,
IntVar * b )

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

Catch empty and singleton intervals.

Catch the trivial cases first.

Catch one-sided constraints.

Simplify the common factor, if any.

No further reduction is possible.

Definition at line 1057 of file expr_cst.cc.

◆ MakeIsBetweenVar()

IntVar * operations_research::Solver::MakeIsBetweenVar ( IntExpr * v,
int64_t l,
int64_t u )

Definition at line 1093 of file expr_cst.cc.

◆ MakeIsDifferentCstCt()

Constraint * operations_research::Solver::MakeIsDifferentCstCt ( IntExpr * var,
int64_t value,
IntVar * boolvar )

boolvar == (var != value)

Definition at line 595 of file expr_cst.cc.

◆ MakeIsDifferentCstVar()

IntVar * operations_research::Solver::MakeIsDifferentCstVar ( IntExpr * var,
int64_t value )

status var of (var != value)

Definition at line 586 of file expr_cst.cc.

◆ MakeIsDifferentCt()

Constraint * operations_research::Solver::MakeIsDifferentCt ( IntExpr * v1,
IntExpr * v2,
IntVar * b )

b == (v1 != v2)

Definition at line 692 of file range_cst.cc.

◆ MakeIsDifferentVar()

IntVar * operations_research::Solver::MakeIsDifferentVar ( IntExpr * v1,
IntExpr * v2 )

status var of (v1 != v2)

Definition at line 647 of file range_cst.cc.

◆ MakeIsEqualCstCt()

Constraint * operations_research::Solver::MakeIsEqualCstCt ( IntExpr * var,
int64_t value,
IntVar * boolvar )

boolvar == (var == value)

Todo
(user) : what happens if the constraint is not posted? The cache becomes tainted.

Definition at line 493 of file expr_cst.cc.

◆ MakeIsEqualCstVar()

IntVar * operations_research::Solver::MakeIsEqualCstVar ( IntExpr * var,
int64_t value )

status var of (var == value)

Definition at line 468 of file expr_cst.cc.

◆ MakeIsEqualCt()

Constraint * operations_research::Solver::MakeIsEqualCt ( IntExpr * v1,
IntExpr * v2,
IntVar * b )

b == (v1 == v2)

Definition at line 628 of file range_cst.cc.

◆ MakeIsEqualVar()

IntVar * operations_research::Solver::MakeIsEqualVar ( IntExpr * v1,
IntExpr * v2 )

status var of (v1 == v2)

Definition at line 583 of file range_cst.cc.

◆ MakeIsGreaterCstCt()

Constraint * operations_research::Solver::MakeIsGreaterCstCt ( IntExpr * v,
int64_t c,
IntVar * b )

b == (v > c)

Definition at line 722 of file expr_cst.cc.

◆ MakeIsGreaterCstVar()

IntVar * operations_research::Solver::MakeIsGreaterCstVar ( IntExpr * var,
int64_t value )

status var of (var > value)

Definition at line 702 of file expr_cst.cc.

◆ MakeIsGreaterCt()

Constraint * operations_research::Solver::MakeIsGreaterCt ( IntExpr * left,
IntExpr * right,
IntVar * b )

b == (left > right)

Definition at line 806 of file range_cst.cc.

◆ MakeIsGreaterOrEqualCstCt()

Constraint * operations_research::Solver::MakeIsGreaterOrEqualCstCt ( IntExpr * var,
int64_t value,
IntVar * boolvar )

boolvar == (var >= value)

Definition at line 706 of file expr_cst.cc.

◆ MakeIsGreaterOrEqualCstVar()

IntVar * operations_research::Solver::MakeIsGreaterOrEqualCstVar ( IntExpr * var,
int64_t value )

status var of (var >= value)

Definition at line 685 of file expr_cst.cc.

◆ MakeIsGreaterOrEqualCt()

Constraint * operations_research::Solver::MakeIsGreaterOrEqualCt ( IntExpr * left,
IntExpr * right,
IntVar * b )

b == (left >= right)

Definition at line 796 of file range_cst.cc.

◆ MakeIsGreaterOrEqualVar()

IntVar * operations_research::Solver::MakeIsGreaterOrEqualVar ( IntExpr * left,
IntExpr * right )

status var of (left >= right)

Definition at line 791 of file range_cst.cc.

◆ MakeIsGreaterVar()

IntVar * operations_research::Solver::MakeIsGreaterVar ( IntExpr * left,
IntExpr * right )

status var of (left > right)

Definition at line 802 of file range_cst.cc.

◆ MakeIsLessCstCt()

Constraint * operations_research::Solver::MakeIsLessCstCt ( IntExpr * v,
int64_t c,
IntVar * b )

b == (v < c)

Definition at line 822 of file expr_cst.cc.

◆ MakeIsLessCstVar()

IntVar * operations_research::Solver::MakeIsLessCstVar ( IntExpr * var,
int64_t value )

status var of (var < value)

Definition at line 802 of file expr_cst.cc.

◆ MakeIsLessCt()

Constraint * operations_research::Solver::MakeIsLessCt ( IntExpr * left,
IntExpr * right,
IntVar * b )

b == (left < right)

Definition at line 779 of file range_cst.cc.

◆ MakeIsLessOrEqualCstCt()

Constraint * operations_research::Solver::MakeIsLessOrEqualCstCt ( IntExpr * var,
int64_t value,
IntVar * boolvar )

boolvar == (var <= value)

Definition at line 806 of file expr_cst.cc.

◆ MakeIsLessOrEqualCstVar()

IntVar * operations_research::Solver::MakeIsLessOrEqualCstVar ( IntExpr * var,
int64_t value )

status var of (var <= value)

Definition at line 785 of file expr_cst.cc.

◆ MakeIsLessOrEqualCt()

Constraint * operations_research::Solver::MakeIsLessOrEqualCt ( IntExpr * left,
IntExpr * right,
IntVar * b )

b == (left <= right)

Definition at line 736 of file range_cst.cc.

◆ MakeIsLessOrEqualVar()

IntVar * operations_research::Solver::MakeIsLessOrEqualVar ( IntExpr * left,
IntExpr * right )

status var of (left <= right)

Definition at line 704 of file range_cst.cc.

◆ MakeIsLessVar()

IntVar * operations_research::Solver::MakeIsLessVar ( IntExpr * left,
IntExpr * right )

status var of (left < right)

Definition at line 748 of file range_cst.cc.

◆ MakeIsLexicalLessOrEqualWithOffsetsCt()

Constraint * operations_research::Solver::MakeIsLexicalLessOrEqualWithOffsetsCt ( std::vector< IntVar * > left,
std::vector< IntVar * > right,
std::vector< int64_t > offsets,
IntVar * boolvar )

Semi-reified version of the above: boolvar -> LexLE(left, right, offsets).

Definition at line 579 of file constraints.cc.

◆ MakeIsMemberCt() [1/2]

Constraint * operations_research::Solver::MakeIsMemberCt ( IntExpr * expr,
const std::vector< int > & values,
IntVar * boolvar )

Definition at line 1495 of file expr_cst.cc.

◆ MakeIsMemberCt() [2/2]

Constraint * operations_research::Solver::MakeIsMemberCt ( IntExpr * expr,
const std::vector< int64_t > & values,
IntVar * boolvar )

boolvar == (expr in set)

Definition at line 1489 of file expr_cst.cc.

◆ MakeIsMemberVar() [1/2]

IntVar * operations_research::Solver::MakeIsMemberVar ( IntExpr * expr,
const std::vector< int > & values )

Definition at line 1508 of file expr_cst.cc.

◆ MakeIsMemberVar() [2/2]

IntVar * operations_research::Solver::MakeIsMemberVar ( IntExpr * expr,
const std::vector< int64_t > & values )

Definition at line 1501 of file expr_cst.cc.

◆ MakeLastSolutionCollector() [1/2]

SolutionCollector * operations_research::Solver::MakeLastSolutionCollector ( )

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

Definition at line 2636 of file search.cc.

◆ MakeLastSolutionCollector() [2/2]

SolutionCollector * operations_research::Solver::MakeLastSolutionCollector ( const Assignment * assignment)

Collect the last solution of the search.

Definition at line 2631 of file search.cc.

◆ MakeLess() [1/3]

Constraint * operations_research::Solver::MakeLess ( IntExpr * expr,
int value )

expr < value

Definition at line 305 of file expr_cst.cc.

◆ MakeLess() [2/3]

Constraint * operations_research::Solver::MakeLess ( IntExpr * expr,
int64_t value )

expr < value

Definition at line 294 of file expr_cst.cc.

◆ MakeLess() [3/3]

Constraint * operations_research::Solver::MakeLess ( IntExpr * left,
IntExpr * right )

left < right

Definition at line 552 of file range_cst.cc.

◆ MakeLessOrEqual() [1/3]

Constraint * operations_research::Solver::MakeLessOrEqual ( IntExpr * expr,
int value )

expr <= value

Definition at line 283 of file expr_cst.cc.

◆ MakeLessOrEqual() [2/3]

Constraint * operations_research::Solver::MakeLessOrEqual ( IntExpr * expr,
int64_t value )

expr <= value

Definition at line 272 of file expr_cst.cc.

◆ MakeLessOrEqual() [3/3]

Constraint * operations_research::Solver::MakeLessOrEqual ( IntExpr * left,
IntExpr * right )

left <= right

Definition at line 532 of file range_cst.cc.

◆ MakeLexicalLess()

Constraint * operations_research::Solver::MakeLexicalLess ( const std::vector< IntVar * > & left,
const std::vector< IntVar * > & right )
Todo
(user): Add void MakeSortedArray( const std::vector<IntVar*>& vars, std::vector<IntVar*>* const sorted);

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

Definition at line 555 of file constraints.cc.

◆ MakeLexicalLessOrEqual()

Constraint * operations_research::Solver::MakeLexicalLessOrEqual ( 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.

Definition at line 566 of file constraints.cc.

◆ MakeLexicalLessOrEqualWithOffsets()

Constraint * operations_research::Solver::MakeLexicalLessOrEqualWithOffsets ( std::vector< IntVar * > left,
std::vector< IntVar * > right,
std::vector< int64_t > offsets )

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

Definition at line 572 of file constraints.cc.

◆ MakeLexicographicImprovementLimit()

ImprovementSearchLimit * operations_research::Solver::MakeLexicographicImprovementLimit ( std::vector< IntVar * > objective_vars,
std::vector< bool > maximize,
std::vector< double > objective_scaling_factors,
std::vector< double > objective_offsets,
double improvement_rate_coefficient,
int improvement_rate_solutions_distance )

Same as MakeImprovementLimit on a lexicographic objective based on 'objective_vars' and related arguments.

Definition at line 4730 of file search.cc.

◆ MakeLexicographicOptimize()

OptimizeVar * operations_research::Solver::MakeLexicographicOptimize ( std::vector< bool > maximize,
std::vector< IntVar * > variables,
std::vector< int64_t > steps )

Creates a lexicographic objective, following the order of the variables given. Each variable has a corresponding optimization direction and step.

Definition at line 3143 of file search.cc.

◆ MakeLexicographicSimulatedAnnealing()

ObjectiveMonitor * operations_research::Solver::MakeLexicographicSimulatedAnnealing ( const std::vector< bool > & maximize,
std::vector< IntVar * > vars,
std::vector< int64_t > steps,
std::vector< int64_t > initial_temperatures )

Definition at line 3652 of file search.cc.

◆ MakeLexicographicTabuSearch()

ObjectiveMonitor * operations_research::Solver::MakeLexicographicTabuSearch ( const std::vector< bool > & maximize,
std::vector< IntVar * > objectives,
std::vector< int64_t > steps,
const std::vector< IntVar * > & vars,
int64_t keep_tenure,
int64_t forbid_tenure,
double tabu_factor )

Definition at line 3540 of file search.cc.

◆ MakeLightElement() [1/2]

template<typename F >
Constraint * operations_research::Solver::MakeLightElement ( F values,
IntVar *const var,
IntVar *const index,
std::function< bool()> deep_serialize = nullptr )
inline

Light versions of function-based elements, in constraint version only, well-suited for use within Local Search. These constraints are "checking" constraints, only triggered on WhenBound events. They provide very little (or no) domain filtering. Returns a light one-dimension function-based element constraint ensuring var == values(index). The constraint does not perform bound reduction of the resulting variable until the index variable is bound. If deep_serialize returns false, the model visitor will not extract all possible values from the values function.

Definition at line 1248 of file constraint_solver.h.

◆ MakeLightElement() [2/2]

template<typename F >
Constraint * operations_research::Solver::MakeLightElement ( F values,
IntVar *const var,
IntVar *const index1,
IntVar *const index2,
std::function< bool()> deep_serialize = nullptr )
inline

Light two-dimension function-based element constraint ensuring var == values(index1, index2). The constraint does not perform bound reduction of the resulting variable until the index variables are bound. If deep_serialize returns false, the model visitor will not extract all possible values from the values function.

Definition at line 1261 of file constraint_solver.h.

◆ MakeLimit() [1/4]

RegularLimit * operations_research::Solver::MakeLimit ( 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.

Definition at line 4536 of file search.cc.

◆ MakeLimit() [2/4]

RegularLimit * operations_research::Solver::MakeLimit ( const RegularLimitParameters & proto)

Creates a search limit from its protobuf description.

Definition at line 4543 of file search.cc.

◆ MakeLimit() [3/4]

RegularLimit * operations_research::Solver::MakeLimit ( int64_t time,
int64_t branches,
int64_t failures,
int64_t solutions,
bool smart_time_check = false,
bool cumulative = false )

Definition at line 4529 of file search.cc.

◆ MakeLimit() [4/4]

SearchLimit * operations_research::Solver::MakeLimit ( SearchLimit * limit_1,
SearchLimit * limit_2 )

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

Definition at line 4804 of file search.cc.

◆ MakeLocalSearchPhase() [1/4]

DecisionBuilder * operations_research::Solver::MakeLocalSearchPhase ( Assignment * assignment,
LocalSearchPhaseParameters * parameters )

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

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

Definition at line 5566 of file local_search.cc.

◆ MakeLocalSearchPhase() [2/4]

DecisionBuilder * operations_research::Solver::MakeLocalSearchPhase ( const std::vector< IntVar * > & vars,
DecisionBuilder * first_solution,
DecisionBuilder * first_solution_sub_decision_builder,
LocalSearchPhaseParameters * parameters )

Variant with a sub_decison_builder specific to the first solution.

Definition at line 5584 of file local_search.cc.

◆ MakeLocalSearchPhase() [3/4]

DecisionBuilder * operations_research::Solver::MakeLocalSearchPhase ( const std::vector< IntVar * > & vars,
DecisionBuilder * first_solution,
LocalSearchPhaseParameters * parameters )

Definition at line 5574 of file local_search.cc.

◆ MakeLocalSearchPhase() [4/4]

DecisionBuilder * operations_research::Solver::MakeLocalSearchPhase ( const std::vector< SequenceVar * > & vars,
DecisionBuilder * first_solution,
LocalSearchPhaseParameters * parameters )

Definition at line 5595 of file local_search.cc.

◆ MakeLocalSearchPhaseParameters() [1/6]

LocalSearchPhaseParameters * operations_research::Solver::MakeLocalSearchPhaseParameters ( IntVar * objective,
LocalSearchOperator * ls_operator,
DecisionBuilder * sub_decision_builder )

Local Search Phase Parameters.

Definition at line 5143 of file local_search.cc.

◆ MakeLocalSearchPhaseParameters() [2/6]

LocalSearchPhaseParameters * operations_research::Solver::MakeLocalSearchPhaseParameters ( IntVar * objective,
LocalSearchOperator * ls_operator,
DecisionBuilder * sub_decision_builder,
RegularLimit * limit )

Definition at line 5151 of file local_search.cc.

◆ MakeLocalSearchPhaseParameters() [3/6]

LocalSearchPhaseParameters * operations_research::Solver::MakeLocalSearchPhaseParameters ( IntVar * objective,
LocalSearchOperator * ls_operator,
DecisionBuilder * sub_decision_builder,
RegularLimit * limit,
LocalSearchFilterManager * filter_manager )

Definition at line 5159 of file local_search.cc.

◆ MakeLocalSearchPhaseParameters() [4/6]

LocalSearchPhaseParameters * operations_research::Solver::MakeLocalSearchPhaseParameters ( IntVar * objective,
SolutionPool * pool,
LocalSearchOperator * ls_operator,
DecisionBuilder * sub_decision_builder )

Definition at line 5168 of file local_search.cc.

◆ MakeLocalSearchPhaseParameters() [5/6]

LocalSearchPhaseParameters * operations_research::Solver::MakeLocalSearchPhaseParameters ( IntVar * objective,
SolutionPool * pool,
LocalSearchOperator * ls_operator,
DecisionBuilder * sub_decision_builder,
RegularLimit * limit )

Definition at line 5176 of file local_search.cc.

◆ MakeLocalSearchPhaseParameters() [6/6]

LocalSearchPhaseParameters * operations_research::Solver::MakeLocalSearchPhaseParameters ( IntVar * objective,
SolutionPool * pool,
LocalSearchOperator * ls_operator,
DecisionBuilder * sub_decision_builder,
RegularLimit * limit,
LocalSearchFilterManager * filter_manager )

Definition at line 5184 of file local_search.cc.

◆ MakeLubyRestart()

SearchMonitor * operations_research::Solver::MakeLubyRestart ( int scale_factor)

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

Definition at line 5119 of file search.cc.

◆ MakeMapDomain()

Constraint * operations_research::Solver::MakeMapDomain ( IntVar * 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);

Definition at line 550 of file constraints.cc.

◆ MakeMax() [1/4]

IntExpr * operations_research::Solver::MakeMax ( const std::vector< IntVar * > & vars)

std::max(vars)

Definition at line 3346 of file expr_array.cc.

◆ MakeMax() [2/4]

IntExpr * operations_research::Solver::MakeMax ( IntExpr * expr,
int value )

std::max(expr, value)

Definition at line 7190 of file expressions.cc.

◆ MakeMax() [3/4]

IntExpr * operations_research::Solver::MakeMax ( IntExpr * expr,
int64_t value )

std::max(expr, value)

Definition at line 7176 of file expressions.cc.

◆ MakeMax() [4/4]

IntExpr * operations_research::Solver::MakeMax ( IntExpr * left,
IntExpr * right )

std::max(left, right)

Definition at line 7158 of file expressions.cc.

◆ MakeMaxEquality()

Constraint * operations_research::Solver::MakeMaxEquality ( const std::vector< IntVar * > & vars,
IntVar * max_var )

Definition at line 3411 of file expr_array.cc.

◆ MakeMaximize()

OptimizeVar * operations_research::Solver::MakeMaximize ( IntVar * v,
int64_t step )

Creates a maximization objective.

Definition at line 3134 of file search.cc.

◆ MakeMemberCt() [1/2]

Constraint * operations_research::Solver::MakeMemberCt ( IntExpr * expr,
const std::vector< int > & values )

Definition at line 1234 of file expr_cst.cc.

◆ MakeMemberCt() [2/2]

Constraint * operations_research::Solver::MakeMemberCt ( IntExpr * expr,
const std::vector< int64_t > & values )

--— Member and related constraints --—

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

If the expression is a non-trivial product, we filter out the values that aren't multiples of "coeff", and divide them.

Filter out the values that are outside the [Min, Max] interval.

Catch empty set.

Sort and remove duplicates.

Special case for singleton.

Catch contiguous intervals.

Note
MakeBetweenCt() has a fast-track for trivially true constraints.

If the set of values in [expr.Min(), expr.Max()] that are not in "values" is smaller than "values", then it's more efficient to use NotMemberCt. Catch that case here.

Convert "copied_values" to list the values not allowed.

We use the zero valued indices of is_among_input_values to build the complement of copied_values.

The empty' case (all values in range [expr.Min(), expr.Max()] are in the "values" input) was caught earlier, by the "contiguous interval" case.

Otherwise, just use MemberCt. No further reduction is possible.

Definition at line 1169 of file expr_cst.cc.

◆ MakeMin() [1/4]

IntExpr * operations_research::Solver::MakeMin ( const std::vector< IntVar * > & vars)

std::min(vars)

Definition at line 3303 of file expr_array.cc.

◆ MakeMin() [2/4]

IntExpr * operations_research::Solver::MakeMin ( IntExpr * expr,
int value )

std::min(expr, value)

Definition at line 7154 of file expressions.cc.

◆ MakeMin() [3/4]

IntExpr * operations_research::Solver::MakeMin ( IntExpr * expr,
int64_t value )

std::min(expr, value)

Definition at line 7140 of file expressions.cc.

◆ MakeMin() [4/4]

IntExpr * operations_research::Solver::MakeMin ( IntExpr * left,
IntExpr * right )

std::min (left, right)

Definition at line 7122 of file expressions.cc.

◆ MakeMinEquality()

Constraint * operations_research::Solver::MakeMinEquality ( const std::vector< IntVar * > & vars,
IntVar * min_var )

Definition at line 3389 of file expr_array.cc.

◆ MakeMinimize()

OptimizeVar * operations_research::Solver::MakeMinimize ( IntVar * v,
int64_t step )

Creates a minimization objective.

Definition at line 3130 of file search.cc.

◆ MakeMirrorInterval()

IntervalVar * operations_research::Solver::MakeMirrorInterval ( IntervalVar * interval_var)

--— API --—

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

Definition at line 2249 of file interval.cc.

◆ MakeModulo() [1/2]

IntExpr * operations_research::Solver::MakeModulo ( IntExpr * x,
int64_t mod )

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

--— Modulo --—

Definition at line 7305 of file expressions.cc.

◆ MakeModulo() [2/2]

IntExpr * operations_research::Solver::MakeModulo ( IntExpr * x,
IntExpr * mod )

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

Definition at line 7316 of file expressions.cc.

◆ MakeMonotonicElement()

IntExpr * operations_research::Solver::MakeMonotonicElement ( Solver::IndexEvaluator1 values,
bool increasing,
IntVar * index )

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

You need to pass by copy such that opposite_value does not include a dandling reference when leaving this scope.

Definition at line 869 of file element.cc.

◆ MakeMoveTowardTargetOperator() [1/2]

LocalSearchOperator * operations_research::Solver::MakeMoveTowardTargetOperator ( 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.

Copy target values and construct the vector of variables

Definition at line 278 of file local_search.cc.

◆ MakeMoveTowardTargetOperator() [2/2]

LocalSearchOperator * operations_research::Solver::MakeMoveTowardTargetOperator ( 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.

Definition at line 294 of file local_search.cc.

◆ MakeNBestLexicographicValueSolutionCollector() [1/2]

SolutionCollector * operations_research::Solver::MakeNBestLexicographicValueSolutionCollector ( const Assignment * assignment,
int solution_count,
std::vector< bool > maximize )

Same as above but supporting lexicographic objectives; 'maximize' specifies the optimization direction for each objective.

Definition at line 2876 of file search.cc.

◆ MakeNBestLexicographicValueSolutionCollector() [2/2]

SolutionCollector * operations_research::Solver::MakeNBestLexicographicValueSolutionCollector ( int solution_count,
std::vector< bool > maximize )

Definition at line 2887 of file search.cc.

◆ MakeNBestValueSolutionCollector() [1/2]

SolutionCollector * operations_research::Solver::MakeNBestValueSolutionCollector ( const Assignment * 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).

Definition at line 2858 of file search.cc.

◆ MakeNBestValueSolutionCollector() [2/2]

SolutionCollector * operations_research::Solver::MakeNBestValueSolutionCollector ( int solution_count,
bool maximize )

Definition at line 2867 of file search.cc.

◆ MakeNeighborhoodLimit()

LocalSearchOperator * operations_research::Solver::MakeNeighborhoodLimit ( LocalSearchOperator * 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.

Definition at line 2030 of file local_search.cc.

◆ MakeNestedOptimize() [1/6]

DecisionBuilder * operations_research::Solver::MakeNestedOptimize ( DecisionBuilder * db,
Assignment * 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.

Definition at line 5006 of file search.cc.

◆ MakeNestedOptimize() [2/6]

DecisionBuilder * operations_research::Solver::MakeNestedOptimize ( DecisionBuilder * db,
Assignment * solution,
bool maximize,
int64_t step,
const std::vector< SearchMonitor * > & monitors )

Definition at line 5057 of file search.cc.

◆ MakeNestedOptimize() [3/6]

DecisionBuilder * operations_research::Solver::MakeNestedOptimize ( DecisionBuilder * db,
Assignment * solution,
bool maximize,
int64_t step,
SearchMonitor * monitor1 )

Definition at line 5012 of file search.cc.

◆ MakeNestedOptimize() [4/6]

DecisionBuilder * operations_research::Solver::MakeNestedOptimize ( DecisionBuilder * db,
Assignment * solution,
bool maximize,
int64_t step,
SearchMonitor * monitor1,
SearchMonitor * monitor2 )

Definition at line 5021 of file search.cc.

◆ MakeNestedOptimize() [5/6]

DecisionBuilder * operations_research::Solver::MakeNestedOptimize ( DecisionBuilder * db,
Assignment * solution,
bool maximize,
int64_t step,
SearchMonitor * monitor1,
SearchMonitor * monitor2,
SearchMonitor * monitor3 )

Definition at line 5032 of file search.cc.

◆ MakeNestedOptimize() [6/6]

DecisionBuilder * operations_research::Solver::MakeNestedOptimize ( DecisionBuilder * db,
Assignment * solution,
bool maximize,
int64_t step,
SearchMonitor * monitor1,
SearchMonitor * monitor2,
SearchMonitor * monitor3,
SearchMonitor * monitor4 )

Definition at line 5045 of file search.cc.

◆ MakeNoCycle() [1/2]

Constraint * operations_research::Solver::MakeNoCycle ( const std::vector< IntVar * > & nexts,
const std::vector< IntVar * > & active,
Solver::IndexFilter1 sink_handler,
bool assume_paths )

Definition at line 621 of file graph_constraints.cc.

◆ MakeNoCycle() [2/2]

Constraint * operations_research::Solver::MakeNoCycle ( const std::vector< IntVar * > & nexts,
const std::vector< IntVar * > & active,
Solver::IndexFilter1 sink_handler = nullptr )
Todo
(user): Implement MakeAllNullIntersect taking an array of variable vectors.

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.

Definition at line 633 of file graph_constraints.cc.

◆ MakeNonEquality() [1/3]

Constraint * operations_research::Solver::MakeNonEquality ( IntExpr * expr,
int value )

expr != value

Definition at line 400 of file expr_cst.cc.

◆ MakeNonEquality() [2/3]

Constraint * operations_research::Solver::MakeNonEquality ( IntExpr * expr,
int64_t value )

expr != value

Definition at line 385 of file expr_cst.cc.

◆ MakeNonEquality() [3/3]

Constraint * operations_research::Solver::MakeNonEquality ( IntExpr * left,
IntExpr * right )

left != right

Definition at line 570 of file range_cst.cc.

◆ MakeNonOverlappingBoxesConstraint() [1/3]

Constraint * operations_research::Solver::MakeNonOverlappingBoxesConstraint ( const std::vector< IntVar * > & x_vars,
const std::vector< IntVar * > & y_vars,
absl::Span< const int > x_size,
absl::Span< const int > y_size )

Definition at line 318 of file diffn.cc.

◆ MakeNonOverlappingBoxesConstraint() [2/3]

Constraint * operations_research::Solver::MakeNonOverlappingBoxesConstraint ( const std::vector< IntVar * > & x_vars,
const std::vector< IntVar * > & y_vars,
absl::Span< const int64_t > x_size,
absl::Span< const int64_t > y_size )

Definition at line 306 of file diffn.cc.

◆ MakeNonOverlappingBoxesConstraint() [3/3]

Constraint * operations_research::Solver::MakeNonOverlappingBoxesConstraint ( 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.

Definition at line 300 of file diffn.cc.

◆ MakeNonOverlappingNonStrictBoxesConstraint() [1/3]

Constraint * operations_research::Solver::MakeNonOverlappingNonStrictBoxesConstraint ( const std::vector< IntVar * > & x_vars,
const std::vector< IntVar * > & y_vars,
absl::Span< const int > x_size,
absl::Span< const int > y_size )

Definition at line 348 of file diffn.cc.

◆ MakeNonOverlappingNonStrictBoxesConstraint() [2/3]

Constraint * operations_research::Solver::MakeNonOverlappingNonStrictBoxesConstraint ( const std::vector< IntVar * > & x_vars,
const std::vector< IntVar * > & y_vars,
absl::Span< const int64_t > x_size,
absl::Span< const int64_t > y_size )

Definition at line 336 of file diffn.cc.

◆ MakeNonOverlappingNonStrictBoxesConstraint() [3/3]

Constraint * operations_research::Solver::MakeNonOverlappingNonStrictBoxesConstraint ( 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.

Definition at line 330 of file diffn.cc.

◆ MakeNotBetweenCt()

Constraint * operations_research::Solver::MakeNotBetweenCt ( IntExpr * 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.

Catch empty interval.

Catch the trivial cases first.

Catch one-sided constraints.

Todo
(user): Add back simplification code if expr is constant * other_expr.

Definition at line 962 of file expr_cst.cc.

◆ MakeNotMemberCt() [1/5]

Constraint * operations_research::Solver::MakeNotMemberCt ( IntExpr * expr,
const std::vector< int > & values )

Definition at line 1303 of file expr_cst.cc.

◆ MakeNotMemberCt() [2/5]

Constraint * operations_research::Solver::MakeNotMemberCt ( IntExpr * expr,
const std::vector< int64_t > & values )

expr not in set.

If the expression is a non-trivial product, we filter out the values that aren't multiples of "coeff", and divide them.

Filter out the values that are outside the [Min, Max] interval.

Catch empty set.

Sort and remove duplicates.

Special case for singleton.

Catch contiguous intervals.

If the set of values in [expr.Min(), expr.Max()] that are not in "values" is smaller than "values", then it's more efficient to use MemberCt. Catch that case here.

Convert "copied_values" to a dense boolean vector.

Use zero valued indices for is_among_input_values to build the complement of copied_values.

The empty' case (all values in range [expr.Min(), expr.Max()] are in the "values" input) was caught earlier, by the "contiguous interval" case.

Otherwise, just use NotMemberCt. No further reduction is possible.

Definition at line 1239 of file expr_cst.cc.

◆ MakeNotMemberCt() [3/5]

Constraint * operations_research::Solver::MakeNotMemberCt ( IntExpr * expr,
SortedDisjointIntervalList intervals )

expr should not be in the list of forbidden intervals.

Definition at line 1596 of file expr_cst.cc.

◆ MakeNotMemberCt() [4/5]

Constraint * operations_research::Solver::MakeNotMemberCt ( IntExpr * expr,
std::vector< int > starts,
std::vector< int > ends )

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

Definition at line 1589 of file expr_cst.cc.

◆ MakeNotMemberCt() [5/5]

Constraint * operations_research::Solver::MakeNotMemberCt ( IntExpr * 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]].

Definition at line 1582 of file expr_cst.cc.

◆ MakeNullIntersect()

Constraint * operations_research::Solver::MakeNullIntersect ( 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.

Definition at line 737 of file alldiff_cst.cc.

◆ MakeNullIntersectExcept()

Constraint * operations_research::Solver::MakeNullIntersectExcept ( 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.

Definition at line 742 of file alldiff_cst.cc.

◆ MakeOperator() [1/4]

LocalSearchOperator * operations_research::Solver::MakeOperator ( const std::vector< IntVar * > & vars,
const std::vector< IntVar * > & secondary_vars,
Solver::IndexEvaluator3 evaluator,
Solver::EvaluatorLocalSearchOperators op )

Definition at line 2592 of file local_search.cc.

◆ MakeOperator() [2/4]

LocalSearchOperator * operations_research::Solver::MakeOperator ( const std::vector< IntVar * > & vars,
const std::vector< IntVar * > & secondary_vars,
Solver::LocalSearchOperators op,
std::function< const std::vector< int > &(int, int)> get_neighbors = nullptr )

Definition at line 2494 of file local_search.cc.

◆ MakeOperator() [3/4]

LocalSearchOperator * operations_research::Solver::MakeOperator ( const std::vector< IntVar * > & vars,
Solver::IndexEvaluator3 evaluator,
Solver::EvaluatorLocalSearchOperators op )
Todo
(user): Make the callback an IndexEvaluator2 when there are no secondary variables.

Definition at line 2586 of file local_search.cc.

◆ MakeOperator() [4/4]

LocalSearchOperator * operations_research::Solver::MakeOperator ( const std::vector< IntVar * > & vars,
Solver::LocalSearchOperators op,
std::function< const std::vector< int > &(int, int)> get_neighbors = nullptr )

Local Search Operators.

Todo
(user): Remove (parts of) the following methods as they are mostly redundant with the MakeLocalSearchOperatorWithNeighbors and MakeLocalSearchOperator functions.

Definition at line 2488 of file local_search.cc.

◆ MakeOpposite()

IntExpr * operations_research::Solver::MakeOpposite ( IntExpr * expr)

-expr

Definition at line 6793 of file expressions.cc.

◆ MakeOptimize()

OptimizeVar * operations_research::Solver::MakeOptimize ( bool maximize,
IntVar * v,
int64_t step )

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

Definition at line 3138 of file search.cc.

◆ MakePack()

Pack * operations_research::Solver::MakePack ( 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.

Definition at line 1612 of file pack.cc.

◆ MakePathConnected()

Constraint * operations_research::Solver::MakePathConnected ( 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.

Definition at line 1438 of file graph_constraints.cc.

◆ MakePathCumul() [1/3]

Constraint * operations_research::Solver::MakePathCumul ( const std::vector< IntVar * > & nexts,
const std::vector< IntVar * > & active,
const std::vector< IntVar * > & cumuls,
const std::vector< IntVar * > & slacks,
Solver::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.

Definition at line 1318 of file graph_constraints.cc.

◆ MakePathCumul() [2/3]

Constraint * operations_research::Solver::MakePathCumul ( 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.

Definition at line 1300 of file graph_constraints.cc.

◆ MakePathCumul() [3/3]

Constraint * operations_research::Solver::MakePathCumul ( const std::vector< IntVar * > & nexts,
const std::vector< IntVar * > & active,
const std::vector< IntVar * > & cumuls,
Solver::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.

Definition at line 1309 of file graph_constraints.cc.

◆ MakePathEnergyCostConstraint()

Constraint * operations_research::Solver::MakePathEnergyCostConstraint ( PathEnergyCostConstraintSpecification specification)

Definition at line 1771 of file graph_constraints.cc.

◆ MakePathPrecedenceConstraint() [1/2]

Constraint * operations_research::Solver::MakePathPrecedenceConstraint ( 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.

Definition at line 1623 of file graph_constraints.cc.

◆ MakePathPrecedenceConstraint() [2/2]

Constraint * operations_research::Solver::MakePathPrecedenceConstraint ( std::vector< IntVar * > nexts,
const std::vector< std::pair< int, int > > & precedences,
absl::Span< const int > lifo_path_starts,
absl::Span< const 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).

Definition at line 1629 of file graph_constraints.cc.

◆ MakePathTransitPrecedenceConstraint()

Constraint * operations_research::Solver::MakePathTransitPrecedenceConstraint ( 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.

Definition at line 1646 of file graph_constraints.cc.

◆ MakePhase() [1/15]

DecisionBuilder * operations_research::Solver::MakePhase ( const std::vector< IntervalVar * > & intervals,
IntervalStrategy str )

Scheduling phases.

Definition at line 855 of file sched_search.cc.

◆ MakePhase() [2/15]

DecisionBuilder * operations_research::Solver::MakePhase ( const std::vector< IntVar * > & vars,
Solver::IndexEvaluator1 var_evaluator,
Solver::IndexEvaluator2 value_evaluator )

Definition at line 2179 of file search.cc.

◆ MakePhase() [3/15]

DecisionBuilder * operations_research::Solver::MakePhase ( const std::vector< IntVar * > & vars,
Solver::IndexEvaluator1 var_evaluator,
Solver::IndexEvaluator2 value_evaluator,
Solver::IndexEvaluator1 tie_breaker )

Definition at line 2217 of file search.cc.

◆ MakePhase() [4/15]

DecisionBuilder * operations_research::Solver::MakePhase ( const std::vector< IntVar * > & vars,
Solver::IndexEvaluator1 var_evaluator,
Solver::IntValueStrategy val_str )

Definition at line 2128 of file search.cc.

◆ MakePhase() [5/15]

DecisionBuilder * operations_research::Solver::MakePhase ( const std::vector< IntVar * > & vars,
Solver::IndexEvaluator2 eval,
Solver::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.

Definition at line 2239 of file search.cc.

◆ MakePhase() [6/15]

DecisionBuilder * operations_research::Solver::MakePhase ( const std::vector< IntVar * > & vars,
Solver::IndexEvaluator2 eval,
Solver::IndexEvaluator1 tie_breaker,
Solver::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.

Todo
(user): support tie breaker

Definition at line 2245 of file search.cc.

◆ MakePhase() [7/15]

DecisionBuilder * operations_research::Solver::MakePhase ( const std::vector< IntVar * > & vars,
Solver::IntVarStrategy var_str,
Solver::IndexEvaluator2 value_evaluator )

Definition at line 2146 of file search.cc.

◆ MakePhase() [8/15]

DecisionBuilder * operations_research::Solver::MakePhase ( const std::vector< IntVar * > & vars,
Solver::IntVarStrategy var_str,
Solver::IndexEvaluator2 value_evaluator,
Solver::IndexEvaluator1 tie_breaker )

Definition at line 2200 of file search.cc.

◆ MakePhase() [9/15]

DecisionBuilder * operations_research::Solver::MakePhase ( const std::vector< IntVar * > & vars,
Solver::IntVarStrategy var_str,
Solver::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).

Definition at line 2116 of file search.cc.

◆ MakePhase() [10/15]

DecisionBuilder * operations_research::Solver::MakePhase ( 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".

Definition at line 2163 of file search.cc.

◆ MakePhase() [11/15]

DecisionBuilder * operations_research::Solver::MakePhase ( const std::vector< SequenceVar * > & sequences,
SequenceStrategy str )

Definition at line 880 of file sched_search.cc.

◆ MakePhase() [12/15]

DecisionBuilder * operations_research::Solver::MakePhase ( IntVar * v0,
IntVar * v1,
IntVar * v2,
IntVar * v3,
Solver::IntVarStrategy var_str,
Solver::IntValueStrategy val_str )

Definition at line 2094 of file search.cc.

◆ MakePhase() [13/15]

DecisionBuilder * operations_research::Solver::MakePhase ( IntVar * v0,
IntVar * v1,
IntVar * v2,
Solver::IntVarStrategy var_str,
Solver::IntValueStrategy val_str )

Definition at line 2083 of file search.cc.

◆ MakePhase() [14/15]

DecisionBuilder * operations_research::Solver::MakePhase ( IntVar * v0,
IntVar * v1,
Solver::IntVarStrategy var_str,
Solver::IntValueStrategy val_str )

Definition at line 2074 of file search.cc.

◆ MakePhase() [15/15]

DecisionBuilder * operations_research::Solver::MakePhase ( IntVar * v0,
Solver::IntVarStrategy var_str,
Solver::IntValueStrategy val_str )

Shortcuts for small arrays.

Definition at line 2066 of file search.cc.

◆ MakePiecewiseLinearExpr()

IntExpr * operations_research::Solver::MakePiecewiseLinearExpr ( IntExpr * expr,
const PiecewiseLinearFunction & f )

General piecewise-linear function expression, built from f(x) where f is piecewise-linear. The resulting expression is f(expr).

Todo
(user): Investigate if we can merge all three piecewise linear expressions.

Definition at line 7274 of file expressions.cc.

◆ MakePower()

IntExpr * operations_research::Solver::MakePower ( IntExpr * expr,
int64_t n )

expr ^ n (n > 0)

Definition at line 7088 of file expressions.cc.

◆ MakePrintModelVisitor()

ModelVisitor * operations_research::Solver::MakePrintModelVisitor ( )

Prints the model.

Definition at line 814 of file utilities.cc.

◆ MakeProd() [1/2]

IntExpr * operations_research::Solver::MakeProd ( IntExpr * expr,
int64_t value )

expr * value

Definition at line 6811 of file expressions.cc.

◆ MakeProd() [2/2]

IntExpr * operations_research::Solver::MakeProd ( IntExpr * left,
IntExpr * right )

left * right

--— Discover squares and powers --—

--— Discover nested products --—

--— Standard build --—

Definition at line 6901 of file expressions.cc.

◆ MakeProfiledDecisionBuilderWrapper()

DecisionBuilder * operations_research::Solver::MakeProfiledDecisionBuilderWrapper ( DecisionBuilder * db)

Activates profiling on a decision builder.

Definition at line 4566 of file local_search.cc.

◆ MakeRandomLnsOperator() [1/2]

LocalSearchOperator * operations_research::Solver::MakeRandomLnsOperator ( 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.

Definition at line 200 of file local_search.cc.

◆ MakeRandomLnsOperator() [2/2]

LocalSearchOperator * operations_research::Solver::MakeRandomLnsOperator ( const std::vector< IntVar * > & vars,
int number_of_variables,
int32_t seed )

Definition at line 205 of file local_search.cc.

◆ MakeRankFirstInterval()

Decision * operations_research::Solver::MakeRankFirstInterval ( SequenceVar * sequence,
int index )

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

Definition at line 869 of file sched_search.cc.

◆ MakeRankLastInterval()

Decision * operations_research::Solver::MakeRankLastInterval ( SequenceVar * sequence,
int index )

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

Definition at line 875 of file sched_search.cc.

◆ MakeRejectFilter()

LocalSearchFilter * operations_research::Solver::MakeRejectFilter ( )

Definition at line 2650 of file local_search.cc.

◆ MakeRestoreAssignment()

DecisionBuilder * operations_research::Solver::MakeRestoreAssignment ( Assignment * assignment)

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

Definition at line 1013 of file assignment.cc.

◆ MakeScalProd() [1/2]

IntExpr * operations_research::Solver::MakeScalProd ( const std::vector< IntVar * > & vars,
const std::vector< int > & coefs )

scalar product

Definition at line 3572 of file expr_array.cc.

◆ MakeScalProd() [2/2]

IntExpr * operations_research::Solver::MakeScalProd ( const std::vector< IntVar * > & vars,
const std::vector< int64_t > & coefs )

scalar product

Definition at line 3566 of file expr_array.cc.

◆ MakeScalProdEquality() [1/4]

Constraint * operations_research::Solver::MakeScalProdEquality ( const std::vector< IntVar * > & vars,
const std::vector< int > & coefficients,
int64_t cst )

Definition at line 3515 of file expr_array.cc.

◆ MakeScalProdEquality() [2/4]

Constraint * operations_research::Solver::MakeScalProdEquality ( const std::vector< IntVar * > & vars,
const std::vector< int > & coefficients,
IntVar * target )

Definition at line 3529 of file expr_array.cc.

◆ MakeScalProdEquality() [3/4]

Constraint * operations_research::Solver::MakeScalProdEquality ( const std::vector< IntVar * > & vars,
const std::vector< int64_t > & coefficients,
int64_t cst )

Definition at line 3508 of file expr_array.cc.

◆ MakeScalProdEquality() [4/4]

Constraint * operations_research::Solver::MakeScalProdEquality ( const std::vector< IntVar * > & vars,
const std::vector< int64_t > & coefficients,
IntVar * target )

Definition at line 3522 of file expr_array.cc.

◆ MakeScalProdGreaterOrEqual() [1/2]

Constraint * operations_research::Solver::MakeScalProdGreaterOrEqual ( const std::vector< IntVar * > & vars,
const std::vector< int > & coeffs,
int64_t cst )

Definition at line 3544 of file expr_array.cc.

◆ MakeScalProdGreaterOrEqual() [2/2]

Constraint * operations_research::Solver::MakeScalProdGreaterOrEqual ( const std::vector< IntVar * > & vars,
const std::vector< int64_t > & coeffs,
int64_t cst )

Definition at line 3537 of file expr_array.cc.

◆ MakeScalProdLessOrEqual() [1/2]

Constraint * operations_research::Solver::MakeScalProdLessOrEqual ( const std::vector< IntVar * > & vars,
const std::vector< int > & coefficients,
int64_t cst )

Definition at line 3558 of file expr_array.cc.

◆ MakeScalProdLessOrEqual() [2/2]

Constraint * operations_research::Solver::MakeScalProdLessOrEqual ( const std::vector< IntVar * > & vars,
const std::vector< int64_t > & coefficients,
int64_t cst )

Definition at line 3551 of file expr_array.cc.

◆ MakeScheduleOrExpedite()

Decision * operations_research::Solver::MakeScheduleOrExpedite ( IntervalVar * var,
int64_t est,
int64_t * 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.

Definition at line 848 of file sched_search.cc.

◆ MakeScheduleOrPostpone()

Decision * operations_research::Solver::MakeScheduleOrPostpone ( IntervalVar * var,
int64_t est,
int64_t * 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.

Definition at line 841 of file sched_search.cc.

◆ MakeSearchLog() [1/8]

SearchMonitor * operations_research::Solver::MakeSearchLog ( int branch_period)
Todo
(user): DEPRECATE API of MakeSearchLog(.., IntVar* var,..).

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

Definition at line 309 of file search.cc.

◆ MakeSearchLog() [2/8]

SearchMonitor * operations_research::Solver::MakeSearchLog ( int branch_period,
IntVar * var )

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

Definition at line 313 of file search.cc.

◆ MakeSearchLog() [3/8]

SearchMonitor * operations_research::Solver::MakeSearchLog ( 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 display_callback.

Definition at line 323 of file search.cc.

◆ MakeSearchLog() [4/8]

SearchMonitor * operations_research::Solver::MakeSearchLog ( int branch_period,
OptimizeVar * opt_var )

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

Definition at line 338 of file search.cc.

◆ MakeSearchLog() [5/8]

SearchMonitor * operations_research::Solver::MakeSearchLog ( int branch_period,
OptimizeVar * opt_var,
std::function< std::string()> display_callback )

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

Definition at line 342 of file search.cc.

◆ MakeSearchLog() [6/8]

SearchMonitor * operations_research::Solver::MakeSearchLog ( int branch_period,
std::function< std::string()> display_callback )

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

Definition at line 317 of file search.cc.

◆ MakeSearchLog() [7/8]

SearchMonitor * operations_research::Solver::MakeSearchLog ( int branch_period,
std::vector< IntVar * > vars,
std::function< std::string()> display_callback )

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

Definition at line 330 of file search.cc.

◆ MakeSearchLog() [8/8]

SearchMonitor * operations_research::Solver::MakeSearchLog ( SearchLogParameters parameters)

Definition at line 353 of file search.cc.

◆ MakeSearchTrace()

SearchMonitor * operations_research::Solver::MakeSearchTrace ( const std::string & prefix)

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

Definition at line 436 of file search.cc.

◆ MakeSemiContinuousExpr()

IntExpr * operations_research::Solver::MakeSemiContinuousExpr ( IntExpr * 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

Todo
(user) : benchmark with virtualization of PosIntDivDown and PosIntDivUp - or function pointers.

Definition at line 7201 of file expressions.cc.

◆ MakeSimulatedAnnealing()

ObjectiveMonitor * operations_research::Solver::MakeSimulatedAnnealing ( bool maximize,
IntVar * v,
int64_t step,
int64_t initial_temperature )

Creates a Simulated Annealing monitor.

Todo
(user): document behavior

Definition at line 3645 of file search.cc.

◆ MakeSolutionsLimit()

RegularLimit * operations_research::Solver::MakeSolutionsLimit ( int64_t solutions)

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

Definition at line 4522 of file search.cc.

◆ MakeSolveOnce() [1/6]

DecisionBuilder * operations_research::Solver::MakeSolveOnce ( DecisionBuilder * db)

SolveOnce will collapse a search tree described by a decision builder 'db' and a set of monitors and wrap it into a single point. If there are no solutions to this nested tree, then SolveOnce will fail. If there is a solution, it will find it and returns nullptr.

Definition at line 4887 of file search.cc.

◆ MakeSolveOnce() [2/6]

DecisionBuilder * operations_research::Solver::MakeSolveOnce ( DecisionBuilder * db,
const std::vector< SearchMonitor * > & monitors )

Definition at line 4931 of file search.cc.

◆ MakeSolveOnce() [3/6]

DecisionBuilder * operations_research::Solver::MakeSolveOnce ( DecisionBuilder * db,
SearchMonitor * monitor1 )

Definition at line 4891 of file search.cc.

◆ MakeSolveOnce() [4/6]

DecisionBuilder * operations_research::Solver::MakeSolveOnce ( DecisionBuilder * db,
SearchMonitor * monitor1,
SearchMonitor * monitor2 )

Definition at line 4898 of file search.cc.

◆ MakeSolveOnce() [5/6]

DecisionBuilder * operations_research::Solver::MakeSolveOnce ( DecisionBuilder * db,
SearchMonitor * monitor1,
SearchMonitor * monitor2,
SearchMonitor * monitor3 )

Definition at line 4907 of file search.cc.

◆ MakeSolveOnce() [6/6]

DecisionBuilder * operations_research::Solver::MakeSolveOnce ( DecisionBuilder * db,
SearchMonitor * monitor1,
SearchMonitor * monitor2,
SearchMonitor * monitor3,
SearchMonitor * monitor4 )

Definition at line 4918 of file search.cc.

◆ MakeSortingConstraint()

Constraint * operations_research::Solver::MakeSortingConstraint ( const std::vector< IntVar * > & vars,
const std::vector< IntVar * > & sorted )
Todo
(user): Do we need a version with an array of escape values.

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:

Definition at line 718 of file alldiff_cst.cc.

◆ MakeSplitVariableDomain()

Decision * operations_research::Solver::MakeSplitVariableDomain ( IntVar * var,
int64_t val,
bool start_with_lower_half )

Definition at line 1737 of file search.cc.

◆ MakeSquare()

IntExpr * operations_research::Solver::MakeSquare ( IntExpr * expr)

expr * expr

Definition at line 7070 of file expressions.cc.

◆ MakeStatisticsModelVisitor()

ModelVisitor * operations_research::Solver::MakeStatisticsModelVisitor ( )

Displays some nice statistics on the model.

Definition at line 818 of file utilities.cc.

◆ MakeStoreAssignment()

DecisionBuilder * operations_research::Solver::MakeStoreAssignment ( Assignment * assignment)

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

Definition at line 1017 of file assignment.cc.

◆ MakeStrictDisjunctiveConstraint()

DisjunctiveConstraint * operations_research::Solver::MakeStrictDisjunctiveConstraint ( 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.

Definition at line 2613 of file resource.cc.

◆ MakeSubCircuit()

Constraint * operations_research::Solver::MakeSubCircuit ( const std::vector< IntVar * > & nexts)

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

Definition at line 644 of file graph_constraints.cc.

◆ MakeSum() [1/3]

IntExpr * operations_research::Solver::MakeSum ( const std::vector< IntVar * > & vars)

sum of all vars.

--— API --—

Definition at line 3254 of file expr_array.cc.

◆ MakeSum() [2/3]

IntExpr * operations_research::Solver::MakeSum ( IntExpr * expr,
int64_t value )

expr + value.

Definition at line 6628 of file expressions.cc.

◆ MakeSum() [3/3]

IntExpr * operations_research::Solver::MakeSum ( IntExpr * left,
IntExpr * right )

--— Integer Expressions --—

left + right.

Definition at line 6596 of file expressions.cc.

◆ MakeSumEquality() [1/2]

Constraint * operations_research::Solver::MakeSumEquality ( const std::vector< IntVar * > & vars,
int64_t cst )

Definition at line 3453 of file expr_array.cc.

◆ MakeSumEquality() [2/2]

Constraint * operations_research::Solver::MakeSumEquality ( const std::vector< IntVar * > & vars,
IntVar * var )

Definition at line 3483 of file expr_array.cc.

◆ MakeSumGreaterOrEqual()

Constraint * operations_research::Solver::MakeSumGreaterOrEqual ( const std::vector< IntVar * > & vars,
int64_t cst )

Definition at line 3443 of file expr_array.cc.

◆ MakeSumLessOrEqual()

Constraint * operations_research::Solver::MakeSumLessOrEqual ( const std::vector< IntVar * > & vars,
int64_t cst )

Variation on arrays.

Definition at line 3433 of file expr_array.cc.

◆ MakeSumObjectiveFilter() [1/2]

IntVarLocalSearchFilter * operations_research::Solver::MakeSumObjectiveFilter ( const std::vector< IntVar * > & vars,
const std::vector< IntVar * > & secondary_vars,
Solver::IndexEvaluator3 values,
Solver::LocalSearchFilterBound filter_enum )

Definition at line 3734 of file local_search.cc.

◆ MakeSumObjectiveFilter() [2/2]

IntVarLocalSearchFilter * operations_research::Solver::MakeSumObjectiveFilter ( const std::vector< IntVar * > & vars,
Solver::IndexEvaluator2 values,
Solver::LocalSearchFilterBound filter_enum )

Definition at line 3702 of file local_search.cc.

◆ MakeSymmetryManager() [1/5]

SearchMonitor * operations_research::Solver::MakeSymmetryManager ( const std::vector< SymmetryBreaker * > & visitors)

Symmetry Breaking.

--— API --—

Definition at line 5293 of file search.cc.

◆ MakeSymmetryManager() [2/5]

SearchMonitor * operations_research::Solver::MakeSymmetryManager ( SymmetryBreaker * v1)

Definition at line 5298 of file search.cc.

◆ MakeSymmetryManager() [3/5]

SearchMonitor * operations_research::Solver::MakeSymmetryManager ( SymmetryBreaker * v1,
SymmetryBreaker * v2 )

Definition at line 5304 of file search.cc.

◆ MakeSymmetryManager() [4/5]

SearchMonitor * operations_research::Solver::MakeSymmetryManager ( SymmetryBreaker * v1,
SymmetryBreaker * v2,
SymmetryBreaker * v3 )

Definition at line 5312 of file search.cc.

◆ MakeSymmetryManager() [5/5]

SearchMonitor * operations_research::Solver::MakeSymmetryManager ( SymmetryBreaker * v1,
SymmetryBreaker * v2,
SymmetryBreaker * v3,
SymmetryBreaker * v4 )

Definition at line 5322 of file search.cc.

◆ MakeTabuSearch()

ObjectiveMonitor * operations_research::Solver::MakeTabuSearch ( bool maximize,
IntVar * objective,
int64_t step,
const std::vector< IntVar * > & vars,
int64_t keep_tenure,
int64_t forbid_tenure,
double tabu_factor )

MetaHeuristics which try to get the search out of local optima.

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

  • improving the best solution found so far
  • variables in the "keep" list must keep their value, variables in the "forbid" list must not take the value they have in the list. Variables with new values enter the tabu lists after each new solution found and leave the lists after a given number of iterations (called tenure). Only the variables passed to the method can enter the lists. The tabu criterion is softened by the tabu factor which gives the number of "tabu" violations which is tolerated; a factor of 1 means no violations allowed; a factor of 0 means all violations are allowed.

Definition at line 3530 of file search.cc.

◆ MakeTemporalDisjunction() [1/2]

Constraint * operations_research::Solver::MakeTemporalDisjunction ( IntervalVar * t1,
IntervalVar * t2 )

This constraint implements a temporal disjunction between two interval vars.

Definition at line 408 of file timetabling.cc.

◆ MakeTemporalDisjunction() [2/2]

Constraint * operations_research::Solver::MakeTemporalDisjunction ( IntervalVar * t1,
IntervalVar * t2,
IntVar * alt )

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

Definition at line 402 of file timetabling.cc.

◆ MakeTimeLimit() [1/2]

RegularLimit * operations_research::Solver::MakeTimeLimit ( absl::Duration time)

Creates a search limit that constrains the running time.

Definition at line 4501 of file search.cc.

◆ MakeTimeLimit() [2/2]

ABSL_MUST_USE_RESULT RegularLimit * operations_research::Solver::MakeTimeLimit ( int64_t time_in_ms)
inline

Definition at line 2390 of file constraint_solver.h.

◆ MakeTransitionConstraint() [1/2]

Constraint * operations_research::Solver::MakeTransitionConstraint ( 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.

Definition at line 1279 of file table.cc.

◆ MakeTransitionConstraint() [2/2]

Constraint * operations_research::Solver::MakeTransitionConstraint ( 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.

Definition at line 1272 of file table.cc.

◆ MakeTrueConstraint()

Constraint * operations_research::Solver::MakeTrueConstraint ( )

This constraint always succeeds.

Definition at line 530 of file constraints.cc.

◆ MakeVariableDegreeVisitor()

ModelVisitor * operations_research::Solver::MakeVariableDegreeVisitor ( absl::flat_hash_map< const IntVar *, int > * map)

Compute the number of constraints a variable is attached to.

Definition at line 822 of file utilities.cc.

◆ MakeVariableDomainFilter()

LocalSearchFilter * operations_research::Solver::MakeVariableDomainFilter ( )

Definition at line 3437 of file local_search.cc.

◆ MakeVariableGreaterOrEqualValue()

Decision * operations_research::Solver::MakeVariableGreaterOrEqualValue ( IntVar * var,
int64_t value )

Definition at line 1747 of file search.cc.

◆ MakeVariableLessOrEqualValue()

Decision * operations_research::Solver::MakeVariableLessOrEqualValue ( IntVar * var,
int64_t value )

Definition at line 1742 of file search.cc.

◆ MakeWeightedMaximize() [1/2]

OptimizeVar * operations_research::Solver::MakeWeightedMaximize ( const std::vector< IntVar * > & sub_objectives,
const std::vector< int > & weights,
int64_t step )

Creates a maximization weigthed objective.

Definition at line 3208 of file search.cc.

◆ MakeWeightedMaximize() [2/2]

OptimizeVar * operations_research::Solver::MakeWeightedMaximize ( const std::vector< IntVar * > & sub_objectives,
const std::vector< int64_t > & weights,
int64_t step )

Creates a maximization weigthed objective.

Definition at line 3188 of file search.cc.

◆ MakeWeightedMinimize() [1/2]

OptimizeVar * operations_research::Solver::MakeWeightedMinimize ( 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).

Definition at line 3202 of file search.cc.

◆ MakeWeightedMinimize() [2/2]

OptimizeVar * operations_research::Solver::MakeWeightedMinimize ( 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).

Definition at line 3181 of file search.cc.

◆ MakeWeightedOptimize() [1/2]

OptimizeVar * operations_research::Solver::MakeWeightedOptimize ( 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).

Definition at line 3195 of file search.cc.

◆ MakeWeightedOptimize() [2/2]

OptimizeVar * operations_research::Solver::MakeWeightedOptimize ( 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).

Definition at line 3174 of file search.cc.

◆ MemoryUsage()

int64_t operations_research::Solver::MemoryUsage ( )
static

Current memory usage in bytes.

Definition at line 1549 of file constraint_solver.cc.

◆ model_name()

std::string operations_research::Solver::model_name ( ) const

Returns the name of the model.

Definition at line 1428 of file constraint_solver.cc.

◆ MultiArmedBanditConcatenateOperators()

LocalSearchOperator * operations_research::Solver::MultiArmedBanditConcatenateOperators ( 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.

Definition at line 2415 of file local_search.cc.

◆ NameAllVariables()

bool operations_research::Solver::NameAllVariables ( ) const

Returns whether all variables should be named.

Definition at line 198 of file constraint_solver.cc.

◆ neighbors()

int64_t operations_research::Solver::neighbors ( ) const
inline

The number of neighbors created.

Definition at line 1070 of file constraint_solver.h.

◆ NewSearch() [1/6]

void operations_research::Solver::NewSearch ( DecisionBuilder * db)

Definition at line 1821 of file constraint_solver.cc.

◆ NewSearch() [2/6]

void operations_research::Solver::NewSearch ( DecisionBuilder * db,
const std::vector< SearchMonitor * > & monitors )

Opens a new top level search.

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

Todo
(user) : reset statistics

--— jumps to correct state --—

Nested searches are created on demand, and deleted afterwards.

Top level search is persistent.

Todo
(user): delete top level search after EndSearch().
Todo
(user): Check if these two lines are still necessary.

--— manages all monitors --—

Always install the main propagation and local search monitors.

Push monitors and enter search.

Install the print trace if needed. The print_trace needs to be last to detect propagation from the objective.

This is useful to trace the exact behavior of the search. The '######## ' prefix is the same as the progagation trace. Search trace is subsumed by propagation trace, thus only one is necessary.

--— enters search --—

Push sentinel and set decision builder.

Definition at line 1842 of file constraint_solver.cc.

◆ NewSearch() [3/6]

void operations_research::Solver::NewSearch ( DecisionBuilder * db,
SearchMonitor * m1 )

Definition at line 1817 of file constraint_solver.cc.

◆ NewSearch() [4/6]

void operations_research::Solver::NewSearch ( DecisionBuilder * db,
SearchMonitor * m1,
SearchMonitor * m2 )

Definition at line 1823 of file constraint_solver.cc.

◆ NewSearch() [5/6]

void operations_research::Solver::NewSearch ( DecisionBuilder * db,
SearchMonitor * m1,
SearchMonitor * m2,
SearchMonitor * m3 )

Definition at line 1828 of file constraint_solver.cc.

◆ NewSearch() [6/6]

void operations_research::Solver::NewSearch ( DecisionBuilder * db,
SearchMonitor * m1,
SearchMonitor * m2,
SearchMonitor * m3,
SearchMonitor * m4 )

Definition at line 1833 of file constraint_solver.cc.

◆ NextSolution()

bool operations_research::Solver::NextSolution ( )

Search for the next solution in the search tree.

Check the fail state that could have been set in the python/java/C# layer.

We reverse the decision and fall through the normal code.

We do not need to push back the sentinel as we are exiting anyway.

Definition at line 2092 of file constraint_solver.cc.

◆ Now()

absl::Time operations_research::Solver::Now ( ) const

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.

Definition at line 1555 of file constraint_solver.cc.

◆ operator=()

Solver & operations_research::Solver::operator= ( const Solver & )
delete

◆ optimization_direction()

OptimizationDirection operations_research::Solver::optimization_direction ( ) const
inline

The direction of optimization, getter and setter.

Definition at line 1097 of file constraint_solver.h.

◆ parameters()

ConstraintSolverParameters operations_research::Solver::parameters ( ) const
inline

Stored Parameters.

Definition at line 823 of file constraint_solver.h.

◆ PopState()

void operations_research::Solver::PopState ( )

Definition at line 1594 of file constraint_solver.cc.

◆ PushState()

void operations_research::Solver::PushState ( )

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

Definition at line 1589 of file constraint_solver.cc.

◆ Rand32()

int32_t operations_research::Solver::Rand32 ( int32_t size)
inline

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

Definition at line 3040 of file constraint_solver.h.

◆ Rand64()

int64_t operations_research::Solver::Rand64 ( int64_t size)
inline

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

Definition at line 3034 of file constraint_solver.h.

◆ RandomConcatenateOperators() [1/2]

LocalSearchOperator * operations_research::Solver::RandomConcatenateOperators ( const std::vector< LocalSearchOperator * > & ops)

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

Definition at line 2251 of file local_search.cc.

◆ RandomConcatenateOperators() [2/2]

LocalSearchOperator * operations_research::Solver::RandomConcatenateOperators ( 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.

Definition at line 2256 of file local_search.cc.

◆ RegisterDemon()

Demon * operations_research::Solver::RegisterDemon ( Demon * demon)

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

Definition at line 455 of file demon_profiler.cc.

◆ RegisterIntervalVar()

IntervalVar * operations_research::Solver::RegisterIntervalVar ( IntervalVar * var)

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

Definition at line 869 of file trace.cc.

◆ RegisterIntExpr()

IntExpr * operations_research::Solver::RegisterIntExpr ( IntExpr * expr)

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

Definition at line 848 of file trace.cc.

◆ RegisterIntVar()

IntVar * operations_research::Solver::RegisterIntVar ( IntVar * var)

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

trace var.

Definition at line 860 of file trace.cc.

◆ ReSeed()

void operations_research::Solver::ReSeed ( int32_t seed)
inline

Reseed the solver random generator.

Definition at line 3046 of file constraint_solver.h.

◆ RestartCurrentSearch()

void operations_research::Solver::RestartCurrentSearch ( )

Definition at line 2421 of file constraint_solver.cc.

◆ RestartSearch()

void operations_research::Solver::RestartSearch ( )

Definition at line 1984 of file constraint_solver.cc.

◆ RevAlloc()

template<typename T >
T * operations_research::Solver::RevAlloc ( T * object)
inline

Registers the given object as being reversible. By calling this method, the caller gives ownership of the object to the solver, which will delete it when there is a backtrack out of the current state. Returns the argument for convenience: this way, the caller may directly invoke a constructor in the argument, without having to store the pointer first. This function is only for users that define their own subclasses of BaseObject: for all subclasses predefined in the library, the corresponding factory methods (e.g., MakeIntVar(...), MakeAllDifferent(...) already take care of the registration.

Definition at line 857 of file constraint_solver.h.

◆ RevAllocArray()

template<typename T >
T * operations_research::Solver::RevAllocArray ( T * object)
inline

Like RevAlloc() above, but for an array of objects: the array must have been allocated with the new[] operator. The entire array will be deleted when backtracking out of the current state. This method is valid for arrays of int, int64_t, uint64_t, bool, BaseObject*, IntVar*, IntExpr*, and Constraint*.

Definition at line 869 of file constraint_solver.h.

◆ RunUncheckedLocalSearch()

Assignment * operations_research::Solver::RunUncheckedLocalSearch ( const Assignment * initial_solution,
LocalSearchFilterManager * filter_manager,
LocalSearchOperator * ls_operator,
const std::vector< SearchMonitor * > & monitors,
RegularLimit * limit,
absl::flat_hash_set< IntVar * > * touched = nullptr )

Experimental: runs a local search on the given initial solution, checking the feasibility and the objective value of solutions using the filter manager only (solutions are never restored in the CP world). Only greedy descent is supported.

Definition at line 5704 of file local_search.cc.

◆ SaveAndAdd()

template<class T >
void operations_research::Solver::SaveAndAdd ( T * adr,
T val )
inline

All-in-one SaveAndAdd_value.

Definition at line 3026 of file constraint_solver.h.

◆ SaveAndSetValue()

template<class T >
void operations_research::Solver::SaveAndSetValue ( T * adr,
T val )
inline

All-in-one SaveAndSetValue.

Definition at line 3017 of file constraint_solver.h.

◆ SaveValue()

template<class T >
void operations_research::Solver::SaveValue ( T * o)
inline

reversibility

SaveValue() saves the value of the corresponding object. It must be called before modifying the object. The value will be restored upon backtrack.

Definition at line 838 of file constraint_solver.h.

◆ SearchContext() [1/2]

std::string operations_research::Solver::SearchContext ( ) const

Definition at line 3246 of file constraint_solver.cc.

◆ SearchContext() [2/2]

std::string operations_research::Solver::SearchContext ( const Search * search) const

Definition at line 3250 of file constraint_solver.cc.

◆ SearchDepth()

int operations_research::Solver::SearchDepth ( ) const

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

Definition at line 1203 of file constraint_solver.cc.

◆ SearchLeftDepth()

int operations_research::Solver::SearchLeftDepth ( ) const

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

Definition at line 1205 of file constraint_solver.cc.

◆ set_context()

void operations_research::Solver::set_context ( absl::string_view context)
inline

Sets the current context of the search.

Definition at line 1091 of file constraint_solver.h.

◆ set_fail_intercept()

void operations_research::Solver::set_fail_intercept ( std::function< void()> fail_intercept)
inline

Internal.

Definition at line 3080 of file constraint_solver.h.

◆ set_optimization_direction()

void operations_research::Solver::set_optimization_direction ( OptimizationDirection direction)
inline

Definition at line 1100 of file constraint_solver.h.

◆ SetBranchSelector()

void operations_research::Solver::SetBranchSelector ( BranchSelector bs)

Sets the given branch selector on the current active search.

We cannot use the trail as the search can be nested and thus deleted upon backtrack. Thus we guard the undo action by a check on the number of nesting of solve().

Definition at line 1180 of file constraint_solver.cc.

◆ SetSearchContext()

void operations_research::Solver::SetSearchContext ( Search * search,
absl::string_view search_context )

Definition at line 3241 of file constraint_solver.cc.

◆ SetUseFastLocalSearch()

void operations_research::Solver::SetUseFastLocalSearch ( bool use_fast_local_search)
inline
Todo
(user): Get rid of the following methods once fast local search is enabled for metaheuristics. Disables/enables fast local search.

Definition at line 3090 of file constraint_solver.h.

◆ ShouldFail()

void operations_research::Solver::ShouldFail ( )
inline

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

Definition at line 3191 of file constraint_solver.h.

◆ solutions()

int64_t operations_research::Solver::solutions ( ) const

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

Definition at line 1559 of file constraint_solver.cc.

◆ Solve() [1/6]

bool operations_research::Solver::Solve ( DecisionBuilder * db)

Definition at line 1789 of file constraint_solver.cc.

◆ Solve() [2/6]

bool operations_research::Solver::Solve ( DecisionBuilder * 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
the definition of 'solution' is subtle. A solution here is defined as a leaf of the search tree with respect to the given decision builder for which there is no failure. What this means is that, contrary to intuition, a solution may not have all variables of the model bound. It is the responsibility of the decision builder to keep returning decisions until all variables are indeed bound. The most extreme counterexample is calling Solve with a trivial decision builder whose Next() method always returns nullptr. In this case, Solve immediately returns 'true', since not assigning any variable to any value is a solution, unless the root node propagation discovers that the model is infeasible. This function must be called either from outside of search, or from within the Next() method of a decision builder. Solve will terminate whenever any of the following event arise:
  • A search monitor asks the solver to terminate the search by calling solver()->FinishCurrentSearch().
  • A solution is found that is accepted by all search monitors, and none of the search monitors decides to search for another one. Upon search termination, there will be a series of backtracks all the way to the top level. This means that a user cannot expect to inspect the solution by querying variables after a call to Solve(): all the information will be lost. In order to do something with the solution, the user must either:
  • Use a search monitor that can process such a leaf. See, in particular, the SolutionCollector class.
  • Do not use Solve. Instead, use the more fine-grained approach using methods NewSearch(...), NextSolution(), and EndSearch().
Parameters
dbThe decision builder that will generate the search tree.
monitorsA 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.

Definition at line 1807 of file constraint_solver.cc.

◆ Solve() [3/6]

bool operations_research::Solver::Solve ( DecisionBuilder * db,
SearchMonitor * m1 )

Definition at line 1785 of file constraint_solver.cc.

◆ Solve() [4/6]

bool operations_research::Solver::Solve ( DecisionBuilder * db,
SearchMonitor * m1,
SearchMonitor * m2 )

Definition at line 1791 of file constraint_solver.cc.

◆ Solve() [5/6]

bool operations_research::Solver::Solve ( DecisionBuilder * db,
SearchMonitor * m1,
SearchMonitor * m2,
SearchMonitor * m3 )

Definition at line 1796 of file constraint_solver.cc.

◆ Solve() [6/6]

bool operations_research::Solver::Solve ( DecisionBuilder * db,
SearchMonitor * m1,
SearchMonitor * m2,
SearchMonitor * m3,
SearchMonitor * m4 )

Definition at line 1801 of file constraint_solver.cc.

◆ SolveAndCommit() [1/5]

bool operations_research::Solver::SolveAndCommit ( DecisionBuilder * db)

Definition at line 2381 of file constraint_solver.cc.

◆ SolveAndCommit() [2/5]

bool operations_research::Solver::SolveAndCommit ( DecisionBuilder * 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.

Definition at line 2395 of file constraint_solver.cc.

◆ SolveAndCommit() [3/5]

bool operations_research::Solver::SolveAndCommit ( DecisionBuilder * db,
SearchMonitor * m1 )

Definition at line 2376 of file constraint_solver.cc.

◆ SolveAndCommit() [4/5]

bool operations_research::Solver::SolveAndCommit ( DecisionBuilder * db,
SearchMonitor * m1,
SearchMonitor * m2 )

Definition at line 2385 of file constraint_solver.cc.

◆ SolveAndCommit() [5/5]

bool operations_research::Solver::SolveAndCommit ( DecisionBuilder * db,
SearchMonitor * m1,
SearchMonitor * m2,
SearchMonitor * m3 )

Definition at line 2390 of file constraint_solver.cc.

◆ SolveDepth()

int operations_research::Solver::SolveDepth ( ) const

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.

Definition at line 1199 of file constraint_solver.cc.

◆ stamp()

uint64_t operations_research::Solver::stamp ( ) const

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.

Definition at line 1676 of file constraint_solver.cc.

◆ state()

SolverState operations_research::Solver::state ( ) const
inline

State of the solver.

Definition at line 1025 of file constraint_solver.h.

◆ TopPeriodicCheck()

void operations_research::Solver::TopPeriodicCheck ( )

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

Definition at line 1575 of file constraint_solver.cc.

◆ TopProgressPercent()

int operations_research::Solver::TopProgressPercent ( )

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

Definition at line 1577 of file constraint_solver.cc.

◆ Try() [1/4]

DecisionBuilder * operations_research::Solver::Try ( const std::vector< DecisionBuilder * > & dbs)

Definition at line 787 of file search.cc.

◆ Try() [2/4]

DecisionBuilder * operations_research::Solver::Try ( DecisionBuilder * db1,
DecisionBuilder * db2 )

Creates a decision builder which will create a search tree where each decision builder is called from the top of the search tree. For instance the decision builder Try(db1, db2) will entirely explore the search tree of db1 then the one of db2, resulting in the following search tree: Tree root | / \ | db1 tree db2 tree | This is very handy to try a decision builder which partially explores the search space and if it fails to try another decision builder.

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.

Definition at line 757 of file search.cc.

◆ Try() [3/4]

DecisionBuilder * operations_research::Solver::Try ( DecisionBuilder * db1,
DecisionBuilder * db2,
DecisionBuilder * db3 )

Definition at line 765 of file search.cc.

◆ Try() [4/4]

DecisionBuilder * operations_research::Solver::Try ( DecisionBuilder * db1,
DecisionBuilder * db2,
DecisionBuilder * db3,
DecisionBuilder * db4 )

Definition at line 775 of file search.cc.

◆ unchecked_solutions()

int64_t operations_research::Solver::unchecked_solutions ( ) const

The number of unchecked solutions found by local search.

Definition at line 1563 of file constraint_solver.cc.

◆ UseFastLocalSearch()

bool operations_research::Solver::UseFastLocalSearch ( ) const
inline

Returns true if fast local search is enabled.

Definition at line 3094 of file constraint_solver.h.

◆ wall_time()

int64_t operations_research::Solver::wall_time ( ) const
Deprecated
Use Now() instead. Time elapsed, in ms since the creation of the solver.

Definition at line 1551 of file constraint_solver.cc.

Friends And Related Symbol Documentation

◆ BaseIntExpr

friend class BaseIntExpr
friend

Definition at line 3148 of file constraint_solver.h.

◆ Constraint

friend class Constraint
friend

Definition at line 3149 of file constraint_solver.h.

◆ DemonProfiler

friend class DemonProfiler
friend

Definition at line 3150 of file constraint_solver.h.

◆ FindOneNeighbor

friend class FindOneNeighbor
friend

Definition at line 3151 of file constraint_solver.h.

◆ InternalSaveBooleanVarValue

void InternalSaveBooleanVarValue ( Solver * solver,
IntVar * var )
friend

Definition at line 965 of file constraint_solver.cc.

◆ IntVar

friend class IntVar
friend

Definition at line 3152 of file constraint_solver.h.

◆ LocalSearch

friend class LocalSearch
friend

Definition at line 3158 of file constraint_solver.h.

◆ LocalSearchProfiler

friend class LocalSearchProfiler
friend

Definition at line 3159 of file constraint_solver.h.

◆ PropagationBaseObject

friend class PropagationBaseObject
friend

Definition at line 3153 of file constraint_solver.h.

◆ Queue

friend class Queue
friend

Definition at line 3154 of file constraint_solver.h.

◆ RevImmutableMultiMap

template<class K , class V >
friend class RevImmutableMultiMap
friend

Definition at line 3166 of file constraint_solver.h.

◆ RoutingModel

friend class RoutingModel
friend

Definition at line 3157 of file constraint_solver.h.

◆ SearchLimit

friend class SearchLimit
friend

Definition at line 3156 of file constraint_solver.h.

◆ SearchMonitor

friend class SearchMonitor
friend

Definition at line 3155 of file constraint_solver.h.

◆ SimpleRevFIFO

template<class >
friend class SimpleRevFIFO
friend

Definition at line 3164 of file constraint_solver.h.

Member Data Documentation

◆ kNumPriorities

int operations_research::Solver::kNumPriorities = 3
staticconstexpr

Number of priorities for demons.

Definition at line 283 of file constraint_solver.h.

◆ tmp_vector_

std::vector<int64_t> operations_research::Solver::tmp_vector_

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

Definition at line 3146 of file constraint_solver.h.


The documentation for this class was generated from the following files: