Interface SetVar

  • All Superinterfaces:
    Comparable<Variable>, Identity, Variable
    All Known Implementing Classes:
    SetVarImpl

    public interface SetVar
    extends Variable
    A Set Variable is defined by a domain which is a set interval [LB,UB], where: LB is the set of integers that must belong to every single solution. UB is the set of integers that may belong to at least one solution.

    One must notice that in this context, a VALUE of the variable is a set of integers.

    Since:
    15 nov. 2012 Major update 2016
    Author:
    Charles Prud'homme, Jean-Guillaume Fages
    • Method Detail

      • getLB

        ISet getLB()
        Get SetVar Lower Bound : the set of integers that must belong to every solution (i.e. a subset of all solutions) To iterate over this set, use the following loop: ISet lbSet = getLB(); for(int i : lbSet){ ... } This object is read-only. Use variable methods force to update the domain
        Returns:
        the lower bound of this SetVar.
      • getUB

        ISet getUB()
        Get SetVar Upper Bound : the set of integers that may belong to a solution (i.e. a superset of all solutions) To iterate over this set, use the following loop: ISet ubSet = getUB(); for(int i : ubSet){ ... } This object is read-only. Use variable methods remove to update the domain
        Returns:
        the lower bound of this SetVar.
      • getCard

        IntVar getCard()
        get the constrained cardinality variable of this set.
        • if no variable already has this role, creates a new variable, store and constraint it.
        • if a variable already has this role, return it.
        Returns:
        a variable constrained to this set cardinality. Successive calls should return the same value
      • hasCard

        boolean hasCard()
        Returns:
        true if a variable is constrained to this set's cardinality, false otherwise
      • setCard

        void setCard​(IntVar card)
        ensure a variable is equal to the cardinality of this set.
        • If not call has been already performed to this set cardinality, post a constraint on the number of variables
        • if this set already has a variable constrained to the cardinality, post an equality
        Parameters:
        card - a variable of the same model.
      • force

        boolean force​(int element,
                      ICause cause)
               throws ContradictionException
        Adds element to the lower bound, i.e. every solution must include element
        Parameters:
        element - value to add
        cause - cause of value addition
        Returns:
        true iff element has been added to the lower bound
        Throws:
        ContradictionException
      • remove

        boolean remove​(int element,
                       ICause cause)
                throws ContradictionException
        Removes element from the upper bound, i.e. the set variable cannot contain element anymore
        Parameters:
        element - value to remove
        cause - cause of value removal
        Returns:
        true iff element has been removed from the upper bound
        Throws:
        ContradictionException
      • instantiateTo

        boolean instantiateTo​(int[] value,
                              ICause cause)
                       throws ContradictionException
        Enforces the set variable to contain exactly the set of integers given in parameter
        Parameters:
        value - a set of integers
        cause - cause of instantiation
        Returns:
        true iff a domain modification occurred
        Throws:
        ContradictionException
      • getValue

        default ISet getValue()
        Retrieves the current value of the variable if instantiated, otherwise the lower bound (kernel).
        Returns:
        the current value (or kernel if not yet instantiated).
      • monitorDelta

        ISetDeltaMonitor monitorDelta​(ICause propagator)
        Allow propagator to monitor element removal/enforcing of this
        Parameters:
        propagator - observer
        Returns:
        a new SetDeltaMonitor