Package com.artelys.kalis
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.artelys.kalis.KNumVar
KNumVar.Type
-
-
Field Summary
-
Fields inherited from class com.artelys.kalis.KNumVar
swigCMemOwn
-
-
Constructor Summary
Constructors Modifier Constructor Description KIntVar()Default constructorprotectedKIntVar(long cPtr, boolean cMemoryOwn)KIntVar(KIntVar toCopy)Copy constructorKIntVar(KProblem problem)Basic constructorKIntVar(KProblem problem, java.lang.String name)Main constructor : minValue and maxValue are the bounds of the KIntVar's domain
KIntVar(KProblem problem, java.lang.String name, int minValue)Main constructor : minValue and maxValue are the bounds of the KIntVar's domain
KIntVar(KProblem problem, java.lang.String name, int minValue, int maxValue)Main constructor : minValue and maxValue are the bounds of the KIntVar's domain
KIntVar(KProblem problem, java.lang.String name, int minValue, int maxValue, boolean isBoundIntVar)Main constructor : minValue and maxValue are the bounds of the KIntVar's domain
KIntVar(KProblem problem, java.lang.String name, KIntArray domain)Main constructor : enumerated domainKIntVar(com.artelys.kalis.SWIGTYPE_p_KIntVar_I var_I)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int_instanceof()Return the type of this variable
booleancanBeInstantiatedTo(int value)Check if value is in the domainvoidcreateIndicators()voiddelete()protected voidfinalize()KIntVargetCopyPtr()Return a copy of this KIntVar objectprotected static longgetCPtr(KIntVar obj)intgetDegree()Returns the number of constraints where this variable appearsintgetDomainSize()Returns current domain size of the variableKAuxVargetIndicator(int value)doublegetInf()Returns lower bound of this variableKIntVargetInstance(long pb)intgetIntInf()Returns integer lower bound of this variableintgetIntSup()Returns integer upper bound of this variableintgetIntValue()Returns current instantiation of the variable (when the variable is not instantiated the returned value is undefined)com.artelys.kalis.SWIGTYPE_p_KIntVar_IgetIntVar_I_ptr()booleangetIsInstantiated()Returns true if the variable has been assigned a value, false otherwisedoublegetMiddle()Returns value in variable's domain and close to the middlejava.lang.StringgetName()Return the name of the variablevoidgetNextDomainValue(com.artelys.kalis.SWIGTYPE_p_int next)Get value immediatly after "next" in the domain of the variable and put it into nextcom.artelys.kalis.SWIGTYPE_p_KNumVar_IgetNumVar_I_ptr()voidgetPrevDomainValue(com.artelys.kalis.SWIGTYPE_p_int prev)Get value immediatly before "prev" in the domain of the variable and put it into previntgetRandomValue()Get a random value in the domain of the variabledoublegetSup()Returns upper bound of this variabledoublegetTarget()Get target valuedoublegetValue()Returns current instantiation of the variable (when the variable is not instantiated the returned value is undefined)voidinstantiate(int value)Instantiate the variable to a valuebooleanisEqualTo(KIntVar x)Check if equal to xvoidoptimizeDomainRepresentation()Optimize the internal representation of the domainvoidprint()Pretty printing to the standard ouput streamvoidprint(com.artelys.kalis.SWIGTYPE_p_std__ostream fout)Pretty printing of the variable to an ouput streamvoidprint(com.artelys.kalis.SWIGTYPE_p_void ctx, com.artelys.kalis.SWIGTYPE_p_f_p_void_p_q_const__char__int pfp)Pretty printingvoidremVal(int value)Remove value from the variable's domainvoidsetInf(int value)Set the lower bound to valuevoidsetIntVar_I_ptr(com.artelys.kalis.SWIGTYPE_p_KIntVar_I intVar)voidsetName(java.lang.String name)Set the name of the variablevoidsetSup(int value)Set the upper bound to valuevoidsetTarget(int value)Set the target valuebooleanshaveFromLeft()Shave lower bound of variablebooleanshaveFromRight()Shave upper bound of variablebooleanshaveOnValue(int val)Shave the value 'val'voidupdateIndicators()-
Methods inherited from class com.artelys.kalis.KNumVar
canBeInstantiatedTo, getCPtr, getIndex, getInternalObject, getKProblem, getProblem, instantiate, isHidden, printConstraints, printConstraints, setHidden, setInf, setNumVar_I_ptr, setSup, setTarget, useShaving
-
-
-
-
Constructor Detail
-
KIntVar
protected KIntVar(long cPtr, boolean cMemoryOwn)
-
KIntVar
public KIntVar()
Default constructor
-
KIntVar
public KIntVar(KProblem problem, java.lang.String name, int minValue, int maxValue, boolean isBoundIntVar)
Main constructor : minValue and maxValue are the bounds of the KIntVar's domain
- Parameters:
problem- Involved problemname- Name of the variableminValue- lower bound for the variablemaxValue- upper bound for the variableisBoundIntVar- false if the domain may have holes, true otherwise
-
KIntVar
public KIntVar(KProblem problem, java.lang.String name, int minValue, int maxValue)
Main constructor : minValue and maxValue are the bounds of the KIntVar's domain
- Parameters:
problem- Involved problemname- Name of the variableminValue- lower bound for the variablemaxValue- upper bound for the variable
-
KIntVar
public KIntVar(KProblem problem, java.lang.String name, int minValue)
Main constructor : minValue and maxValue are the bounds of the KIntVar's domain
- Parameters:
problem- Involved problemname- Name of the variableminValue- lower bound for the variable
-
KIntVar
public KIntVar(KProblem problem, java.lang.String name)
Main constructor : minValue and maxValue are the bounds of the KIntVar's domain
- Parameters:
problem- Involved problemname- Name of the variable
-
KIntVar
public KIntVar(KProblem problem, java.lang.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 Detail
-
getCPtr
protected static long getCPtr(KIntVar obj)
-
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 java.lang.String getName()
Return the name of the variable
-
setName
public void setName(java.lang.String name)
Set the name of the variable
-
getInf
public double getInf()
Returns lower bound of this variable
-
getIntInf
public int getIntInf()
Returns integer lower bound of this variable
-
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
-
getIntSup
public int getIntSup()
Returns integer upper bound of this variable
-
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)
-
getIntValue
public int getIntValue()
Returns current instantiation of the variable (when the variable is not instantiated the returned value is undefined)
-
getIsInstantiated
public boolean getIsInstantiated()
Returns true if the variable has been assigned a value, false otherwise- Overrides:
getIsInstantiatedin classKNumVar
-
getDegree
public int getDegree()
Returns the number of constraints where this variable appears
-
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:
getCopyPtrin classKNumVar
-
getNumVar_I_ptr
public com.artelys.kalis.SWIGTYPE_p_KNumVar_I getNumVar_I_ptr()
- Overrides:
getNumVar_I_ptrin classKNumVar
-
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
-
print
public void print()
Pretty printing to the standard ouput stream
-
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:KNumVarPretty printing
-
_instanceof
public int _instanceof()
Description copied from class:KNumVarReturn the type of this variable
- Overrides:
_instanceofin classKNumVar
-
createIndicators
public void createIndicators()
-
updateIndicators
public void updateIndicators()
-
getIndicator
public KAuxVar getIndicator(int value)
-
-