KXPRSLinearRelaxationSolver

class KXPRSLinearRelaxationSolver : public KLinearRelaxationSolver

This linear relaxation solver relies on XPress Optimizer to solve the LP/MIP problem.

Example:

// ...
KProblem myProblem(mySession,"");
// ...
KLinearRelaxation * relax = myProblem.getLinearRelaxation();
KXPRSLinearRelaxationSolver mySolver(*relax, objectiveVar, KProblem::Minimize);

You must have XPress Optimizer installed to use this.

Since

2016.1

Public Functions

KXPRSLinearRelaxationSolver(KLinearRelaxation &relax, const KNumVar &obj, KProblem::Sense sense, int storedBasisSize = 1000)

Constructor (note: no default constructor).

Parameters
  • relax – domain (a linear relaxation)

  • obj – the objective variable

  • sense – the sense for optimization

  • storedBasisSize – maximum depth for basis reload

KXPRSLinearRelaxationSolver(const KXPRSLinearRelaxationSolver&)

copy constructor

virtual ~KXPRSLinearRelaxationSolver()

destructor

virtual void setObjective(const KNumVar &var)

Set objective variable.

Parameters

var – the new objective variable

virtual int solve()

Call (XPress-Optimizer) and return an error code (see class KLinearRelaxationSolver for its meaning).

virtual double getBound(void) const

Get the bound computed by the solver (see class KLinearRelaxationSolver).

virtual double getBestBound(void) const

Get the best bound in a branch and bound tree.

Useful if search terminated before optimality.

virtual void print(void) const

Print the internal state of the solver. Use is discouraged, use method writeLP to output the content of the solver.

virtual int writeLP(const char *filename) const

Write the current problem to a file in lp format.

virtual void generateCuts(KLinearRelaxation *relaxation)

Generate cuts.

If possible, cuts are added to the matrix of constraints to make the relaxation tighter and improve the bound.

void printSolution(bool MIPflag)

Print the current solution.

Parameters

MIPflag – to choose whether to print the current MIP solution or the current LP solution

void printVariables(void) const

Print variables name and their rank. This is useful to recover the meaning of the columns in the LP file produced by writeLP().

virtual double getMIPSolution(const KNumVar &var) const

Get the current MIP solution for a KNumVar variable.

Parameters

var – variable whose value is checked

virtual double getMIPSolution(const KAuxVar &var) const

Get the current MIP solution for a KAuxVar variable.

Parameters

var – variable whose value is checked

virtual double getLPSolution(const KNumVar &var) const

Get the current MIP solution for a KNumVar variable.

Parameters

var – variable whose value is checked

virtual double getLPSolution(const KAuxVar &var) const

Get the current LP solution for a KAuxVar variable.

Parameters

var – variable whose value is checked

void updateSolution(bool MIPflag)

Update the KHybridSolution object with the current MIP (MIPflag=true) or LP (MIPflag=false) solution.

Parameters

MIPflag – true to get the current MIP solution, false for LP.

KHybridSolution *getSolutionPtr(void) const

Get a pointer to the solution contained in the solver. Method updateSolution must be used before the call.

virtual int getNumberGlobals(void) const

Get the number of global variables.

Returns

number of global variables

virtual double getReducedCost(const KNumVar &var) const

Get reduced costs. Note that LP solve is must be complete.

Parameters

var – the variable whose reduced cost in the current LP solution is retrieved

Returns

reduced cost value

virtual double getReducedCost(const KAuxVar &var) const

Get reduced costs. Note that LP solve must be complete.

Parameters

var – the variable whose reduced cost in the current LP solution is retrieved

Returns

reduced cost value

void printSolverOutput(bool flag)

Activate or deactivate solver verbose output.

void setPresolve(bool)

Activate or deactivate presolve.

void setMipRelStop(double)

Set MIPRELSTOP double control.

virtual void instantiateNumVarsToCurrentSol(void)

Instantiate variables to current solution obtained by linear relaxation solver.

virtual void instantiateNumVarToCurrentSol(KNumVar *var)

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