Module org.maxicp

Class CPIntVarViewOffset

java.lang.Object
org.maxicp.cp.engine.core.CPIntVarViewOffset
All Implemented Interfaces:
Serializable, CPIntVar, CPVar, Expression, IntExpression, ConcreteIntVar, ConcreteVar, IntVar, Var

public class CPIntVarViewOffset extends Object implements CPIntVar
A view on a variable of type x+o
See Also:
  • Constructor Details

    • CPIntVarViewOffset

      public CPIntVarViewOffset(CPIntVar x, int offset)
  • Method Details

    • getSolver

      public CPSolver getSolver()
      Description copied from interface: CPIntVar
      Returns the solver in which this variable was created.
      Specified by:
      getSolver in interface CPIntVar
      Returns:
      the solver in which this variable was created
    • whenFixed

      public void whenFixed(Runnable f)
      Description copied from interface: CPIntVar
      Asks that the closure is called whenever the domain of this variable is reduced to a single setValue.
      Specified by:
      whenFixed in interface CPIntVar
      Parameters:
      f - the closure
    • whenBoundChange

      public void whenBoundChange(Runnable f)
      Description copied from interface: CPIntVar
      Asks that the closure is called whenever the max or min setValue of the domain of this variable changes
      Specified by:
      whenBoundChange in interface CPIntVar
      Parameters:
      f - the closure
    • whenDomainChange

      public void whenDomainChange(Runnable f)
      Description copied from interface: CPIntVar
      Asks that the closure is called whenever the domain change of this variable changes
      Specified by:
      whenDomainChange in interface CPIntVar
      Parameters:
      f - the closure
    • whenDomainChange

      public void whenDomainChange(Consumer<DeltaCPIntVar> f)
      Description copied from interface: CPIntVar
      Asks that the consumer is called whenever the domain change of this variable changes. The consumer is called with a delta object that allows to retrieve the changes in the domain of the variable (removed values) since the previous call.
      Specified by:
      whenDomainChange in interface CPIntVar
      Parameters:
      f - the consumer with the delta of the domain since last call
    • propagateOnDomainChange

      public void propagateOnDomainChange(CPConstraint c)
      Description copied from interface: CPIntVar
      Asks that CPConstraint.propagate() is called whenever the domain of this variable changes. We say that a change event occurs.
      Specified by:
      propagateOnDomainChange in interface CPIntVar
      Parameters:
      c - the constraint for which the CPConstraint.propagate() method should be called on change events of this variable.
    • propagateOnFix

      public void propagateOnFix(CPConstraint c)
      Description copied from interface: CPIntVar
      Asks that CPConstraint.propagate() is called whenever the domain of this variable is reduced to a singleton. In such a state the variable is bind and we say that a bind event occurs.
      Specified by:
      propagateOnFix in interface CPIntVar
      Parameters:
      c - the constraint for which the CPConstraint.propagate() method should be called on bind events of this variable.
    • propagateOnBoundChange

      public void propagateOnBoundChange(CPConstraint c)
      Description copied from interface: CPIntVar
      Asks that CPConstraint.propagate() is called whenever the bound (maximum or minimum values) of the domain of this variable is changes. We say that a bound change event occurs in this case.
      Specified by:
      propagateOnBoundChange in interface CPIntVar
      Parameters:
      c - the constraint for which the CPConstraint.propagate() method should be called on bound change events of this variable.
    • min

      public int min()
      Description copied from interface: CPIntVar
      Returns the minimum of the domain of the variable
      Specified by:
      min in interface CPIntVar
      Specified by:
      min in interface IntExpression
      Returns:
      the minimum of the domain of the variable
    • max

      public int max()
      Description copied from interface: CPIntVar
      Returns the maximum of the domain of the variable
      Specified by:
      max in interface CPIntVar
      Specified by:
      max in interface IntExpression
      Returns:
      the maximum of the domain of the variable
    • size

      public int size()
      Description copied from interface: CPIntVar
      Returns the size of the domain of the variable
      Specified by:
      size in interface CPIntVar
      Specified by:
      size in interface IntExpression
      Returns:
      the size of the domain of the variable
    • fillArray

      public int fillArray(int[] dest)
      Description copied from interface: CPIntVar
      Copies the values of the domain into an array.
      Specified by:
      fillArray in interface CPIntVar
      Specified by:
      fillArray in interface IntExpression
      Parameters:
      dest - an array large enough dest.length >= size()
      Returns:
      the size of the domain and dest[0,...,size-1] contains the values in the domain in an arbitrary order
    • isFixed

      public boolean isFixed()
      Description copied from interface: CPIntVar
      Returns true if the domain of the variable has a single value.
      Specified by:
      isFixed in interface CPIntVar
      Specified by:
      isFixed in interface CPVar
      Specified by:
      isFixed in interface Expression
      Specified by:
      isFixed in interface IntVar
      Returns:
      true if the domain of the variable is a singleton.
    • contains

      public boolean contains(int v)
      Description copied from interface: CPIntVar
      Returns true if the domain contains the specified value.
      Specified by:
      contains in interface CPIntVar
      Specified by:
      contains in interface IntExpression
      Parameters:
      v - the value whose presence in the domain is to be tested
      Returns:
      true if the domain contains the specified value
    • remove

      public void remove(int v)
      Description copied from interface: CPIntVar
      Removes the specified value.
      Specified by:
      remove in interface CPIntVar
      Parameters:
      v - the value to remove
    • fix

      public void fix(int v)
      Description copied from interface: CPIntVar
      Fixes the specified value.
      Specified by:
      fix in interface CPIntVar
      Parameters:
      v - the value to assign.
    • removeBelow

      public void removeBelow(int v)
      Description copied from interface: CPIntVar
      Removes all the values less than a given value.
      Specified by:
      removeBelow in interface CPIntVar
      Parameters:
      v - the value such that all the values less than v are removed
    • removeAbove

      public void removeAbove(int v)
      Description copied from interface: CPIntVar
      Removes all the values above a given value.
      Specified by:
      removeAbove in interface CPIntVar
      Parameters:
      v - the value such that all the values larger than v are removed
    • fillDeltaArray

      public int fillDeltaArray(int oldMin, int oldMax, int oldSize, int[] arr)
      Description copied from interface: CPIntVar
      Copies the values of the domain that have been removed (delta set) wrt to a previous state of the domain described by oldMin, oldMax and oldSize.
      Specified by:
      fillDeltaArray in interface CPIntVar
      Parameters:
      arr - an array large enough dest.length >= oldSize-size()
      Returns:
      the size of delta set stored in prefix of dest
    • delta

      public DeltaCPIntVar delta(CPConstraint c)
      Description copied from interface: CPIntVar
      Returns a delta object allowing to retrieve the changes in the domain of the variable (removed values) since the previous call to the Constraint.propagate of the constraint. This can be useful to implement some constraint with incremental reasoning.
      Specified by:
      delta in interface CPIntVar
      Parameters:
      c - the constraint wrt the delta set is computed
      Returns:
      the delta object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getModelProxy

      public ModelProxy getModelProxy()
      Description copied from interface: Expression
      Returns the ModelDispatcher linked to this Expression
      Specified by:
      getModelProxy in interface Expression
      Specified by:
      getModelProxy in interface Var