LpSolver

Declared in lemon/lp_base.h, in the group LP and MIP Solvers; the same class on the Doxygen site.

class LpSolver : public virtual LpBase

Common base class for LP solvers.

This class is an abstract base class for LP solvers. This class provides a full interface for set and modify an LP problem, solve it and retrieve the solution. You can use one of the descendants as a concrete implementation, or the Lp default LP solver. However, if you would like to handle LP solvers as reference or pointer in a generic way, you can use this class directly.

Subclassed by ClpLp, CplexLp, GlpkLp, LpSkeleton, SoplexLp

Solve the LP

inline SolveExitStatus solve()

SolveExitStatus.

Solve the LP problem at hand

Returns:

The result of the optimization procedure. Possible values and their meanings can be found in the documentation of

Obtain the Solution

inline ProblemType primalType() const

The type of the primal problem.

inline ProblemType dualType() const

The type of the dual problem.

inline Value primal( Col c ) const

Return the primal value of the column.

Pre:

The problem is solved.

inline Value primal( const Expr & e ) const

Return the primal value of the expression.

Return the primal value of the expression, i.e. the dot product of the primal solution and the expression.

Pre:

The problem is solved.

inline Value primalRay( Col c ) const

Returns a component of the primal ray.

The primal ray is solution of the modified primal problem, where we change each finite bound to 0, and we looking for a negative objective value in case of minimization, and positive objective value for maximization. If there is such solution, that proofs the unsolvability of the dual problem, and if a feasible primal solution exists, then the unboundness of primal problem.

Note

Some solvers does not provide primal ray calculation functions.

Pre:

The problem is solved and the dual problem is infeasible.

inline Value dual( Row r ) const

Return the dual value of the row.

Pre:

The problem is solved.

inline Value dual( const DualExpr & e ) const

Return the dual value of the dual expression.

Return the dual value of the dual expression, i.e. the dot product of the dual solution and the dual expression.

Pre:

The problem is solved.

inline Value dualRay( Row r ) const

Returns a component of the dual ray.

The dual ray is solution of the modified dual problem, where we change its right-hand sides (i.e. the objective function coefficients in the primal problem) to 0, and we look for a positive objective value. If there is such solution, that proofs the unsolvability of the primal problem, and if a feasible dual solution exists, then the unboundness of dual problem.

Note

Some solvers does not provide dual ray calculation functions.

Pre:

The problem is solved and the primal problem is infeasible.

inline VarStatus colStatus( Col c ) const

Return the basis status of the column.

See also

VarStatus

inline VarStatus rowStatus( Row r ) const

Return the basis status of the row.

See also

VarStatus

inline Value primal() const

The value of the objective function.

Returns:

  • INF or -INF means either infeasibility or unboundedness of the primal problem, depending on whether we minimize or maximize.

  • NaN if no primal solution is found.

  • The (finite) objective value if an optimal solution is found.

Public Types

enum ProblemType

The problem types for primal and dual problems.

Values:

enumerator UNDEFINED

= 0. Feasible solution hasn’t been found (but may exist).

enumerator INFEASIBLE

= 1. The problem has no feasible solution.

enumerator FEASIBLE

= 2. Feasible solution found.

enumerator OPTIMAL

= 3. Optimal solution exists and found.

enumerator UNBOUNDED

= 4. The cost function is unbounded.

enum VarStatus

The basis status of variables.

Values:

enumerator BASIC

The variable is in the basis.

enumerator FREE

The variable is free, but not basic.

enumerator LOWER

The variable has active lower bound.

enumerator UPPER

The variable has active upper bound.

enumerator FIXED

The variable is non-basic and fixed.

Public Functions

virtual LpSolver * newSolver() const = 0

Allocate a new LP problem instance.

virtual LpSolver * cloneSolver() const = 0

Make a copy of the LP problem.

Protected Functions

virtual SolveExitStatus _solve() = 0
virtual Value _getPrimal( int i ) const = 0
virtual Value _getDual( int i ) const = 0
virtual Value _getPrimalRay( int i ) const = 0
virtual Value _getDualRay( int i ) const = 0
virtual Value _getPrimalValue() const = 0
virtual VarStatus _getColStatus( int i ) const = 0
virtual VarStatus _getRowStatus( int i ) const = 0
virtual ProblemType _getPrimalType() const = 0
virtual ProblemType _getDualType() const = 0