-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q3.1.py
35 lines (24 loc) · 832 Bytes
/
Q3.1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#Question 3.1 by Hamed Rahimi
# s= stream r= reservoir
# Goal is to minimizae Cost which is equal to 100R+50S
# S+R <= 100
# S<= 100
# ((50S+250R)/(S+R)) <= 100 which is equal to 150R-50S<=0
import cvxpy as cp
# Create two scalar optimization variables.
r = cp.Variable()
s = cp.Variable()
# Create constraints.
constraints = [r + s == 500,
150*s-50*r <= 100,
s <= 100]
# Form objective.
obj = cp.Minimize(100*r + 50*s)
# Form and solve problem.
prob = cp.Problem(obj, constraints)
prob.solve() # Returns the optimal value.
print("The status of the problem is:", prob.status)
print("optimal value of minimization is:", prob.value)
print("optimal value of stream is :", r.value)
print("optimal value of reservoir is :", s.value)
#############################