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 constructorprotected
KIntVar(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
boolean
canBeInstantiatedTo(int value)
Check if value is in the domainvoid
createIndicators()
void
delete()
protected void
finalize()
KIntVar
getCopyPtr()
Return a copy of this KIntVar objectprotected static long
getCPtr(KIntVar obj)
int
getDegree()
Returns the number of constraints where this variable appearsint
getDomainSize()
Returns current domain size of the variableKAuxVar
getIndicator(int value)
double
getInf()
Returns lower bound of this variableKIntVar
getInstance(long pb)
int
getIntInf()
Returns integer lower bound of this variableint
getIntSup()
Returns integer upper bound of this variableint
getIntValue()
Returns current instantiation of the variable (when the variable is not instantiated the returned value is undefined)com.artelys.kalis.SWIGTYPE_p_KIntVar_I
getIntVar_I_ptr()
boolean
getIsInstantiated()
Returns true if the variable has been assigned a value, false otherwisedouble
getMiddle()
Returns value in variable's domain and close to the middlejava.lang.String
getName()
Return the name of the variablevoid
getNextDomainValue(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_I
getNumVar_I_ptr()
void
getPrevDomainValue(com.artelys.kalis.SWIGTYPE_p_int prev)
Get value immediatly before "prev" in the domain of the variable and put it into prevint
getRandomValue()
Get a random value in the domain of the variabledouble
getSup()
Returns upper bound of this variabledouble
getTarget()
Get target valuedouble
getValue()
Returns current instantiation of the variable (when the variable is not instantiated the returned value is undefined)void
instantiate(int value)
Instantiate the variable to a valueboolean
isEqualTo(KIntVar x)
Check if equal to xvoid
optimizeDomainRepresentation()
Optimize the internal representation of the domainvoid
print()
Pretty printing to the standard ouput streamvoid
print(com.artelys.kalis.SWIGTYPE_p_std__ostream fout)
Pretty printing of the variable to an ouput streamvoid
print(com.artelys.kalis.SWIGTYPE_p_void ctx, com.artelys.kalis.SWIGTYPE_p_f_p_void_p_q_const__char__int pfp)
Pretty printingvoid
remVal(int value)
Remove value from the variable's domainvoid
setInf(int value)
Set the lower bound to valuevoid
setIntVar_I_ptr(com.artelys.kalis.SWIGTYPE_p_KIntVar_I intVar)
void
setName(java.lang.String name)
Set the name of the variablevoid
setSup(int value)
Set the upper bound to valuevoid
setTarget(int value)
Set the target valueboolean
shaveFromLeft()
Shave lower bound of variableboolean
shaveFromRight()
Shave upper bound of variableboolean
shaveOnValue(int val)
Shave the value 'val'void
updateIndicators()
-
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:
getIsInstantiated
in 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:
getCopyPtr
in classKNumVar
-
getNumVar_I_ptr
public com.artelys.kalis.SWIGTYPE_p_KNumVar_I getNumVar_I_ptr()
- Overrides:
getNumVar_I_ptr
in 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:KNumVar
Pretty printing
-
_instanceof
public int _instanceof()
Description copied from class:KNumVar
Return the type of this variable
- Overrides:
_instanceof
in classKNumVar
-
createIndicators
public void createIndicators()
-
updateIndicators
public void updateIndicators()
-
getIndicator
public KAuxVar getIndicator(int value)
-
-