-
Notifications
You must be signed in to change notification settings - Fork 0
/
T-Shirts.py
27 lines (22 loc) · 882 Bytes
/
T-Shirts.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
import pulp
#
# Initialize model
model = pulp.LpProblem("Tshirt_Problem", pulp.LpMaximize)
# Define variables
x1 = pulp.LpVariable("white", lowBound=0, upBound=50, cat="Integer")
x2 = pulp.LpVariable("blue", lowBound=0, upBound=15, cat="Integer")
x3 = pulp.LpVariable("yellow", lowBound=0, upBound=10, cat="Integer")
x4 = pulp.LpVariable("red", lowBound=0, upBound=12, cat="Integer")
# Profit
model += 7 * x1 + 8 * x2 + 8 * x3 + 6 * x4, "Total Profit"
# Constraints
model += x1 + x2 + x3 + x4 == 50 # Total shirts constraint
model += 20 * x2 + 20 * x3 + 40 * x4 <= 480 # Time constraint
# Solve the problem
model.solve()
# Print the solution
print(f"White shirts: {x1.value()}")
print(f"Blue shirts: {x2.value()}")
print(f"Yellow shirts: {x3.value()}")
print(f"Red shirts: {x4.value()}")
print(f"Total profit: {pulp.value(model.objective)}")