-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar Optimization.py
More file actions
73 lines (41 loc) · 1.08 KB
/
Copy pathCar Optimization.py
File metadata and controls
73 lines (41 loc) · 1.08 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
# coding: utf-8
from IPython.display import Image
Image(filename = r"Car Problem.PNG", width=875)
# ### Ignore the Fuel Economy Constraint!
import pandas as pd
from pulp import *
# initialize problem
prob = LpProblem("",)
# Initialize empty variables for how many cars to make
x = LpVariable("",0)
# Objective Function
prob += _____, ""
# Constraints
prob += + + + <= , " Constraint"
# Capacity Constraints
prob +=
# Market Demand Potential
prob +=
# Fuel Constraints
# IGNORE
# Subcompact and Compacts Constraint
prob +=
# Solve and Status
# No Need to Edit
prob.solve()
print("Status:", LpStatus[prob.status])
# Objective Solve
print("____ = ", value(prob.objective))
# Optimal Values
# No Need to Edit
# Each of the variables is printed with it's resolved optimum value
for v in prob.variables():
print(v.name, "=", v.varValue)
# Shadow Prices and Slack
# No Need to Edit
o = [{'name':name, 'shadow price':c.pi, 'slack': c.slack}
for name, c in prob.constraints.items()]
print(pd.DataFrame(o))
# Complete LP Problem Setup
print(prob)