KFloatVar¶
-
class KFloatVar : public KNumVar¶
This class implements a variable with continuous real valued domain. Conceptually the continuous variables can be represented the following way :
Example:
KProblem p(...); // X is a continuous variable that can take real value between interval [0..10] KFloatVar X(p,"X",0,10);
- See
KNumVarArray KFloatVarArray
- Since
2016.1
Public Functions
-
KFloatVar()¶
Empty constructor.
-
KFloatVar(KProblem &pb, const char *name)¶
Main constructor : minValue and maxValue are the bounds of the KFloatVar’s domain.
-
KFloatVar(KProblem &pb, const char *name, double lowerBound, double upperBound)¶
Constructor
- Parameters
pb – the problem
lowerBound – domain lower bound
upperBound – domain upper bound
-
KFloatVar(KProblem &pb, const char *name, double lowerBound, double upperBound, bool relativity, double precision)¶
Constructor
- Parameters
pb – the problem
lowerBound – domain lower bound
upperBound – domain upper bound
-
virtual ~KFloatVar()¶
Destructor
-
virtual void instantiate(const double value)¶
Instantiate the variable to value.
-
virtual void setName(const char *name)¶
Set the name of the variable.
-
virtual double getInf() const¶
returns lower bound of this variable
-
double getMiddle() const¶
returns value in variable’s domain and close to the middle
-
virtual double getSup() const¶
returns upper bound of this variable
-
int getDomainSize() const¶
returns current domain size of the variable
-
virtual double getValue(void) const¶
returns current instantiation of the variable (when the variable is not instantiated the returned value is undefined)
-
virtual bool getIsInstantiated() const¶
returns true if the variable has been assigned a value, false otherwhise
-
virtual int getDegree() const¶
returns the number of constraints where this variable appears
-
virtual double getTarget() const¶
get target value
-
double getRandomValue() const¶
get a random value in the domain of the variable
-
virtual void useShaving(bool use)¶
activate shaving Y/N
-
bool shaveFromLeft(void)¶
shave lower bound of variable
-
bool shaveFromRight(void)¶
shave upper bound of variable
-
bool shaveOnValue(int val)¶
shave the value ‘val’
-
virtual void setInf(double value)¶
set the lower bound to value
-
virtual void setSup(double value)¶
set the upper bound to value
-
virtual void setTarget(double value)¶
set the target value
-
void optimizeDomainRepresentation()¶
optimize the internal representation of the domain
-
bool canBeInstantiatedTo(int value)¶
check if value is in the domain
-
virtual void print() const¶
pretty printing of the variable
-
virtual void print(void *ctx, PrintFunctionPtr *pfp) const¶
pretty printing of the variable
-
void setPrecisionRelativity(bool relativity)¶
Set the precision relativity (true for relative precision and false for absolute precision.