Class DefaultSettings

  • All Implemented Interfaces:
    Settings

    public class DefaultSettings
    extends Object
    implements Settings
    A concrete implementation of Settings that enables to modify settings programmatically.

    Project: choco-solver.

    Since:
    14/12/2017.
    Author:
    Charles Prud'homme
    • Constructor Detail

      • DefaultSettings

        public DefaultSettings()
    • Method Detail

      • setWelcomeMessage

        public DefaultSettings setWelcomeMessage​(String welcomeMessage)
        Description copied from interface: Settings
        Define the welcome message, printed in the console
        Specified by:
        setWelcomeMessage in interface Settings
        Parameters:
        welcomeMessage - a message
        Returns:
        the current instance
      • checkModel

        public boolean checkModel​(Solver solver)
        Specified by:
        checkModel in interface Settings
        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: Settings
        Define what to do when a solution is found. By default, it makes a weak check of the model:
             
                 return !ESat.FALSE.equals(solver.isSatisfied());
             
         
        A hard check of the model can be done like this:
             
             return ESat.TRUE.equals(solver.isSatisfied());
             
         
        Specified by:
        setModelChecker in interface Settings
        Parameters:
        modelChecker - a predicate to check the solution
        Returns:
        the current instance
      • enableViews

        public boolean enableViews()
        Specified by:
        enableViews in interface Settings
        Returns:
        true if views are enabled.
      • setEnableViews

        public DefaultSettings setEnableViews​(boolean enableViews)
        Description copied from interface: Settings
        Set to 'true' to allow the creation of views in the Model. Creates new variables with channeling constraints otherwise.
        Specified by:
        setEnableViews in interface Settings
        Parameters:
        enableViews - true to enable views
        Returns:
        the current instance
      • getMaxDomSizeForEnumerated

        public int getMaxDomSizeForEnumerated()
        Specified by:
        getMaxDomSizeForEnumerated in interface Settings
        Returns:
        maximum domain size threshold to force integer variable to be enumerated
      • setMaxDomSizeForEnumerated

        public DefaultSettings setMaxDomSizeForEnumerated​(int maxDomSizeForEnumerated)
        Description copied from interface: Settings
        Define the minimum number of cardinality threshold to a sum/scalar constraint to be decomposed in intermediate sub-sums.
        Specified by:
        setMaxDomSizeForEnumerated in interface Settings
        Parameters:
        maxDomSizeForEnumerated - cardinality threshold
        Returns:
        the current instance
      • getMinCardForSumDecomposition

        public int getMinCardForSumDecomposition()
        Specified by:
        getMinCardForSumDecomposition in interface Settings
        Returns:
        minimum number of cardinality threshold to a sum constraint to be decomposed
      • setMinCardinalityForSumDecomposition

        public Settings setMinCardinalityForSumDecomposition​(int defaultMinCardinalityForSumDecomposition)
        Description copied from interface: Settings
        Define the default minimum number of cardinality threshold to a sum/scalar constraint to be decomposed into intermediate sub-sums.
        Specified by:
        setMinCardinalityForSumDecomposition in interface Settings
        Parameters:
        defaultMinCardinalityForSumDecomposition - cardinality threshold
        Returns:
        the current instance
      • enableTableSubstitution

        public boolean enableTableSubstitution()
        Specified by:
        enableTableSubstitution in interface Settings
        Returns:
        true if some intension constraints can be replaced by extension constraints
      • setEnableTableSubstitution

        public DefaultSettings setEnableTableSubstitution​(boolean enableTableSubstitution)
        Description copied from interface: Settings
        Define whether some intension constraints are replaced by extension constraints
        Specified by:
        setEnableTableSubstitution in interface Settings
        Parameters:
        enableTableSubstitution - enable table substitution
        Returns:
        the current instance
      • getMaxTupleSizeForSubstitution

        public int getMaxTupleSizeForSubstitution()
        Specified by:
        getMaxTupleSizeForSubstitution in interface Settings
        Returns:
        maximum domain size threshold to replace intension constraints by extension constraints
      • setMaxTupleSizeForSubstitution

        public DefaultSettings setMaxTupleSizeForSubstitution​(int maxTupleSizeForSubstitution)
        Description copied from interface: Settings
        Define the maximum domain size threshold to replace intension constraints by extension constraints Only checked when Settings.enableTableSubstitution() returns true
        Specified by:
        setMaxTupleSizeForSubstitution in interface Settings
        Parameters:
        maxTupleSizeForSubstitution - threshold to substitute intension constraint by table one.
        Returns:
        the current instance
      • sortPropagatorActivationWRTPriority

        public boolean sortPropagatorActivationWRTPriority()
        Specified by:
        sortPropagatorActivationWRTPriority in interface Settings
        Returns:
        true if propagators are sorted wrt their priority on initial activation.
      • setSortPropagatorActivationWRTPriority

        public DefaultSettings setSortPropagatorActivationWRTPriority​(boolean sortPropagatorActivationWRTPriority)
        Description copied from interface: Settings
        Set whether propagators are sorted wrt their priority in PropagationEngine when dealing with propagator activation.
        Specified by:
        setSortPropagatorActivationWRTPriority in interface Settings
        Parameters:
        sortPropagatorActivationWRTPriority - true to allow sorting static propagators.
        Returns:
        the current instance
      • setEnvironmentHistorySimulationCondition

        public DefaultSettings setEnvironmentHistorySimulationCondition​(ICondition environmentHistorySimulationCondition)
        Description copied from interface: Settings
        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 to ICondition.FALSE if no backtrackable object is created during the search.
        Specified by:
        setEnvironmentHistorySimulationCondition in interface Settings
        Parameters:
        environmentHistorySimulationCondition - the condition to satisfy when rebuilding history of backtrackable objects is needed.
        Returns:
        the current instance
      • warnUser

        public boolean warnUser()
        Specified by:
        warnUser in interface Settings
        Returns:
        true if warnings detected during modeling/solving are output.
      • setWarnUser

        public DefaultSettings setWarnUser​(boolean warnUser)
        Description copied from interface: Settings
        To be informed of warnings detected during modeling/solving
        Specified by:
        setWarnUser in interface Settings
        Parameters:
        warnUser - true to be print warnings on console
        Returns:
        the current instance
      • enableDecompositionOfBooleanSum

        public boolean enableDecompositionOfBooleanSum()
        Specified by:
        enableDecompositionOfBooleanSum in interface Settings
        Returns:
        true if 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: Settings
        Define if boolean sums should be decomposed into an equality constraint + arithmetic constraint
        Specified by:
        setEnableDecompositionOfBooleanSum in interface Settings
        Parameters:
        enableDecompositionOfBooleanSum - true to enable decomposition
        Returns:
        the current instance
      • enableIncrementalityOnBoolSum

        public boolean enableIncrementalityOnBoolSum​(int nbvars)
        Specified by:
        enableIncrementalityOnBoolSum in interface Settings
        Parameters:
        nbvars - number of variables in the constraint
        Returns:
        true if the incrementality is enabled on boolean sum, based on the number of variables involved.
      • setEnableIncrementalityOnBoolSum

        public DefaultSettings setEnableIncrementalityOnBoolSum​(IntPredicate enableIncrementalityOnBoolSum)
        Description copied from interface: Settings
        Define the predicate to choose incremental sum, based on number variables declared
        Specified by:
        setEnableIncrementalityOnBoolSum in interface Settings
        Parameters:
        enableIncrementalityOnBoolSum - predicate to pick declare sum
        Returns:
        the current instance
      • cloneVariableArrayInPropagator

        public boolean cloneVariableArrayInPropagator()
        Specified by:
        cloneVariableArrayInPropagator in interface Settings
        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: Settings
        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.
        Specified by:
        setCloneVariableArrayInPropagator in interface Settings
        Parameters:
        cloneVariableArrayInPropagator - true to clone variables array on constructor
        Returns:
        the current instance
      • enableACOnTernarySum

        public boolean enableACOnTernarySum()
        Specified by:
        enableACOnTernarySum in interface Settings
        Returns:
        true if AC is enabled to filter ternary sums by default.
      • setEnableACOnTernarySum

        public Settings setEnableACOnTernarySum​(boolean enable)
        Description copied from interface: Settings
        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.
        Specified by:
        setEnableACOnTernarySum in interface Settings
        Parameters:
        enable - true to enable AC by default
        Returns:
        the current instance
      • setDefaultPrefix

        public DefaultSettings setDefaultPrefix​(String defaultPrefix)
        Description copied from interface: Settings
        Define prefix of internally created variables
        Specified by:
        setDefaultPrefix in interface Settings
        Parameters:
        defaultPrefix - prefix of internally created variables' name
        Returns:
        the current instance
      • enableSAT

        public boolean enableSAT()
        Specified by:
        enableSAT in interface Settings
        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: Settings
        Indicate if clauses are managed by a unique SAT solver.
        Specified by:
        setEnableSAT in interface Settings
        Parameters:
        enableSAT - true to rely on SAT Solver to handle clauses
        Returns:
        the current instance
      • swapOnPassivate

        public boolean swapOnPassivate()
        Specified by:
        swapOnPassivate in interface Settings
        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: Settings
        Define if passivation of propagator swap it in variables' list
        Specified by:
        setSwapOnPassivate in interface Settings
        Parameters:
        swapOnPassivate - true to enable swapping
        Returns:
        the current instance
      • checkDeclaredConstraints

        public boolean checkDeclaredConstraints()
        Specified by:
        checkDeclaredConstraints in interface Settings
        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: Settings
        Indicate if the declared constraints are either posted or reified.
        Specified by:
        setCheckDeclaredConstraints in interface Settings
        Parameters:
        checkDeclaredConstraints - true to check constraints before resolution
        Returns:
        the current instance
      • setInitSolver

        public DefaultSettings setInitSolver​(Function<Model,​Solver> initSolver)
        Description copied from interface: Settings
        Define the solver initialization
        Specified by:
        setInitSolver in interface Settings
        Parameters:
        initSolver - function to initialize the solver
        Returns:
        the current instance
      • enableHybridizationOfPropagationEngine

        public byte enableHybridizationOfPropagationEngine()
        Specified by:
        enableHybridizationOfPropagationEngine in interface Settings
        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: Settings
        Define behavior of the propagation engine.
        Specified by:
        setHybridizationOfPropagationEngine in interface Settings
        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