Class Solver
- java.lang.Object
-
- com.google.ortools.constraintsolver.Solver
-
public class Solver extends java.lang.ObjectSolver Class
A solver represents the main computation engine. It implements the entire
range of Constraint Programming protocols:
- Reversibility
- Propagation
- Search
Usually, Constraint Programming code consists of
- the creation of the Solver,
- the creation of the decision variables of the model,
- the creation of the constraints of the model and their addition to the
solver() through the AddConstraint() method,
- the creation of the main DecisionBuilder class,
- the launch of the solve() method with the decision builder.
For the time being, Solver is neither MT_SAFE nor MT_HOT.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSolver.FailExceptionThis exceptions signal that a failure has been raised in the C++ world.static classSolver.IntegerCastInfoHolds semantic information stating that the 'expression' has been
cast into 'variable' using the Var() method, and that
'maintainer' is responsible for maintaining the equality between
'variable' and 'expression'.
-
Field Summary
Fields Modifier and Type Field Description static intASSIGN_CENTER_VALUESelects 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.static intASSIGN_MAX_VALUESelects the max value of the selected variable.static intASSIGN_MIN_VALUESelects the min value of the selected variable.static intASSIGN_RANDOM_VALUESelects randomly one of the possible values of the selected variable.static intAT_SOLUTIONAfter successful NextSolution and before EndSearch.static intAVOID_DATESTARTS_AFTER or ENDS_BEFORE, i.e.static intCHOICE_POINTstatic intCHOOSE_DYNAMIC_GLOBAL_BESTPairs are compared each time a variable is selected.static intCHOOSE_FIRST_UNBOUNDSelect the first unbound variable.
Variables are considered in the order of the vector of IntVars used
to create the selector.static intCHOOSE_HIGHEST_MAXAmong 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.static intCHOOSE_LOWEST_MINAmong 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.static intCHOOSE_MAX_REGRET_ON_MINAmong unbound variables, select the variable with the largest
gap between the first and the second values of the domain.static intCHOOSE_MAX_SIZEAmong 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.static intCHOOSE_MIN_SIZEAmong 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.static intCHOOSE_MIN_SIZE_HIGHEST_MAXAmong 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.static intCHOOSE_MIN_SIZE_HIGHEST_MINAmong 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.static intCHOOSE_MIN_SIZE_LOWEST_MAXAmong 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.static intCHOOSE_MIN_SIZE_LOWEST_MINAmong 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.static intCHOOSE_MIN_SLACK_RANK_FORWARDstatic intCHOOSE_PATHSelects 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.static intCHOOSE_RANDOMRandomly select one of the remaining unbound variables.static intCHOOSE_RANDOM_RANK_FORWARDstatic intCHOOSE_STATIC_GLOBAL_BESTPairs are compared at the first call of the selector, and results are
cached.static intCROSSOperator 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] -> 8static intCROSS_DATESTARTS_BEFORE and ENDS_AFTER at the same time, i.e.static intDECREMENTOperator which defines a neighborhood to decrement values.
The behavior is the same as INCREMENT, except values are decremented
instead of incremented.static intDELAYED_PRIORITYDELAYED_PRIORITY is the lowest priority: Demons will be processed after
VAR_PRIORITY and NORMAL_PRIORITY demons.static intENDS_AFTERt ends after d, i.e.static intENDS_AFTER_ENDt1 ends after t2 end, i.e.static intENDS_AFTER_STARTt1 ends after t2 start, i.e.static intENDS_ATt ends at d, i.e.static intENDS_AT_ENDt1 ends at t2 end, i.e.static intENDS_AT_STARTt1 ends at t2 start, i.e.static intENDS_BEFOREt ends before d, i.e.static intEQMove is accepted when the current objective value is in the interval
objective.Min ..static intEXCHANGEOperator 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] -> 5static intEXTENDEDSWAPACTIVEOperator 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 inactivestatic intFULLPATHLNSOperator which relaxes one entire path and all inactive nodes, thus
defining num_paths neighbors.static intGEMove is accepted when the current objective value >= objective.Min.static intIN_ROOT_NODEExecuting the root node.static intIN_SEARCHExecuting the search code.static intINCREMENTOperator which defines one neighbor per variable.static intINT_VALUE_DEFAULTThe default behavior is ASSIGN_MIN_VALUE.static intINT_VALUE_SIMPLEThe simple selection is ASSIGN_MIN_VALUE.static intINT_VAR_DEFAULTThe default behavior is CHOOSE_FIRST_UNBOUND.static intINT_VAR_SIMPLEThe simple selection is CHOOSE_FIRST_UNBOUND.static intINTERVAL_DEFAULTThe default is INTERVAL_SET_TIMES_FORWARD.static intINTERVAL_SET_TIMES_BACKWARDSelects the variable with the highest ending time of all variables,
and fixes the ending time to this highest values.static intINTERVAL_SET_TIMES_FORWARDSelects the variable with the lowest starting time of all variables,
and fixes its starting time to this lowest value.static intINTERVAL_SIMPLEThe simple is INTERVAL_SET_TIMES_FORWARD.static intKEEP_LEFTRight branches are ignored.static intKEEP_RIGHTLeft branches are ignored.static intKILL_BOTHBacktracks to the previous decisions, i.e.static intkNumPrioritiesNumber of priorities for demons.static intLEMove is accepted when the current objective value <= objective.Max.static intLKLin-Kernighan local search.
While the accumulated local gain is positive, perform a 2opt or a 3opt
move followed by a series of 2opt moves.static intMAKEACTIVEOperator 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] -> 4static intMAKECHAININACTIVEOperator 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 inactivestatic intMAKEINACTIVEOperator 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 inactivestatic intMAXIMIZATIONstatic intMINIMIZATIONstatic intNO_CHANGEKeeps the default behavior, i.e.static intNO_MORE_SOLUTIONSAfter failed NextSolution and before EndSearch.static intNORMAL_PRIORITYNORMAL_PRIORITY is the highest priority: Demons will be processed first.static intNOT_SETOptimization directions.static intOROPTRelocate: 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.static intOUTSIDE_SEARCHBefore search, after search.static intPATHLNSOperator which relaxes two sub-chains of three consecutive arcs each.
Each sub-chain is defined by a start node and the next three arcs.static intPROBLEM_INFEASIBLEAfter search, the model is infeasible.static intRELOCATERelocate neighborhood with length of 1 (see OROPT comment).static intREVERSIBLE_ACTIONstatic intSENTINELThis enum is used internally in private methods Solver::PushState and
Solver::PopState to tag states in the search tree.static intSEQUENCE_DEFAULTUsed for scheduling.static intSEQUENCE_SIMPLEstatic intSIMPLE_MARKERstatic intSIMPLELNSOperator which defines one neighbor per variable.static intSPLIT_LOWER_HALFSplit the domain in two around the center, and choose the lower
part first.static intSPLIT_UPPER_HALFSplit the domain in two around the center, and choose the lower
part first.static intSTARTS_AFTERt starts after d, i.e.static intSTARTS_AFTER_ENDt1 starts after t2 end, i.e.static intSTARTS_AFTER_STARTt1 starts after t2 start, i.e.static intSTARTS_ATt starts at d, i.e.static intSTARTS_AT_ENDt1 starts at t2 end, i.e.static intSTARTS_AT_STARTt1 starts at t2 start, i.e.static intSTARTS_BEFOREt starts before d, i.e.static intSTAYS_IN_SYNCSTARTS_AT_START and ENDS_AT_END at the same time.
t1 starts at t2 start, i.e.static intSWAPACTIVEOperator 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 inactiveprotected booleanswigCMemOwnstatic intSWITCH_BRANCHESApplies right branch first.static intTSPLNSTSP-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.static intTSPOPTSliding 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).static intTWOOPTOperator which reverses a sub-chain of a path.static intUNACTIVELNSOperator which relaxes all inactive nodes and one sub-chain of six
consecutive arcs.static intVAR_PRIORITYVAR_PRIORITY is between DELAYED_PRIORITY and NORMAL_PRIORITY.
-
Constructor Summary
Constructors Modifier Constructor Description protectedSolver(long cPtr, boolean cMemoryOwn)Solver(java.lang.String name)Solver APISolver(java.lang.String name, ConstraintSolverParameters parameters)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(ModelVisitor visitor)Accepts the given model visitor.longacceptedNeighbors()The number of accepted neighbors.voidaddCastConstraint(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.voidaddConstraint(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.voidaddLocalSearchMonitor(LocalSearchMonitor monitor)Adds the local search monitor to the solver.voidaddPropagationMonitor(PropagationMonitor monitor)Adds the propagation monitor to the solver.Decisionbalancing_decision()longbranches()The number of branches explored since the creation of the solver.ModelCachecache()Returns the cache of the model.IntExprcastExpression(IntVar var)Internal.booleancheckAssignment(Assignment solution)Checks whether the given assignment satisfies all relevant constraints.booleancheckConstraint(Constraint ct)Checks whether adding this constraint will lead to an immediate
failure.voidcheckFail()voidclear_fail_intercept()InternalvoidClearLocalSearchState()Clears the local search state.voidClearNeighbors()Manipulate neighbors count; to be used for testing purposes only.
TODO(user): Find a workaround to avoid exposing this.DecisionBuildercompose(DecisionBuilder[] dbs)DecisionBuildercompose(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.DecisionBuildercompose(DecisionBuilder db1, DecisionBuilder db2, DecisionBuilder db3)DecisionBuildercompose(DecisionBuilder db1, DecisionBuilder db2, DecisionBuilder db3, DecisionBuilder db4)LocalSearchOperatorconcatenateOperators(LocalSearchOperator[] ops)Creates a local search operator which concatenates a vector of operators.
Each operator from the vector is called sequentially.LocalSearchOperatorconcatenateOperators(LocalSearchOperator[] ops, boolean restart)LocalSearchOperatorconcatenateOperators(LocalSearchOperator[] ops, IntIntToLongFunction evaluator)SWIGTYPE_p_operations_research__ConstraintSolverParametersconst_parameters()intconstraints()Counts the number of constraints that have been added
to the solver before the search.java.lang.Stringcontext()Gets the current context of the search.booleancurrentlyInSolve()Returns true whether the current search has been
created using a Solve() call instead of a NewSearch one.static ConstraintSolverParametersdefaultSolverParameters()Create a ConstraintSolverParameters proto with all the default values.voiddelete()longdemon_runs(int p)The number of demons executed during search for a given priority.voidendSearch()voidexportProfilingOverview(java.lang.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.voidfail()Abandon the current branch in the search tree.java.math.BigIntegerfail_stamp()The fail_stamp() is incremented after each backtrack.longfailures()The number of failures encountered since the creation of the solver.longfilteredNeighbors()The number of filtered neighbors (neighbors accepted by filters).protected voidfinalize()voidfinishCurrentSearch()Tells the solver to kill or restart the current search.protected static longgetCPtr(Solver obj)LocalSearchMonitorgetLocalSearchMonitor()Returns the local search monitor.AssignmentGetOrCreateLocalSearchState()Returns (or creates) an assignment representing the state of local search.PropagationMonitorgetPropagationMonitor()Returns the propagation monitor.long[]getTmpVector()Unsafe temporary vector.booleanhasName(PropagationBaseObject object)Returns whether the object has been named or not.voidIncrementNeighbors()booleaninstrumentsDemons()Returns whether we are instrumenting demons.booleaninstrumentsVariables()Returns whether we are tracing variables.booleanisLocalSearchProfilingEnabled()Returns whether we are profiling local search.booleanisProfilingEnabled()Returns whether we are profiling the solver.voidkeepAliveDecisionBuilder(DecisionBuilder db)voidkeepAliveDecisionBuilder(DecisionBuilder[] dbs)java.lang.StringlocalSearchProfile()Returns local search profiling information in a human readable format.IntExprmakeAbs(IntExpr expr)|expr|ConstraintmakeAbsEquality(IntVar var, IntVar abs_var)Creates the constraint abs(var) == abs_var.LocalSearchFilterMakeAcceptFilter()Local Search FiltersConstraintmakeAllDifferent(IntVar[] vars)All variables are pairwise different.ConstraintmakeAllDifferent(IntVar[] vars, boolean stronger_propagation)All variables are pairwise different.ConstraintmakeAllDifferentExcept(IntVar[] vars, long escape_value)All variables are pairwise different, unless they are assigned to
the escape value.ConstraintmakeAllowedAssignment(IntVar[] vars, IntTupleSet tuples)This method creates a constraint where the graph of the relation
between the variables is given in extension.SolutionCollectormakeAllSolutionCollector()Collect all solutions of the search.SolutionCollectormakeAllSolutionCollector(Assignment assignment)Collect all solutions of the search.AssignmentmakeAssignment()This method creates an empty assignment.AssignmentmakeAssignment(Assignment a)This method creates an assignment which is a copy of 'a'.DecisionmakeAssignVariablesValues(IntVar[] vars, long[] values)DecisionMakeAssignVariablesValuesOrDoNothing(IntVar[] vars, long[] values)DecisionMakeAssignVariablesValuesOrFail(IntVar[] vars, long[] values)DecisionmakeAssignVariableValue(IntVar var, long val)Decisions.DecisionMakeAssignVariableValueOrDoNothing(IntVar var, long value)DecisionmakeAssignVariableValueOrFail(IntVar var, long value)SearchMonitormakeAtSolutionCallback(java.lang.Runnable callback)SolutionCollectorMakeBestLexicographicValueSolutionCollector(Assignment assignment, SWIGTYPE_p_std__vectorT_bool_t maximize)Same as above, but supporting lexicographic objectives; 'maximize'
specifies the optimization direction for each objective in 'assignment'.SolutionCollectorMakeBestLexicographicValueSolutionCollector(SWIGTYPE_p_std__vectorT_bool_t maximize)Same as above, but supporting lexicographic objectives; 'maximize'
specifies the optimization direction for each objective.SolutionCollectormakeBestValueSolutionCollector(boolean maximize)Collect the solution corresponding to the optimal value of the
objective of the internal assignment; if this assignment does not have an
objective no solution is collected.SolutionCollectormakeBestValueSolutionCollector(Assignment assignment, boolean maximize)Collect the solution corresponding to the optimal value of the objective
of 'assignment'; if 'assignment' does not have an objective no solution is
collected.ConstraintmakeBetweenCt(IntExpr expr, long l, long u)(l <= expr <= u)IntVarmakeBoolVar()MakeBoolVar will create a variable with a {0, 1} domain.IntVarmakeBoolVar(java.lang.String name)MakeBoolVar will create a variable with a {0, 1} domain.IntVar[]makeBoolVarArray(int count)IntVar[]makeBoolVarArray(int count, java.lang.String name)RegularLimitmakeBranchesLimit(long branches)Creates a search limit that constrains the number of branches
explored in the search tree.ConstraintmakeCircuit(IntVar[] nexts)Force the "nexts" variable to create a complete Hamiltonian path.DemonmakeClosureDemon(java.lang.Runnable closure)Creates a demon from a closure.IntExprmakeConditionalExpression(IntVar condition, IntExpr expr, long unperformed_value)Conditional Expr condition ? expr : unperformed_valueSearchMonitormakeConstantRestart(int frequency)This search monitor will restart the search periodically after 'frequency'
failures.DecisionBuildermakeConstraintAdder(Constraint ct)Returns a decision builder that will add the given constraint to
the model.DemonmakeConstraintInitialPropagateCallback(Constraint ct)This method is a specialized case of the MakeConstraintDemon
method to call the InitiatePropagate of the constraint 'ct'.IntExprmakeConvexPiecewiseExpr(IntExpr expr, long early_cost, long early_date, long late_date, long late_cost)Convex piecewise function.ConstraintmakeCount(IntVar[] vars, long value, long max_count)|{i | vars[i] == value}| == max_countConstraintmakeCount(IntVar[] vars, long value, IntVar max_count)|{i | vars[i] == value}| == max_countConstraintmakeCover(IntervalVar[] vars, IntervalVar target_var)This constraint states that the target_var is the convex hull of
the intervals.ConstraintmakeCumulative(IntervalVar[] intervals, int[] demands, long capacity, java.lang.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.ConstraintmakeCumulative(IntervalVar[] intervals, int[] demands, IntVar capacity, java.lang.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.ConstraintmakeCumulative(IntervalVar[] intervals, long[] demands, long capacity, java.lang.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.ConstraintmakeCumulative(IntervalVar[] intervals, long[] demands, IntVar capacity, java.lang.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.ConstraintmakeCumulative(IntervalVar[] intervals, IntVar[] demands, long capacity, java.lang.String name)This constraint enforces that, for any integer t, the sum of demands
corresponding to an interval containing t does not exceed the given
capacity.
Intervals and demands should be vectors of equal size.
Demands should be positive.ConstraintmakeCumulative(IntervalVar[] intervals, IntVar[] demands, IntVar capacity, java.lang.String name)This constraint enforces that, for any integer t, the sum of demands
corresponding to an interval containing t does not exceed the given
capacity.
Intervals and demands should be vectors of equal size.
Demands should be positive.SearchLimitmakeCustomLimit(java.util.function.BooleanSupplier limiter)Callback-based search limit.DecisionmakeDecision(java.util.function.Consumer<Solver> apply, java.util.function.Consumer<Solver> refute)DecisionBuildermakeDecisionBuilderFromAssignment(Assignment assignment, DecisionBuilder db, IntVar[] vars)Returns a decision builder for which the left-most leaf corresponds
to assignment, the rest of the tree being explored using 'db'.DecisionBuildermakeDefaultPhase(IntVar[] vars)DecisionBuildermakeDefaultPhase(IntVar[] vars, DefaultPhaseParameters parameters)RegularLimitParametersmakeDefaultRegularLimitParameters()Creates a regular limit proto containing default values.SolutionPoolmakeDefaultSolutionPool()Solution Pool.DemonmakeDelayedConstraintInitialPropagateCallback(Constraint ct)This method is a specialized case of the MakeConstraintDemon
method to call the InitiatePropagate of the constraint 'ct' with
low priority.ConstraintmakeDelayedPathCumul(IntVar[] nexts, IntVar[] active, IntVar[] cumuls, IntVar[] transits)Delayed version of the same constraint: propagation on the nexts variables
is delayed until all constraints have propagated.ConstraintmakeDeviation(IntVar[] vars, IntVar deviation_var, long total_sum)Deviation constraint:
sum_i |n * vars[i] - total_sum| <= deviation_var and
sum_i vars[i] == total_sum
n = #varsIntExprmakeDifference(long value, IntExpr expr)value - exprIntExprmakeDifference(IntExpr left, IntExpr right)left - rightDisjunctiveConstraintmakeDisjunctiveConstraint(IntervalVar[] intervals, java.lang.String name)This constraint forces all interval vars into an non-overlapping
sequence.ConstraintmakeDistribute(IntVar[] vars, int[] card_min, int[] card_max)Aggregated version of count with bounded cardinalities:
forall j in 0 ..ConstraintmakeDistribute(IntVar[] vars, int[] values, int[] card_min, int[] card_max)Aggregated version of count with bounded cardinalities:
forall j in 0 ..ConstraintmakeDistribute(IntVar[] vars, int[] values, IntVar[] cards)Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]ConstraintmakeDistribute(IntVar[] vars, long[] card_min, long[] card_max)Aggregated version of count with bounded cardinalities:
forall j in 0 ..ConstraintmakeDistribute(IntVar[] vars, long[] values, long[] card_min, long[] card_max)Aggregated version of count with bounded cardinalities:
forall j in 0 ..ConstraintmakeDistribute(IntVar[] vars, long[] values, IntVar[] cards)Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]ConstraintmakeDistribute(IntVar[] vars, long card_min, long card_max, long card_size)Aggregated version of count with bounded cardinalities:
forall j in 0 ..ConstraintmakeDistribute(IntVar[] vars, IntVar[] cards)Aggregated version of count: |{i | v[i] == j}| == cards[j]IntExprmakeDiv(IntExpr expr, long value)expr / value (integer division)IntExprmakeDiv(IntExpr numerator, IntExpr denominator)numerator / denominator (integer division).IntExprmakeElement(int[] values, IntVar index)values[index]IntExprmakeElement(long[] values, IntVar index)values[index]IntExprmakeElement(IntVar[] vars, IntVar index)vars[expr]IntExprmakeElement(java.util.function.LongBinaryOperator values, IntVar index1, IntVar index2)2D version of function-based element expression, values(expr1, expr2).IntExprmakeElement(java.util.function.LongUnaryOperator values, IntVar index)Function-based element.ConstraintmakeElementEquality(int[] vals, IntVar index, IntVar target)ConstraintmakeElementEquality(long[] vals, IntVar index, IntVar target)ConstraintmakeElementEquality(IntVar[] vars, IntVar index, long target)ConstraintmakeElementEquality(IntVar[] vars, IntVar index, IntVar target)SearchMonitormakeEnterSearchCallback(java.lang.Runnable callback)----- Callback-based search monitors -----ConstraintmakeEquality(IntervalVar var1, IntervalVar var2)This constraints states that the two interval variables are equal.ConstraintmakeEquality(IntExpr expr, int value)expr == valueConstraintmakeEquality(IntExpr expr, long value)expr == valueConstraintmakeEquality(IntExpr left, IntExpr right)left == rightSearchMonitormakeExitSearchCallback(java.lang.Runnable callback)DecisionmakeFailDecision()RegularLimitmakeFailuresLimit(long failures)Creates a search limit that constrains the number of failures
that can happen when exploring the search tree.ConstraintmakeFalseConstraint()This constraint always fails.ConstraintmakeFalseConstraint(java.lang.String explanation)SolutionCollectormakeFirstSolutionCollector()Collect the first solution of the search.SolutionCollectormakeFirstSolutionCollector(Assignment assignment)Collect the first solution of the search.IntervalVarmakeFixedDurationEndSyncedOnEndIntervalVar(IntervalVar interval_var, long duration, long offset)Creates an interval var with a fixed duration whose end is
synchronized with the end of another interval, with a given
offset.IntervalVarmakeFixedDurationEndSyncedOnStartIntervalVar(IntervalVar interval_var, long duration, long offset)Creates an interval var with a fixed duration whose end is
synchronized with the start of another interval, with a given
offset.IntervalVarmakeFixedDurationIntervalVar(long start_min, long start_max, long duration, boolean optional, java.lang.String name)Creates an interval var with a fixed duration.IntervalVarmakeFixedDurationIntervalVar(IntVar start_variable, long duration, IntVar performed_variable, java.lang.String name)Creates an interval var with a fixed duration, and performed_variable.
The duration must be greater than 0.IntervalVarmakeFixedDurationIntervalVar(IntVar start_variable, long duration, java.lang.String name)Creates a performed interval var with a fixed duration.IntervalVar[]makeFixedDurationIntervalVarArray(int count, long start_min, long start_max, long duration, boolean optional)IntervalVar[]makeFixedDurationIntervalVarArray(int count, long start_min, long start_max, long duration, boolean optional, java.lang.String name)IntervalVarmakeFixedDurationStartSyncedOnEndIntervalVar(IntervalVar interval_var, long duration, long offset)Creates an interval var with a fixed duration whose start is
synchronized with the end of another interval, with a given
offset.IntervalVarmakeFixedDurationStartSyncedOnStartIntervalVar(IntervalVar interval_var, long duration, long offset)Creates an interval var with a fixed duration whose start is
synchronized with the start of another interval, with a given
offset.IntervalVarmakeFixedInterval(long start, long duration, java.lang.String name)Creates a fixed and performed interval.ObjectiveMonitormakeGenericTabuSearch(boolean maximize, IntVar v, long step, IntVar[] tabu_vars, long forbid_tenure)Creates a Tabu Search based on the vars |vars|.
A solution is "tabu" if all the vars in |vars| keep their value.ConstraintmakeGreater(IntExpr expr, int value)expr > valueConstraintmakeGreater(IntExpr expr, long value)expr > valueConstraintmakeGreater(IntExpr left, IntExpr right)left > rightConstraintmakeGreaterOrEqual(IntExpr expr, int value)expr >= valueConstraintmakeGreaterOrEqual(IntExpr expr, long value)expr >= valueConstraintmakeGreaterOrEqual(IntExpr left, IntExpr right)left >= rightObjectiveMonitormakeGuidedLocalSearch(boolean maximize, IntVar objective, LongTernaryOperator objective_function, long step, IntVar[] vars, IntVar[] secondary_vars, double penalty_factor)ObjectiveMonitormakeGuidedLocalSearch(boolean maximize, IntVar objective, LongTernaryOperator objective_function, long step, IntVar[] vars, IntVar[] secondary_vars, double penalty_factor, boolean reset_penalties_on_new_best_solution)ObjectiveMonitormakeGuidedLocalSearch(boolean maximize, IntVar objective, java.util.function.LongBinaryOperator objective_function, long step, IntVar[] vars, double penalty_factor)Creates a Guided Local Search monitor.
Description here: http://en.wikipedia.org/wiki/Guided_Local_SearchObjectiveMonitormakeGuidedLocalSearch(boolean maximize, IntVar objective, java.util.function.LongBinaryOperator objective_function, long step, IntVar[] vars, double penalty_factor, boolean reset_penalties_on_new_best_solution)Creates a Guided Local Search monitor.
Description here: http://en.wikipedia.org/wiki/Guided_Local_SearchConstraintmakeIfThenElseCt(IntVar condition, IntExpr then_expr, IntExpr else_expr, IntVar target_var)Special cases with arrays of size two.ImprovementSearchLimitMakeImprovementLimit(IntVar objective_var, boolean maximize, double objective_scaling_factor, double objective_offset, double improvement_rate_coefficient, int improvement_rate_solutions_distance)Limits the search based on the improvements of 'objective_var'.IntExprmakeIndexExpression(IntVar[] vars, long value)Returns the expression expr such that vars[expr] == value.
It assumes that vars are all different.ConstraintmakeIndexOfConstraint(IntVar[] vars, IntVar index, long target)This constraint is a special case of the element constraint with
an array of integer variables, where the variables are all
different and the index variable is constrained such that
vars[index] == target.ConstraintmakeIndexOfFirstMaxValueConstraint(IntVar index, IntVar[] vars)Creates a constraint that binds the index variable to the index of the
first variable with the maximum value.ConstraintmakeIndexOfFirstMinValueConstraint(IntVar index, IntVar[] vars)Creates a constraint that binds the index variable to the index of the
first variable with the minimum value.IntVarmakeIntConst(long val)IntConst will create a constant expression.IntVarmakeIntConst(long val, java.lang.String name)IntConst will create a constant expression.IntervalVarmakeIntervalRelaxedMax(IntervalVar interval_var)Creates and returns an interval variable that wraps around the given one,
relaxing the max start and end.IntervalVarmakeIntervalRelaxedMin(IntervalVar interval_var)Creates and returns an interval variable that wraps around the given one,
relaxing the min start and end.IntervalVarmakeIntervalVar(long start_min, long start_max, long duration_min, long duration_max, long end_min, long end_max, boolean optional, java.lang.String name)Creates an interval var by specifying the bounds on start,
duration, and end.ConstraintmakeIntervalVarRelation(IntervalVar t, int r, long d)This method creates a relation between an interval var and a
date.ConstraintmakeIntervalVarRelation(IntervalVar t1, int r, IntervalVar t2)This method creates a relation between two interval vars.ConstraintmakeIntervalVarRelationWithDelay(IntervalVar t1, int r, IntervalVar t2, long delay)This method creates a relation between two interval vars.
The given delay is added to the second interval.
i.e.: t1 STARTS_AFTER_END of t2 with a delay of 2
means t1 will start at least two units of time after the end of t2.IntVarmakeIntVar(int[] values)MakeIntVar will create a variable with the given sparse domain.IntVarmakeIntVar(int[] values, java.lang.String name)MakeIntVar will create a variable with the given sparse domain.IntVarmakeIntVar(long[] values)MakeIntVar will create a variable with the given sparse domain.IntVarmakeIntVar(long[] values, java.lang.String name)MakeIntVar will create a variable with the given sparse domain.IntVarmakeIntVar(long min, long max)MakeIntVar will create the best range based int var for the bounds given.IntVarmakeIntVar(long min, long max, java.lang.String name)MakeIntVar will create the best range based int var for the bounds given.IntVar[]makeIntVarArray(int count, long min, long max)IntVar[]makeIntVarArray(int count, long min, long max, java.lang.String name)ConstraintmakeInversePermutationConstraint(IntVar[] left, IntVar[] right)Creates a constraint that enforces that 'left' and 'right' both
represent permutations of [0..left.size()-1], and that 'right' is
the inverse permutation of 'left', i.e.ConstraintmakeIsBetweenCt(IntExpr expr, long l, long u, IntVar b)b == (l <= expr <= u)IntVarmakeIsBetweenVar(IntExpr v, long l, long u)ConstraintmakeIsDifferentCstCt(IntExpr var, long value, IntVar boolvar)boolvar == (var != value)ConstraintmakeIsDifferentCstCt(IntExpr v1, IntExpr v2, IntVar b)b == (v1 != v2)IntVarmakeIsDifferentCstVar(IntExpr var, long value)status var of (var != value)IntVarmakeIsDifferentCstVar(IntExpr v1, IntExpr v2)status var of (v1 != v2)ConstraintmakeIsEqualCstCt(IntExpr var, long value, IntVar boolvar)boolvar == (var == value)IntVarmakeIsEqualCstVar(IntExpr var, long value)status var of (var == value)IntVarmakeIsEqualVar(IntExpr v1, IntExpr v2)status var of (v1 == v2)ConstraintmakeIsEqualVar(IntExpr v1, IntExpr v2, IntVar b)b == (v1 == v2)ConstraintmakeIsGreaterCstCt(IntExpr v, long c, IntVar b)b == (v > c)IntVarmakeIsGreaterCstVar(IntExpr var, long value)status var of (var > value)ConstraintmakeIsGreaterCt(IntExpr left, IntExpr right, IntVar b)b == (left > right)ConstraintmakeIsGreaterOrEqualCstCt(IntExpr var, long value, IntVar boolvar)boolvar == (var >= value)IntVarmakeIsGreaterOrEqualCstVar(IntExpr var, long value)status var of (var >= value)ConstraintmakeIsGreaterOrEqualCt(IntExpr left, IntExpr right, IntVar b)b == (left >= right)IntVarmakeIsGreaterOrEqualVar(IntExpr left, IntExpr right)status var of (left >= right)IntVarmakeIsGreaterVar(IntExpr left, IntExpr right)status var of (left > right)ConstraintmakeIsLessCstCt(IntExpr v, long c, IntVar b)b == (v < c)IntVarmakeIsLessCstVar(IntExpr var, long value)status var of (var < value)ConstraintmakeIsLessCt(IntExpr left, IntExpr right, IntVar b)b == (left < right)ConstraintmakeIsLessOrEqualCstCt(IntExpr var, long value, IntVar boolvar)boolvar == (var <= value)IntVarmakeIsLessOrEqualCstVar(IntExpr var, long value)status var of (var <= value)ConstraintmakeIsLessOrEqualCt(IntExpr left, IntExpr right, IntVar b)b == (left <= right)IntVarmakeIsLessOrEqualVar(IntExpr left, IntExpr right)status var of (left <= right)IntVarmakeIsLessVar(IntExpr left, IntExpr right)status var of (left < right)ConstraintMakeIsLexicalLessOrEqualWithOffsetsCt(IntVar[] left, IntVar[] right, long[] offsets, IntVar boolvar)ConstraintmakeIsMemberCt(IntExpr expr, int[] values, IntVar boolvar)ConstraintmakeIsMemberCt(IntExpr expr, long[] values, IntVar boolvar)boolvar == (expr in set)IntVarmakeIsMemberVar(IntExpr expr, int[] values)IntVarmakeIsMemberVar(IntExpr expr, long[] values)SolutionCollectormakeLastSolutionCollector()Collect the last solution of the search.SolutionCollectormakeLastSolutionCollector(Assignment assignment)Collect the last solution of the search.ConstraintmakeLess(IntExpr expr, int value)expr < valueConstraintmakeLess(IntExpr expr, long value)expr < valueConstraintmakeLess(IntExpr left, IntExpr right)left < rightConstraintmakeLessOrEqual(IntExpr expr, int value)expr <= valueConstraintmakeLessOrEqual(IntExpr expr, long value)expr <= valueConstraintmakeLessOrEqual(IntExpr left, IntExpr right)left <= rightConstraintmakeLexicalLess(IntVar[] left, IntVar[] right)Creates a constraint that enforces that left is lexicographically less
than right.ConstraintmakeLexicalLessOrEqual(IntVar[] left, IntVar[] right)Creates a constraint that enforces that left is lexicographically less
than or equal to right.ConstraintMakeLexicalLessOrEqualWithOffsets(IntVar[] left, IntVar[] right, long[] offsets)Creates a constraint that enforces that left is lexicographically less
than or equal to right with an offset.ImprovementSearchLimitMakeLexicographicImprovementLimit(IntVar[] objective_vars, SWIGTYPE_p_std__vectorT_bool_t maximize, double[] objective_scaling_factors, double[] objective_offsets, double improvement_rate_coefficient, int improvement_rate_solutions_distance)Same as MakeImprovementLimit on a lexicographic objective based on
'objective_vars' and related arguments.OptimizeVarMakeLexicographicOptimize(SWIGTYPE_p_std__vectorT_bool_t maximize, IntVar[] variables, long[] steps)Creates a lexicographic objective, following the order of the variables
given.ObjectiveMonitorMakeLexicographicSimulatedAnnealing(SWIGTYPE_p_std__vectorT_bool_t maximize, IntVar[] vars, long[] steps, long[] initial_temperatures)ObjectiveMonitorMakeLexicographicTabuSearch(SWIGTYPE_p_std__vectorT_bool_t maximize, IntVar[] objectives, long[] steps, IntVar[] vars, long keep_tenure, long forbid_tenure, double tabu_factor)RegularLimitmakeLimit(long time, long branches, long failures, long solutions)RegularLimitmakeLimit(long time, long branches, long failures, long solutions, boolean smart_time_check)RegularLimitmakeLimit(long time, long branches, long failures, long solutions, boolean smart_time_check, boolean cumulative)RegularLimitmakeLimit(RegularLimitParameters proto)Creates a search limit from its protobuf descriptionSearchLimitmakeLimit(SearchLimit limit_1, SearchLimit limit_2)Creates a search limit that is reached when either of the underlying limit
is reached.RegularLimitmakeLimit(SWIGTYPE_p_absl__Duration time, long branches, long failures, long solutions)Limits the search with the 'time', 'branches', 'failures' and
'solutions' limits.RegularLimitmakeLimit(SWIGTYPE_p_absl__Duration time, long branches, long failures, long solutions, boolean smart_time_check)Limits the search with the 'time', 'branches', 'failures' and
'solutions' limits.RegularLimitmakeLimit(SWIGTYPE_p_absl__Duration time, long branches, long failures, long solutions, boolean smart_time_check, boolean cumulative)Limits the search with the 'time', 'branches', 'failures' and
'solutions' limits.DecisionBuildermakeLocalSearchPhase(Assignment assignment, LocalSearchPhaseParameters parameters)Local Search decision builders factories.
Local search is used to improve a given solution.DecisionBuildermakeLocalSearchPhase(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(IntVar[] vars, DecisionBuilder first_solution, LocalSearchPhaseParameters parameters)DecisionBuildermakeLocalSearchPhase(SequenceVar[] vars, DecisionBuilder first_solution, LocalSearchPhaseParameters parameters)LocalSearchPhaseParametersmakeLocalSearchPhaseParameters(IntVar objective, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder)Local Search Phase ParametersLocalSearchPhaseParametersmakeLocalSearchPhaseParameters(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)SearchMonitormakeLubyRestart(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.ConstraintmakeMapDomain(IntVar var, IntVar[] actives)This constraint maps the domain of 'var' onto the array of
variables 'actives'.IntExprmakeMax(IntExpr expr, int value)std::max(expr, value)IntExprmakeMax(IntExpr expr, long value)std::max(expr, value)IntExprmakeMax(IntExpr left, IntExpr right)std::max(left, right)IntExprmakeMax(IntVar[] vars)std::max(vars)ConstraintmakeMaxEquality(IntVar[] vars, IntVar max_var)OptimizeVarmakeMaximize(IntVar v, long step)Creates a maximization objective.ConstraintmakeMemberCt(IntExpr expr, int[] values)ConstraintmakeMemberCt(IntExpr expr, long[] values)expr in set.IntExprmakeMin(IntExpr expr, int value)std::min(expr, value)IntExprmakeMin(IntExpr expr, long value)std::min(expr, value)IntExprmakeMin(IntExpr left, IntExpr right)std::min (left, right)IntExprmakeMin(IntVar[] vars)std::min(vars)ConstraintmakeMinEquality(IntVar[] vars, IntVar min_var)OptimizeVarmakeMinimize(IntVar v, long step)Creates a minimization objective.IntervalVarmakeMirrorInterval(IntervalVar interval_var)Creates an interval var that is the mirror image of the given one, that
is, the interval var obtained by reversing the axis.IntExprmakeModulo(IntExpr x, long mod)General piecewise-linear function expression, built from f(x) where f is
piecewise-linear.IntExprmakeModulo(IntExpr x, IntExpr mod)Modulo expression x % mod (with the python convention for modulo).IntExprmakeMonotonicElement(java.util.function.LongUnaryOperator values, boolean increasing, IntVar index)Function based element.LocalSearchOperatormakeMoveTowardTargetOperator(Assignment target)Creates a local search operator that tries to move the assignment of some
variables toward a target.LocalSearchOperatormakeMoveTowardTargetOperator(IntVar[] variables, long[] target_values)Creates a local search operator that tries to move the assignment of some
variables toward a target.SolutionCollectorMakeNBestLexicographicValueSolutionCollector(int solution_count, SWIGTYPE_p_std__vectorT_bool_t maximize)SolutionCollectorMakeNBestLexicographicValueSolutionCollector(Assignment assignment, int solution_count, SWIGTYPE_p_std__vectorT_bool_t maximize)Same as above but supporting lexicographic objectives; 'maximize'
specifies the optimization direction for each objective.SolutionCollectormakeNBestValueSolutionCollector(int solution_count, boolean maximize)SolutionCollectormakeNBestValueSolutionCollector(Assignment assignment, int solution_count, boolean maximize)Same as MakeBestValueSolutionCollector but collects the best
solution_count solutions.LocalSearchOperatormakeNeighborhoodLimit(LocalSearchOperator op, long limit)Creates a local search operator that wraps another local search
operator and limits the number of neighbors explored (i.e., calls
to MakeNextNeighbor from the current solution (between two calls
to Start()).DecisionBuildermakeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step)NestedOptimize will collapse a search tree described by a
decision builder 'db' and a set of monitors and wrap it into a
single point.DecisionBuildermakeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor monitor1)DecisionBuildermakeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor[] monitors)DecisionBuildermakeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor monitor1, SearchMonitor monitor2)DecisionBuildermakeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor monitor1, SearchMonitor monitor2, SearchMonitor monitor3)DecisionBuildermakeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor monitor1, SearchMonitor monitor2, SearchMonitor monitor3, SearchMonitor monitor4)ConstraintmakeNoCycle(IntVar[] nexts, IntVar[] active)Prevent cycles.ConstraintmakeNoCycle(IntVar[] nexts, IntVar[] active, java.util.function.LongPredicate sink_handler)Prevent cycles.ConstraintmakeNoCycle(IntVar[] nexts, IntVar[] active, java.util.function.LongPredicate sink_handler, boolean assume_paths)ConstraintmakeNonEquality(IntExpr expr, int value)expr != valueConstraintmakeNonEquality(IntExpr expr, long value)expr != valueConstraintmakeNonEquality(IntExpr left, IntExpr right)left != rightConstraintmakeNonOverlappingBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, IntVar[] x_size, IntVar[] y_size)This constraint states that all the boxes must not overlap.
The coordinates of box i are:
(x_vars[i], y_vars[i]),
(x_vars[i], y_vars[i] + y_size[i]),
(x_vars[i] + x_size[i], y_vars[i]),
(x_vars[i] + x_size[i], y_vars[i] + y_size[i]).
The sizes must be non-negative.ConstraintmakeNonOverlappingBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, SWIGTYPE_p_absl__SpanT_int_const_t x_size, SWIGTYPE_p_absl__SpanT_int_const_t y_size)ConstraintmakeNonOverlappingBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, SWIGTYPE_p_absl__SpanT_int64_t_const_t x_size, SWIGTYPE_p_absl__SpanT_int64_t_const_t y_size)ConstraintmakeNonOverlappingNonStrictBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, IntVar[] x_size, IntVar[] y_size)This constraint states that all the boxes must not overlap.
The coordinates of box i are:
(x_vars[i], y_vars[i]),
(x_vars[i], y_vars[i] + y_size[i]),
(x_vars[i] + x_size[i], y_vars[i]),
(x_vars[i] + x_size[i], y_vars[i] + y_size[i]).
The sizes must be positive.
Boxes with a zero dimension can be placed anywhere.ConstraintmakeNonOverlappingNonStrictBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, SWIGTYPE_p_absl__SpanT_int_const_t x_size, SWIGTYPE_p_absl__SpanT_int_const_t y_size)ConstraintmakeNonOverlappingNonStrictBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, SWIGTYPE_p_absl__SpanT_int64_t_const_t x_size, SWIGTYPE_p_absl__SpanT_int64_t_const_t y_size)ConstraintmakeNotBetweenCt(IntExpr expr, long l, long u)(expr < l || expr > u)
This constraint is lazy as it will not make holes in the domain of
variables.ConstraintmakeNotMemberCt(IntExpr expr, int[] values)ConstraintmakeNotMemberCt(IntExpr expr, int[] starts, int[] ends)expr should not be in the list of forbidden intervals [start[i]..end[i]].ConstraintmakeNotMemberCt(IntExpr expr, long[] values)expr not in set.ConstraintmakeNotMemberCt(IntExpr expr, long[] starts, long[] ends)expr should not be in the list of forbidden intervals [start[i]..end[i]].ConstraintmakeNullIntersect(IntVar[] first_vars, IntVar[] second_vars)Creates a constraint that states that all variables in the first
vector are different from all variables in the second
group.ConstraintmakeNullIntersectExcept(IntVar[] first_vars, IntVar[] second_vars, long escape_value)Creates a constraint that states that all variables in the first
vector are different from all variables from the second group,
unless they are assigned to the escape value.LocalSearchOperatormakeOperator(IntVar[] vars, int op)Local Search Operators.LocalSearchOperatormakeOperator(IntVar[] vars, int op, SWIGTYPE_p_std__functionT_std__vectorT_int_t_const_Rfint_intF_t get_neighbors)Local Search Operators.LocalSearchOperatormakeOperator(IntVar[] vars, IntVar[] secondary_vars, int op)LocalSearchOperatormakeOperator(IntVar[] vars, IntVar[] secondary_vars, int op, SWIGTYPE_p_std__functionT_std__vectorT_int_t_const_Rfint_intF_t get_neighbors)LocalSearchOperatormakeOperator(IntVar[] vars, IntVar[] secondary_vars, LongTernaryOperator evaluator, int op)LocalSearchOperatormakeOperator(IntVar[] vars, LongTernaryOperator evaluator, int op)IntExprmakeOpposite(IntExpr expr)-exprOptimizeVarmakeOptimize(boolean maximize, IntVar v, long step)Creates a objective with a given sense (true = maximization).PackmakePack(IntVar[] vars, int number_of_bins)This constraint packs all variables onto 'number_of_bins'
variables.ConstraintmakePathConnected(IntVar[] nexts, long[] sources, long[] sinks, IntVar[] status)Constraint enforcing that status[i] is true iff there's a path defined on
next variables from sources[i] to sinks[i].
Check whether more propagation is needed.ConstraintmakePathCumul(IntVar[] nexts, IntVar[] active, IntVar[] cumuls, IntVar[] transits)Creates a constraint which accumulates values along a path such that:
cumuls[next[i]] = cumuls[i] + transits[i].
Active variables indicate if the corresponding next variable is active;
this could be useful to model unperformed nodes in a routing problem.ConstraintmakePathCumul(IntVar[] nexts, IntVar[] active, IntVar[] cumuls, IntVar[] slacks, java.util.function.LongBinaryOperator transit_evaluator)Creates a constraint which accumulates values along a path such that:
cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i].
Active variables indicate if the corresponding next variable is active;
this could be useful to model unperformed nodes in a routing problem.
Ownership of transit_evaluator is taken and it must be a repeatable
callback.ConstraintmakePathCumul(IntVar[] nexts, IntVar[] active, IntVar[] cumuls, java.util.function.LongBinaryOperator transit_evaluator)Creates a constraint which accumulates values along a path such that:
cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]).
Active variables indicate if the corresponding next variable is active;
this could be useful to model unperformed nodes in a routing problem.
Ownership of transit_evaluator is taken and it must be a repeatable
callback.DecisionBuildermakePhase(IntervalVar[] intervals, int str)Scheduling phases.DecisionBuildermakePhase(IntVar[] vars, int var_str, int val_str)Phases on IntVar arrays.
for all other functions that have several homonyms in this .h).DecisionBuildermakePhase(IntVar[] vars, int var_str, LongTernaryPredicate var_val1_val2_comparator)var_val1_val2_comparator(var, val1, val2) is true iff assigning value
"val1" to variable "var" is better than assigning value "val2".DecisionBuildermakePhase(IntVar[] vars, int var_str, java.util.function.LongBinaryOperator value_evaluator)DecisionBuildermakePhase(IntVar[] vars, int var_str, java.util.function.LongBinaryOperator value_evaluator, java.util.function.LongUnaryOperator tie_breaker)DecisionBuildermakePhase(IntVar[] vars, java.util.function.LongBinaryOperator eval, int str)Returns a decision builder which assigns values to variables which
minimize the values returned by the evaluator.DecisionBuildermakePhase(IntVar[] vars, java.util.function.LongBinaryOperator eval, java.util.function.LongUnaryOperator tie_breaker, int str)Returns a decision builder which assigns values to variables
which minimize the values returned by the evaluator.DecisionBuildermakePhase(IntVar[] vars, java.util.function.LongUnaryOperator var_evaluator, int val_str)DecisionBuildermakePhase(IntVar[] vars, java.util.function.LongUnaryOperator var_evaluator, java.util.function.LongBinaryOperator value_evaluator)DecisionBuildermakePhase(IntVar[] vars, java.util.function.LongUnaryOperator var_evaluator, java.util.function.LongBinaryOperator value_evaluator, java.util.function.LongUnaryOperator tie_breaker)DecisionBuildermakePhase(IntVar v0, int var_str, int val_str)Shortcuts for small arrays.DecisionBuildermakePhase(IntVar v0, IntVar v1, int var_str, int val_str)DecisionBuildermakePhase(IntVar v0, IntVar v1, IntVar v2, int var_str, int val_str)DecisionBuildermakePhase(IntVar v0, IntVar v1, IntVar v2, IntVar v3, int var_str, int val_str)DecisionBuildermakePhase(SequenceVar[] sequences, int str)IntExprmakePower(IntExpr expr, long n)expr ^ n (n > 0)ModelVisitormakePrintModelVisitor()Prints the model.IntExprmakeProd(IntExpr expr, long value)expr * valueIntExprmakeProd(IntExpr left, IntExpr right)left * rightDecisionBuilderMakeProfiledDecisionBuilderWrapper(DecisionBuilder db)Activates profiling on a decision builder.LocalSearchOperatormakeRandomLnsOperator(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).LocalSearchOperatormakeRandomLnsOperator(IntVar[] vars, int number_of_variables, int seed)DecisionmakeRankFirstInterval(SequenceVar sequence, int index)Returns a decision that tries to rank first the ith interval var
in the sequence variable.DecisionmakeRankLastInterval(SequenceVar sequence, int index)Returns a decision that tries to rank last the ith interval var
in the sequence variable.LocalSearchFilterMakeRejectFilter()DecisionBuildermakeRestoreAssignment(Assignment assignment)Returns a DecisionBuilder which restores an Assignment
(calls void Assignment::Restore())IntExprmakeScalProd(IntVar[] vars, int[] coefs)scalar productIntExprmakeScalProd(IntVar[] vars, long[] coefs)scalar productConstraintmakeScalProdEquality(IntVar[] vars, int[] coefficients, long cst)ConstraintmakeScalProdEquality(IntVar[] vars, int[] coefficients, IntVar target)ConstraintmakeScalProdEquality(IntVar[] vars, long[] coefficients, long cst)ConstraintmakeScalProdEquality(IntVar[] vars, long[] coefficients, IntVar target)ConstraintmakeScalProdGreaterOrEqual(IntVar[] vars, int[] coeffs, long cst)ConstraintmakeScalProdGreaterOrEqual(IntVar[] vars, long[] coeffs, long cst)ConstraintmakeScalProdLessOrEqual(IntVar[] vars, int[] coefficients, long cst)ConstraintmakeScalProdLessOrEqual(IntVar[] vars, long[] coefficients, long cst)DecisionmakeScheduleOrExpedite(IntervalVar var, long est, SWIGTYPE_p_long_long marker)Returns a decision that tries to schedule a task at a given time.
On the Apply branch, it will set that interval var as performed and set
its end to 'est'.DecisionmakeScheduleOrPostpone(IntervalVar var, long est, SWIGTYPE_p_long_long marker)Returns a decision that tries to schedule a task at a given time.
On the Apply branch, it will set that interval var as performed and set
its start to 'est'.SearchMonitormakeSearchLog(int branch_period)The SearchMonitors below will display a periodic search log
on LOG(INFO) every branch_period branches explored.SearchMonitormakeSearchLog(int branch_period, IntVar var)At each solution, this monitor also display the var value.SearchMonitormakeSearchLog(int branch_period, IntVar[] vars, java.util.function.Supplier<java.lang.String> display_callback)At each solution, this monitor will display the 'vars' values and the
result ofdisplay_callback.SearchMonitormakeSearchLog(int branch_period, IntVar var, java.util.function.Supplier<java.lang.String> display_callback)At each solution, this monitor will display the 'var' value and the
result ofdisplay_callback.SearchMonitormakeSearchLog(int branch_period, OptimizeVar opt_var)OptimizeVar Search Logs
At each solution, this monitor will also display the 'opt_var' value.SearchMonitormakeSearchLog(int branch_period, OptimizeVar opt_var, java.util.function.Supplier<java.lang.String> display_callback)Creates a search monitor that will also print the result of the
display callback.SearchMonitormakeSearchLog(int branch_period, java.util.function.Supplier<java.lang.String> display_callback)At each solution, this monitor will also display result of
display_callback.SearchMonitormakeSearchTrace(java.lang.String prefix)Creates a search monitor that will trace precisely the behavior of the
search.IntExprmakeSemiContinuousExpr(IntExpr expr, long fixed_charge, long step)Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b)
a >= 0 and b >= 0ObjectiveMonitormakeSimulatedAnnealing(boolean maximize, IntVar v, long step, long initial_temperature)Creates a Simulated Annealing monitor.RegularLimitmakeSolutionsLimit(long solutions)Creates a search limit that constrains the number of solutions found
during the search.DecisionBuildermakeSolveOnce(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.DecisionBuildermakeSolveOnce(DecisionBuilder db, SearchMonitor monitor1)DecisionBuildermakeSolveOnce(DecisionBuilder db, SearchMonitor[] monitors)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)ConstraintmakeSortingConstraint(IntVar[] vars, IntVar[] sorted)Creates a constraint binding the arrays of variables "vars" and
"sorted_vars": sorted_vars[0] must be equal to the minimum of all
variables in vars, and so on: the value of sorted_vars[i] must be
equal to the i-th value of variables invars.
This constraint propagates in both directions: from "vars" to
"sorted_vars" and vice-versa.
Behind the scenes, this constraint maintains that:
- sorted is always increasing.
- whatever the values of vars, there exists a permutation that
injects its values into the sorted variables.
For more info, please have a look at:
https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdfDecisionmakeSplitVariableDomain(IntVar var, long val, boolean start_with_lower_half)IntExprmakeSquare(IntExpr expr)expr * exprModelVisitormakeStatisticsModelVisitor()Displays some nice statistics on the model.DecisionBuildermakeStoreAssignment(Assignment assignment)Returns a DecisionBuilder which stores an Assignment
(calls void Assignment::Store())DisjunctiveConstraintmakeStrictDisjunctiveConstraint(IntervalVar[] intervals, java.lang.String name)This constraint forces all interval vars into an non-overlapping
sequence.ConstraintmakeSubCircuit(IntVar[] nexts)Force the "nexts" variable to create a complete Hamiltonian path
for those that do not loop upon themselves.IntExprmakeSum(IntExpr expr, long value)expr + value.IntExprmakeSum(IntExpr left, IntExpr right)left + right.IntExprmakeSum(IntVar[] vars)sum of all vars.ConstraintmakeSumEquality(IntVar[] vars, long cst)ConstraintmakeSumEquality(IntVar[] vars, IntVar var)ConstraintmakeSumGreaterOrEqual(IntVar[] vars, long cst)ConstraintmakeSumLessOrEqual(IntVar[] vars, long cst)Variation on arrays.IntVarLocalSearchFiltermakeSumObjectiveFilter(IntVar[] vars, IntVar[] secondary_vars, LongTernaryOperator values, int filter_enum)IntVarLocalSearchFiltermakeSumObjectiveFilter(IntVar[] vars, java.util.function.LongBinaryOperator values, int filter_enum)SearchMonitormakeSymmetryManager(SymmetryBreaker v1)SearchMonitormakeSymmetryManager(SymmetryBreaker[] visitors)Symmetry Breaking.SearchMonitormakeSymmetryManager(SymmetryBreaker v1, SymmetryBreaker v2)SearchMonitormakeSymmetryManager(SymmetryBreaker v1, SymmetryBreaker v2, SymmetryBreaker v3)SearchMonitormakeSymmetryManager(SymmetryBreaker v1, SymmetryBreaker v2, SymmetryBreaker v3, SymmetryBreaker v4)ObjectiveMonitormakeTabuSearch(boolean maximize, IntVar objective, long step, IntVar[] vars, long keep_tenure, long forbid_tenure, double tabu_factor)MetaHeuristics which try to get the search out of local optima.
Creates a Tabu Search monitor.
In the context of local search the behavior is similar to MakeOptimize(),
creating an objective in a given sense.ConstraintmakeTemporalDisjunction(IntervalVar t1, IntervalVar t2)This constraint implements a temporal disjunction between two
interval vars.ConstraintmakeTemporalDisjunction(IntervalVar t1, IntervalVar t2, IntVar alt)This constraint implements a temporal disjunction between two
interval vars t1 and t2.RegularLimitmakeTimeLimit(long time_in_ms)RegularLimitmakeTimeLimit(SWIGTYPE_p_absl__Duration time)Creates a search limit that constrains the running time.ConstraintmakeTransitionConstraint(IntVar[] vars, IntTupleSet transition_table, long initial_state, int[] final_states)This constraint create a finite automaton that will check the
sequence of variables vars.ConstraintmakeTransitionConstraint(IntVar[] vars, IntTupleSet transition_table, long initial_state, long[] final_states)This constraint create a finite automaton that will check the
sequence of variables vars.ConstraintmakeTrueConstraint()This constraint always succeeds.LocalSearchFiltermakeVariableDomainFilter()DecisionmakeVariableGreaterOrEqualValue(IntVar var, long value)DecisionmakeVariableLessOrEqualValue(IntVar var, long value)OptimizeVarmakeWeightedMaximize(IntVar[] sub_objectives, int[] weights, long step)Creates a maximization weigthed objective.OptimizeVarmakeWeightedMaximize(IntVar[] sub_objectives, long[] weights, long step)Creates a maximization weigthed objective.OptimizeVarmakeWeightedMinimize(IntVar[] sub_objectives, int[] weights, long step)Creates a minimization weighted objective.OptimizeVarmakeWeightedMinimize(IntVar[] sub_objectives, long[] weights, long step)Creates a minimization weighted objective.OptimizeVarmakeWeightedOptimize(boolean maximize, IntVar[] sub_objectives, int[] weights, long step)Creates a weighted objective with a given sense (true = maximization).OptimizeVarmakeWeightedOptimize(boolean maximize, IntVar[] sub_objectives, long[] weights, long step)Creates a weighted objective with a given sense (true = maximization).static longmemoryUsage()Current memory usage in bytesjava.lang.Stringmodel_name()Returns the name of the model.LocalSearchOperatorMultiArmedBanditConcatenateOperators(LocalSearchOperator[] ops, double memory_coefficient, double exploration_coefficient, boolean maximize)Creates a local search operator which concatenates a vector of operators.
Uses Multi-Armed Bandit approach for choosing the next operator to use.
Sorts operators based on Upper Confidence Bound Algorithm which evaluates
each operator as sum of average improvement and exploration function.
Updates the order of operators when accepts a neighbor with objective
improvement.booleannameAllVariables()Returns whether all variables should be named.longneighbors()The number of neighbors created.voidnewSearch(DecisionBuilder db)voidnewSearch(DecisionBuilder db, SearchMonitor m1)voidnewSearch(DecisionBuilder db, SearchMonitor[] monitors)
Decomposed search.
The code for a top level search should look like
solver->NewSearch(db);
while (solver->NextSolution()) {
..voidnewSearch(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2)voidnewSearch(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3)voidnewSearch(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3, SearchMonitor m4)booleannextSolution()intoptimization_direction()The direction of optimization, getter and setter.ConstraintSolverParametersparameters()Stored Parameters.voidpopState()voidpushState()The PushState and PopState methods manipulates the states
of the reversible objects.intrand32(int size)Returns a random value between 0 and 'size' - 1;longrand64(long size)Returns a random value between 0 and 'size' - 1;LocalSearchOperatorrandomConcatenateOperators(LocalSearchOperator[] ops)Randomized version of local search concatenator; calls a random operator
at each call to MakeNextNeighbor().LocalSearchOperatorrandomConcatenateOperators(LocalSearchOperator[] ops, int seed)Randomized version of local search concatenator; calls a random operator
at each call to MakeNextNeighbor().DemonregisterDemon(Demon demon)Adds a new demon and wraps it inside a DemonProfiler if necessary.IntervalVarregisterIntervalVar(IntervalVar var)Registers a new IntervalVar and wraps it inside a TraceIntervalVar
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.voidreSeed(int seed)Reseed the solver random generator.voidrestartCurrentSearch()voidrestartSearch()intsearchDepth()Gets the search depth of the current active search.intsearchLeftDepth()Gets the search left depth of the current active search.voidset_context(SWIGTYPE_p_absl__string_view context)Sets the current context of the search.voidset_optimization_direction(int direction)voidsetTmpVector(long[] value)Unsafe temporary vector.voidSetUseFastLocalSearch(boolean use_fast_local_search)enabled for metaheuristics.
Disables/enables fast local search.voidshouldFail()These methods are only useful for the SWIG wrappers, which need a way
to externally cause the Solver to fail.longsolutions()The number of solutions found since the start of the search.booleansolve(DecisionBuilder db)booleansolve(DecisionBuilder db, SearchMonitor m1)booleansolve(DecisionBuilder db, SearchMonitor[] monitors)
Solves the problem using the given DecisionBuilder and returns true if a
solution was found and accepted.
These methods are the ones most users should use to search for a solution.
Note that the definition of 'solution' is subtle.booleansolve(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2)booleansolve(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3)booleansolve(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3, SearchMonitor m4)booleansolveAndCommit(DecisionBuilder db)booleansolveAndCommit(DecisionBuilder db, SearchMonitor m1)booleansolveAndCommit(DecisionBuilder db, SearchMonitor[] monitors)
SolveAndCommit using a decision builder and up to three
search monitors, usually one for the objective, one for the limits
and one to collect solutions.
The difference between a SolveAndCommit() and a Solve() method
call is the fact that SolveAndCommit will not backtrack all
modifications at the end of the search.booleansolveAndCommit(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2)booleansolveAndCommit(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3)intsolveDepth()Gets the number of nested searches.java.math.BigIntegerstamp()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.intstate()State of the solver.protected static longswigRelease(Solver obj)voidtopPeriodicCheck()Performs PeriodicCheck on the top-level search; for instance, can be
called from a nested solve to check top-level limits.inttopProgressPercent()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).java.lang.StringtoString()misc debug string.DecisionBuildertryDecisions(DecisionBuilder[] dbs)DecisionBuildertryDecisions(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.DecisionBuildertryDecisions(DecisionBuilder db1, DecisionBuilder db2, DecisionBuilder db3)DecisionBuildertryDecisions(DecisionBuilder db1, DecisionBuilder db2, DecisionBuilder db3, DecisionBuilder db4)longunchecked_solutions()The number of unchecked solutions found by local search.booleanUseFastLocalSearch()Returns true if fast local search is enabled.longwallTime()DEPRECATED: Use Now() instead.
Time elapsed, in ms since the creation of the solver.
-
-
-
Field Detail
-
swigCMemOwn
protected transient boolean swigCMemOwn
-
kNumPriorities
public static final int kNumPriorities
Number of priorities for demons.
-
INT_VAR_DEFAULT
public static final int INT_VAR_DEFAULT
The default behavior is CHOOSE_FIRST_UNBOUND.
-
INT_VAR_SIMPLE
public static final int INT_VAR_SIMPLE
The simple selection is CHOOSE_FIRST_UNBOUND.
-
CHOOSE_FIRST_UNBOUND
public static final int CHOOSE_FIRST_UNBOUND
Select the first unbound variable.
Variables are considered in the order of the vector of IntVars used
to create the selector.
-
CHOOSE_RANDOM
public static final int CHOOSE_RANDOM
Randomly select one of the remaining unbound variables.
-
CHOOSE_MIN_SIZE_LOWEST_MIN
public static final int CHOOSE_MIN_SIZE_LOWEST_MIN
Among unbound variables, select the variable with the smallest size,
i.e., the smallest number of possible values.
In case of a tie, the selected variables is the one with the lowest min
value.
In case of a tie, the first one is selected, first being defined by the
order in the vector of IntVars used to create the selector.
-
CHOOSE_MIN_SIZE_HIGHEST_MIN
public static final int CHOOSE_MIN_SIZE_HIGHEST_MIN
Among unbound variables, select the variable with the smallest size,
i.e., the smallest number of possible values.
In case of a tie, the selected variable is the one with the highest min
value.
In case of a tie, the first one is selected, first being defined by the
order in the vector of IntVars used to create the selector.
-
CHOOSE_MIN_SIZE_LOWEST_MAX
public static final int CHOOSE_MIN_SIZE_LOWEST_MAX
Among unbound variables, select the variable with the smallest size,
i.e., the smallest number of possible values.
In case of a tie, the selected variables is the one with the lowest max
value.
In case of a tie, the first one is selected, first being defined by the
order in the vector of IntVars used to create the selector.
-
CHOOSE_MIN_SIZE_HIGHEST_MAX
public static final int CHOOSE_MIN_SIZE_HIGHEST_MAX
Among unbound variables, select the variable with the smallest size,
i.e., the smallest number of possible values.
In case of a tie, the selected variable is the one with the highest max
value.
In case of a tie, the first one is selected, first being defined by the
order in the vector of IntVars used to create the selector.
-
CHOOSE_LOWEST_MIN
public static final int CHOOSE_LOWEST_MIN
Among unbound variables, select the variable with the smallest minimal
value.
In case of a tie, the first one is selected, "first" defined by the
order in the vector of IntVars used to create the selector.
-
CHOOSE_HIGHEST_MAX
public static final int CHOOSE_HIGHEST_MAX
Among unbound variables, select the variable with the highest maximal
value.
In case of a tie, the first one is selected, first being defined by the
order in the vector of IntVars used to create the selector.
-
CHOOSE_MIN_SIZE
public static final int CHOOSE_MIN_SIZE
Among unbound variables, select the variable with the smallest size.
In case of a tie, the first one is selected, first being defined by the
order in the vector of IntVars used to create the selector.
-
CHOOSE_MAX_SIZE
public static final int CHOOSE_MAX_SIZE
Among unbound variables, select the variable with the highest size.
In case of a tie, the first one is selected, first being defined by the
order in the vector of IntVars used to create the selector.
-
CHOOSE_MAX_REGRET_ON_MIN
public static final int CHOOSE_MAX_REGRET_ON_MIN
Among unbound variables, select the variable with the largest
gap between the first and the second values of the domain.
-
CHOOSE_PATH
public static final int CHOOSE_PATH
Selects the next unbound variable on a path, the path being defined by
the variables: var[i] corresponds to the index of the next of i.
-
INT_VALUE_DEFAULT
public static final int INT_VALUE_DEFAULT
The default behavior is ASSIGN_MIN_VALUE.
-
INT_VALUE_SIMPLE
public static final int INT_VALUE_SIMPLE
The simple selection is ASSIGN_MIN_VALUE.
-
ASSIGN_MIN_VALUE
public static final int ASSIGN_MIN_VALUE
Selects the min value of the selected variable.
-
ASSIGN_MAX_VALUE
public static final int ASSIGN_MAX_VALUE
Selects the max value of the selected variable.
-
ASSIGN_RANDOM_VALUE
public static final int ASSIGN_RANDOM_VALUE
Selects randomly one of the possible values of the selected variable.
-
ASSIGN_CENTER_VALUE
public static final int ASSIGN_CENTER_VALUE
Selects the first possible value which is the closest to the center
of the domain of the selected variable.
The center is defined as (min + max) / 2.
-
SPLIT_LOWER_HALF
public static final int SPLIT_LOWER_HALF
Split the domain in two around the center, and choose the lower
part first.
-
SPLIT_UPPER_HALF
public static final int SPLIT_UPPER_HALF
Split the domain in two around the center, and choose the lower
part first.
-
CHOOSE_STATIC_GLOBAL_BEST
public static final int CHOOSE_STATIC_GLOBAL_BEST
Pairs are compared at the first call of the selector, and results are
cached. Next calls to the selector use the previous computation, and so
are not up-to-date, e.g. some <variable, value> pairs may not be
possible anymore due to propagation since the first to call.
-
CHOOSE_DYNAMIC_GLOBAL_BEST
public static final int CHOOSE_DYNAMIC_GLOBAL_BEST
Pairs are compared each time a variable is selected. That way all pairs
are relevant and evaluation is accurate.
This strategy runs in O(number-of-pairs) at each variable selection,
versus O(1) in the static version.
-
SEQUENCE_DEFAULT
public static final int SEQUENCE_DEFAULT
Used for scheduling. Not yet implemented.
-
SEQUENCE_SIMPLE
public static final int SEQUENCE_SIMPLE
-
CHOOSE_MIN_SLACK_RANK_FORWARD
public static final int CHOOSE_MIN_SLACK_RANK_FORWARD
-
CHOOSE_RANDOM_RANK_FORWARD
public static final int CHOOSE_RANDOM_RANK_FORWARD
-
INTERVAL_DEFAULT
public static final int INTERVAL_DEFAULT
The default is INTERVAL_SET_TIMES_FORWARD.
-
INTERVAL_SIMPLE
public static final int INTERVAL_SIMPLE
The simple is INTERVAL_SET_TIMES_FORWARD.
-
INTERVAL_SET_TIMES_FORWARD
public static final int INTERVAL_SET_TIMES_FORWARD
Selects the variable with the lowest starting time of all variables,
and fixes its starting time to this lowest value.
-
INTERVAL_SET_TIMES_BACKWARD
public static final int INTERVAL_SET_TIMES_BACKWARD
Selects the variable with the highest ending time of all variables,
and fixes the ending time to this highest values.
-
TWOOPT
public static final int TWOOPT
Operator which reverses a sub-chain of a path. It is called TwoOpt
because it breaks two arcs on the path; resulting paths are called
two-optimal.
Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5
(where (1, 5) are first and last nodes of the path and can therefore not
be moved):
1 -> [3 -> 2] -> 4 -> 5
1 -> [4 -> 3 -> 2] -> 5
1 -> 2 -> [4 -> 3] -> 5
-
OROPT
public static final int OROPT
Relocate: OROPT and RELOCATE.
Operator which moves a sub-chain of a path to another position; the
specified chain length is the fixed length of the chains being moved.
When this length is 1, the operator simply moves a node to another
position.
Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5, for a chain
length of 2 (where (1, 5) are first and last nodes of the path and can
therefore not be moved):
1 -> 4 -> [2 -> 3] -> 5
1 -> [3 -> 4] -> 2 -> 5
Using Relocate with chain lengths of 1, 2 and 3 together is equivalent
to the OrOpt operator on a path. The OrOpt operator is a limited
version of 3Opt (breaks 3 arcs on a path).
-
RELOCATE
public static final int RELOCATE
Relocate neighborhood with length of 1 (see OROPT comment).
-
EXCHANGE
public static final int EXCHANGE
Operator which exchanges the positions of two nodes.
Possible neighbors for the path 1 -> 2 -> 3 -> 4 -> 5
(where (1, 5) are first and last nodes of the path and can therefore not
be moved):
1 -> [3] -> [2] -> 4 -> 5
1 -> [4] -> 3 -> [2] -> 5
1 -> 2 -> [4] -> [3] -> 5
-
CROSS
public static final int CROSS
Operator which cross exchanges the starting chains of 2 paths, including
exchanging the whole paths.
First and last nodes are not moved.
Possible neighbors for the paths 1 -> 2 -> 3 -> 4 -> 5 and 6 -> 7 -> 8
(where (1, 5) and (6, 8) are first and last nodes of the paths and can
therefore not be moved):
1 -> [7] -> 3 -> 4 -> 5 6 -> [2] -> 8
1 -> [7] -> 4 -> 5 6 -> [2 -> 3] -> 8
1 -> [7] -> 5 6 -> [2 -> 3 -> 4] -> 8
-
MAKEACTIVE
public static final int MAKEACTIVE
Operator which inserts an inactive node into a path.
Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
(where 1 and 4 are first and last nodes of the path) are:
1 -> [5] -> 2 -> 3 -> 4
1 -> 2 -> [5] -> 3 -> 4
1 -> 2 -> 3 -> [5] -> 4
-
MAKEINACTIVE
public static final int MAKEINACTIVE
Operator which makes path nodes inactive.
Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are
first and last nodes of the path) are:
1 -> 3 -> 4 with 2 inactive
1 -> 2 -> 4 with 3 inactive
-
MAKECHAININACTIVE
public static final int MAKECHAININACTIVE
Operator which makes a "chain" of path nodes inactive.
Possible neighbors for the path 1 -> 2 -> 3 -> 4 (where 1 and 4 are
first and last nodes of the path) are:
1 -> 3 -> 4 with 2 inactive
1 -> 2 -> 4 with 3 inactive
1 -> 4 with 2 and 3 inactive
-
SWAPACTIVE
public static final int SWAPACTIVE
Operator which replaces an active node by an inactive one.
Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
(where 1 and 4 are first and last nodes of the path) are:
1 -> [5] -> 3 -> 4 with 2 inactive
1 -> 2 -> [5] -> 4 with 3 inactive
-
EXTENDEDSWAPACTIVE
public static final int EXTENDEDSWAPACTIVE
Operator which makes an inactive node active and an active one inactive.
It is similar to SwapActiveOperator except that it tries to insert the
inactive node in all possible positions instead of just the position of
the node made inactive.
Possible neighbors for the path 1 -> 2 -> 3 -> 4 with 5 inactive
(where 1 and 4 are first and last nodes of the path) are:
1 -> [5] -> 3 -> 4 with 2 inactive
1 -> 3 -> [5] -> 4 with 2 inactive
1 -> [5] -> 2 -> 4 with 3 inactive
1 -> 2 -> [5] -> 4 with 3 inactive
-
PATHLNS
public static final int PATHLNS
Operator which relaxes two sub-chains of three consecutive arcs each.
Each sub-chain is defined by a start node and the next three arcs. Those
six arcs are relaxed to build a new neighbor.
PATHLNS explores all possible pairs of starting nodes and so defines
n^2 neighbors, n being the number of nodes.
Note that the two sub-chains can be part of the same path; they even may
overlap.
-
FULLPATHLNS
public static final int FULLPATHLNS
Operator which relaxes one entire path and all inactive nodes, thus
defining num_paths neighbors.
-
UNACTIVELNS
public static final int UNACTIVELNS
Operator which relaxes all inactive nodes and one sub-chain of six
consecutive arcs. That way the path can be improved by inserting
inactive nodes or swapping arcs.
-
INCREMENT
public static final int INCREMENT
Operator which defines one neighbor per variable. Each neighbor tries to
increment by one the value of the corresponding variable. When a new
solution is found the neighborhood is rebuilt from scratch, i.e., tries
to increment values in the variable order.
Consider for instance variables x and y. x is incremented one by one to
its max, and when it is not possible to increment x anymore, y is
incremented once. If this is a solution, then next neighbor tries to
increment x.
-
DECREMENT
public static final int DECREMENT
Operator which defines a neighborhood to decrement values.
The behavior is the same as INCREMENT, except values are decremented
instead of incremented.
-
SIMPLELNS
public static final int SIMPLELNS
Operator which defines one neighbor per variable. Each neighbor relaxes
one variable.
When a new solution is found the neighborhood is rebuilt from scratch.
Consider for instance variables x and y. First x is relaxed and the
solver is looking for the best possible solution (with only x relaxed).
Then y is relaxed, and the solver is looking for a new solution.
If a new solution is found, then the next variable to be relaxed is x.
-
LK
public static final int LK
Lin-Kernighan local search.
While the accumulated local gain is positive, perform a 2opt or a 3opt
move followed by a series of 2opt moves. Return a neighbor for which the
global gain is positive.
-
TSPOPT
public static final int TSPOPT
Sliding TSP operator.
Uses an exact dynamic programming algorithm to solve the TSP
corresponding to path sub-chains.
For a subchain 1 -> 2 -> 3 -> 4 -> 5 -> 6, solves the TSP on
nodes A, 2, 3, 4, 5, where A is a merger of nodes 1 and 6 such that
cost(A,i) = cost(1,i) and cost(i,A) = cost(i,6).
-
TSPLNS
public static final int TSPLNS
TSP-base LNS.
Randomly merge consecutive nodes until n "meta"-nodes remain and solve
the corresponding TSP.
This is an "unlimited" neighborhood which must be stopped by search
limits. To force diversification, the operator iteratively forces each
node to serve as base of a meta-node.
-
GE
public static final int GE
Move is accepted when the current objective value >= objective.Min.
-
LE
public static final int LE
Move is accepted when the current objective value <= objective.Max.
-
EQ
public static final int EQ
Move is accepted when the current objective value is in the interval
objective.Min .. objective.Max.
-
DELAYED_PRIORITY
public static final int DELAYED_PRIORITY
DELAYED_PRIORITY is the lowest priority: Demons will be processed after
VAR_PRIORITY and NORMAL_PRIORITY demons.
-
VAR_PRIORITY
public static final int VAR_PRIORITY
VAR_PRIORITY is between DELAYED_PRIORITY and NORMAL_PRIORITY.
-
NORMAL_PRIORITY
public static final int NORMAL_PRIORITY
NORMAL_PRIORITY is the highest priority: Demons will be processed first.
-
ENDS_AFTER_END
public static final int ENDS_AFTER_END
t1 ends after t2 end, i.e. End(t1) >= End(t2) + delay.
-
ENDS_AFTER_START
public static final int ENDS_AFTER_START
t1 ends after t2 start, i.e. End(t1) >= Start(t2) + delay.
-
ENDS_AT_END
public static final int ENDS_AT_END
t1 ends at t2 end, i.e. End(t1) == End(t2) + delay.
-
ENDS_AT_START
public static final int ENDS_AT_START
t1 ends at t2 start, i.e. End(t1) == Start(t2) + delay.
-
STARTS_AFTER_END
public static final int STARTS_AFTER_END
t1 starts after t2 end, i.e. Start(t1) >= End(t2) + delay.
-
STARTS_AFTER_START
public static final int STARTS_AFTER_START
t1 starts after t2 start, i.e. Start(t1) >= Start(t2) + delay.
-
STARTS_AT_END
public static final int STARTS_AT_END
t1 starts at t2 end, i.e. Start(t1) == End(t2) + delay.
-
STARTS_AT_START
public static final int STARTS_AT_START
t1 starts at t2 start, i.e. Start(t1) == Start(t2) + delay.
-
STAYS_IN_SYNC
public static final int STAYS_IN_SYNC
STARTS_AT_START and ENDS_AT_END at the same time.
t1 starts at t2 start, i.e. Start(t1) == Start(t2) + delay.
t1 ends at t2 end, i.e. End(t1) == End(t2).
-
ENDS_AFTER
public static final int ENDS_AFTER
t ends after d, i.e. End(t) >= d.
-
ENDS_AT
public static final int ENDS_AT
t ends at d, i.e. End(t) == d.
-
ENDS_BEFORE
public static final int ENDS_BEFORE
t ends before d, i.e. End(t) <= d.
-
STARTS_AFTER
public static final int STARTS_AFTER
t starts after d, i.e. Start(t) >= d.
-
STARTS_AT
public static final int STARTS_AT
t starts at d, i.e. Start(t) == d.
-
STARTS_BEFORE
public static final int STARTS_BEFORE
t starts before d, i.e. Start(t) <= d.
-
CROSS_DATE
public static final int CROSS_DATE
STARTS_BEFORE and ENDS_AFTER at the same time, i.e. d is in t.
t starts before d, i.e. Start(t) <= d.
t ends after d, i.e. End(t) >= d.
-
AVOID_DATE
public static final int AVOID_DATE
STARTS_AFTER or ENDS_BEFORE, i.e. d is not in t.
t starts after d, i.e. Start(t) >= d.
t ends before d, i.e. End(t) <= d.
-
NO_CHANGE
public static final int NO_CHANGE
Keeps the default behavior, i.e. apply left branch first, and then right
branch in case of backtracking.
-
KEEP_LEFT
public static final int KEEP_LEFT
Right branches are ignored. This is used to make the code faster when
backtrack makes no sense or is not useful.
This is faster as there is no need to create one new node per decision.
-
KEEP_RIGHT
public static final int KEEP_RIGHT
Left branches are ignored. This is used to make the code faster when
backtrack makes no sense or is not useful.
This is faster as there is no need to create one new node per decision.
-
KILL_BOTH
public static final int KILL_BOTH
Backtracks to the previous decisions, i.e. left and right branches are
not applied.
-
SWITCH_BRANCHES
public static final int SWITCH_BRANCHES
Applies right branch first. Left branch will be applied in case of
backtracking.
-
SENTINEL
public static final int SENTINEL
This enum is used internally in private methods Solver::PushState and
Solver::PopState to tag states in the search tree.
-
SIMPLE_MARKER
public static final int SIMPLE_MARKER
-
CHOICE_POINT
public static final int CHOICE_POINT
-
REVERSIBLE_ACTION
public static final int REVERSIBLE_ACTION
-
OUTSIDE_SEARCH
public static final int OUTSIDE_SEARCH
Before search, after search.
-
IN_ROOT_NODE
public static final int IN_ROOT_NODE
Executing the root node.
-
IN_SEARCH
public static final int IN_SEARCH
Executing the search code.
-
AT_SOLUTION
public static final int AT_SOLUTION
After successful NextSolution and before EndSearch.
-
NO_MORE_SOLUTIONS
public static final int NO_MORE_SOLUTIONS
After failed NextSolution and before EndSearch.
-
PROBLEM_INFEASIBLE
public static final int PROBLEM_INFEASIBLE
After search, the model is infeasible.
-
NOT_SET
public static final int NOT_SET
Optimization directions.
-
MAXIMIZATION
public static final int MAXIMIZATION
-
MINIMIZATION
public static final int MINIMIZATION
-
-
Constructor Detail
-
Solver
protected Solver(long cPtr, boolean cMemoryOwn)
-
Solver
public Solver(java.lang.String name)
Solver API
-
Solver
public Solver(java.lang.String name, ConstraintSolverParameters parameters)
-
-
Method Detail
-
getCPtr
protected static long getCPtr(Solver obj)
-
swigRelease
protected static long swigRelease(Solver obj)
-
finalize
protected void finalize()
- Overrides:
finalizein classjava.lang.Object
-
delete
public void delete()
-
makeIntVarArray
public IntVar[] makeIntVarArray(int count, long min, long max)
-
makeIntVarArray
public IntVar[] makeIntVarArray(int count, long min, long max, java.lang.String name)
-
makeBoolVarArray
public IntVar[] makeBoolVarArray(int count)
-
makeBoolVarArray
public IntVar[] makeBoolVarArray(int count, java.lang.String name)
-
makeFixedDurationIntervalVarArray
public IntervalVar[] makeFixedDurationIntervalVarArray(int count, long start_min, long start_max, long duration, boolean optional)
-
makeFixedDurationIntervalVarArray
public IntervalVar[] makeFixedDurationIntervalVarArray(int count, long start_min, long start_max, long duration, boolean optional, java.lang.String name)
-
keepAliveDecisionBuilder
public void keepAliveDecisionBuilder(DecisionBuilder db)
-
keepAliveDecisionBuilder
public void keepAliveDecisionBuilder(DecisionBuilder[] dbs)
-
parameters
public ConstraintSolverParameters parameters()
Stored Parameters.
-
const_parameters
public SWIGTYPE_p_operations_research__ConstraintSolverParameters const_parameters()
-
defaultSolverParameters
public static ConstraintSolverParameters defaultSolverParameters()
Create a ConstraintSolverParameters proto with all the default values.
-
addConstraint
public void addConstraint(Constraint c)
Adds the constraint 'c' to the model.
After calling this method, and until there is a backtrack that undoes the
addition, any assignment of variables to values must satisfy the given
constraint in order to be considered feasible. There are two fairly
different use cases:
- the most common use case is modeling: the given constraint is really
part of the problem that the user is trying to solve. In this use case,
AddConstraint is called outside of search (i.e., with state() ==
OUTSIDE_SEARCH). Most users should only use AddConstraint in this
way. In this case, the constraint will belong to the model forever: it
cannot be removed by backtracking.
- a rarer use case is that 'c' is not a real constraint of the model. It
may be a constraint generated by a branching decision (a constraint whose
goal is to restrict the search space), a symmetry breaking constraint (a
constraint that does restrict the search space, but in a way that cannot
have an impact on the quality of the solutions in the subtree), or an
inferred constraint that, while having no semantic value to the model (it
does not restrict the set of solutions), is worth having because we
believe it may strengthen the propagation. In these cases, it happens
that the constraint is added during the search (i.e., with state() ==
IN_SEARCH or state() == IN_ROOT_NODE). When a constraint is
added during a search, it applies only to the subtree of the search tree
rooted at the current node, and will be automatically removed by
backtracking.
This method does not take ownership of the constraint. If the constraint
has been created by any factory method (Solver::MakeXXX), it will
automatically be deleted. However, power users who implement their own
constraints should do: solver.AddConstraint(solver.RevAlloc(new
MyConstraint(...));
-
addCastConstraint
public void addCastConstraint(CastConstraint constraint, IntVar target_var, IntExpr expr)
Adds 'constraint' to the solver and marks it as a cast constraint, that
is, a constraint created calling Var() on an expression. This is used
internally.
-
solve
public boolean solve(DecisionBuilder db, SearchMonitor[] monitors)
Solves the problem using the given DecisionBuilder and returns true if a
solution was found and accepted.
These methods are the ones most users should use to search for a solution.
Note that the definition of 'solution' is subtle. A solution here is
defined as a leaf of the search tree with respect to the given decision
builder for which there is no failure. What this means is that, contrary
to intuition, a solution may not have all variables of the model bound.
It is the responsibility of the decision builder to keep returning
decisions until all variables are indeed bound. The most extreme
counterexample is calling Solve with a trivial decision builder whose
Next() method always returns nullptr. In this case, Solve immediately
returns 'true', since not assigning any variable to any value is a
solution, unless the root node propagation discovers that the model is
infeasible.
This function must be called either from outside of search,
or from within the Next() method of a decision builder.
Solve will terminate whenever any of the following event arise:
A search monitor asks the solver to terminate the search by calling
solver()->FinishCurrentSearch().
A solution is found that is accepted by all search monitors, and none of
the search monitors decides to search for another one.
Upon search termination, there will be a series of backtracks all the way
to the top level. This means that a user cannot expect to inspect the
solution by querying variables after a call to Solve(): all the
information will be lost. In order to do something with the solution, the
user must either:
Use a search monitor that can process such a leaf. See, in particular,
the SolutionCollector class.
Do not use Solve. Instead, use the more fine-grained approach using
methods NewSearch(...), NextSolution(), and EndSearch().
- Parameters:
db- The decision builder that will generate the search tree.monitors- A vector of search monitors that will be notified of
various events during the search. In their reaction to these events, such
monitors may influence the search.
-
solve
public boolean solve(DecisionBuilder db)
-
solve
public boolean solve(DecisionBuilder db, SearchMonitor m1)
-
solve
public boolean solve(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2)
-
solve
public boolean solve(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3)
-
solve
public boolean solve(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3, SearchMonitor m4)
-
newSearch
public void newSearch(DecisionBuilder db, SearchMonitor[] monitors)
Decomposed search.
The code for a top level search should look like
solver->NewSearch(db);
while (solver->NextSolution()) {
.. use the current solution
}
solver()->EndSearch();
-
newSearch
public void newSearch(DecisionBuilder db)
-
newSearch
public void newSearch(DecisionBuilder db, SearchMonitor m1)
-
newSearch
public void newSearch(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2)
-
newSearch
public void newSearch(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3)
-
newSearch
public void newSearch(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3, SearchMonitor m4)
-
nextSolution
public boolean nextSolution()
-
restartSearch
public void restartSearch()
-
endSearch
public void endSearch()
-
solveAndCommit
public boolean solveAndCommit(DecisionBuilder db, SearchMonitor[] monitors)
SolveAndCommit using a decision builder and up to three
search monitors, usually one for the objective, one for the limits
and one to collect solutions.
The difference between a SolveAndCommit() and a Solve() method
call is the fact that SolveAndCommit will not backtrack all
modifications at the end of the search. This method is only
usable during the Next() method of a decision builder.
-
solveAndCommit
public boolean solveAndCommit(DecisionBuilder db)
-
solveAndCommit
public boolean solveAndCommit(DecisionBuilder db, SearchMonitor m1)
-
solveAndCommit
public boolean solveAndCommit(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2)
-
solveAndCommit
public boolean solveAndCommit(DecisionBuilder db, SearchMonitor m1, SearchMonitor m2, SearchMonitor m3)
-
checkAssignment
public boolean checkAssignment(Assignment solution)
Checks whether the given assignment satisfies all relevant constraints.
-
checkConstraint
public boolean checkConstraint(Constraint ct)
Checks whether adding this constraint will lead to an immediate
failure. It will return false if the model is already inconsistent, or if
adding the constraint makes it inconsistent.
-
state
public int state()
State of the solver.
-
fail
public void fail()
Abandon the current branch in the search tree. A backtrack will follow.
-
toString
public java.lang.String toString()
misc debug string.- Overrides:
toStringin classjava.lang.Object
-
memoryUsage
public static long memoryUsage()
Current memory usage in bytes
-
wallTime
public long wallTime()
DEPRECATED: Use Now() instead.
Time elapsed, in ms since the creation of the solver.
-
branches
public long branches()
The number of branches explored since the creation of the solver.
-
solutions
public long solutions()
The number of solutions found since the start of the search.
-
unchecked_solutions
public long unchecked_solutions()
The number of unchecked solutions found by local search.
-
demon_runs
public long demon_runs(int p)
The number of demons executed during search for a given priority.
-
failures
public long failures()
The number of failures encountered since the creation of the solver.
-
neighbors
public long neighbors()
The number of neighbors created.
-
ClearNeighbors
public void ClearNeighbors()
Manipulate neighbors count; to be used for testing purposes only.
TODO(user): Find a workaround to avoid exposing this.
-
IncrementNeighbors
public void IncrementNeighbors()
-
filteredNeighbors
public long filteredNeighbors()
The number of filtered neighbors (neighbors accepted by filters).
-
acceptedNeighbors
public long acceptedNeighbors()
The number of accepted neighbors.
-
stamp
public java.math.BigInteger stamp()
The stamp indicates how many moves in the search tree we have performed.
It is useful to detect if we need to update same lazy structures.
-
fail_stamp
public java.math.BigInteger fail_stamp()
The fail_stamp() is incremented after each backtrack.
-
set_context
public void set_context(SWIGTYPE_p_absl__string_view context)
Sets the current context of the search.
-
context
public java.lang.String context()
Gets the current context of the search.
-
optimization_direction
public int optimization_direction()
The direction of optimization, getter and setter.
-
set_optimization_direction
public void set_optimization_direction(int direction)
-
makeIntVar
public IntVar makeIntVar(long min, long max, java.lang.String name)
MakeIntVar will create the best range based int var for the bounds given.
-
makeIntVar
public IntVar makeIntVar(long[] values, java.lang.String name)
MakeIntVar will create a variable with the given sparse domain.
-
makeIntVar
public IntVar makeIntVar(int[] values, java.lang.String name)
MakeIntVar will create a variable with the given sparse domain.
-
makeIntVar
public IntVar makeIntVar(long min, long max)
MakeIntVar will create the best range based int var for the bounds given.
-
makeIntVar
public IntVar makeIntVar(long[] values)
MakeIntVar will create a variable with the given sparse domain.
-
makeIntVar
public IntVar makeIntVar(int[] values)
MakeIntVar will create a variable with the given sparse domain.
-
makeBoolVar
public IntVar makeBoolVar(java.lang.String name)
MakeBoolVar will create a variable with a {0, 1} domain.
-
makeBoolVar
public IntVar makeBoolVar()
MakeBoolVar will create a variable with a {0, 1} domain.
-
makeIntConst
public IntVar makeIntConst(long val, java.lang.String name)
IntConst will create a constant expression.
-
makeIntConst
public IntVar makeIntConst(long val)
IntConst will create a constant expression.
-
makeDiv
public IntExpr makeDiv(IntExpr numerator, IntExpr denominator)
numerator / denominator (integer division). Terms need to be positive.
-
makeElement
public IntExpr makeElement(java.util.function.LongUnaryOperator values, IntVar index)
Function-based element. The constraint takes ownership of the
callback. The callback must be able to cope with any possible
value in the domain of 'index' (potentially negative ones too).
-
makeMonotonicElement
public IntExpr makeMonotonicElement(java.util.function.LongUnaryOperator values, boolean increasing, IntVar index)
Function based element. The constraint takes ownership of the
callback. The callback must be monotonic. It must be able to
cope with any possible value in the domain of 'index'
(potentially negative ones too). Furtermore, monotonicity is not
checked. Thus giving a non-monotonic function, or specifying an
incorrect increasing parameter will result in undefined behavior.
-
makeElement
public IntExpr makeElement(java.util.function.LongBinaryOperator values, IntVar index1, IntVar index2)
2D version of function-based element expression, values(expr1, expr2).
-
makeIndexExpression
public IntExpr makeIndexExpression(IntVar[] vars, long value)
Returns the expression expr such that vars[expr] == value.
It assumes that vars are all different.
-
makeIfThenElseCt
public Constraint makeIfThenElseCt(IntVar condition, IntExpr then_expr, IntExpr else_expr, IntVar target_var)
Special cases with arrays of size two.
-
makeConvexPiecewiseExpr
public IntExpr makeConvexPiecewiseExpr(IntExpr expr, long early_cost, long early_date, long late_date, long late_cost)
Convex piecewise function.
-
makeSemiContinuousExpr
public IntExpr makeSemiContinuousExpr(IntExpr expr, long fixed_charge, long step)
Semi continuous Expression (x <= 0 -> f(x) = 0; x > 0 -> f(x) = ax + b)
a >= 0 and b >= 0
-
makeModulo
public IntExpr makeModulo(IntExpr x, long mod)
General piecewise-linear function expression, built from f(x) where f is
piecewise-linear. The resulting expression is f(expr).
expressions.
Modulo expression x % mod (with the python convention for modulo).
-
makeModulo
public IntExpr makeModulo(IntExpr x, IntExpr mod)
Modulo expression x % mod (with the python convention for modulo).
-
makeConditionalExpression
public IntExpr makeConditionalExpression(IntVar condition, IntExpr expr, long unperformed_value)
Conditional Expr condition ? expr : unperformed_value
-
makeTrueConstraint
public Constraint makeTrueConstraint()
This constraint always succeeds.
-
makeFalseConstraint
public Constraint makeFalseConstraint()
This constraint always fails.
-
makeFalseConstraint
public Constraint makeFalseConstraint(java.lang.String explanation)
-
makeIsEqualCstCt
public Constraint makeIsEqualCstCt(IntExpr var, long value, IntVar boolvar)
boolvar == (var == value)
-
makeIsEqualCstVar
public IntVar makeIsEqualCstVar(IntExpr var, long value)
status var of (var == value)
-
makeIsEqualVar
public Constraint makeIsEqualVar(IntExpr v1, IntExpr v2, IntVar b)
b == (v1 == v2)
-
makeEquality
public Constraint makeEquality(IntExpr left, IntExpr right)
left == right
-
makeEquality
public Constraint makeEquality(IntExpr expr, long value)
expr == value
-
makeEquality
public Constraint makeEquality(IntExpr expr, int value)
expr == value
-
makeIsDifferentCstCt
public Constraint makeIsDifferentCstCt(IntExpr var, long value, IntVar boolvar)
boolvar == (var != value)
-
makeIsDifferentCstVar
public IntVar makeIsDifferentCstVar(IntExpr var, long value)
status var of (var != value)
-
makeIsDifferentCstVar
public IntVar makeIsDifferentCstVar(IntExpr v1, IntExpr v2)
status var of (v1 != v2)
-
makeIsDifferentCstCt
public Constraint makeIsDifferentCstCt(IntExpr v1, IntExpr v2, IntVar b)
b == (v1 != v2)
-
makeNonEquality
public Constraint makeNonEquality(IntExpr left, IntExpr right)
left != right
-
makeNonEquality
public Constraint makeNonEquality(IntExpr expr, long value)
expr != value
-
makeNonEquality
public Constraint makeNonEquality(IntExpr expr, int value)
expr != value
-
makeIsLessOrEqualCstCt
public Constraint makeIsLessOrEqualCstCt(IntExpr var, long value, IntVar boolvar)
boolvar == (var <= value)
-
makeIsLessOrEqualCstVar
public IntVar makeIsLessOrEqualCstVar(IntExpr var, long value)
status var of (var <= value)
-
makeIsLessOrEqualVar
public IntVar makeIsLessOrEqualVar(IntExpr left, IntExpr right)
status var of (left <= right)
-
makeIsLessOrEqualCt
public Constraint makeIsLessOrEqualCt(IntExpr left, IntExpr right, IntVar b)
b == (left <= right)
-
makeLessOrEqual
public Constraint makeLessOrEqual(IntExpr left, IntExpr right)
left <= right
-
makeLessOrEqual
public Constraint makeLessOrEqual(IntExpr expr, long value)
expr <= value
-
makeLessOrEqual
public Constraint makeLessOrEqual(IntExpr expr, int value)
expr <= value
-
makeIsGreaterOrEqualCstCt
public Constraint makeIsGreaterOrEqualCstCt(IntExpr var, long value, IntVar boolvar)
boolvar == (var >= value)
-
makeIsGreaterOrEqualCstVar
public IntVar makeIsGreaterOrEqualCstVar(IntExpr var, long value)
status var of (var >= value)
-
makeIsGreaterOrEqualVar
public IntVar makeIsGreaterOrEqualVar(IntExpr left, IntExpr right)
status var of (left >= right)
-
makeIsGreaterOrEqualCt
public Constraint makeIsGreaterOrEqualCt(IntExpr left, IntExpr right, IntVar b)
b == (left >= right)
-
makeGreaterOrEqual
public Constraint makeGreaterOrEqual(IntExpr left, IntExpr right)
left >= right
-
makeGreaterOrEqual
public Constraint makeGreaterOrEqual(IntExpr expr, long value)
expr >= value
-
makeGreaterOrEqual
public Constraint makeGreaterOrEqual(IntExpr expr, int value)
expr >= value
-
makeIsGreaterCstCt
public Constraint makeIsGreaterCstCt(IntExpr v, long c, IntVar b)
b == (v > c)
-
makeIsGreaterCstVar
public IntVar makeIsGreaterCstVar(IntExpr var, long value)
status var of (var > value)
-
makeIsGreaterVar
public IntVar makeIsGreaterVar(IntExpr left, IntExpr right)
status var of (left > right)
-
makeIsGreaterCt
public Constraint makeIsGreaterCt(IntExpr left, IntExpr right, IntVar b)
b == (left > right)
-
makeGreater
public Constraint makeGreater(IntExpr left, IntExpr right)
left > right
-
makeGreater
public Constraint makeGreater(IntExpr expr, long value)
expr > value
-
makeGreater
public Constraint makeGreater(IntExpr expr, int value)
expr > value
-
makeIsLessCstCt
public Constraint makeIsLessCstCt(IntExpr v, long c, IntVar b)
b == (v < c)
-
makeIsLessCstVar
public IntVar makeIsLessCstVar(IntExpr var, long value)
status var of (var < value)
-
makeIsLessVar
public IntVar makeIsLessVar(IntExpr left, IntExpr right)
status var of (left < right)
-
makeIsLessCt
public Constraint makeIsLessCt(IntExpr left, IntExpr right, IntVar b)
b == (left < right)
-
makeLess
public Constraint makeLess(IntExpr left, IntExpr right)
left < right
-
makeLess
public Constraint makeLess(IntExpr expr, long value)
expr < value
-
makeLess
public Constraint makeLess(IntExpr expr, int value)
expr < value
-
makeSumLessOrEqual
public Constraint makeSumLessOrEqual(IntVar[] vars, long cst)
Variation on arrays.
-
makeSumGreaterOrEqual
public Constraint makeSumGreaterOrEqual(IntVar[] vars, long cst)
-
makeSumEquality
public Constraint makeSumEquality(IntVar[] vars, long cst)
-
makeSumEquality
public Constraint makeSumEquality(IntVar[] vars, IntVar var)
-
makeScalProdEquality
public Constraint makeScalProdEquality(IntVar[] vars, long[] coefficients, long cst)
-
makeScalProdEquality
public Constraint makeScalProdEquality(IntVar[] vars, int[] coefficients, long cst)
-
makeScalProdEquality
public Constraint makeScalProdEquality(IntVar[] vars, long[] coefficients, IntVar target)
-
makeScalProdEquality
public Constraint makeScalProdEquality(IntVar[] vars, int[] coefficients, IntVar target)
-
makeScalProdGreaterOrEqual
public Constraint makeScalProdGreaterOrEqual(IntVar[] vars, long[] coeffs, long cst)
-
makeScalProdGreaterOrEqual
public Constraint makeScalProdGreaterOrEqual(IntVar[] vars, int[] coeffs, long cst)
-
makeScalProdLessOrEqual
public Constraint makeScalProdLessOrEqual(IntVar[] vars, long[] coefficients, long cst)
-
makeScalProdLessOrEqual
public Constraint makeScalProdLessOrEqual(IntVar[] vars, int[] coefficients, long cst)
-
makeMinEquality
public Constraint makeMinEquality(IntVar[] vars, IntVar min_var)
-
makeMaxEquality
public Constraint makeMaxEquality(IntVar[] vars, IntVar max_var)
-
makeElementEquality
public Constraint makeElementEquality(long[] vals, IntVar index, IntVar target)
-
makeElementEquality
public Constraint makeElementEquality(int[] vals, IntVar index, IntVar target)
-
makeElementEquality
public Constraint makeElementEquality(IntVar[] vars, IntVar index, IntVar target)
-
makeElementEquality
public Constraint makeElementEquality(IntVar[] vars, IntVar index, long target)
-
makeAbsEquality
public Constraint makeAbsEquality(IntVar var, IntVar abs_var)
Creates the constraint abs(var) == abs_var.
-
makeIndexOfConstraint
public Constraint makeIndexOfConstraint(IntVar[] vars, IntVar index, long target)
This constraint is a special case of the element constraint with
an array of integer variables, where the variables are all
different and the index variable is constrained such that
vars[index] == target.
-
makeConstraintInitialPropagateCallback
public Demon makeConstraintInitialPropagateCallback(Constraint ct)
This method is a specialized case of the MakeConstraintDemon
method to call the InitiatePropagate of the constraint 'ct'.
-
makeDelayedConstraintInitialPropagateCallback
public Demon makeDelayedConstraintInitialPropagateCallback(Constraint ct)
This method is a specialized case of the MakeConstraintDemon
method to call the InitiatePropagate of the constraint 'ct' with
low priority.
-
makeClosureDemon
public Demon makeClosureDemon(java.lang.Runnable closure)
Creates a demon from a closure.
-
makeBetweenCt
public Constraint makeBetweenCt(IntExpr expr, long l, long u)
(l <= expr <= u)
-
makeNotBetweenCt
public Constraint makeNotBetweenCt(IntExpr expr, long l, long u)
(expr < l || expr > u)
This constraint is lazy as it will not make holes in the domain of
variables. It will propagate only when expr->Min() >= l
or expr->Max() <= u.
-
makeIsBetweenCt
public Constraint makeIsBetweenCt(IntExpr expr, long l, long u, IntVar b)
b == (l <= expr <= u)
-
makeMemberCt
public Constraint makeMemberCt(IntExpr expr, long[] values)
expr in set. Propagation is lazy, i.e. this constraint does not
creates holes in the domain of the variable.
-
makeMemberCt
public Constraint makeMemberCt(IntExpr expr, int[] values)
-
makeNotMemberCt
public Constraint makeNotMemberCt(IntExpr expr, long[] values)
expr not in set.
-
makeNotMemberCt
public Constraint makeNotMemberCt(IntExpr expr, int[] values)
-
makeNotMemberCt
public Constraint makeNotMemberCt(IntExpr expr, long[] starts, long[] ends)
expr should not be in the list of forbidden intervals [start[i]..end[i]].
-
makeNotMemberCt
public Constraint makeNotMemberCt(IntExpr expr, int[] starts, int[] ends)
expr should not be in the list of forbidden intervals [start[i]..end[i]].
-
makeIsMemberCt
public Constraint makeIsMemberCt(IntExpr expr, long[] values, IntVar boolvar)
boolvar == (expr in set)
-
makeIsMemberCt
public Constraint makeIsMemberCt(IntExpr expr, int[] values, IntVar boolvar)
-
makeCount
public Constraint makeCount(IntVar[] vars, long value, long max_count)
|{i | vars[i] == value}| == max_count
-
makeCount
public Constraint makeCount(IntVar[] vars, long value, IntVar max_count)
|{i | vars[i] == value}| == max_count
-
makeDistribute
public Constraint makeDistribute(IntVar[] vars, long[] values, IntVar[] cards)
Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]
-
makeDistribute
public Constraint makeDistribute(IntVar[] vars, int[] values, IntVar[] cards)
Aggregated version of count: |{i | v[i] == values[j]}| == cards[j]
-
makeDistribute
public Constraint makeDistribute(IntVar[] vars, IntVar[] cards)
Aggregated version of count: |{i | v[i] == j}| == cards[j]
-
makeDistribute
public Constraint makeDistribute(IntVar[] vars, long card_min, long card_max, long card_size)
Aggregated version of count with bounded cardinalities:
forall j in 0 .. card_size - 1: card_min <= |{i | v[i] == j}| <= card_max
-
makeDistribute
public Constraint makeDistribute(IntVar[] vars, long[] card_min, long[] card_max)
Aggregated version of count with bounded cardinalities:
forall j in 0 .. card_size - 1:
card_min[j] <= |{i | v[i] == j}| <= card_max[j]
-
makeDistribute
public Constraint makeDistribute(IntVar[] vars, int[] card_min, int[] card_max)
Aggregated version of count with bounded cardinalities:
forall j in 0 .. card_size - 1:
card_min[j] <= |{i | v[i] == j}| <= card_max[j]
-
makeDistribute
public Constraint makeDistribute(IntVar[] vars, long[] values, long[] card_min, long[] card_max)
Aggregated version of count with bounded cardinalities:
forall j in 0 .. card_size - 1:
card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
-
makeDistribute
public Constraint makeDistribute(IntVar[] vars, int[] values, int[] card_min, int[] card_max)
Aggregated version of count with bounded cardinalities:
forall j in 0 .. card_size - 1:
card_min[j] <= |{i | v[i] == values[j]}| <= card_max[j]
-
makeDeviation
public Constraint makeDeviation(IntVar[] vars, IntVar deviation_var, long total_sum)
Deviation constraint:
sum_i |n * vars[i] - total_sum| <= deviation_var and
sum_i vars[i] == total_sum
n = #vars
-
makeAllDifferent
public Constraint makeAllDifferent(IntVar[] vars)
All variables are pairwise different. This corresponds to the
stronger version of the propagation algorithm.
-
makeAllDifferent
public Constraint makeAllDifferent(IntVar[] vars, boolean stronger_propagation)
All variables are pairwise different. If 'stronger_propagation'
is true, stronger, and potentially slower propagation will
occur. This API will be deprecated in the future.
-
makeAllDifferentExcept
public Constraint makeAllDifferentExcept(IntVar[] vars, long escape_value)
All variables are pairwise different, unless they are assigned to
the escape value.
-
makeSortingConstraint
public Constraint makeSortingConstraint(IntVar[] vars, IntVar[] sorted)
Creates a constraint binding the arrays of variables "vars" and
"sorted_vars": sorted_vars[0] must be equal to the minimum of all
variables in vars, and so on: the value of sorted_vars[i] must be
equal to the i-th value of variables invars.
This constraint propagates in both directions: from "vars" to
"sorted_vars" and vice-versa.
Behind the scenes, this constraint maintains that:
- sorted is always increasing.
- whatever the values of vars, there exists a permutation that
injects its values into the sorted variables.
For more info, please have a look at:
https://mpi-inf.mpg.de/~mehlhorn/ftp/Mehlhorn-Thiel.pdf
-
makeLexicalLess
public Constraint makeLexicalLess(IntVar[] left, IntVar[] right)
Creates a constraint that enforces that left is lexicographically less
than right.
-
makeLexicalLessOrEqual
public Constraint makeLexicalLessOrEqual(IntVar[] left, IntVar[] right)
Creates a constraint that enforces that left is lexicographically less
than or equal to right.
-
MakeLexicalLessOrEqualWithOffsets
public Constraint MakeLexicalLessOrEqualWithOffsets(IntVar[] left, IntVar[] right, long[] offsets)
Creates a constraint that enforces that left is lexicographically less
than or equal to right with an offset. This means that for the first index
i such that left[i] is not in [right[i] - (offset[i] - 1), right[i]],
left[i] + offset[i] <= right[i]. Offset values must be > 0.
-
MakeIsLexicalLessOrEqualWithOffsetsCt
public Constraint MakeIsLexicalLessOrEqualWithOffsetsCt(IntVar[] left, IntVar[] right, long[] offsets, IntVar boolvar)
-
makeInversePermutationConstraint
public Constraint makeInversePermutationConstraint(IntVar[] left, IntVar[] right)
Creates a constraint that enforces that 'left' and 'right' both
represent permutations of [0..left.size()-1], and that 'right' is
the inverse permutation of 'left', i.e. for all i in
[0..left.size()-1], right[left[i]] = i.
-
makeIndexOfFirstMaxValueConstraint
public Constraint makeIndexOfFirstMaxValueConstraint(IntVar index, IntVar[] vars)
Creates a constraint that binds the index variable to the index of the
first variable with the maximum value.
-
makeIndexOfFirstMinValueConstraint
public Constraint makeIndexOfFirstMinValueConstraint(IntVar index, IntVar[] vars)
Creates a constraint that binds the index variable to the index of the
first variable with the minimum value.
-
makeNullIntersect
public Constraint makeNullIntersect(IntVar[] first_vars, IntVar[] second_vars)
Creates a constraint that states that all variables in the first
vector are different from all variables in the second
group. Thus the set of values in the first vector does not
intersect with the set of values in the second vector.
-
makeNullIntersectExcept
public Constraint makeNullIntersectExcept(IntVar[] first_vars, IntVar[] second_vars, long escape_value)
Creates a constraint that states that all variables in the first
vector are different from all variables from the second group,
unless they are assigned to the escape value. Thus the set of
values in the first vector minus the escape value does not
intersect with the set of values in the second vector.
-
makeNoCycle
public Constraint makeNoCycle(IntVar[] nexts, IntVar[] active, java.util.function.LongPredicate sink_handler)
Prevent cycles. The "nexts" variables represent the next in the chain.
"active" variables indicate if the corresponding next variable is active;
this could be useful to model unperformed nodes in a routing problem.
A callback can be added to specify sink values (by default sink values
are values >= vars.size()). Ownership of the callback is passed to the
constraint.
If assume_paths is either not specified or true, the constraint assumes
the "nexts" variables represent paths (and performs a faster propagation);
otherwise the constraint assumes they represent a forest.
-
makeNoCycle
public Constraint makeNoCycle(IntVar[] nexts, IntVar[] active)
Prevent cycles. The "nexts" variables represent the next in the chain.
"active" variables indicate if the corresponding next variable is active;
this could be useful to model unperformed nodes in a routing problem.
A callback can be added to specify sink values (by default sink values
are values >= vars.size()). Ownership of the callback is passed to the
constraint.
If assume_paths is either not specified or true, the constraint assumes
the "nexts" variables represent paths (and performs a faster propagation);
otherwise the constraint assumes they represent a forest.
-
makeNoCycle
public Constraint makeNoCycle(IntVar[] nexts, IntVar[] active, java.util.function.LongPredicate sink_handler, boolean assume_paths)
-
makeCircuit
public Constraint makeCircuit(IntVar[] nexts)
Force the "nexts" variable to create a complete Hamiltonian path.
-
makeSubCircuit
public Constraint makeSubCircuit(IntVar[] nexts)
Force the "nexts" variable to create a complete Hamiltonian path
for those that do not loop upon themselves.
-
makePathCumul
public Constraint makePathCumul(IntVar[] nexts, IntVar[] active, IntVar[] cumuls, IntVar[] transits)
Creates a constraint which accumulates values along a path such that:
cumuls[next[i]] = cumuls[i] + transits[i].
Active variables indicate if the corresponding next variable is active;
this could be useful to model unperformed nodes in a routing problem.
-
makeDelayedPathCumul
public Constraint makeDelayedPathCumul(IntVar[] nexts, IntVar[] active, IntVar[] cumuls, IntVar[] transits)
Delayed version of the same constraint: propagation on the nexts variables
is delayed until all constraints have propagated.
-
makePathCumul
public Constraint makePathCumul(IntVar[] nexts, IntVar[] active, IntVar[] cumuls, java.util.function.LongBinaryOperator transit_evaluator)
Creates a constraint which accumulates values along a path such that:
cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]).
Active variables indicate if the corresponding next variable is active;
this could be useful to model unperformed nodes in a routing problem.
Ownership of transit_evaluator is taken and it must be a repeatable
callback.
-
makePathCumul
public Constraint makePathCumul(IntVar[] nexts, IntVar[] active, IntVar[] cumuls, IntVar[] slacks, java.util.function.LongBinaryOperator transit_evaluator)
Creates a constraint which accumulates values along a path such that:
cumuls[next[i]] = cumuls[i] + transit_evaluator(i, next[i]) + slacks[i].
Active variables indicate if the corresponding next variable is active;
this could be useful to model unperformed nodes in a routing problem.
Ownership of transit_evaluator is taken and it must be a repeatable
callback.
-
makePathConnected
public Constraint makePathConnected(IntVar[] nexts, long[] sources, long[] sinks, IntVar[] status)
Constraint enforcing that status[i] is true iff there's a path defined on
next variables from sources[i] to sinks[i].
Check whether more propagation is needed.
-
makeMapDomain
public Constraint makeMapDomain(IntVar var, IntVar[] actives)
This constraint maps the domain of 'var' onto the array of
variables 'actives'. That is
for all i in [0 .. size - 1]: actives[i] == 1 <=> var->Contains(i);
-
makeAllowedAssignment
public Constraint makeAllowedAssignment(IntVar[] vars, IntTupleSet tuples)
This method creates a constraint where the graph of the relation
between the variables is given in extension. There are 'arity'
variables involved in the relation and the graph is given by a
integer tuple set.
-
makeTransitionConstraint
public Constraint makeTransitionConstraint(IntVar[] vars, IntTupleSet transition_table, long initial_state, long[] final_states)
This constraint create a finite automaton that will check the
sequence of variables vars. It uses a transition table called
'transition_table'. Each transition is a triple
(current_state, variable_value, new_state).
The initial state is given, and the set of accepted states is decribed
by 'final_states'. These states are hidden inside the constraint.
Only the transitions (i.e. the variables) are visible.
-
makeTransitionConstraint
public Constraint makeTransitionConstraint(IntVar[] vars, IntTupleSet transition_table, long initial_state, int[] final_states)
This constraint create a finite automaton that will check the
sequence of variables vars. It uses a transition table called
'transition_table'. Each transition is a triple
(current_state, variable_value, new_state).
The initial state is given, and the set of accepted states is decribed
by 'final_states'. These states are hidden inside the constraint.
Only the transitions (i.e. the variables) are visible.
-
makeNonOverlappingBoxesConstraint
public Constraint makeNonOverlappingBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, IntVar[] x_size, IntVar[] y_size)
This constraint states that all the boxes must not overlap.
The coordinates of box i are:
(x_vars[i], y_vars[i]),
(x_vars[i], y_vars[i] + y_size[i]),
(x_vars[i] + x_size[i], y_vars[i]),
(x_vars[i] + x_size[i], y_vars[i] + y_size[i]).
The sizes must be non-negative. Boxes with a zero dimension can be
pushed like any box.
-
makeNonOverlappingBoxesConstraint
public Constraint makeNonOverlappingBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, SWIGTYPE_p_absl__SpanT_int64_t_const_t x_size, SWIGTYPE_p_absl__SpanT_int64_t_const_t y_size)
-
makeNonOverlappingBoxesConstraint
public Constraint makeNonOverlappingBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, SWIGTYPE_p_absl__SpanT_int_const_t x_size, SWIGTYPE_p_absl__SpanT_int_const_t y_size)
-
makeNonOverlappingNonStrictBoxesConstraint
public Constraint makeNonOverlappingNonStrictBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, IntVar[] x_size, IntVar[] y_size)
This constraint states that all the boxes must not overlap.
The coordinates of box i are:
(x_vars[i], y_vars[i]),
(x_vars[i], y_vars[i] + y_size[i]),
(x_vars[i] + x_size[i], y_vars[i]),
(x_vars[i] + x_size[i], y_vars[i] + y_size[i]).
The sizes must be positive.
Boxes with a zero dimension can be placed anywhere.
-
makeNonOverlappingNonStrictBoxesConstraint
public Constraint makeNonOverlappingNonStrictBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, SWIGTYPE_p_absl__SpanT_int64_t_const_t x_size, SWIGTYPE_p_absl__SpanT_int64_t_const_t y_size)
-
makeNonOverlappingNonStrictBoxesConstraint
public Constraint makeNonOverlappingNonStrictBoxesConstraint(IntVar[] x_vars, IntVar[] y_vars, SWIGTYPE_p_absl__SpanT_int_const_t x_size, SWIGTYPE_p_absl__SpanT_int_const_t y_size)
-
makePack
public Pack makePack(IntVar[] vars, int number_of_bins)
This constraint packs all variables onto 'number_of_bins'
variables. For any given variable, a value of 'number_of_bins'
indicates that the variable is not assigned to any bin.
Dimensions, i.e., cumulative constraints on this packing, can be
added directly from the pack class.
-
makeFixedDurationIntervalVar
public IntervalVar makeFixedDurationIntervalVar(long start_min, long start_max, long duration, boolean optional, java.lang.String name)
Creates an interval var with a fixed duration. The duration must
be greater than 0. If optional is true, then the interval can be
performed or unperformed. If optional is false, then the interval
is always performed.
-
makeFixedDurationIntervalVar
public IntervalVar makeFixedDurationIntervalVar(IntVar start_variable, long duration, java.lang.String name)
Creates a performed interval var with a fixed duration. The duration must
be greater than 0.
-
makeFixedDurationIntervalVar
public IntervalVar makeFixedDurationIntervalVar(IntVar start_variable, long duration, IntVar performed_variable, java.lang.String name)
Creates an interval var with a fixed duration, and performed_variable.
The duration must be greater than 0.
-
makeFixedInterval
public IntervalVar makeFixedInterval(long start, long duration, java.lang.String name)
Creates a fixed and performed interval.
-
makeIntervalVar
public IntervalVar makeIntervalVar(long start_min, long start_max, long duration_min, long duration_max, long end_min, long end_max, boolean optional, java.lang.String name)
Creates an interval var by specifying the bounds on start,
duration, and end.
-
makeMirrorInterval
public IntervalVar makeMirrorInterval(IntervalVar interval_var)
Creates an interval var that is the mirror image of the given one, that
is, the interval var obtained by reversing the axis.
-
makeFixedDurationStartSyncedOnStartIntervalVar
public IntervalVar makeFixedDurationStartSyncedOnStartIntervalVar(IntervalVar interval_var, long duration, long offset)
Creates an interval var with a fixed duration whose start is
synchronized with the start of another interval, with a given
offset. The performed status is also in sync with the performed
status of the given interval variable.
-
makeFixedDurationStartSyncedOnEndIntervalVar
public IntervalVar makeFixedDurationStartSyncedOnEndIntervalVar(IntervalVar interval_var, long duration, long offset)
Creates an interval var with a fixed duration whose start is
synchronized with the end of another interval, with a given
offset. The performed status is also in sync with the performed
status of the given interval variable.
-
makeFixedDurationEndSyncedOnStartIntervalVar
public IntervalVar makeFixedDurationEndSyncedOnStartIntervalVar(IntervalVar interval_var, long duration, long offset)
Creates an interval var with a fixed duration whose end is
synchronized with the start of another interval, with a given
offset. The performed status is also in sync with the performed
status of the given interval variable.
-
makeFixedDurationEndSyncedOnEndIntervalVar
public IntervalVar makeFixedDurationEndSyncedOnEndIntervalVar(IntervalVar interval_var, long duration, long offset)
Creates an interval var with a fixed duration whose end is
synchronized with the end of another interval, with a given
offset. The performed status is also in sync with the performed
status of the given interval variable.
-
makeIntervalRelaxedMin
public IntervalVar makeIntervalRelaxedMin(IntervalVar interval_var)
Creates and returns an interval variable that wraps around the given one,
relaxing the min start and end. Relaxing means making unbounded when
optional. If the variable is non-optional, this method returns
interval_var.
More precisely, such an interval variable behaves as follows:
When the underlying must be performed, the returned interval variable
behaves exactly as the underlying;
When the underlying may or may not be performed, the returned interval
variable behaves like the underlying, except that it is unbounded on
the min side;
When the underlying cannot be performed, the returned interval variable
is of duration 0 and must be performed in an interval unbounded on
both sides.
This is very useful to implement propagators that may only modify
the start max or end max.
-
makeIntervalRelaxedMax
public IntervalVar makeIntervalRelaxedMax(IntervalVar interval_var)
Creates and returns an interval variable that wraps around the given one,
relaxing the max start and end. Relaxing means making unbounded when
optional. If the variable is non optional, this method returns
interval_var.
More precisely, such an interval variable behaves as follows:
When the underlying must be performed, the returned interval variable
behaves exactly as the underlying;
When the underlying may or may not be performed, the returned interval
variable behaves like the underlying, except that it is unbounded on
the max side;
When the underlying cannot be performed, the returned interval variable
is of duration 0 and must be performed in an interval unbounded on
both sides.
This is very useful for implementing propagators that may only modify
the start min or end min.
-
makeIntervalVarRelation
public Constraint makeIntervalVarRelation(IntervalVar t, int r, long d)
This method creates a relation between an interval var and a
date.
-
makeIntervalVarRelation
public Constraint makeIntervalVarRelation(IntervalVar t1, int r, IntervalVar t2)
This method creates a relation between two interval vars.
-
makeIntervalVarRelationWithDelay
public Constraint makeIntervalVarRelationWithDelay(IntervalVar t1, int r, IntervalVar t2, long delay)
This method creates a relation between two interval vars.
The given delay is added to the second interval.
i.e.: t1 STARTS_AFTER_END of t2 with a delay of 2
means t1 will start at least two units of time after the end of t2.
-
makeTemporalDisjunction
public Constraint makeTemporalDisjunction(IntervalVar t1, IntervalVar t2, IntVar alt)
This constraint implements a temporal disjunction between two
interval vars t1 and t2. 'alt' indicates which alternative was
chosen (alt == 0 is equivalent to t1 before t2).
-
makeTemporalDisjunction
public Constraint makeTemporalDisjunction(IntervalVar t1, IntervalVar t2)
This constraint implements a temporal disjunction between two
interval vars.
-
makeDisjunctiveConstraint
public DisjunctiveConstraint makeDisjunctiveConstraint(IntervalVar[] intervals, java.lang.String name)
This constraint forces all interval vars into an non-overlapping
sequence. Intervals with zero duration can be scheduled anywhere.
-
makeStrictDisjunctiveConstraint
public DisjunctiveConstraint makeStrictDisjunctiveConstraint(IntervalVar[] intervals, java.lang.String name)
This constraint forces all interval vars into an non-overlapping
sequence. Intervals with zero durations cannot overlap with over
intervals.
-
makeCumulative
public Constraint makeCumulative(IntervalVar[] intervals, long[] demands, long capacity, java.lang.String name)
This constraint forces that, for any integer t, the sum of the demands
corresponding to an interval containing t does not exceed the given
capacity.
Intervals and demands should be vectors of equal size.
Demands should only contain non-negative values. Zero values are
supported, and the corresponding intervals are filtered out, as they
neither impact nor are impacted by this constraint.
-
makeCumulative
public Constraint makeCumulative(IntervalVar[] intervals, int[] demands, long capacity, java.lang.String name)
This constraint forces that, for any integer t, the sum of the demands
corresponding to an interval containing t does not exceed the given
capacity.
Intervals and demands should be vectors of equal size.
Demands should only contain non-negative values. Zero values are
supported, and the corresponding intervals are filtered out, as they
neither impact nor are impacted by this constraint.
-
makeCumulative
public Constraint makeCumulative(IntervalVar[] intervals, long[] demands, IntVar capacity, java.lang.String name)
This constraint forces that, for any integer t, the sum of the demands
corresponding to an interval containing t does not exceed the given
capacity.
Intervals and demands should be vectors of equal size.
Demands should only contain non-negative values. Zero values are
supported, and the corresponding intervals are filtered out, as they
neither impact nor are impacted by this constraint.
-
makeCumulative
public Constraint makeCumulative(IntervalVar[] intervals, int[] demands, IntVar capacity, java.lang.String name)
This constraint enforces that, for any integer t, the sum of the demands
corresponding to an interval containing t does not exceed the given
capacity.
Intervals and demands should be vectors of equal size.
Demands should only contain non-negative values. Zero values are
supported, and the corresponding intervals are filtered out, as they
neither impact nor are impacted by this constraint.
-
makeCumulative
public Constraint makeCumulative(IntervalVar[] intervals, IntVar[] demands, long capacity, java.lang.String name)
This constraint enforces that, for any integer t, the sum of demands
corresponding to an interval containing t does not exceed the given
capacity.
Intervals and demands should be vectors of equal size.
Demands should be positive.
-
makeCumulative
public Constraint makeCumulative(IntervalVar[] intervals, IntVar[] demands, IntVar capacity, java.lang.String name)
This constraint enforces that, for any integer t, the sum of demands
corresponding to an interval containing t does not exceed the given
capacity.
Intervals and demands should be vectors of equal size.
Demands should be positive.
-
makeCover
public Constraint makeCover(IntervalVar[] vars, IntervalVar target_var)
This constraint states that the target_var is the convex hull of
the intervals. If none of the interval variables is performed,
then the target var is unperformed too. Also, if the target
variable is unperformed, then all the intervals variables are
unperformed too.
-
makeEquality
public Constraint makeEquality(IntervalVar var1, IntervalVar var2)
This constraints states that the two interval variables are equal.
-
makeAssignment
public Assignment makeAssignment()
This method creates an empty assignment.
-
makeAssignment
public Assignment makeAssignment(Assignment a)
This method creates an assignment which is a copy of 'a'.
-
makeFirstSolutionCollector
public SolutionCollector makeFirstSolutionCollector(Assignment assignment)
Collect the first solution of the search.
-
makeFirstSolutionCollector
public SolutionCollector makeFirstSolutionCollector()
Collect the first solution of the search. The variables will need to
be added later.
-
makeLastSolutionCollector
public SolutionCollector makeLastSolutionCollector(Assignment assignment)
Collect the last solution of the search.
-
makeLastSolutionCollector
public SolutionCollector makeLastSolutionCollector()
Collect the last solution of the search. The variables will need to
be added later.
-
makeBestValueSolutionCollector
public SolutionCollector makeBestValueSolutionCollector(Assignment assignment, boolean maximize)
Collect the solution corresponding to the optimal value of the objective
of 'assignment'; if 'assignment' does not have an objective no solution is
collected. This collector only collects one solution corresponding to the
best objective value (the first one found).
-
MakeBestLexicographicValueSolutionCollector
public SolutionCollector MakeBestLexicographicValueSolutionCollector(Assignment assignment, SWIGTYPE_p_std__vectorT_bool_t maximize)
Same as above, but supporting lexicographic objectives; 'maximize'
specifies the optimization direction for each objective in 'assignment'.
-
makeBestValueSolutionCollector
public SolutionCollector makeBestValueSolutionCollector(boolean maximize)
Collect the solution corresponding to the optimal value of the
objective of the internal assignment; if this assignment does not have an
objective no solution is collected. This collector only collects one
solution corresponding to the best objective value (the first one found).
The variables and objective(s) will need to be added later.
-
MakeBestLexicographicValueSolutionCollector
public SolutionCollector MakeBestLexicographicValueSolutionCollector(SWIGTYPE_p_std__vectorT_bool_t maximize)
Same as above, but supporting lexicographic objectives; 'maximize'
specifies the optimization direction for each objective.
-
makeNBestValueSolutionCollector
public SolutionCollector makeNBestValueSolutionCollector(Assignment assignment, int solution_count, boolean maximize)
Same as MakeBestValueSolutionCollector but collects the best
solution_count solutions. Collected solutions are sorted in increasing
optimality order (the best solution is the last one).
-
makeNBestValueSolutionCollector
public SolutionCollector makeNBestValueSolutionCollector(int solution_count, boolean maximize)
-
MakeNBestLexicographicValueSolutionCollector
public SolutionCollector MakeNBestLexicographicValueSolutionCollector(Assignment assignment, int solution_count, SWIGTYPE_p_std__vectorT_bool_t maximize)
Same as above but supporting lexicographic objectives; 'maximize'
specifies the optimization direction for each objective.
-
MakeNBestLexicographicValueSolutionCollector
public SolutionCollector MakeNBestLexicographicValueSolutionCollector(int solution_count, SWIGTYPE_p_std__vectorT_bool_t maximize)
-
makeAllSolutionCollector
public SolutionCollector makeAllSolutionCollector(Assignment assignment)
Collect all solutions of the search.
-
makeAllSolutionCollector
public SolutionCollector makeAllSolutionCollector()
Collect all solutions of the search. The variables will need to
be added later.
-
makeMinimize
public OptimizeVar makeMinimize(IntVar v, long step)
Creates a minimization objective.
-
makeMaximize
public OptimizeVar makeMaximize(IntVar v, long step)
Creates a maximization objective.
-
makeOptimize
public OptimizeVar makeOptimize(boolean maximize, IntVar v, long step)
Creates a objective with a given sense (true = maximization).
-
makeWeightedMinimize
public OptimizeVar makeWeightedMinimize(IntVar[] sub_objectives, long[] weights, long step)
Creates a minimization weighted objective. The actual objective is
scalar_prod(sub_objectives, weights).
-
makeWeightedMinimize
public OptimizeVar makeWeightedMinimize(IntVar[] sub_objectives, int[] weights, long step)
Creates a minimization weighted objective. The actual objective is
scalar_prod(sub_objectives, weights).
-
makeWeightedMaximize
public OptimizeVar makeWeightedMaximize(IntVar[] sub_objectives, long[] weights, long step)
Creates a maximization weigthed objective.
-
makeWeightedMaximize
public OptimizeVar makeWeightedMaximize(IntVar[] sub_objectives, int[] weights, long step)
Creates a maximization weigthed objective.
-
makeWeightedOptimize
public OptimizeVar makeWeightedOptimize(boolean maximize, IntVar[] sub_objectives, long[] weights, long step)
Creates a weighted objective with a given sense (true = maximization).
-
makeWeightedOptimize
public OptimizeVar makeWeightedOptimize(boolean maximize, IntVar[] sub_objectives, int[] weights, long step)
Creates a weighted objective with a given sense (true = maximization).
-
MakeLexicographicOptimize
public OptimizeVar MakeLexicographicOptimize(SWIGTYPE_p_std__vectorT_bool_t maximize, IntVar[] variables, long[] steps)
Creates a lexicographic objective, following the order of the variables
given. Each variable has a corresponding optimization direction and step.
-
makeTabuSearch
public ObjectiveMonitor makeTabuSearch(boolean maximize, IntVar objective, long step, IntVar[] vars, long keep_tenure, long forbid_tenure, double tabu_factor)
MetaHeuristics which try to get the search out of local optima.
Creates a Tabu Search monitor.
In the context of local search the behavior is similar to MakeOptimize(),
creating an objective in a given sense. The behavior differs once a local
optimum is reached: thereafter solutions which degrade the value of the
objective are allowed if they are not "tabu". A solution is "tabu" if it
doesn't respect the following rules:
- improving the best solution found so far
- variables in the "keep" list must keep their value, variables in the
"forbid" list must not take the value they have in the list.
Variables with new values enter the tabu lists after each new solution
found and leave the lists after a given number of iterations (called
tenure). Only the variables passed to the method can enter the lists.
The tabu criterion is softened by the tabu factor which gives the number
of "tabu" violations which is tolerated; a factor of 1 means no violations
allowed; a factor of 0 means all violations are allowed.
-
MakeLexicographicTabuSearch
public ObjectiveMonitor MakeLexicographicTabuSearch(SWIGTYPE_p_std__vectorT_bool_t maximize, IntVar[] objectives, long[] steps, IntVar[] vars, long keep_tenure, long forbid_tenure, double tabu_factor)
-
makeGenericTabuSearch
public ObjectiveMonitor makeGenericTabuSearch(boolean maximize, IntVar v, long step, IntVar[] tabu_vars, long forbid_tenure)
Creates a Tabu Search based on the vars |vars|.
A solution is "tabu" if all the vars in |vars| keep their value.
-
makeSimulatedAnnealing
public ObjectiveMonitor makeSimulatedAnnealing(boolean maximize, IntVar v, long step, long initial_temperature)
Creates a Simulated Annealing monitor.
-
MakeLexicographicSimulatedAnnealing
public ObjectiveMonitor MakeLexicographicSimulatedAnnealing(SWIGTYPE_p_std__vectorT_bool_t maximize, IntVar[] vars, long[] steps, long[] initial_temperatures)
-
makeGuidedLocalSearch
public ObjectiveMonitor makeGuidedLocalSearch(boolean maximize, IntVar objective, java.util.function.LongBinaryOperator objective_function, long step, IntVar[] vars, double penalty_factor, boolean reset_penalties_on_new_best_solution)
Creates a Guided Local Search monitor.
Description here: http://en.wikipedia.org/wiki/Guided_Local_Search
-
makeGuidedLocalSearch
public ObjectiveMonitor makeGuidedLocalSearch(boolean maximize, IntVar objective, java.util.function.LongBinaryOperator objective_function, long step, IntVar[] vars, double penalty_factor)
Creates a Guided Local Search monitor.
Description here: http://en.wikipedia.org/wiki/Guided_Local_Search
-
makeGuidedLocalSearch
public ObjectiveMonitor makeGuidedLocalSearch(boolean maximize, IntVar objective, LongTernaryOperator objective_function, long step, IntVar[] vars, IntVar[] secondary_vars, double penalty_factor, boolean reset_penalties_on_new_best_solution)
-
makeGuidedLocalSearch
public ObjectiveMonitor makeGuidedLocalSearch(boolean maximize, IntVar objective, LongTernaryOperator objective_function, long step, IntVar[] vars, IntVar[] secondary_vars, double penalty_factor)
-
makeLubyRestart
public SearchMonitor makeLubyRestart(int scale_factor)
This search monitor will restart the search periodically.
At the iteration n, it will restart after scale_factor * Luby(n) failures
where Luby is the Luby Strategy (i.e. 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8...).
-
makeConstantRestart
public SearchMonitor makeConstantRestart(int frequency)
This search monitor will restart the search periodically after 'frequency'
failures.
-
makeTimeLimit
public RegularLimit makeTimeLimit(SWIGTYPE_p_absl__Duration time)
Creates a search limit that constrains the running time.
-
makeTimeLimit
public RegularLimit makeTimeLimit(long time_in_ms)
-
makeBranchesLimit
public RegularLimit makeBranchesLimit(long branches)
Creates a search limit that constrains the number of branches
explored in the search tree.
-
makeFailuresLimit
public RegularLimit makeFailuresLimit(long failures)
Creates a search limit that constrains the number of failures
that can happen when exploring the search tree.
-
makeSolutionsLimit
public RegularLimit makeSolutionsLimit(long solutions)
Creates a search limit that constrains the number of solutions found
during the search.
-
makeLimit
public RegularLimit makeLimit(SWIGTYPE_p_absl__Duration time, long branches, long failures, long solutions, boolean smart_time_check, boolean cumulative)
Limits the search with the 'time', 'branches', 'failures' and
'solutions' limits. 'smart_time_check' reduces the calls to the wall
-
makeLimit
public RegularLimit makeLimit(SWIGTYPE_p_absl__Duration time, long branches, long failures, long solutions, boolean smart_time_check)
Limits the search with the 'time', 'branches', 'failures' and
'solutions' limits. 'smart_time_check' reduces the calls to the wall
-
makeLimit
public RegularLimit makeLimit(SWIGTYPE_p_absl__Duration time, long branches, long failures, long solutions)
Limits the search with the 'time', 'branches', 'failures' and
'solutions' limits. 'smart_time_check' reduces the calls to the wall
-
makeLimit
public RegularLimit makeLimit(RegularLimitParameters proto)
Creates a search limit from its protobuf description
-
makeLimit
public RegularLimit makeLimit(long time, long branches, long failures, long solutions, boolean smart_time_check, boolean cumulative)
-
makeLimit
public RegularLimit makeLimit(long time, long branches, long failures, long solutions, boolean smart_time_check)
-
makeLimit
public RegularLimit makeLimit(long time, long branches, long failures, long solutions)
-
makeDefaultRegularLimitParameters
public RegularLimitParameters makeDefaultRegularLimitParameters()
Creates a regular limit proto containing default values.
-
makeLimit
public SearchLimit makeLimit(SearchLimit limit_1, SearchLimit limit_2)
Creates a search limit that is reached when either of the underlying limit
is reached. That is, the returned limit is more stringent than both
argument limits.
-
MakeImprovementLimit
public ImprovementSearchLimit MakeImprovementLimit(IntVar objective_var, boolean maximize, double objective_scaling_factor, double objective_offset, double improvement_rate_coefficient, int improvement_rate_solutions_distance)
Limits the search based on the improvements of 'objective_var'. Stops the
search when the improvement rate gets lower than a threshold value. This
threshold value is computed based on the improvement rate during the first
phase of the search.
-
MakeLexicographicImprovementLimit
public ImprovementSearchLimit MakeLexicographicImprovementLimit(IntVar[] objective_vars, SWIGTYPE_p_std__vectorT_bool_t maximize, double[] objective_scaling_factors, double[] objective_offsets, double improvement_rate_coefficient, int improvement_rate_solutions_distance)
Same as MakeImprovementLimit on a lexicographic objective based on
'objective_vars' and related arguments.
-
makeCustomLimit
public SearchLimit makeCustomLimit(java.util.function.BooleanSupplier limiter)
Callback-based search limit. Search stops when limiter returns true; if
this happens at a leaf the corresponding solution will be rejected.
-
makeSearchLog
public SearchMonitor makeSearchLog(int branch_period)
The SearchMonitors below will display a periodic search log
on LOG(INFO) every branch_period branches explored.
-
makeSearchLog
public SearchMonitor makeSearchLog(int branch_period, IntVar var)
At each solution, this monitor also display the var value.
-
makeSearchLog
public SearchMonitor makeSearchLog(int branch_period, java.util.function.Supplier<java.lang.String> display_callback)
At each solution, this monitor will also display result of
display_callback.
-
makeSearchLog
public SearchMonitor makeSearchLog(int branch_period, IntVar var, java.util.function.Supplier<java.lang.String> display_callback)
At each solution, this monitor will display the 'var' value and the
result ofdisplay_callback.
-
makeSearchLog
public SearchMonitor makeSearchLog(int branch_period, IntVar[] vars, java.util.function.Supplier<java.lang.String> display_callback)
At each solution, this monitor will display the 'vars' values and the
result ofdisplay_callback.
-
makeSearchLog
public SearchMonitor makeSearchLog(int branch_period, OptimizeVar opt_var)
OptimizeVar Search Logs
At each solution, this monitor will also display the 'opt_var' value.
-
makeSearchLog
public SearchMonitor makeSearchLog(int branch_period, OptimizeVar opt_var, java.util.function.Supplier<java.lang.String> display_callback)
Creates a search monitor that will also print the result of the
display callback.
-
makeSearchTrace
public SearchMonitor makeSearchTrace(java.lang.String prefix)
Creates a search monitor that will trace precisely the behavior of the
search. Use this only for low level debugging.
-
makeEnterSearchCallback
public SearchMonitor makeEnterSearchCallback(java.lang.Runnable callback)
----- Callback-based search monitors -----
-
makeExitSearchCallback
public SearchMonitor makeExitSearchCallback(java.lang.Runnable callback)
-
makeAtSolutionCallback
public SearchMonitor makeAtSolutionCallback(java.lang.Runnable callback)
-
makePrintModelVisitor
public ModelVisitor makePrintModelVisitor()
Prints the model.
-
makeStatisticsModelVisitor
public ModelVisitor makeStatisticsModelVisitor()
Displays some nice statistics on the model.
-
makeSymmetryManager
public SearchMonitor makeSymmetryManager(SymmetryBreaker[] visitors)
Symmetry Breaking.
-
makeSymmetryManager
public SearchMonitor makeSymmetryManager(SymmetryBreaker v1)
-
makeSymmetryManager
public SearchMonitor makeSymmetryManager(SymmetryBreaker v1, SymmetryBreaker v2)
-
makeSymmetryManager
public SearchMonitor makeSymmetryManager(SymmetryBreaker v1, SymmetryBreaker v2, SymmetryBreaker v3)
-
makeSymmetryManager
public SearchMonitor makeSymmetryManager(SymmetryBreaker v1, SymmetryBreaker v2, SymmetryBreaker v3, SymmetryBreaker v4)
-
makeVariableGreaterOrEqualValue
public Decision makeVariableGreaterOrEqualValue(IntVar var, long value)
-
makeSplitVariableDomain
public Decision makeSplitVariableDomain(IntVar var, long val, boolean start_with_lower_half)
-
makeAssignVariableValueOrFail
public Decision makeAssignVariableValueOrFail(IntVar var, long value)
-
MakeAssignVariableValueOrDoNothing
public Decision MakeAssignVariableValueOrDoNothing(IntVar var, long value)
-
MakeAssignVariablesValuesOrDoNothing
public Decision MakeAssignVariablesValuesOrDoNothing(IntVar[] vars, long[] values)
-
MakeAssignVariablesValuesOrFail
public Decision MakeAssignVariablesValuesOrFail(IntVar[] vars, long[] values)
-
makeFailDecision
public Decision makeFailDecision()
-
makeDecision
public Decision makeDecision(java.util.function.Consumer<Solver> apply, java.util.function.Consumer<Solver> refute)
-
compose
public DecisionBuilder compose(DecisionBuilder db1, DecisionBuilder db2)
Creates a decision builder which sequentially composes decision builders.
At each leaf of a decision builder, the next decision builder is therefore
called. For instance, Compose(db1, db2) will result in the following tree:
d1 tree |
| \ |
db1 leaves |
| \ |
db2 tree db2 tree db2 tree |
-
compose
public DecisionBuilder compose(DecisionBuilder db1, DecisionBuilder db2, DecisionBuilder db3)
-
compose
public DecisionBuilder compose(DecisionBuilder db1, DecisionBuilder db2, DecisionBuilder db3, DecisionBuilder db4)
-
compose
public DecisionBuilder compose(DecisionBuilder[] dbs)
-
tryDecisions
public DecisionBuilder tryDecisions(DecisionBuilder db1, DecisionBuilder db2)
Creates a decision builder which will create a search tree where each
decision builder is called from the top of the search tree. For instance
the decision builder Try(db1, db2) will entirely explore the search tree
of db1 then the one of db2, resulting in the following search tree:
Tree root |
\ |
db1 tree db2 tree |
This is very handy to try a decision builder which partially explores the
search space and if it fails to try another decision builder.
"Try"-builders "recursively". For instance, Try(a,b,c,d) will give a tree
unbalanced to the right, whereas Try(Try(a,b), Try(b,c)) will give a
balanced tree. Investigate if we should only provide the binary version
and/or if we should balance automatically.
-
tryDecisions
public DecisionBuilder tryDecisions(DecisionBuilder db1, DecisionBuilder db2, DecisionBuilder db3)
-
tryDecisions
public DecisionBuilder tryDecisions(DecisionBuilder db1, DecisionBuilder db2, DecisionBuilder db3, DecisionBuilder db4)
-
tryDecisions
public DecisionBuilder tryDecisions(DecisionBuilder[] dbs)
-
makePhase
public DecisionBuilder makePhase(IntVar[] vars, int var_str, int val_str)
Phases on IntVar arrays.
for all other functions that have several homonyms in this .h).
-
makePhase
public DecisionBuilder makePhase(IntVar[] vars, java.util.function.LongUnaryOperator var_evaluator, int val_str)
-
makePhase
public DecisionBuilder makePhase(IntVar[] vars, int var_str, java.util.function.LongBinaryOperator value_evaluator)
-
makePhase
public DecisionBuilder makePhase(IntVar[] vars, int var_str, LongTernaryPredicate var_val1_val2_comparator)
var_val1_val2_comparator(var, val1, val2) is true iff assigning value
"val1" to variable "var" is better than assigning value "val2".
-
makePhase
public DecisionBuilder makePhase(IntVar[] vars, java.util.function.LongUnaryOperator var_evaluator, java.util.function.LongBinaryOperator value_evaluator)
-
makePhase
public DecisionBuilder makePhase(IntVar[] vars, int var_str, java.util.function.LongBinaryOperator value_evaluator, java.util.function.LongUnaryOperator tie_breaker)
-
makePhase
public DecisionBuilder makePhase(IntVar[] vars, java.util.function.LongUnaryOperator var_evaluator, java.util.function.LongBinaryOperator value_evaluator, java.util.function.LongUnaryOperator tie_breaker)
-
makeDefaultPhase
public DecisionBuilder makeDefaultPhase(IntVar[] vars)
-
makeDefaultPhase
public DecisionBuilder makeDefaultPhase(IntVar[] vars, DefaultPhaseParameters parameters)
-
makePhase
public DecisionBuilder makePhase(IntVar v0, int var_str, int val_str)
Shortcuts for small arrays.
-
makePhase
public DecisionBuilder makePhase(IntVar v0, IntVar v1, int var_str, int val_str)
-
makePhase
public DecisionBuilder makePhase(IntVar v0, IntVar v1, IntVar v2, int var_str, int val_str)
-
makePhase
public DecisionBuilder makePhase(IntVar v0, IntVar v1, IntVar v2, IntVar v3, int var_str, int val_str)
-
makeScheduleOrPostpone
public Decision makeScheduleOrPostpone(IntervalVar var, long est, SWIGTYPE_p_long_long marker)
Returns a decision that tries to schedule a task at a given time.
On the Apply branch, it will set that interval var as performed and set
its start to 'est'. On the Refute branch, it will just update the
'marker' to 'est' + 1. This decision is used in the
INTERVAL_SET_TIMES_FORWARD strategy.
-
makeScheduleOrExpedite
public Decision makeScheduleOrExpedite(IntervalVar var, long est, SWIGTYPE_p_long_long marker)
Returns a decision that tries to schedule a task at a given time.
On the Apply branch, it will set that interval var as performed and set
its end to 'est'. On the Refute branch, it will just update the
'marker' to 'est' - 1. This decision is used in the
INTERVAL_SET_TIMES_BACKWARD strategy.
-
makeRankFirstInterval
public Decision makeRankFirstInterval(SequenceVar sequence, int index)
Returns a decision that tries to rank first the ith interval var
in the sequence variable.
-
makeRankLastInterval
public Decision makeRankLastInterval(SequenceVar sequence, int index)
Returns a decision that tries to rank last the ith interval var
in the sequence variable.
-
makePhase
public DecisionBuilder makePhase(IntVar[] vars, java.util.function.LongBinaryOperator eval, int str)
Returns a decision builder which assigns values to variables which
minimize the values returned by the evaluator. The arguments passed to the
evaluator callback are the indices of the variables in vars and the values
of these variables. Ownership of the callback is passed to the decision
builder.
-
makePhase
public DecisionBuilder makePhase(IntVar[] vars, java.util.function.LongBinaryOperator eval, java.util.function.LongUnaryOperator tie_breaker, int str)
Returns a decision builder which assigns values to variables
which minimize the values returned by the evaluator. In case of
tie breaks, the second callback is used to choose the best index
in the array of equivalent pairs with equivalent evaluations. The
arguments passed to the evaluator callback are the indices of the
variables in vars and the values of these variables. Ownership of
the callback is passed to the decision builder.
-
makePhase
public DecisionBuilder makePhase(IntervalVar[] intervals, int str)
Scheduling phases.
-
makePhase
public DecisionBuilder makePhase(SequenceVar[] sequences, int str)
-
makeDecisionBuilderFromAssignment
public DecisionBuilder makeDecisionBuilderFromAssignment(Assignment assignment, DecisionBuilder db, IntVar[] vars)
Returns a decision builder for which the left-most leaf corresponds
to assignment, the rest of the tree being explored using 'db'.
-
makeConstraintAdder
public DecisionBuilder makeConstraintAdder(Constraint ct)
Returns a decision builder that will add the given constraint to
the model.
-
makeSolveOnce
public DecisionBuilder makeSolveOnce(DecisionBuilder db)
SolveOnce will collapse a search tree described by a decision
builder 'db' and a set of monitors and wrap it into a single point.
If there are no solutions to this nested tree, then SolveOnce will
fail. If there is a solution, it will find it and returns nullptr.
-
makeSolveOnce
public DecisionBuilder makeSolveOnce(DecisionBuilder db, SearchMonitor monitor1)
-
makeSolveOnce
public DecisionBuilder makeSolveOnce(DecisionBuilder db, SearchMonitor monitor1, SearchMonitor monitor2)
-
makeSolveOnce
public DecisionBuilder makeSolveOnce(DecisionBuilder db, SearchMonitor monitor1, SearchMonitor monitor2, SearchMonitor monitor3)
-
makeSolveOnce
public DecisionBuilder makeSolveOnce(DecisionBuilder db, SearchMonitor monitor1, SearchMonitor monitor2, SearchMonitor monitor3, SearchMonitor monitor4)
-
makeSolveOnce
public DecisionBuilder makeSolveOnce(DecisionBuilder db, SearchMonitor[] monitors)
-
makeNestedOptimize
public DecisionBuilder makeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step)
NestedOptimize will collapse a search tree described by a
decision builder 'db' and a set of monitors and wrap it into a
single point. If there are no solutions to this nested tree, then
NestedOptimize will fail. If there are solutions, it will find
the best as described by the mandatory objective in the solution
as well as the optimization direction, instantiate all variables
to this solution, and return nullptr.
-
makeNestedOptimize
public DecisionBuilder makeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor monitor1)
-
makeNestedOptimize
public DecisionBuilder makeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor monitor1, SearchMonitor monitor2)
-
makeNestedOptimize
public DecisionBuilder makeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor monitor1, SearchMonitor monitor2, SearchMonitor monitor3)
-
makeNestedOptimize
public DecisionBuilder makeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor monitor1, SearchMonitor monitor2, SearchMonitor monitor3, SearchMonitor monitor4)
-
makeNestedOptimize
public DecisionBuilder makeNestedOptimize(DecisionBuilder db, Assignment solution, boolean maximize, long step, SearchMonitor[] monitors)
-
makeRestoreAssignment
public DecisionBuilder makeRestoreAssignment(Assignment assignment)
Returns a DecisionBuilder which restores an Assignment
(calls void Assignment::Restore())
-
makeStoreAssignment
public DecisionBuilder makeStoreAssignment(Assignment assignment)
Returns a DecisionBuilder which stores an Assignment
(calls void Assignment::Store())
-
makeOperator
public LocalSearchOperator makeOperator(IntVar[] vars, int op, SWIGTYPE_p_std__functionT_std__vectorT_int_t_const_Rfint_intF_t get_neighbors)
Local Search Operators.
-
makeOperator
public LocalSearchOperator makeOperator(IntVar[] vars, int op)
Local Search Operators.
-
makeOperator
public LocalSearchOperator makeOperator(IntVar[] vars, IntVar[] secondary_vars, int op, SWIGTYPE_p_std__functionT_std__vectorT_int_t_const_Rfint_intF_t get_neighbors)
-
makeOperator
public LocalSearchOperator makeOperator(IntVar[] vars, IntVar[] secondary_vars, int op)
-
makeOperator
public LocalSearchOperator makeOperator(IntVar[] vars, LongTernaryOperator evaluator, int op)
-
makeOperator
public LocalSearchOperator makeOperator(IntVar[] vars, IntVar[] secondary_vars, LongTernaryOperator evaluator, int op)
-
makeRandomLnsOperator
public LocalSearchOperator makeRandomLnsOperator(IntVar[] vars, int number_of_variables)
Creates a large neighborhood search operator which creates fragments (set
of relaxed variables) with up to number_of_variables random variables
(sampling with replacement is performed meaning that at most
number_of_variables variables are selected). Warning: this operator will
always return neighbors; using it without a search limit will result in a
non-ending search.
Optionally a random seed can be specified.
-
makeRandomLnsOperator
public LocalSearchOperator makeRandomLnsOperator(IntVar[] vars, int number_of_variables, int seed)
-
makeMoveTowardTargetOperator
public LocalSearchOperator makeMoveTowardTargetOperator(Assignment target)
Creates a local search operator that tries to move the assignment of some
variables toward a target. The target is given as an Assignment. This
operator generates neighbors in which the only difference compared to the
current state is that one variable that belongs to the target assignment
is set to its target value.
-
makeMoveTowardTargetOperator
public LocalSearchOperator makeMoveTowardTargetOperator(IntVar[] variables, long[] target_values)
Creates a local search operator that tries to move the assignment of some
variables toward a target. The target is given either as two vectors: a
vector of variables and a vector of associated target values. The two
vectors should be of the same length. This operator generates neighbors in
which the only difference compared to the current state is that one
variable that belongs to the given vector is set to its target value.
-
concatenateOperators
public LocalSearchOperator concatenateOperators(LocalSearchOperator[] ops)
Creates a local search operator which concatenates a vector of operators.
Each operator from the vector is called sequentially. By default, when a
neighbor is found the neighborhood exploration restarts from the last
active operator (the one which produced the neighbor).
This can be overridden by setting restart to true to force the exploration
to start from the first operator in the vector.
The default behavior can also be overridden using an evaluation callback
to set the order in which the operators are explored (the callback is
called in LocalSearchOperator::Start()). The first argument of the
callback is the index of the operator which produced the last move, the
second argument is the index of the operator to be evaluated. Ownership of
the callback is taken by ConcatenateOperators.
Example:
const int kPriorities = {10, 100, 10, 0};
int64_t Evaluate(int active_operator, int current_operator) {
return kPriorities[current_operator];
}
LocalSearchOperator* concat =
solver.ConcatenateOperators(operators,
NewPermanentCallback(&Evaluate));
The elements of the vector operators will be sorted by increasing priority
and explored in that order (tie-breaks are handled by keeping the relative
operator order in the vector). This would result in the following order:
operators[3], operators[0], operators[2], operators[1].
-
concatenateOperators
public LocalSearchOperator concatenateOperators(LocalSearchOperator[] ops, boolean restart)
-
concatenateOperators
public LocalSearchOperator concatenateOperators(LocalSearchOperator[] ops, IntIntToLongFunction evaluator)
-
randomConcatenateOperators
public LocalSearchOperator randomConcatenateOperators(LocalSearchOperator[] ops)
Randomized version of local search concatenator; calls a random operator
at each call to MakeNextNeighbor().
-
randomConcatenateOperators
public LocalSearchOperator randomConcatenateOperators(LocalSearchOperator[] ops, int seed)
Randomized version of local search concatenator; calls a random operator
at each call to MakeNextNeighbor(). The provided seed is used to
initialize the random number generator.
-
MultiArmedBanditConcatenateOperators
public LocalSearchOperator MultiArmedBanditConcatenateOperators(LocalSearchOperator[] ops, double memory_coefficient, double exploration_coefficient, boolean maximize)
Creates a local search operator which concatenates a vector of operators.
Uses Multi-Armed Bandit approach for choosing the next operator to use.
Sorts operators based on Upper Confidence Bound Algorithm which evaluates
each operator as sum of average improvement and exploration function.
Updates the order of operators when accepts a neighbor with objective
improvement.
-
makeNeighborhoodLimit
public LocalSearchOperator makeNeighborhoodLimit(LocalSearchOperator op, long limit)
Creates a local search operator that wraps another local search
operator and limits the number of neighbors explored (i.e., calls
to MakeNextNeighbor from the current solution (between two calls
to Start()). When this limit is reached, MakeNextNeighbor()
returns false. The counter is cleared when Start() is called.
-
makeLocalSearchPhase
public DecisionBuilder makeLocalSearchPhase(Assignment assignment, LocalSearchPhaseParameters parameters)
Local Search decision builders factories.
Local search is used to improve a given solution. This initial solution
can be specified either by an Assignment or by a DecisionBulder, and the
corresponding variables, the initial solution being the first solution
found by the DecisionBuilder.
The LocalSearchPhaseParameters parameter holds the actual definition of
the local search phase:
- a local search operator used to explore the neighborhood of the current
solution,
- a decision builder to instantiate unbound variables once a neighbor has
been defined; in the case of LNS-based operators instantiates fragment
variables; search monitors can be added to this sub-search by wrapping
the decision builder with MakeSolveOnce.
- a search limit specifying how long local search looks for neighbors
before accepting one; the last neighbor is always taken and in the case
of a greedy search, this corresponds to the best local neighbor;
first-accept (which is the default behavior) can be modeled using a
solution found limit of 1,
- a vector of local search filters used to speed up the search by pruning
unfeasible neighbors.
Metaheuristics can be added by defining specialized search monitors;
currently down/up-hill climbing is available through OptimizeVar, as well
as Guided Local Search, Tabu Search and Simulated Annealing.
-
makeLocalSearchPhase
public DecisionBuilder makeLocalSearchPhase(IntVar[] vars, DecisionBuilder first_solution, LocalSearchPhaseParameters parameters)
-
makeLocalSearchPhase
public DecisionBuilder makeLocalSearchPhase(IntVar[] vars, DecisionBuilder first_solution, DecisionBuilder first_solution_sub_decision_builder, LocalSearchPhaseParameters parameters)
Variant with a sub_decison_builder specific to the first solution.
-
makeLocalSearchPhase
public DecisionBuilder makeLocalSearchPhase(SequenceVar[] vars, DecisionBuilder first_solution, LocalSearchPhaseParameters parameters)
-
makeDefaultSolutionPool
public SolutionPool makeDefaultSolutionPool()
Solution Pool.
-
makeLocalSearchPhaseParameters
public LocalSearchPhaseParameters makeLocalSearchPhaseParameters(IntVar objective, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder)
Local Search Phase Parameters
-
makeLocalSearchPhaseParameters
public LocalSearchPhaseParameters makeLocalSearchPhaseParameters(IntVar objective, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder, RegularLimit limit)
-
makeLocalSearchPhaseParameters
public LocalSearchPhaseParameters makeLocalSearchPhaseParameters(IntVar objective, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder, RegularLimit limit, LocalSearchFilterManager filter_manager)
-
makeLocalSearchPhaseParameters
public LocalSearchPhaseParameters makeLocalSearchPhaseParameters(IntVar objective, SolutionPool pool, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder)
-
makeLocalSearchPhaseParameters
public LocalSearchPhaseParameters makeLocalSearchPhaseParameters(IntVar objective, SolutionPool pool, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder, RegularLimit limit)
-
makeLocalSearchPhaseParameters
public LocalSearchPhaseParameters makeLocalSearchPhaseParameters(IntVar objective, SolutionPool pool, LocalSearchOperator ls_operator, DecisionBuilder sub_decision_builder, RegularLimit limit, LocalSearchFilterManager filter_manager)
-
MakeAcceptFilter
public LocalSearchFilter MakeAcceptFilter()
Local Search Filters
-
MakeRejectFilter
public LocalSearchFilter MakeRejectFilter()
-
makeVariableDomainFilter
public LocalSearchFilter makeVariableDomainFilter()
-
makeSumObjectiveFilter
public IntVarLocalSearchFilter makeSumObjectiveFilter(IntVar[] vars, java.util.function.LongBinaryOperator values, int filter_enum)
-
makeSumObjectiveFilter
public IntVarLocalSearchFilter makeSumObjectiveFilter(IntVar[] vars, IntVar[] secondary_vars, LongTernaryOperator values, int filter_enum)
-
topPeriodicCheck
public void topPeriodicCheck()
Performs PeriodicCheck on the top-level search; for instance, can be
called from a nested solve to check top-level limits.
-
topProgressPercent
public int topProgressPercent()
Returns a percentage representing the propress of the search before
reaching the limits of the top-level search (can be called from a nested
solve).
-
pushState
public void pushState()
The PushState and PopState methods manipulates the states
of the reversible objects. They are visible only because they
are useful to write unitary tests.
-
popState
public void popState()
-
searchDepth
public int searchDepth()
Gets the search depth of the current active search. Returns -1 if
there is no active search opened.
-
searchLeftDepth
public int searchLeftDepth()
Gets the search left depth of the current active search. Returns -1 if
there is no active search opened.
-
solveDepth
public int solveDepth()
Gets the number of nested searches. It returns 0 outside search,
1 during the top level search, 2 or more in case of nested searches.
-
rand64
public long rand64(long size)
Returns a random value between 0 and 'size' - 1;
-
rand32
public int rand32(int size)
Returns a random value between 0 and 'size' - 1;
-
reSeed
public void reSeed(int seed)
Reseed the solver random generator.
-
exportProfilingOverview
public void exportProfilingOverview(java.lang.String filename)
Exports the profiling information in a human readable overview.
The parameter profile_level used to create the solver must be
set to true.
-
localSearchProfile
public java.lang.String localSearchProfile()
Returns local search profiling information in a human readable format.
-
currentlyInSolve
public boolean currentlyInSolve()
Returns true whether the current search has been
created using a Solve() call instead of a NewSearch one. It
returns false if the solver is not in search at all.
-
constraints
public int constraints()
Counts the number of constraints that have been added
to the solver before the search.
-
accept
public void accept(ModelVisitor visitor)
Accepts the given model visitor.
-
balancing_decision
public Decision balancing_decision()
-
clear_fail_intercept
public void clear_fail_intercept()
Internal
-
SetUseFastLocalSearch
public void SetUseFastLocalSearch(boolean use_fast_local_search)
enabled for metaheuristics.
Disables/enables fast local search.
-
UseFastLocalSearch
public boolean UseFastLocalSearch()
Returns true if fast local search is enabled.
-
hasName
public boolean hasName(PropagationBaseObject object)
Returns whether the object has been named or not.
-
registerDemon
public Demon registerDemon(Demon demon)
Adds a new demon and wraps it inside a DemonProfiler if necessary.
-
registerIntExpr
public IntExpr registerIntExpr(IntExpr expr)
Registers a new IntExpr and wraps it inside a TraceIntExpr if necessary.
-
registerIntVar
public IntVar registerIntVar(IntVar var)
Registers a new IntVar and wraps it inside a TraceIntVar if necessary.
-
registerIntervalVar
public IntervalVar registerIntervalVar(IntervalVar var)
Registers a new IntervalVar and wraps it inside a TraceIntervalVar
if necessary.
-
cache
public ModelCache cache()
Returns the cache of the model.
-
instrumentsDemons
public boolean instrumentsDemons()
Returns whether we are instrumenting demons.
-
isProfilingEnabled
public boolean isProfilingEnabled()
Returns whether we are profiling the solver.
-
isLocalSearchProfilingEnabled
public boolean isLocalSearchProfilingEnabled()
Returns whether we are profiling local search.
-
instrumentsVariables
public boolean instrumentsVariables()
Returns whether we are tracing variables.
-
nameAllVariables
public boolean nameAllVariables()
Returns whether all variables should be named.
-
model_name
public java.lang.String model_name()
Returns the name of the model.
-
getPropagationMonitor
public PropagationMonitor getPropagationMonitor()
Returns the propagation monitor.
-
addPropagationMonitor
public void addPropagationMonitor(PropagationMonitor monitor)
Adds the propagation monitor to the solver. This is called internally when
a propagation monitor is passed to the Solve() or NewSearch() method.
-
getLocalSearchMonitor
public LocalSearchMonitor getLocalSearchMonitor()
Returns the local search monitor.
-
addLocalSearchMonitor
public void addLocalSearchMonitor(LocalSearchMonitor monitor)
Adds the local search monitor to the solver. This is called internally
when a propagation monitor is passed to the Solve() or NewSearch() method.
-
GetOrCreateLocalSearchState
public Assignment GetOrCreateLocalSearchState()
Returns (or creates) an assignment representing the state of local search.
-
ClearLocalSearchState
public void ClearLocalSearchState()
Clears the local search state.
-
setTmpVector
public void setTmpVector(long[] value)
Unsafe temporary vector. It is used to avoid leaks in operations
that need storage and that may fail. See IntVar::SetValues() for
instance. It is not locked; do not use in a multi-threaded or reentrant
setup.
-
getTmpVector
public long[] getTmpVector()
Unsafe temporary vector. It is used to avoid leaks in operations
that need storage and that may fail. See IntVar::SetValues() for
instance. It is not locked; do not use in a multi-threaded or reentrant
setup.
-
castExpression
public IntExpr castExpression(IntVar var)
Internal. If the variables is the result of expr->Var(), this
method returns expr, nullptr otherwise.
-
finishCurrentSearch
public void finishCurrentSearch()
Tells the solver to kill or restart the current search.
-
restartCurrentSearch
public void restartCurrentSearch()
-
shouldFail
public void shouldFail()
These methods are only useful for the SWIG wrappers, which need a way
to externally cause the Solver to fail.
-
checkFail
public void checkFail()
-
MakeProfiledDecisionBuilderWrapper
public DecisionBuilder MakeProfiledDecisionBuilderWrapper(DecisionBuilder db)
Activates profiling on a decision builder.
-
-