KLinTerm

class KLinTerm : public KTerm

This class represent a linear term of the form Sum(coeffs[i].lvars[i]) + cst

Example :

KProblem p(...);
KIntVarArray X(...);

KLinTerm linTerm;

linTerm = 3 * X[0];
linTerm = linTerm + 5;
linTerm = linTerm + 2 * X[1];
linTerm = linTerm - 3 * X[2] + 5 * X[3];
linTerm = linTerm - 7;
// these lines are equivalent to :
// linTerm = 3 * X[0] + 2 * X[1] - 3 * X[2] + 5 * X[3] - 2

// posting the constraint  3 * X[0] + 2 * X[1] - 3 * X[2] + 5 * X[3] - 2 >= 5
// will be converted into  -3 * X[0] - 2 * X[1] + 3 * X[2] - 5 * X[3] + 7 <= 0
p.post(linTerm >= 5);

See

KConstraint KLinComb

Since

2016.1

Public Functions

KLinTerm()

Default constructor.

KLinTerm(const KNumVarArray &lvars, const KDoubleArray &coeffs, const double cste)

Main constructor.

KLinTerm(const KNumVarArray &lvars, const double cste)

Each KIntVar has a coefficient 1.

KLinTerm(const KLinTerm &linTermToCopy)

Copy constructor.

KLinTerm(const KLinTerm &linTermToCopy, int pb)

Copy constructor for a specific instance.

KLinTerm(const KNumVarArray &lvars, const KIntArray &coeffs, const double cste)

Constructor with a KIntArray (integers are casted to double)

KLinTerm(const KIntVarArray &lvars, const KDoubleArray &coeffs, const double cste)

Constructor with a KIntVarArray and double array.

KLinTerm(const KIntVarArray &lvars, const KIntArray &coeffs, const double cste)

Constructor with a KIntVars KIntArray (integers are casted to double)

KLinTerm(const KNumVar &intVar)

Cast a KIntVar into a KLinTerm.

KLinTerm(const KUnTerm &unTerm)

Cast a KNumUnTerm into a KLinTerm.

KLinTerm(const KBinTerm &binTerm)

Cast a KNumBinTerm into a KLinTerm.

virtual void print(std::ostream &fout) const

pretty print method

virtual void print() const

pretty print method