java.lang.Object
org.maxicp.ModelDispatcher
- All Implemented Interfaces:
AutoCloseable,ModelProxyInstantiatorWithCP,ModelProxy,ModelProxyInstantiator
public class ModelDispatcher
extends Object
implements ModelProxyInstantiator, AutoCloseable, ModelProxyInstantiatorWithCP, ModelProxy
A class that allows to create symbolic models
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.maxicp.modeling.ModelProxy
ModelProxy.NotConcreteExceptionNested classes/interfaces inherited from interface org.maxicp.modeling.ModelProxyInstantiator
ModelProxyInstantiator.ModelInstantiator<T extends ConcreteModel> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddVariableGroup(List<IntExpression> group) <U extends Comparable<U>>
BestFirstSearch<U> bestFirstSearch(Supplier<Runnable[]> branching, Supplier<U> nodeEvaluator) Creates a black-box search that automatically discovers the model's decision variables (eitherIntervalVars for scheduling models orIntVars for combinatorial models).blackBoxSearch(IntExpression... vars) Creates a black-box search over the specified integer decision variables.blackBoxSearch(IntervalVar... intervals) Creates a black-box search over the specified interval variables.blackBoxSearch(IntervalVar[][] intervals) Creates a black-box search over the specified 2D matrix of interval variables.boolVar()BoolVar[]boolVarArray(int n) voidclose()concurrentDFSearch(Supplier<SymbolicModel[]> symbolicBranching) constant(int value) Shortcut for baseModel.getModel().getConstraints();Infers the decision variables from the constraint graph of the current model.Infers the interval variables from the constraint graph and variable registrations of the current model.getModel()Returns allIntervalVarinstances created on this model dispatcher.Returns all non-constantIntVarinstances created on this model dispatcher.intervalVar(boolean isPresent) intervalVar(int duration, boolean isPresent) intervalVar(int startMin, int endMax, int duration, boolean isPresent) intervalVar(int startMin, int startMax, int endMin, int endMax, int lengthMin, int lengthMax, boolean isPresent) intervalVarArray(int n, boolean present) intervalVarArray(int n, Function<Integer, IntervalVar> body) intVar(int[] values) intVar(int min, int max) IntVar[]intVarArray(int n, int domSize) Create an array of n IntVars with domain between 0 and domSize-1, inclusive.intVarArray(int n, Function<Integer, IntExpression> body) booleanInstantiates the model and optimizes the given objective using black-box search.Instantiates the model and optimizes the given objective using black-box search within the given time limit (in seconds).optimize(Objective objective, Predicate<SearchStatistics> limit) Instantiates the model and optimizes the given objective using black-box search with a stopping predicate.<T extends IntervalVar>
T<T extends IntVar>
TregisterRawIntVar(T v) seqVar(int nNode, int begin, int end) <T extends Model>
TsetModel(T m) Set the current model to m. m should have this base model as origin.solve()Instantiates the model and solves it using black-box search.solve(int timeLimitInSeconds) Instantiates the model and solves it using black-box search within the given time limit (in seconds).solve(Predicate<SearchStatistics> limit) Instantiates the model and solves it using black-box search with a stopping predicate.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.maxicp.modeling.ModelProxy
add, add, add, add, fixpoint, getConcreteModel, getSymbolicModel, isConcrete, isSymbolic, runWithModel, runWithModelMethods inherited from interface org.maxicp.modeling.ModelProxyInstantiator
instantiate, runAsConcrete, runAsConcrete, runAsConcrete, runAsConcrete, runAsConcrete, runAsConcrete, runAsConcrete, runAsConcreteMethods inherited from interface org.maxicp.cp.modeling.ModelProxyInstantiatorWithCP
cpInstantiate, runCP, runCP, runCP, runCP, runCP, runCP, runCP, runCP
-
Constructor Details
-
ModelDispatcher
public ModelDispatcher() -
ModelDispatcher
public ModelDispatcher(boolean rawSolver)
-
-
Method Details
-
isRawSolver
public boolean isRawSolver() -
getModel
- Specified by:
getModelin interfaceModelProxy- Returns:
- the current model
-
setModel
Set the current model to m. m should have this base model as origin.- Specified by:
setModelin interfaceModelProxy- Parameters:
m-
-
getConstraints
Shortcut for baseModel.getModel().getConstraints();- Returns:
- an iterable with all the constraints in the current model
-
getDecisionVariables
Infers the decision variables from the constraint graph of the current model.A variable is considered a decision variable when it appears as an "index / choice" argument in a constraint or expression that implements
DecisionVarsProvider. Examples: the index variable of anElement1D/2Dexpression, or any variable in the scope of anAllDifferent,Circuit,Table, etc.Only leaf
IntVarinstances are returned – derived expressions (sums, element results, views) are always excluded.The returned list is ordered by first-seen occurrence during a depth-first walk of the constraint graph and contains no duplicates (identity-based).
- Returns:
- unmodifiable list of candidate decision variables
- See Also:
-
getIntervalVariables
Infers the interval variables from the constraint graph and variable registrations of the current model.- Returns:
- unmodifiable list of interval variables
-
getRegisteredIntVars
Returns all non-constantIntVarinstances created on this model dispatcher. -
getRegisteredIntervalVars
Returns allIntervalVarinstances created on this model dispatcher. -
registerRawIntVar
-
registerRawIntervalVar
-
intVarArray
Create an array of n IntVars with domain between 0 and domSize-1, inclusive.- Parameters:
n- size of the array, number of IntVarsdomSize- size of the domains. Domains are [0, domsize-1]
-
intVarArray
-
intVar
-
intVar
-
intVar
-
intVar
-
intVar
-
constant
-
intervalVar
public IntervalVar intervalVar(int startMin, int startMax, int endMin, int endMax, int lengthMin, int lengthMax, boolean isPresent) -
intervalVar
-
intervalVar
-
intervalVar
-
intervalVarArray
-
intervalVarArray
-
boolVarArray
-
boolVar
-
seqVar
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
minimize
-
maximize
-
dfSearch
-
concurrentDFSearch
-
bestFirstSearch
public <U extends Comparable<U>> BestFirstSearch<U> bestFirstSearch(Supplier<Runnable[]> branching, Supplier<U> nodeEvaluator) -
blackBoxSearch
Creates a black-box search that automatically discovers the model's decision variables (eitherIntervalVars for scheduling models orIntVars for combinatorial models). -
blackBoxSearch
Creates a black-box search over the specified integer decision variables. -
blackBoxSearch
Creates a black-box search over the specified interval variables. -
blackBoxSearch
Creates a black-box search over the specified 2D matrix of interval variables. -
solve
Instantiates the model and solves it using black-box search. -
solve
Instantiates the model and solves it using black-box search within the given time limit (in seconds). -
solve
Instantiates the model and solves it using black-box search with a stopping predicate. -
optimize
Instantiates the model and optimizes the given objective using black-box search. -
optimize
Instantiates the model and optimizes the given objective using black-box search within the given time limit (in seconds). -
optimize
Instantiates the model and optimizes the given objective using black-box search with a stopping predicate. -
addVariableGroup
-