Class KIntVar

java.lang.Object
com.artelys.kalis.KNumVar
com.artelys.kalis.KIntVar

public class KIntVar extends KNumVar
This class implements an integer variable with enumerated (finite) domain.
Decision variables are the variable quantities that we are trying to
instantiate in order to satisfy the constraints of our problem.
In this version, Artelys Kalis works with integer variables : decision
variables which are constrained to take only integer values.
These integer variables are represented by instances of the class KIntVar.

Example :

KProblem  p(...);
// X is an integer variable that can take value 0,1,2,3,4,5,6,7,8,9,10
KIntVar X(p, "X", 0, 10);
// Y is an integer variable that can take value 7,8,10 (3 different values)
KIntVar Y(p, "Y", KIntArray(3, 7, 8, 10));

// Z is an integer variable that can take value 3,4,5
KIntVar Z;
Z = KIntVar(p,3,5);


Since:
2016.1
See Also:
KIntVarArray
  • Constructor Details

    • KIntVar

      protected KIntVar(long cPtr, boolean cMemoryOwn)
    • KIntVar

      public KIntVar()
      Default constructor
    • KIntVar

      public KIntVar(KProblem problem, String name, int minValue, int maxValue, boolean isBoundIntVar)
      Main constructor : minValue and maxValue are the bounds of the KIntVar's domain

      Parameters:
      problem - Involved problem
      name - Name of the variable
      minValue - lower bound for the variable
      maxValue - upper bound for the variable
      isBoundIntVar - false if the domain may have holes, true otherwise
    • KIntVar

      public KIntVar(KProblem problem, String name, int minValue, int maxValue)
      Main constructor : minValue and maxValue are the bounds of the KIntVar's domain

      Parameters:
      problem - Involved problem
      name - Name of the variable
      minValue - lower bound for the variable
      maxValue - upper bound for the variable
    • KIntVar

      public KIntVar(KProblem problem, String name, int minValue)
      Main constructor : minValue and maxValue are the bounds of the KIntVar's domain

      Parameters:
      problem - Involved problem
      name - Name of the variable
      minValue - lower bound for the variable

    • KIntVar

      public KIntVar(KProblem problem, String name)
      Main constructor : minValue and maxValue are the bounds of the KIntVar's domain

      Parameters:
      problem - Involved problem
      name - Name of the variable


    • KIntVar

      public KIntVar(KProblem problem, String name, KIntArray domain)
      Main constructor : enumerated domain
    • KIntVar

      public KIntVar(KProblem problem)
      Basic constructor
    • KIntVar

      public KIntVar(KIntVar toCopy)
      Copy constructor
    • KIntVar

      public KIntVar(com.artelys.kalis.SWIGTYPE_p_KIntVar_I var_I)
  • Method Details

    • getCPtr

      protected static long getCPtr(KIntVar obj)
    • finalize

      protected void finalize()
      Overrides:
      finalize in class KNumVar
    • delete

      public void delete()
      Overrides:
      delete in class KNumVar
    • getInstance

      public KIntVar getInstance(long pb)
    • instantiate

      public void instantiate(int value)
      Instantiate the variable to a value
    • remVal

      public void remVal(int value)
      Remove value from the variable's domain
    • getName

      public String getName()
      Return the name of the variable
      Overrides:
      getName in class KNumVar
    • setName

      public void setName(String name)
      Set the name of the variable
      Overrides:
      setName in class KNumVar
    • getInf

      public double getInf()
      Returns lower bound of this variable
      Overrides:
      getInf in class KNumVar
    • getMiddle

      public double getMiddle()
      Returns value in variable's domain and close to the middle
    • getSup

      public double getSup()
      Returns upper bound of this variable
      Overrides:
      getSup in class KNumVar
    • getDomainSize

      public int getDomainSize()
      Returns current domain size of the variable
    • getValue

      public double getValue()
      Returns current instantiation of the variable (when the variable is not instantiated the returned value is undefined)
      Overrides:
      getValue in class KNumVar
    • getIsInstantiated

      public boolean getIsInstantiated()
      Returns true if the variable has been assigned a value, false otherwise
      Overrides:
      getIsInstantiated in class KNumVar
    • getDegree

      public int getDegree()
      Returns the number of constraints where this variable appears
      Overrides:
      getDegree in class KNumVar
    • getTarget

      public double getTarget()
      Get target value
      Overrides:
      getTarget in class KNumVar
    • getRandomValue

      public int getRandomValue()
      Get a random value in the domain of the variable
    • getNextDomainValue

      public void getNextDomainValue(com.artelys.kalis.SWIGTYPE_p_int next)
      Get value immediatly after "next" in the domain of the variable and put it into next
    • getPrevDomainValue

      public void getPrevDomainValue(com.artelys.kalis.SWIGTYPE_p_int prev)
      Get value immediatly before "prev" in the domain of the variable and put it into prev
    • shaveFromLeft

      public boolean shaveFromLeft()
      Shave lower bound of variable
    • shaveFromRight

      public boolean shaveFromRight()
      Shave upper bound of variable
    • shaveOnValue

      public boolean shaveOnValue(int val)
      Shave the value 'val'
    • setInf

      public void setInf(int value)
      Set the lower bound to value
    • setSup

      public void setSup(int value)
      Set the upper bound to value
    • setTarget

      public void setTarget(int value)
      Set the target value
    • optimizeDomainRepresentation

      public void optimizeDomainRepresentation()
      Optimize the internal representation of the domain
    • canBeInstantiatedTo

      public boolean canBeInstantiatedTo(int value)
      Check if value is in the domain
    • isEqualTo

      public boolean isEqualTo(KIntVar x)
      Check if equal to x
    • getCopyPtr

      public KIntVar getCopyPtr()
      Return a copy of this KIntVar object
      Overrides:
      getCopyPtr in class KNumVar
    • getNumVar_I_ptr

      public com.artelys.kalis.SWIGTYPE_p_KNumVar_I getNumVar_I_ptr()
      Overrides:
      getNumVar_I_ptr in class KNumVar
    • getIntVar_I_ptr

      public com.artelys.kalis.SWIGTYPE_p_KIntVar_I getIntVar_I_ptr()
    • setIntVar_I_ptr

      public void setIntVar_I_ptr(com.artelys.kalis.SWIGTYPE_p_KIntVar_I intVar)
    • print

      public void print(com.artelys.kalis.SWIGTYPE_p_std__ostream fout)
      Pretty printing of the variable to an ouput stream
      Overrides:
      print in class KNumVar
    • print

      public void print()
      Pretty printing to the standard ouput stream
      Overrides:
      print in class KNumVar
    • print

      public void print(com.artelys.kalis.SWIGTYPE_p_void ctx, com.artelys.kalis.SWIGTYPE_p_f_p_void_p_q_const__char__int pfp)
      Description copied from class: KNumVar
      Pretty printing
      Overrides:
      print in class KNumVar
    • _instanceof

      public int _instanceof()
      Description copied from class: KNumVar
      Return the type of this variable


      Overrides:
      _instanceof in class KNumVar
    • createIndicators

      public void createIndicators()
    • updateIndicators

      public void updateIndicators()
    • getIndicator

      public KAuxVar getIndicator(int value)