Professional Documents
Culture Documents
Python4 2
Python4 2
Lab MST-4
1. Aim:
You are planning to build a portfolio of investments consisting of three assets: Asset X, AssetY,
and Asset Z. Each asset has a certain expected return and risk associated with it. You have a
total of $1,000,000 to invest. However, you also have the following constraints and Maximise
the expected return on investment while minimising the risk. • You want to invest at least
$300,000 in Asset X. • You want to invest at least $200,000 in Asset Y. • You want to invest at
least $100,000 in Asset Z. • You cannot invest more than $600,000 in Asset X. • You cannot
invest more than $400,000 in Asset Y. • You cannot invest more than $300,000 in Asset Z.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
2. Source Code:
import pulp
prob += x + y + z == 1000000,
prob += x >= 300000,
prob += y >= 200000,
prob += z >= 100000,
prob.solve()
print("Optimal Portfolio:")
for var in prob.variables():
print(f"{var.name}: ${var.varValue:.2f}")
print(f"Total Expected Return: ${pulp.value(prob.objective):.2f}")
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Screenshot of Outputs:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Learning Outcomes: