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

Formal Assessment 4

Uploaded by

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

Formal Assessment 4

Uploaded by

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

DEPARTMENT OF

COMPUTER SCIENCE &


ENGINEERING
WORKSHEET 4

Student Name: Piyushree Rani Sinha UID: 22BCS13178


Branch: CSE Section/Group:22BCS_TPP-716A
Semester: 4th
Date of Performance: 11/4/24
Subject Code: 22CSH-259
Subject Name: PYTHON

1. Aim: A company produces two products, Product X and Product Y,


using two types of resources: Labour and Material. Each unit of
Product X requires 2 hours of labour and 1 unit of material, while each
unit of Product Y requires 3 hours of labour and 2 units of material.
The company has 100 hours of labour and 80 units of materials
available. The profit earned from each unit of Product X is $10, and
from Product Y is $15. Maximize the total profit.
Constraints:
xLimited availability of labour(100 hours)
xLimited availability of materials(80 hours)

2. Source Code:
from scipy.optimize import linprog

# Coefficients of the objective function


c = [-10, -15] # Coefficients are negated because linprog minimizes
the objective function

# Coefficients of the inequality constraints


A = [[2, 3], [1, 2]]
B = [100, 80]

# Bounds for decision variables


DEPARTMENT OF
COMPUTER SCIENCE &
ENGINEERING
x0_bounds = (0, None) # Bounds for Product X and Y
x1_bounds = (0, None)

# Solve the linear programming problem


res = linprog(c, A_ub=A, B_ub=B, bounds=[x0_bounds, x1_bounds],
method='highs')

# Print the results


print("Optimal solution:")
print("Number of units of Product X:", round(res.x[0], 2))
print("Number of units of Product Y:", round(res.x[1], 2))
print("Total profit: $", -res.fun,2) # Objective function value needs to
be negated to get the total profit

3. Output:
DEPARTMENT OF
COMPUTER SCIENCE &
ENGINEERING

4. Learning Outcomes:
 Learnt about the concept of optimization and its types.
 Learnt how I can find about the optimised solution in the given set of
feasible solutions.
 Learnt the concept about the linear programming.
 Learnt how to build the constraints based on the limitations given in
the problem, such as limited availability of labor and materials.
 Learnt how to formulate the objective function, which represents the
quantity to be maximized or minimized, in this case, total profit.
 Real-world Application

You might also like