Elpee Logo

elpee.LinearProblem

Class to represent the linear programming optimization problem with its objective function, constraints and other conditions

Import

from elpee import LinearProblem

Methods

__init__(is_maximization: bool = True, objective_expr: str = None) None

Creates an empty elpee.LinearProblem to be solved with sense either Maximize (True) or Minimize (False).

Parameters

  • is_maximizationbool [Default = True]

    Sets a maximization LP problem when True. Else sets a minimization LP problem.

  • objective_exprstr [Optional]

    String expression of the objective function of LP Problem

Example Code

lp_problem = LinearProblem(is_maximization=True)
add_objective(objective_expr: str) None

Define the objective function expression into the linear programming problem. Replaces previous objective function.

Parameters

  • objective_exprstr

    String expression of the objective function of LP Problem

Exceptions

ValueError is thrown when objective function expression is not valid

Example Code

lp_problem.add_objective("5*x1 + 4*x2")
add_constraint(constraint_expr: str) None

Add a new constraint to existing LP Problem.

Parameters

  • constraint_exprstr`

    String expression of a mathematical inequality of equality to represent as a new constraint

Exceptions

ValueError is thrown when objective function expression is not valid

Example Code

lp_problem.add_constraint("6*x1 + 4*x2 <= 24")
lp_problem.add_constraint("x1 + 2*x2 <= 6")
use_bigM None

Configures the LP problem to be solved using big M method

use_dual_simplex None

Configures the LP problem to be solved using Dual Simplex method

standardize_problem `elpee.StandardProblem`

Convert the given Linear Programming problem into a Standardized Linear Programming Problem for computation

Returns

elpee.StandardProblem object with LinearProblem converted for computation

Example Code

lp_problem.standardize_problem()