Module org.maxicp

Interface CPIntVar

All Superinterfaces:
ConcreteIntVar, ConcreteVar, CPVar, Expression, IntExpression, IntVar, Serializable, Var
All Known Subinterfaces:
CPBoolVar
All Known Implementing Classes:
CPBoolVarImpl, CPBoolVarIsEqual, CPIntVarConstant, CPIntVarImpl, CPIntVarViewMul, CPIntVarViewOffset, CPIntVarViewOpposite

public interface CPIntVar extends CPVar, ConcreteIntVar
  • Method Summary

    Modifier and Type
    Method
    Description
    abs()
     
    default int
    after(int value)
    Returns the value that is just after the given value in the domain of the variable if any, if the value is greater than or equal to the maximum of the domain, the value is returned.
    default int
    before(int value)
    Returns the value that is just before the given value in the domain of the variable if any, if the value is less than or equal to the minimum of the domain, the value is returned.
    boolean
    contains(int v)
    Returns true if the domain contains the specified value.
    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.
    default int
    Evaluate this expression.
    int
    fillArray(int[] dest)
    Copies the values of the domain into an array.
    int
    fillDeltaArray(int oldMin, int oldMax, int oldSize, int[] dest)
    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.
    void
    fix(int v)
    Fixes the specified value.
    Returns the solver in which this variable was created.
    boolean
    Returns true if the domain of the variable has a single value.
    int
    max()
    Returns the maximum of the domain of the variable
    int
    min()
    Returns the minimum of the domain of the variable
    minus(int v)
     
     
    plus(int v)
     
     
    void
    Asks that CPConstraint.propagate() is called whenever the bound (maximum or minimum values) of the domain of this variable is changes.
    void
    Asks that CPConstraint.propagate() is called whenever the domain of this variable changes.
    void
    Asks that CPConstraint.propagate() is called whenever the domain of this variable is reduced to a singleton.
    void
    remove(int v)
    Removes the specified value.
    void
    removeAbove(int v)
    Removes all the values above a given value.
    void
    removeBelow(int v)
    Removes all the values less than a given value.
    int
    Returns the size of the domain of the variable
    void
    Asks that the closure is called whenever the max or min setValue of the domain of this variable changes
    void
    Asks that the closure is called whenever the domain change of this variable changes
    void
    Asks that the consumer is called whenever the domain change of this variable changes.
    void
    Asks that the closure is called whenever the domain of this variable is reduced to a single setValue.

    Methods inherited from interface org.maxicp.modeling.algebra.Expression

    getModelProxy, subexpressions

    Methods inherited from interface org.maxicp.modeling.algebra.integer.IntExpression

    show

    Methods inherited from interface org.maxicp.modeling.IntVar

    computeSubexpressions, mapSubexpressions

    Methods inherited from interface org.maxicp.modeling.Var

    getModelProxy
  • Method Details

    • getSolver

      CPSolver getSolver()
      Returns the solver in which this variable was created.
      Returns:
      the solver in which this variable was created
    • whenFixed

      void whenFixed(Runnable f)
      Asks that the closure is called whenever the domain of this variable is reduced to a single setValue.
      Parameters:
      f - the closure
    • whenBoundChange

      void whenBoundChange(Runnable f)
      Asks that the closure is called whenever the max or min setValue of the domain of this variable changes
      Parameters:
      f - the closure
    • whenDomainChange

      void whenDomainChange(Runnable f)
      Asks that the closure is called whenever the domain change of this variable changes
      Parameters:
      f - the closure
    • whenDomainChange

      void whenDomainChange(Consumer<DeltaCPIntVar> f)
      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.
      Parameters:
      f - the consumer with the delta of the domain since last call
    • propagateOnDomainChange

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

      void propagateOnFix(CPConstraint c)
      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.
      Parameters:
      c - the constraint for which the CPConstraint.propagate() method should be called on bind events of this variable.
    • propagateOnBoundChange

      void propagateOnBoundChange(CPConstraint c)
      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.
      Parameters:
      c - the constraint for which the CPConstraint.propagate() method should be called on bound change events of this variable.
    • min

      int min()
      Returns the minimum of the domain of the variable
      Specified by:
      min in interface IntExpression
      Returns:
      the minimum of the domain of the variable
    • max

      int max()
      Returns the maximum of the domain of the variable
      Specified by:
      max in interface IntExpression
      Returns:
      the maximum of the domain of the variable
    • before

      default int before(int value)
      Returns the value that is just before the given value in the domain of the variable if any, if the value is less than or equal to the minimum of the domain, the value is returned.
      Parameters:
      value -
      Returns:
      the value that is just before the given value in the domain of the variable
    • after

      default int after(int value)
      Returns the value that is just after the given value in the domain of the variable if any, if the value is greater than or equal to the maximum of the domain, the value is returned.
      Parameters:
      value -
      Returns:
      the value that is just after the given value in the domain of the variable
    • size

      int size()
      Returns the size of the domain of the variable
      Specified by:
      size in interface IntExpression
      Returns:
      the size of the domain of the variable
    • fillArray

      int fillArray(int[] dest)
      Copies the values of the domain into an array.
      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

      boolean isFixed()
      Returns true if the domain of the variable has a single value.
      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

      boolean contains(int v)
      Returns true if the domain contains the specified value.
      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

      void remove(int v)
      Removes the specified value.
      Parameters:
      v - the value to remove
      Throws:
      InconsistencyException - is thrown if the domain becomes empty
    • fix

      void fix(int v)
      Fixes the specified value.
      Parameters:
      v - the value to assign.
      Throws:
      InconsistencyException - is thrown if the value is not in the domain
    • removeBelow

      void removeBelow(int v)
      Removes all the values less than a given value.
      Parameters:
      v - the value such that all the values less than v are removed
      Throws:
      InconsistencyException - is thrown if the domain becomes empty
    • removeAbove

      void removeAbove(int v)
      Removes all the values above a given value.
      Parameters:
      v - the value such that all the values larger than v are removed
      Throws:
      InconsistencyException - is thrown if the domain becomes empty
    • fillDeltaArray

      int fillDeltaArray(int oldMin, int oldMax, int oldSize, int[] dest)
      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.
      Parameters:
      dest - an array large enough dest.length >= oldSize-size()
      Returns:
      the size of delta set stored in prefix of dest
    • delta

      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.
      Parameters:
      c - the constraint wrt the delta set is computed
      Returns:
      the delta object
    • evaluate

      default int evaluate() throws VariableNotFixedException
      Description copied from interface: IntExpression
      Evaluate this expression. All variables referenced have to be fixed.
      Specified by:
      evaluate in interface IntExpression
      Returns:
      the value of this expression
      Throws:
      VariableNotFixedException - when a variable is not fixed
    • plus

      default IntExpression plus(int v)
      Specified by:
      plus in interface IntExpression
    • minus

      default IntExpression minus(int v)
      Specified by:
      minus in interface IntExpression
    • plus

      default IntExpression plus(IntExpression v)
      Specified by:
      plus in interface IntExpression
    • minus

      default IntExpression minus(IntExpression v)
      Specified by:
      minus in interface IntExpression
    • abs

      default IntExpression abs()
      Specified by:
      abs in interface IntExpression