Skip to content
Permalink
28850df6e6
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
38 lines (24 sloc) 949 Bytes
# Import all classes of PuLP module
from pulp import *
# Create the problem variable to contain the problem data
model = LpProblem("ToolsProblem", LpMaximize)
# Create 3 variables Steel, Molding_machine, and Assembly_machine
T1 = LpVariable("Tool1", 0, None, LpInteger)
T2 = LpVariable("Tool2", 0, None, LpInteger)
T3 = LpVariable("Tool3", 0, None, LpInteger)
# Create maximize objective function
model += 0.13 * T1 + 0.1 * T2 + 0.12 * T3
#Constraints:
model += 1*T1 + 0.7 * T2 + 0.6 * T3 <= 10000, "Steel"
model += 1*T1 + 1 * T2 + 1 * T3 <= 20000, "Molding_machine"
model += 0.3*T1 + 0.5 * T2 + 0.4 * T3 <= 9000, "Assembly_machine"
#Demand limits:
model += T1 <= 15000, "T1_DemandLimit"
model += T2 <= 16000, "T2_DemandLimit"
model += T3 <= 12000, "T3_DemandLimit"
model.solve()
for v in model.variables():
print(v.name, "=", v.varValue)
# print("T1 = ", T1.varValue)
# print("T2 = ", T2.varValue)
# print("T3 =" , T3.varValue)