# Solving linear programming problems (LPPs) using Pyomo

--

In this tutorial, we learn how to solve linear programming problems (LPPs) using Pyomo. Pyomo stands for **P**ython **O**ptimization **M**odeling **O**bjects. This is an algebraic modeling language.

Pyomo is a Python-based, open-source optimization modeling language with a diverse set of optimization capabilities. — http://www.pyomo.org/

In this tutorial, we consider an optimization problem and then we formulate it as a linear programming problem (LPP). After that, we learn how to write a Pyomo-based model using Python to solve the problem.

# Example problem

Consider a chocolate manufacturing company that produces only two types of chocolate — A and B. Both the chocolates require Milk and Choco only. To manufacture each unit of A and B, the following quantities are required:

- Each unit of A requires 1 unit of Milk and 3 units of Choco,
- Each unit of B requires 1 unit of Milk and 2 units of Choco.

The company kitchen has a total of 5 units of Milk and 12 units of Choco. On each sale, the company makes a profit of

- Rs. 6 per unit A sold,
- Rs. 5 per unit B sold.

Now, the company wishes to maximize its profit. How many units of A and B should it produce, respectively?

# Mathematical formulation

Now, we formulate the above optimization problem as an LPP. An LPP has mainly three components — decision variables, the objective function, and constraints.

## Decision variables:

*x*be the total number of units produced by A,*y*be the total number of units produced by B.

## Objective function:

Maximize 6*x *+ 5*y*

## Constraints:

*x *+ *y *≤ 5

3*x *+ 2*y *≤ 12

*x *≥ 0, y ≥ 0