#### Python Day 6:

**Linear Optimization with Paper Company**

Last time we did a Pirelli Glass Linear Optimization, it considered a simple problem, because it has only 2 variables.What should we do if there are more variables and with much more complexed constrain systems?

**Problem:**

Nancy Grant is the owner of Coal Bank Hollow Recycling company, there is two Recycling Process.

Material

- 70 tons of newspaper
- 50 tons of mixed paper
- 30 tons of white office paper
- 40 tons of cardboard

Production:

- 60 newsprint pulp
- 40 packaging paper pulp
- 50 print stock pulp

Let’s use the linear optimation method to minimize the recycle uses and find the most efficient way for recycling.

**Process Flow Chart**

**Solution**

#### Linear Model

#### MInmize total Cost

f(x)= 13×15+12×16+11×25+13×26+9×35+10×36+13×45+14×46+5×57+6×58+8×59+6×67+8×68+7×69

#### General Constraints:

all xij>=0

#### Raw Material constraints :

- newspaper : x15+x16<=70
- mixed paper x25+x26<=50
- White office paper x35+x36<=30
- cardboard x45+x46<=40

#### Recycling Processes Constraints:

- Recycle Method 1:

0.9x15+0.8x25+0.95x35+0.75x45−x57−x58−x59>=0

- Recycle Method 2:

0.85x16+0.85x26+0.9x36+0.85x46−x67−x68−x69>=0

#### Production Paper Constraints:

- newsprint : 0.95x 57 +0.9x 67 >=60

- packaging paper 0.9x 58 +0.95x 68 >=40
- stock paper 0.9x 59 +0.95x 69 >=50

**Python Code:**

import numpy as np from scipy.optimize import linprog from numpy.linalg import solve # Note we need to multiply "-1" in order to change the ">=" sign A_ub= np.array([ [1,1,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,1,1,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,1,1,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,1,1,0,0,0,0,0,0], [-0.95,0,-0.8,0,-0.95,0,-0.75,0,1,1,1,0,0,0], [0,-0.85,0,-85,0,-0.9,0,-0.85,0,0,0,1,1,1], [0,0,0,0,0,0,0,0,-0.95,0,0,-0.9,0,0], [0,0,0,0,0,0,0,0,0,-0.9,0,0,-0.95,0], [0,0,0,0,0,0,0,0,0,0,-0.9,0,0,-0.95] ]) b_ub=np.array([70,50,30,40,0,0,-60,-40,-0]) c=np.array([13, 12, 11,13, 9, 10, 13, 14, 5, 6, 8, 6, 8,7]) best = linprog(c, A_ub= A_ub, b_ub=b_ub, bounds=(0, None)) best.fun best.x

**Output:**

From the result, we can see minimal cost is **1129.94 Dollars**, with 1.89 Mixed paper goes to Recycle process 2 and print 66.67 ton newsprint plus 42.1 ton Packing paper and 52.6 ton Stock Paper