Package org.chocosolver.solver
Interface Settings
-
- All Known Implementing Classes:
DefaultSettings
public interface SettingsSettings forModel.Created by cprudhom on 25/11/14. Project: choco.
- Author:
- Charles Prud'homme
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default 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.default Settingsload(InputStream inStream)Load some settings from a property file.default Settingsload(Properties properties)Load some settings from a property file.AbstractStrategymakeDefaultSearch(Model model)Creates a default search strategy for the input modelSettingssetCheckDeclaredConstraints(boolean checkDeclaredConstraints)Indicate if the declared constraints are either posted or reified.SettingssetCloneVariableArrayInPropagator(boolean cloneVariableArrayInPropagator)If this setting is set to true (default value), a clone of the input variable array is made in any propagator constructors.SettingssetDefaultPrefix(String defaultPrefix)Define prefix of internally created variablesSettingssetDefaultSearch(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.SettingssetEnableDecompositionOfBooleanSum(boolean enableDecompositionOfBooleanSum)Define if boolean sums should be decomposed into an equality constraint + arithmetic constraintSettingssetEnableIncrementalityOnBoolSum(IntPredicate enableIncrementalityOnBoolSum)Define the predicate to choose incremental sum, based on number variables declaredSettingssetEnableSAT(boolean enableSAT)Indicate if clauses are managed by a unique SAT solver.SettingssetEnableTableSubstitution(boolean enableTableSubstitution)Define whether some intension constraints are replaced by extension constraintsSettingssetEnableViews(boolean enableViews)Set to 'true' to allow the creation of views in theModel.SettingssetEnvironmentHistorySimulationCondition(ICondition environmentHistorySimulationCondition)Set the condition to satisfy when rebuilding history of backtrackable objects is needed.SettingssetHybridizationOfPropagationEngine(byte hybrid)Define behavior of the propagation engine.SettingssetInitSolver(Function<Model,Solver> initSolver)Define the solver initializationSettingssetMaxDomSizeForEnumerated(int maxDomSizeForEnumerated)Define the minimum number of cardinality threshold to a sum/scalar constraint to be decomposed in intermediate sub-sums.SettingssetMaxTupleSizeForSubstitution(int maxTupleSizeForSubstitution)Define the maximum domain size threshold to replace intension constraints by extension constraints Only checked whenenableTableSubstitution()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.SettingssetModelChecker(Predicate<Solver> modelChecker)Define what to do when a solution is found.SettingssetSortPropagatorActivationWRTPriority(boolean sortPropagatorActivationWRTPriority)Set whether propagators are sorted wrt their priority inPropagationEnginewhen dealing with propagator activation.SettingssetSwapOnPassivate(boolean swapOnPassivate)Define if passivation of propagator swap it in variables' listSettingssetWarnUser(boolean warnUser)To be informed of warnings detected during modeling/solvingSettingssetWelcomeMessage(String welcomeMessage)Define the welcome message, printed in the consolebooleansortPropagatorActivationWRTPriority()default Propertiesstore()Store some settings into a property file.default voidstore(OutputStream out, String comments)Store some settings into a property file.booleanswapOnPassivate()booleanwarnUser()
-
-
-
Method Detail
-
load
default Settings load(Properties properties)
Load some settings from a property file. The following settings cannot be loaded from a property file:- Parameters:
properties- a property file to load setting from.- Returns:
- the current instance
-
load
default Settings load(InputStream inStream) throws IOException
Load some settings from a property file. The following settings cannot be loaded from a property file:- Parameters:
inStream- the input stream.- Returns:
- the current instance
- Throws:
IOException- if an error occurred when reading from the input stream.IllegalArgumentException- if the input stream contains a malformed Unicode escape sequence.
-
store
default Properties store()
Store some settings into a property file. The following settings cannot be stored into a property file:- Returns:
- the property file
- Throws:
IOException- if writing this property list to the specified output stream throws an IOException.
-
store
default void store(OutputStream out, String comments) throws IOException
Store some settings into a property file. The following settings cannot be stored into a property file:- Parameters:
out- an output stream.comments- a description of the property list.- Throws:
IOException- if writing this property list to the specified output stream throws an IOException.
-
getWelcomeMessage
String getWelcomeMessage()
- Returns:
- the welcome message
-
setWelcomeMessage
Settings setWelcomeMessage(String welcomeMessage)
Define the welcome message, printed in the console- Parameters:
welcomeMessage- a message- Returns:
- the current instance
-
checkModel
boolean checkModel(Solver solver)
- Parameters:
solver- the solver- Returns:
- true if the model is OK wrt the checker, false otherwise
-
setModelChecker
Settings setModelChecker(Predicate<Solver> modelChecker)
Define 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());- Parameters:
modelChecker- a predicate to check the solution- Returns:
- the current instance
-
enableViews
boolean enableViews()
- Returns:
- true if views are enabled.
-
setEnableViews
Settings setEnableViews(boolean enableViews)
Set to 'true' to allow the creation of views in theModel. Creates new variables with channeling constraints otherwise.- Parameters:
enableViews-trueto enable views- Returns:
- the current instance
-
getMaxDomSizeForEnumerated
int getMaxDomSizeForEnumerated()
- Returns:
- maximum domain size threshold to force integer variable to be enumerated
-
setMaxDomSizeForEnumerated
Settings setMaxDomSizeForEnumerated(int maxDomSizeForEnumerated)
Define the minimum number of cardinality threshold to a sum/scalar constraint to be decomposed in intermediate sub-sums.- Parameters:
maxDomSizeForEnumerated- cardinality threshold- Returns:
- the current instance
-
getMinCardForSumDecomposition
int getMinCardForSumDecomposition()
- Returns:
- minimum number of cardinality threshold to a sum constraint to be decomposed
-
setMinCardinalityForSumDecomposition
Settings setMinCardinalityForSumDecomposition(int defaultMinCardinalityForSumDecomposition)
Define the default minimum number of cardinality threshold to a sum/scalar constraint to be decomposed into intermediate sub-sums.- Parameters:
defaultMinCardinalityForSumDecomposition- cardinality threshold- Returns:
- the current instance
-
enableTableSubstitution
boolean enableTableSubstitution()
- Returns:
- true if some intension constraints can be replaced by extension constraints
-
setEnableTableSubstitution
Settings setEnableTableSubstitution(boolean enableTableSubstitution)
Define whether some intension constraints are replaced by extension constraints- Parameters:
enableTableSubstitution- enable table substitution- Returns:
- the current instance
-
getMaxTupleSizeForSubstitution
int getMaxTupleSizeForSubstitution()
- Returns:
- maximum domain size threshold to replace intension constraints by extension constraints
-
getMCRDecimalPrecision
double getMCRDecimalPrecision()
- Returns:
- the smallest used double for
IIntConstraintFactory.multiCostRegular(IntVar[], IntVar[], ICostAutomaton)algorithm
-
setMCRDecimalPrecision
Settings setMCRDecimalPrecision(double precision)
Defines the default smallest used double forIIntConstraintFactory.multiCostRegular(IntVar[], IntVar[], ICostAutomaton)algorithm- Parameters:
precision- default precision for MCR- Returns:
- the current instance
-
setMaxTupleSizeForSubstitution
Settings setMaxTupleSizeForSubstitution(int maxTupleSizeForSubstitution)
Define the maximum domain size threshold to replace intension constraints by extension constraints Only checked whenenableTableSubstitution()returnstrue- Parameters:
maxTupleSizeForSubstitution- threshold to substitute intension constraint by table one.- Returns:
- the current instance
-
sortPropagatorActivationWRTPriority
boolean sortPropagatorActivationWRTPriority()
- Returns:
trueif propagators are sorted wrt their priority on initial activation.
-
setSortPropagatorActivationWRTPriority
Settings setSortPropagatorActivationWRTPriority(boolean sortPropagatorActivationWRTPriority)
Set whether propagators are sorted wrt their priority inPropagationEnginewhen dealing with propagator activation.- Parameters:
sortPropagatorActivationWRTPriority-trueto allow sorting static propagators.- Returns:
- the current instance
-
makeDefaultSearch
AbstractStrategy makeDefaultSearch(Model model)
Creates a default search strategy for the input model- Parameters:
model- a model requiring a default search strategy- Returns:
- a default search strategy for model
- See Also:
Search.defaultSearch(Model)
-
setDefaultSearch
Settings setDefaultSearch(Function<Model,AbstractStrategy> defaultSearch)
Define a default search strategy for the input model- Parameters:
defaultSearch- what default search strategy should be- Returns:
- the current instance
-
getEnvironmentHistorySimulationCondition
ICondition getEnvironmentHistorySimulationCondition()
- Returns:
- the condition to satisfy when rebuilding history of backtrackable objects is needed.
-
setEnvironmentHistorySimulationCondition
Settings setEnvironmentHistorySimulationCondition(ICondition environmentHistorySimulationCondition)
Set 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.- Parameters:
environmentHistorySimulationCondition- the condition to satisfy when rebuilding history of backtrackable objects is needed.- Returns:
- the current instance
-
warnUser
boolean warnUser()
- Returns:
- true if warnings detected during modeling/solving are output.
-
setWarnUser
Settings setWarnUser(boolean warnUser)
To be informed of warnings detected during modeling/solving- Parameters:
warnUser-trueto be print warnings on console- Returns:
- the current instance
-
enableDecompositionOfBooleanSum
boolean enableDecompositionOfBooleanSum()
- Returns:
trueif boolean sum should be decomposed into an equality constraint and an arithmetic constraint,falseif a single constraint should be used instead.
-
setEnableDecompositionOfBooleanSum
Settings setEnableDecompositionOfBooleanSum(boolean enableDecompositionOfBooleanSum)
Define if boolean sums should be decomposed into an equality constraint + arithmetic constraint- Parameters:
enableDecompositionOfBooleanSum-trueto enable decomposition- Returns:
- the current instance
-
enableIncrementalityOnBoolSum
boolean enableIncrementalityOnBoolSum(int nbvars)
- 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
Settings setEnableIncrementalityOnBoolSum(IntPredicate enableIncrementalityOnBoolSum)
Define the predicate to choose incremental sum, based on number variables declared- Parameters:
enableIncrementalityOnBoolSum- predicate to pick declare sum- Returns:
- the current instance
-
cloneVariableArrayInPropagator
boolean cloneVariableArrayInPropagator()
- Returns:
- true if all propagators should clone the input variable array instead of simply referencing it.
-
setCloneVariableArrayInPropagator
Settings setCloneVariableArrayInPropagator(boolean cloneVariableArrayInPropagator)
If 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.- Parameters:
cloneVariableArrayInPropagator-trueto clone variables array on constructor- Returns:
- the current instance
-
enableACOnTernarySum
boolean enableACOnTernarySum()
- Returns:
- true if AC is enabled to filter ternary sums by default.
-
setEnableACOnTernarySum
Settings setEnableACOnTernarySum(boolean enable)
If 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.- Parameters:
enable-trueto enable AC by default- Returns:
- the current instance
-
defaultPrefix
String defaultPrefix()
Define the prefix of internally created variables (through a call toIVariableFactory.generateName()- Returns:
- the prefix of all internally created variables
-
setDefaultPrefix
Settings setDefaultPrefix(String defaultPrefix)
Define prefix of internally created variables- Parameters:
defaultPrefix- prefix of internally created variables' name- Returns:
- the current instance
-
enableSAT
boolean enableSAT()
- 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
Settings setEnableSAT(boolean enableSAT)
Indicate if clauses are managed by a unique SAT solver.- Parameters:
enableSAT-trueto rely on SAT Solver to handle clauses- Returns:
- the current instance
-
swapOnPassivate
boolean swapOnPassivate()
- 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
Settings setSwapOnPassivate(boolean swapOnPassivate)
Define if passivation of propagator swap it in variables' list- Parameters:
swapOnPassivate-trueto enable swapping- Returns:
- the current instance
-
checkDeclaredConstraints
boolean checkDeclaredConstraints()
- 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
Settings setCheckDeclaredConstraints(boolean checkDeclaredConstraints)
Indicate if the declared constraints are either posted or reified.- Parameters:
checkDeclaredConstraints-trueto check constraints before resolution- Returns:
- the current instance
-
initSolver
Solver initSolver(Model model)
This method is called inModel(IEnvironment, String, Settings)to create the solver to associate with a model.- Parameters:
model- a model to initialize with a solver- Returns:
- the new solver
-
setInitSolver
Settings setInitSolver(Function<Model,Solver> initSolver)
Define the solver initialization- Parameters:
initSolver- function to initialize the solver- Returns:
- the current instance
-
enableHybridizationOfPropagationEngine
byte enableHybridizationOfPropagationEngine()
- Returns:
- 0b00 if constraint-oriented propagation engine, 0b01 if hybridization between variable and constraint oriented and 0b10 if variable-oriented.
-
setHybridizationOfPropagationEngine
Settings setHybridizationOfPropagationEngine(byte hybrid)
Define behavior of the propagation engine.- 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
-
-