Package org.chocosolver.solver
Class DefaultSettings
- java.lang.Object
-
- org.chocosolver.solver.DefaultSettings
-
-
Constructor Summary
Constructors Constructor Description DefaultSettings()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckDeclaredConstraints()booleancheckModel(Solver solver)booleancloneVariableArrayInPropagator()StringdefaultPrefix()Define the prefix of internally created variables (through a call toIVariableFactory.generateName()booleanenableACOnTernarySum()booleanenableDecompositionOfBooleanSum()byteenableHybridizationOfPropagationEngine()booleanenableIncrementalityOnBoolSum(int nbvars)booleanenableSAT()booleanenableTableSubstitution()booleanenableViews()IConditiongetEnvironmentHistorySimulationCondition()intgetMaxDomSizeForEnumerated()intgetMaxTupleSizeForSubstitution()doublegetMCRDecimalPrecision()intgetMinCardForSumDecomposition()StringgetWelcomeMessage()SolverinitSolver(Model model)This method is called inModel(IEnvironment, String, Settings)to create the solver to associate with a model.AbstractStrategymakeDefaultSearch(Model model)Creates a default search strategy for the input modelDefaultSettingssetCheckDeclaredConstraints(boolean checkDeclaredConstraints)Indicate if the declared constraints are either posted or reified.DefaultSettingssetCloneVariableArrayInPropagator(boolean cloneVariableArrayInPropagator)If this setting is set to true (default value), a clone of the input variable array is made in any propagator constructors.DefaultSettingssetDefaultPrefix(String defaultPrefix)Define prefix of internally created variablesDefaultSettingssetDefaultSearch(Function<Model,AbstractStrategy> defaultSearch)Define a default search strategy for the input modelSettingssetEnableACOnTernarySum(boolean enable)If this is set to true then AC algorithm is used to filter ternary sum by default, otherwise, BC is used.DefaultSettingssetEnableDecompositionOfBooleanSum(boolean enableDecompositionOfBooleanSum)Define if boolean sums should be decomposed into an equality constraint + arithmetic constraintDefaultSettingssetEnableIncrementalityOnBoolSum(IntPredicate enableIncrementalityOnBoolSum)Define the predicate to choose incremental sum, based on number variables declaredDefaultSettingssetEnableSAT(boolean enableSAT)Indicate if clauses are managed by a unique SAT solver.DefaultSettingssetEnableTableSubstitution(boolean enableTableSubstitution)Define whether some intension constraints are replaced by extension constraintsDefaultSettingssetEnableViews(boolean enableViews)Set to 'true' to allow the creation of views in theModel.DefaultSettingssetEnvironmentHistorySimulationCondition(ICondition environmentHistorySimulationCondition)Set the condition to satisfy when rebuilding history of backtrackable objects is needed.SettingssetHybridizationOfPropagationEngine(byte hybrid)Define behavior of the propagation engine.DefaultSettingssetInitSolver(Function<Model,Solver> initSolver)Define the solver initializationDefaultSettingssetMaxDomSizeForEnumerated(int maxDomSizeForEnumerated)Define the minimum number of cardinality threshold to a sum/scalar constraint to be decomposed in intermediate sub-sums.DefaultSettingssetMaxTupleSizeForSubstitution(int maxTupleSizeForSubstitution)Define the maximum domain size threshold to replace intension constraints by extension constraints Only checked whenSettings.enableTableSubstitution()returnstrueSettingssetMCRDecimalPrecision(double precision)Defines the default smallest used double forIIntConstraintFactory.multiCostRegular(IntVar[], IntVar[], ICostAutomaton)algorithmSettingssetMinCardinalityForSumDecomposition(int defaultMinCardinalityForSumDecomposition)Define the default minimum number of cardinality threshold to a sum/scalar constraint to be decomposed into intermediate sub-sums.DefaultSettingssetModelChecker(Predicate<Solver> modelChecker)Define what to do when a solution is found.DefaultSettingssetSortPropagatorActivationWRTPriority(boolean sortPropagatorActivationWRTPriority)Set whether propagators are sorted wrt their priority inPropagationEnginewhen dealing with propagator activation.DefaultSettingssetSwapOnPassivate(boolean swapOnPassivate)Define if passivation of propagator swap it in variables' listDefaultSettingssetWarnUser(boolean warnUser)To be informed of warnings detected during modeling/solvingDefaultSettingssetWelcomeMessage(String welcomeMessage)Define the welcome message, printed in the consolebooleansortPropagatorActivationWRTPriority()booleanswapOnPassivate()booleanwarnUser()
-
-
-
Method Detail
-
getWelcomeMessage
public String getWelcomeMessage()
- Specified by:
getWelcomeMessagein interfaceSettings- Returns:
- the welcome message
-
setWelcomeMessage
public DefaultSettings setWelcomeMessage(String welcomeMessage)
Description copied from interface:SettingsDefine the welcome message, printed in the console- Specified by:
setWelcomeMessagein interfaceSettings- Parameters:
welcomeMessage- a message- Returns:
- the current instance
-
checkModel
public boolean checkModel(Solver solver)
- Specified by:
checkModelin interfaceSettings- Parameters:
solver- the solver- Returns:
- true if the model is OK wrt the checker, false otherwise
-
setModelChecker
public DefaultSettings setModelChecker(Predicate<Solver> modelChecker)
Description copied from interface:SettingsDefine what to do when a solution is found. By default, it makes a weak check of the model:A hard check of the model can be done like this:return !ESat.FALSE.equals(solver.isSatisfied());return ESat.TRUE.equals(solver.isSatisfied());- Specified by:
setModelCheckerin interfaceSettings- Parameters:
modelChecker- a predicate to check the solution- Returns:
- the current instance
-
enableViews
public boolean enableViews()
- Specified by:
enableViewsin interfaceSettings- Returns:
- true if views are enabled.
-
setEnableViews
public DefaultSettings setEnableViews(boolean enableViews)
Description copied from interface:SettingsSet to 'true' to allow the creation of views in theModel. Creates new variables with channeling constraints otherwise.- Specified by:
setEnableViewsin interfaceSettings- Parameters:
enableViews-trueto enable views- Returns:
- the current instance
-
getMaxDomSizeForEnumerated
public int getMaxDomSizeForEnumerated()
- Specified by:
getMaxDomSizeForEnumeratedin interfaceSettings- Returns:
- maximum domain size threshold to force integer variable to be enumerated
-
setMaxDomSizeForEnumerated
public DefaultSettings setMaxDomSizeForEnumerated(int maxDomSizeForEnumerated)
Description copied from interface:SettingsDefine the minimum number of cardinality threshold to a sum/scalar constraint to be decomposed in intermediate sub-sums.- Specified by:
setMaxDomSizeForEnumeratedin interfaceSettings- Parameters:
maxDomSizeForEnumerated- cardinality threshold- Returns:
- the current instance
-
getMinCardForSumDecomposition
public int getMinCardForSumDecomposition()
- Specified by:
getMinCardForSumDecompositionin interfaceSettings- Returns:
- minimum number of cardinality threshold to a sum constraint to be decomposed
-
setMinCardinalityForSumDecomposition
public Settings setMinCardinalityForSumDecomposition(int defaultMinCardinalityForSumDecomposition)
Description copied from interface:SettingsDefine the default minimum number of cardinality threshold to a sum/scalar constraint to be decomposed into intermediate sub-sums.- Specified by:
setMinCardinalityForSumDecompositionin interfaceSettings- Parameters:
defaultMinCardinalityForSumDecomposition- cardinality threshold- Returns:
- the current instance
-
enableTableSubstitution
public boolean enableTableSubstitution()
- Specified by:
enableTableSubstitutionin interfaceSettings- Returns:
- true if some intension constraints can be replaced by extension constraints
-
setEnableTableSubstitution
public DefaultSettings setEnableTableSubstitution(boolean enableTableSubstitution)
Description copied from interface:SettingsDefine whether some intension constraints are replaced by extension constraints- Specified by:
setEnableTableSubstitutionin interfaceSettings- Parameters:
enableTableSubstitution- enable table substitution- Returns:
- the current instance
-
getMaxTupleSizeForSubstitution
public int getMaxTupleSizeForSubstitution()
- Specified by:
getMaxTupleSizeForSubstitutionin interfaceSettings- Returns:
- maximum domain size threshold to replace intension constraints by extension constraints
-
getMCRDecimalPrecision
public double getMCRDecimalPrecision()
- Specified by:
getMCRDecimalPrecisionin interfaceSettings- Returns:
- the smallest used double for
IIntConstraintFactory.multiCostRegular(IntVar[], IntVar[], ICostAutomaton)algorithm
-
setMCRDecimalPrecision
public Settings setMCRDecimalPrecision(double precision)
Description copied from interface:SettingsDefines the default smallest used double forIIntConstraintFactory.multiCostRegular(IntVar[], IntVar[], ICostAutomaton)algorithm- Specified by:
setMCRDecimalPrecisionin interfaceSettings- Parameters:
precision- default precision for MCR- Returns:
- the current instance
-
setMaxTupleSizeForSubstitution
public DefaultSettings setMaxTupleSizeForSubstitution(int maxTupleSizeForSubstitution)
Description copied from interface:SettingsDefine the maximum domain size threshold to replace intension constraints by extension constraints Only checked whenSettings.enableTableSubstitution()returnstrue- Specified by:
setMaxTupleSizeForSubstitutionin interfaceSettings- Parameters:
maxTupleSizeForSubstitution- threshold to substitute intension constraint by table one.- Returns:
- the current instance
-
sortPropagatorActivationWRTPriority
public boolean sortPropagatorActivationWRTPriority()
- Specified by:
sortPropagatorActivationWRTPriorityin interfaceSettings- Returns:
trueif propagators are sorted wrt their priority on initial activation.
-
setSortPropagatorActivationWRTPriority
public DefaultSettings setSortPropagatorActivationWRTPriority(boolean sortPropagatorActivationWRTPriority)
Description copied from interface:SettingsSet whether propagators are sorted wrt their priority inPropagationEnginewhen dealing with propagator activation.- Specified by:
setSortPropagatorActivationWRTPriorityin interfaceSettings- Parameters:
sortPropagatorActivationWRTPriority-trueto allow sorting static propagators.- Returns:
- the current instance
-
makeDefaultSearch
public AbstractStrategy makeDefaultSearch(Model model)
Description copied from interface:SettingsCreates a default search strategy for the input model- Specified by:
makeDefaultSearchin interfaceSettings- Parameters:
model- a model requiring a default search strategy- Returns:
- a default search strategy for model
- See Also:
Search.defaultSearch(Model)
-
setDefaultSearch
public DefaultSettings setDefaultSearch(Function<Model,AbstractStrategy> defaultSearch)
Description copied from interface:SettingsDefine a default search strategy for the input model- Specified by:
setDefaultSearchin interfaceSettings- Parameters:
defaultSearch- what default search strategy should be- Returns:
- the current instance
-
getEnvironmentHistorySimulationCondition
public ICondition getEnvironmentHistorySimulationCondition()
- Specified by:
getEnvironmentHistorySimulationConditionin interfaceSettings- Returns:
- the condition to satisfy when rebuilding history of backtrackable objects is needed.
-
setEnvironmentHistorySimulationCondition
public DefaultSettings setEnvironmentHistorySimulationCondition(ICondition environmentHistorySimulationCondition)
Description copied from interface:SettingsSet the condition to satisfy when rebuilding history of backtrackable objects is needed. Building "fake" history is needed when a backtrackable object is created during the search, in order to restore a correct state upon backtrack. The default condition is "at least one env.worldPush() has been called since the creation of the bck object". The condition can be set toICondition.FALSEif no backtrackable object is created during the search.- Specified by:
setEnvironmentHistorySimulationConditionin interfaceSettings- Parameters:
environmentHistorySimulationCondition- the condition to satisfy when rebuilding history of backtrackable objects is needed.- Returns:
- the current instance
-
warnUser
public boolean warnUser()
-
setWarnUser
public DefaultSettings setWarnUser(boolean warnUser)
Description copied from interface:SettingsTo be informed of warnings detected during modeling/solving- Specified by:
setWarnUserin interfaceSettings- Parameters:
warnUser-trueto be print warnings on console- Returns:
- the current instance
-
enableDecompositionOfBooleanSum
public boolean enableDecompositionOfBooleanSum()
- Specified by:
enableDecompositionOfBooleanSumin interfaceSettings- Returns:
trueif boolean sum should be decomposed into an equality constraint and an arithmetic constraint,falseif a single constraint should be used instead.
-
setEnableDecompositionOfBooleanSum
public DefaultSettings setEnableDecompositionOfBooleanSum(boolean enableDecompositionOfBooleanSum)
Description copied from interface:SettingsDefine if boolean sums should be decomposed into an equality constraint + arithmetic constraint- Specified by:
setEnableDecompositionOfBooleanSumin interfaceSettings- Parameters:
enableDecompositionOfBooleanSum-trueto enable decomposition- Returns:
- the current instance
-
enableIncrementalityOnBoolSum
public boolean enableIncrementalityOnBoolSum(int nbvars)
- Specified by:
enableIncrementalityOnBoolSumin interfaceSettings- Parameters:
nbvars- number of variables in the constraint- Returns:
trueif the incrementality is enabled on boolean sum, based on the number of variables involved.
-
setEnableIncrementalityOnBoolSum
public DefaultSettings setEnableIncrementalityOnBoolSum(IntPredicate enableIncrementalityOnBoolSum)
Description copied from interface:SettingsDefine the predicate to choose incremental sum, based on number variables declared- Specified by:
setEnableIncrementalityOnBoolSumin interfaceSettings- Parameters:
enableIncrementalityOnBoolSum- predicate to pick declare sum- Returns:
- the current instance
-
cloneVariableArrayInPropagator
public boolean cloneVariableArrayInPropagator()
- Specified by:
cloneVariableArrayInPropagatorin interfaceSettings- Returns:
- true if all propagators should clone the input variable array instead of simply referencing it.
-
setCloneVariableArrayInPropagator
public DefaultSettings setCloneVariableArrayInPropagator(boolean cloneVariableArrayInPropagator)
Description copied from interface:SettingsIf this setting is set to true (default value), a clone of the input variable array is made in any propagator constructors. This prevents, for instance, wrong behavior when permutations occurred on the input array (e.g., sorting variables). Setting this to false may limit the memory consumption during modelling.- Specified by:
setCloneVariableArrayInPropagatorin interfaceSettings- Parameters:
cloneVariableArrayInPropagator-trueto clone variables array on constructor- Returns:
- the current instance
-
enableACOnTernarySum
public boolean enableACOnTernarySum()
- Specified by:
enableACOnTernarySumin interfaceSettings- Returns:
- true if AC is enabled to filter ternary sums by default.
-
setEnableACOnTernarySum
public Settings setEnableACOnTernarySum(boolean enable)
Description copied from interface:SettingsIf this is set to true then AC algorithm is used to filter ternary sum by default, otherwise, BC is used. Note AC brings more filtering when there are holes in variable domains but this comes at a cost.- Specified by:
setEnableACOnTernarySumin interfaceSettings- Parameters:
enable-trueto enable AC by default- Returns:
- the current instance
-
defaultPrefix
public String defaultPrefix()
Description copied from interface:SettingsDefine the prefix of internally created variables (through a call toIVariableFactory.generateName()- Specified by:
defaultPrefixin interfaceSettings- Returns:
- the prefix of all internally created variables
-
setDefaultPrefix
public DefaultSettings setDefaultPrefix(String defaultPrefix)
Description copied from interface:SettingsDefine prefix of internally created variables- Specified by:
setDefaultPrefixin interfaceSettings- Parameters:
defaultPrefix- prefix of internally created variables' name- Returns:
- the current instance
-
enableSAT
public boolean enableSAT()
- Specified by:
enableSATin interfaceSettings- Returns:
- true when an underlying SAT solver is used to manage clauses declared through
ISatFactory, false when clauses are managed with CSP constraints only.
-
setEnableSAT
public DefaultSettings setEnableSAT(boolean enableSAT)
Description copied from interface:SettingsIndicate if clauses are managed by a unique SAT solver.- Specified by:
setEnableSATin interfaceSettings- Parameters:
enableSAT-trueto rely on SAT Solver to handle clauses- Returns:
- the current instance
-
swapOnPassivate
public boolean swapOnPassivate()
- Specified by:
swapOnPassivatein interfaceSettings- Returns:
- true if, on propagator passivation, the propagator is swapped from active to passive in its variables' propagators list. false if, on propagator passivation, only the propagator's state is set to PASSIVE.
-
setSwapOnPassivate
public DefaultSettings setSwapOnPassivate(boolean swapOnPassivate)
Description copied from interface:SettingsDefine if passivation of propagator swap it in variables' list- Specified by:
setSwapOnPassivatein interfaceSettings- Parameters:
swapOnPassivate-trueto enable swapping- Returns:
- the current instance
-
checkDeclaredConstraints
public boolean checkDeclaredConstraints()
- Specified by:
checkDeclaredConstraintsin interfaceSettings- Returns:
- true (default value) to check if all declared constraints are not free anymore, that is either posted or reified, before running the resolution. false to skip the control.
-
setCheckDeclaredConstraints
public DefaultSettings setCheckDeclaredConstraints(boolean checkDeclaredConstraints)
Description copied from interface:SettingsIndicate if the declared constraints are either posted or reified.- Specified by:
setCheckDeclaredConstraintsin interfaceSettings- Parameters:
checkDeclaredConstraints-trueto check constraints before resolution- Returns:
- the current instance
-
initSolver
public Solver initSolver(Model model)
Description copied from interface:SettingsThis method is called inModel(IEnvironment, String, Settings)to create the solver to associate with a model.- Specified by:
initSolverin interfaceSettings- Parameters:
model- a model to initialize with a solver- Returns:
- the new solver
-
setInitSolver
public DefaultSettings setInitSolver(Function<Model,Solver> initSolver)
Description copied from interface:SettingsDefine the solver initialization- Specified by:
setInitSolverin interfaceSettings- Parameters:
initSolver- function to initialize the solver- Returns:
- the current instance
-
enableHybridizationOfPropagationEngine
public byte enableHybridizationOfPropagationEngine()
- Specified by:
enableHybridizationOfPropagationEnginein interfaceSettings- Returns:
- 0b00 if constraint-oriented propagation engine, 0b01 if hybridization between variable and constraint oriented and 0b10 if variable-oriented.
-
setHybridizationOfPropagationEngine
public Settings setHybridizationOfPropagationEngine(byte hybrid)
Description copied from interface:SettingsDefine behavior of the propagation engine.- Specified by:
setHybridizationOfPropagationEnginein interfaceSettings- Parameters:
hybrid- When set to '0b00', this works as a constraint-oriented propagation engine; when set to '0b01', this workds as an hybridization between variable and constraint oriented propagation engine. when set to '0b10', this workds as a variable- oriented propagation engine.- Returns:
- the current instance
-
-