psamm.lpsolver.cplex – CPLEX LP solver

Linear programming solver using Cplex.

class psamm.lpsolver.cplex.Solver

Represents an LP-solver using Cplex

create_problem(**kwargs)

Create a new LP-problem using the solver

class psamm.lpsolver.cplex.CplexRangedProperty(get_prop, doc=None)

Decorator for translating Cplex ranged properties.

class psamm.lpsolver.cplex.Problem(**kwargs)

Represents an LP-problem of a cplex.Solver

cplex

The underlying Cplex object

define(*names, **kwargs)

Define a variable in the problem.

Variables must be defined before they can be accessed by var() or set(). This function takes keyword arguments lower and upper to define the bounds of the variable (default: -inf to inf). The keyword argument types can be used to select the type of the variable (Continuous (default), Binary or Integer). Setting any variables different than Continuous will turn the problem into an MILP problem. Raises ValueError if a name is already defined.

has_variable(name)

Check whether variable is defined in the model.

add_linear_constraints(*relations)

Add constraints to the problem

Each constraint is represented by a Relation, and the expression in that relation can be a set expression.

set_objective(expression)

Set objective expression of the problem.

set_linear_objective(expression)

Set objective of the problem.

Deprecated since version 0.19: Use set_objective() instead.

set_objective_sense(sense)

Set type of problem (maximize or minimize)

solve_unchecked(sense=None)

Solve problem and return result.

The user must manually check the status of the result to determine whether an optimal solution was found. A SolverError may still be raised if the underlying solver raises an exception.

result

Result of solved problem

feasibility_tolerance

Feasibility tolerance.

optimality_tolerance

Optimality tolerance.

integrality_tolerance

Integrality tolerance.

class psamm.lpsolver.cplex.Constraint(prob, name)

Represents a constraint in a cplex.Problem

delete()

Remove constraint from Problem instance

class psamm.lpsolver.cplex.Result(prob)

Represents the solution to a cplex.Problem

This object will be returned from the cplex.Problem.solve() method or by accessing the cplex.Problem.result property after solving a problem. This class should not be instantiated manually.

Result will evaluate to a boolean according to the success of the solution, so checking the truth value of the result will immediately indicate whether solving was successful.

success

Return boolean indicating whether a solution was found

status

Return string indicating the error encountered on failure

unbounded

Whether solution is unbounded

get_value(expression)

Return value of expression.