Class Constraint

    • Field Detail

      • propagators

        protected final Propagator[] propagators
        Propagators of the constraint (they will filter domains and eventually check solutions)
      • boolReif

        protected BoolVar boolReif
        BoolVar that reifies this constraint, unique.
    • Constructor Detail

      • Constraint

        public Constraint​(String name,
                          Propagator... propagators)
        Make a new constraint defined as a set of given propagators
        name - name of the constraint
        propagators - set of propagators defining the constraint
    • Method Detail

      • getPropagators

        public Propagator[] getPropagators()
        Return an array which contains the propagators declared in this.
        an array of Propagator.
      • getPropagator

        public Propagator getPropagator​(int i)
      • isSatisfied

        public ESat isSatisfied()
        Test if this Constraint object is satisfied, regarding its Propagators and its Variable current domains.

        This method is called on each solution as a checker when assertions are enabled (-ea in VM parameters) It is also called for constraint reification (to state whether or not a constraint is satisfied)

        The method calls entailment checks of this propagators

        ESat.FALSE if the constraint cannot be satisfied (from domain consideration), ESat.TRUE if whatever future decisions are, the constraint will be satisfied for sure (without propagating domain modifications) ESat.UNDIFINED otherwise (more decisions/filtering must be made before concluding about constraint satisfaction)
      • isReified

        public final boolean isReified()
        true iff this constraint has been reified
      • reifyWith

        public void reifyWith​(BoolVar bool)
        Reifies the constraint with a boolean variable If the reified boolean variable already exists, an additional (equality) constraint is automatically posted.
        bool - the variable to reify with
      • reify

        public final BoolVar reify()
        Get/make the boolean variable indicating whether the constraint is satisfied or not This should not be posted.
        the boolean reifying the constraint
      • post

        public final void post()
        Posts the constraint to its model so that the constraint must be satisfied. This should not be reified.
      • ignore

        public final void ignore()
        When a constraint has been declared but neither posted or reified, a call to ignore() ensures this constraint will be ignored when declared constraints are checked.
      • declareAs

        public final void declareAs​(Constraint.Status aStatus,
                                    int idx)
                             throws SolverException
        For internal usage only, declare the status of this constraint in the model and, if need be, its position in the constraint list.
        aStatus - status of this constraint in the model
        idx - position of this constraint in the constraint list.
        SolverException - if the constraint a incoherent status is declared
      • checkNewStatus

        public final void checkNewStatus​(Constraint.Status aStatus)
                                  throws SolverException
        Check if the new status is not in conflict with the current one
        aStatus - new status of the constraint
        SolverException - if the constraint a incoherent status is declared
      • getCidxInModel

        public int getCidxInModel()
        the position of this constraint in the model
      • getOpposite

        public Constraint getOpposite()
        Get the opposite constraint of this constraint. At first call, it creates the opposite constraint, links them together (the opposite constraint of this opposite constraint is this constraint) and returns the opposite. Next calls will return the previously created opposite constraint. In other words, there can be only one opposite per instance of constraint. The default opposite constraint does not filter domains but fails if this constraint is satisfied.
        the opposite constraint of this
      • setOpposite

        protected void setOpposite​(Constraint opp)
      • makeOpposite

        protected Constraint makeOpposite()
        Make the opposite constraint of this. BEWARE: this method should never be called by the user but it can be overridden to provide better constraint negations
      • setName

        public void setName​(String newName)
        Changes the name of this constraint
        newName - the name of the constraint
      • getName

        public String getName()
        the name of this constraint
      • computeMaxPriority

        public PropagatorPriority computeMaxPriority()
        the maximum priority of a propagator of this constraint
      • merge

        public static Constraint merge​(String name,
                                       Constraint... toMerge)
        Creates a new constraint with all propagators of toMerge
        name - name of the new constraint
        toMerge - a set of constraints to merge in this
        a new constraint with all propagators of toMerge