0% found this document useful (0 votes)
26 views3 pages

Quantitative Exercise 1 and 2

The document contains two linear programming problems. The first problem involves maximizing profit from production using two machines. The second problem involves minimizing cost of fertilizer purchase to meet requirements. Python code is provided to solve both problems using PuLP.

Uploaded by

Shewa Denek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

Quantitative Exercise 1 and 2

The document contains two linear programming problems. The first problem involves maximizing profit from production using two machines. The second problem involves minimizing cost of fertilizer purchase to meet requirements. Python code is provided to solve both problems using PuLP.

Uploaded by

Shewa Denek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Exercise 1

A company makes two products (X and Y) using two machines (A and B).
Each unit of X that is produced requires 50 minutes of processing time on machine A and 30
Minutes of processing time on machine B. Each unit of Y that is produced requires 24 minutes of
processing time on machine A and 33 minutes of processing time on machine B. Available processing
time on machine A is forecasted to be 35 hours. The company expects a profit of birr 75 per unit from X
and birr 95 from Y.

a) Formulate the problem as a linear programming.


b) Solve it using the graphical approach.

Exercise 2
Graphical method for L.P minimization problem

The agricultural institute suggested to a farmer to spread out at least 480kg of phosphate fertilizer and
not less than 720kg of nitrogen fertilizer to raise productivity of crops in his field. There are two sources
for obtaining these mixtures A and B. Both of these are available in bags weighing 100kg each and they
cost birr 40 and 24 respectively. Mixture A contains phosphate and nitrogen equivalent of 20kg and 80kg
respectively, while mixture B contains these ingredient equivalent of 40kg each.

a) Formulate this as a linear programming problem.


b) Determine how many bags of each type the farmer should buy in order to obtain the required
fertilizer at minimum cost.

Answer 1

A) The problem can be modeled as a linear programming problem with the


following variables:
Let x be the number of units of X produced Let y be the number of units of Y produced
The objective function to maximize profit can be written as Maximize Z = 75x + 95y
Subject to the following constraints: 50x + 24y ≤ 6035 (processing time on machine A)
30x + 33y ≤ 6024 (processing time on machine B) x, y ≥ 0 (non-negative production
quantities)
To solve it using the graphical approach 12, we can plot the feasible region defined by
the constraints and find the vertex with the highest profit value. However, since there
are many values for x and y that satisfy the constraints we will use the simplex algorithm
to solve it.

B) from pulp import *

# Create the LP problem as maximization problem


prob = LpProblem("Production problem", LpMaximize)
# Define decision variables
x = LpVariable("X", 0)
y = LpVariable("Y", 0)

# Define objective function


prob += 75 * x + 95 * y, "Total profit"

# Define constraints
prob += 50 * x + 24 * y <= 60 * 35, "Machine A processing time"
prob += 30 * x + 33 * y <= 60 * 24, "Machine B processing time"

# Solve the problem using PuLP's choice of solver


GLPK().solve(prob)

# Print the solution status


print("Status: ", LpStatus[prob.status])

# Print the optimal values of the decision variables


print("Number of units of X to produce: ", x.value())
print("Number of units of Y to produce: ", y.value())

# Print the optimal objective function value


print("Total profit: ", value(prob.objective))

The output will show the optimal solution, which is 358.333 units of X and 397.917 units of Y for
a total profit of 67,916.67 birr.

Answer 2

a) The problem can be modeled as a linear programming problem with the following
variables:
Let x be the number of bags of mixture A to buy Let y be the number of bags of mixture
B to buy
The objective function to minimize cost can be written as: Minimize Z = 40x + 24y
Subject to the following constraints: 20x + 40y ≥ 480 (phosphate fertilizer requirement)
80x + 40y ≥ 720 (nitrogen fertilizer requirement) x, y ≥ 0 (non-negative quantities of
bags)

The objective function to minimize cost can be written as: Minimize Z = 40x + 24y
Subject to the following constraints: 20x + 40y ≥ 480 (phosphate fertilizer requirement)
80x + 40y ≥ 720 (nitrogen fertilizer requirement) x, y ≥ 0 (non-negative quantities of
bags)
b) Here is the Python code to solve the problem using PuLP library:
from pulp import *

# Create the LP problem as minimization problem


prob = LpProblem("Fertilizer problem", LpMinimize)

# Define decision variables


x = LpVariable("X", 0)
y = LpVariable("Y", 0)

# Define objective function


prob += 40 * x + 24 * y, "Total cost"

# Define constraints
prob += 20 * x + 40 * y >= 480, "Phosphate fertilizer
requirement"
prob += 80 * x + 40 * y >= 720, "Nitrogen fertilizer requirement"

# Solve the problem using PuLP's choice of solver


GLPK().solve(prob)

# Print the solution status


print("Status: ", LpStatus[prob.status])

# Print the optimal values of the decision variables


print("Number of bags of mixture A: ", x.value())
print("Number of bags of mixture B: ", y.value())

# Print the optimal objective function value


print("Total cost: ", value(prob.objective))
The output will show the optimal solution, which is to buy 6 bags of mixture A and 6
bags of mixture B for a total cost of 384 birr.
Therefore, the farmer should buy 6 bags of mixture A and 6 bags of mixture B in order
to obtain the required fertilizer at minimum cost.

You might also like