Class MinusView

    • Constructor Detail

      • MinusView

        public MinusView​(IntVar var)
        Create a -var view
        Parameters:
        var - a integer variable
    • Method Detail

      • monitorDelta

        public IIntDeltaMonitor monitorDelta​(ICause propagator)
        Description copied from interface: IntVar
        Allow to monitor removed values of this.
        Parameters:
        propagator - the cause that requires to monitor delta
        Returns:
        a delta monitor
      • updateBounds

        public boolean updateBounds​(int lb,
                                    int ub,
                                    ICause cause)
                             throws ContradictionException
        Description copied from interface: IntVar
        Updates the lower bound and the upper bound of the domain of this to, resp. lb and ub. The instruction comes from propagator.

        • If lb is smaller than the lower bound of the domain and ub is greater than the upper bound of the domain,

          nothing is done and the return value is false,

        • if updating the lower bound to lb, or updating the upper bound to ub leads to a dead-end (domain wipe-out), or if lb is strictly greater than ub, a ContradictionException is thrown,
        • otherwise, if updating the lower bound to lb and/or the upper bound to ub can be done safely can be done safely, the event type is created (the original event can be promoted) and observers are notified and the return value is true
        Specified by:
        updateBounds in interface IntVar
        Overrides:
        updateBounds in class IntView<IntVar>
        Parameters:
        lb - new lower bound (included)
        ub - new upper bound (included)
        cause - update releaser
        Returns:
        true if the upper bound has been updated, false otherwise
        Throws:
        ContradictionException - if the domain become empty due to this action
      • doRemoveIntervalFromVar

        protected boolean doRemoveIntervalFromVar​(int from,
                                                  int to)
                                           throws ContradictionException
        Description copied from class: IntView
        Action to execute on IntView.var when this view requires to remove an interval from it
        Overrides:
        doRemoveIntervalFromVar in class IntView<IntVar>
        Parameters:
        from - first value of the interval before modification of the view
        to - last value of the interval before modification of the view
        Returns:
        true if IntView.var has been modified
        Throws:
        ContradictionException - if modification fails
      • contains

        public boolean contains​(int value)
        Description copied from interface: IntVar
        Checks if a value v belongs to the domain of this
        Parameters:
        value - int
        Returns:
        true if the value belongs to the domain of this, false otherwise.
      • isInstantiatedTo

        public boolean isInstantiatedTo​(int value)
        Description copied from interface: IntVar
        Checks wether this is instantiated to val
        Parameters:
        value - int
        Returns:
        true if this is instantiated to val, false otherwise
      • getValue

        public int getValue()
        Description copied from interface: IntVar
        Retrieves the current value of the variable if instantiated, otherwier the lower bound.
        Returns:
        the current value (or lower bound if not yet instantiated).
      • getLB

        public int getLB()
        Description copied from interface: IntVar
        Retrieves the lower bound of the variable
        Returns:
        the lower bound
      • getUB

        public int getUB()
        Description copied from interface: IntVar
        Retrieves the upper bound of the variable
        Returns:
        the upper bound
      • nextValue

        public int nextValue​(int v)
        Description copied from interface: IntVar
        Returns the first value just after v in this which is in the domain. If no such value exists, returns Integer.MAX_VALUE;

        To iterate over the values in a IntVar, use the following loop:

         int ub = iv.getUB();
         for (int i = iv.getLB(); i <= ub; i = iv.nextValue(i)) {
             // operate on value i here
         }
        Parameters:
        v - the value to start checking (exclusive)
        Returns:
        the next value in the domain
      • nextValueOut

        public int nextValueOut​(int v)
        Description copied from interface: IntVar
        Returns the first value just after v in this which is out of the domain. If v is less than or equal to IntVar.getLB()-2, returns v + 1, if v is greater than or equal to IntVar.getUB(), returns v + 1.
        Parameters:
        v - the value to start checking (exclusive)
        Returns:
        the next value out of the domain
      • previousValue

        public int previousValue​(int v)
        Description copied from interface: IntVar
        Returns the previous value just before v in this. If no such value exists, returns Integer.MIN_VALUE;

        To iterate over the values in a IntVar, use the following loop:

         int lb = iv.getLB();
         for (int i = iv.getUB(); i >= lb; i = iv.previousValue(i)) {
             // operate on value i here
         }
        Parameters:
        v - the value to start checking (exclusive)
        Returns:
        the previous value in the domain
      • previousValueOut

        public int previousValueOut​(int v)
        Description copied from interface: IntVar
        Returns the first value just before v in this which is out of the domain. If v is greater than or equal to IntVar.getUB()+2, returns v - 1, if v is less than or equal to IntVar.getLB(), returns v - 1.
        Parameters:
        v - the value to start checking (exclusive)
        Returns:
        the previous value out of the domain
      • getValueIterator

        public DisposableValueIterator getValueIterator​(boolean bottomUp)
        Description copied from interface: IntVar
        Retrieves an iterator over values of this.

        The values can be iterated in a bottom-up way or top-down way.

        To bottom-up iterate over the values in a IntVar, use the following loop:

         DisposableValueIterator vit = var.getValueIterator(true);
         while(vit.hasNext()){
             int v = vit.next();
             // operate on value v here
         }
         vit.dispose();
        To top-down iterate over the values in a IntVar, use the following loop:
         DisposableValueIterator vit = var.getValueIterator(false);
         while(vit.hasPrevious()){
             int v = vit.previous();
             // operate on value v here
         }
         vit.dispose();
        Using both previous and next can lead to unexpected behaviour.
        Specified by:
        getValueIterator in interface IntVar
        Overrides:
        getValueIterator in class IntView<IntVar>
        Parameters:
        bottomUp - way to iterate over values. true means from lower bound to upper bound, false means from upper bound to lower bound.
        Returns:
        a disposable iterator over values of this.
      • getRangeIterator

        public DisposableRangeIterator getRangeIterator​(boolean bottomUp)
        Description copied from interface: IntVar
        Retrieves an iterator over ranges (or intervals) of this.

        The ranges can be iterated in a bottom-up way or top-down way.

        To bottom-up iterate over the values in a IntVar, use the following loop:

         DisposableRangeIterator rit = var.getRangeIterator(true);
         while (rit.hasNext()) {
             int from = rit.min();
             int to = rit.max();
             // operate on range [from,to] here
             rit.next();
         }
         rit.dispose();
        To top-down iterate over the values in a IntVar, use the following loop:
         DisposableRangeIterator rit = var.getRangeIterator(false);
         while (rit.hasPrevious()) {
             int from = rit.min();
             int to = rit.max();
             // operate on range [from,to] here
             rit.previous();
         }
         rit.dispose();
        Using both previous and next can lead to unexpected behaviour.
        Specified by:
        getRangeIterator in interface IntVar
        Overrides:
        getRangeIterator in class IntView<IntVar>
        Parameters:
        bottomUp - way to iterate over ranges. true means from lower bound to upper bound, false means from upper bound to lower bound.
        Returns:
        a disposable iterator over ranges of this.
      • justifyEvent

        public void justifyEvent​(IntEventType mask,
                                 int one,
                                 int two,
                                 int three)
        Description copied from interface: IView
        This methods is related to explanations, it binds an event occurring on the observed variable to the view.
        Parameters:
        mask - type of modification
        one - an int
        two - an int
        three - an int