KRelaxationSolver

class KRelaxationSolver : public KAbstractPtrArray<KRelaxationSolver>

This class is intended as a superclass for linear relaxation solvers.

Such a solver must be provided with

It relies on a LP/MIP solver to provide the following information:

  • a value (a bound for the relaxed problem, cf method getBound())

  • a solution, possibly not feasible for the original problem, but which can be used to guide the search for a feasible solution

  • if the problem is LP, reduced costs (that can be used for instance in the “reduced cost fixing” procedure).

Since

2016.1

Subclassed by KLinearRelaxationSolver

Public Functions

virtual void setObjective(const KNumVar &var) = 0

Set objective variable.

Parameters

var – the new objective variable

virtual int solve() = 0

Solve the relaxed optimization problem.

This methods returns the following error codes :

  • 0 : optimal

  • 1 : infeasible

  • 2 : search interrupted prematurely, a solution was found

  • 3 : search interrupted prematurely, no solution was found

  • 4 : other problem

virtual double getBound(void) const = 0

Get the (lower for minimization, upper for maximization) bound computed by solve().

Note that :

bool isGlobal(const KIntVar&)

Return true if the given variable is set as global.

bool isGlobal(const KAuxVar&)

Return true if the given variable is set as global.

void setGlobal(const KIntVar &var, bool isGlobal)

Set (or unset) a KIntVar as global.

Parameters
  • var – variable to modify

  • isGlobal – new global status

void setGlobal(const KAuxVar &var, bool isGlobal)

Set (or unset) a KAuxVar global.

Parameters
  • var – variable to check

  • isGlobal – new global status

void setAllGlobal(bool isGlobal)

(Un)set variables as global.

Set or unset as “global” all KIntVar and KAuxVar with global type (note that a KFloatVar variables are not modified, since it would make little sense to set them global.)

Parameters

isGlobal – new global status

void setIndicatorsGlobal(bool isGlobal)

Set all indicator auxiliary variables global.

Parameters

isGlobal – new global status

void setSense(KProblem::Sense)

Set the sense of optimization (maximize, minimize).

Parameters

sense – new sense for optimization

virtual double getMIPSolution(const KNumVar &var) const = 0

Get the current MIP solution for a given KNumVar variable.

Parameters

var – variable whose solution is checked

Returns

value of var in the current MIP solution

virtual double getMIPSolution(const KAuxVar &var) const = 0

Get the current MIP solution for a given KAuxVar variable.

Parameters

var – variable whose solution is checked

Returns

value of var in the current MIP solution

virtual double getLPSolution(const KNumVar &var) const = 0

Get the current LP solution for a given KNumVar variable.

Parameters

var – variable whose value is checked

Returns

value of var in the current MIP solution

virtual double getLPSolution(const KAuxVar &var) const = 0

Get the current relaxed solution for a given KAuxVar variable.

Parameters

var – variable whose value is checked

Returns

value of var in the current solution

virtual int getNumberGlobals(void) const = 0

Get the total number of global variables.

double getTotalTimeSpentInComputation(void) const

Get the total amount of time spent in computations since the object was built.

double getTimeSpentInLastComputation(void) const

Get the amount of time spent during the last call to solve().

void setSolveAsMIP(bool flag)

Set this flag to 0 if you want to solve as LP a linear relaxation containing global entities (1 is the default).

Deprecated:

The new way of doing this is to use a configurator

Parameters

flag – New flag value

bool solveAsMIP()

Return true if the flag “solveAsMIP” is set.

void setMaxMIPSol(int)

Stop global search after maxMIPSol feasible solutions found.

0 for no limit, this is the default. If the limit is low, this is likely to cause optimization to end before optimality.

void setAlgorithm(int alg)

Set the resolution algorithm.

int getAlgorithm()

Get the resolution algorithm.

virtual void instantiateNumVarsToCurrentSol(void) = 0

Instantiate variables to current solution obtained by linear relaxation solver.

virtual void instantiateNumVarToCurrentSol(KNumVar *var) = 0

Instantiate a variables to current solution obtained by linear relaxation solver.

virtual void generateCuts(KLinearRelaxation *relaxation) = 0

Cut generation.

void setConfigurator(KRelaxationSolverConfigurator *configurator)

Set the configurator of a KRelaxationSolver.

KRelaxationSolverConfigurator *getConfigurator()

Get the configurator of a KRelaxationSolver.