import pulp

# Instantiate our problem class
model = pulp.LpProblem("Profit maximising problem", pulp.LpMaximize)

"""
Explanation: Introduction to Linear Programming with Python - Part 3
Real world examples - Resourcing Problem
We'll now look at 2 more real world examples. 
The first is a resourcing problem and the second is a blending problem.
Resourcing Problem
We're consulting for a boutique car manufacturer, producing luxury cars.
They run on one month (30 days) cycles, we have one cycle to show we can provide value.
There is one robot, 2 engineers and one detailer in the factory. The detailer has some holiday off, so only has 21 days available.
The 2 cars need different time with each resource:
Robot time: Car A - 3 days; Car B - 4 days.
Engineer time: Car A - 5 days; Car B - 6 days.
Detailer time: Car A - 1.5 days; Car B - 3 days.
Car A provides €30,000 profit, whilst Car B offers €45,000 profit.
At the moment, they produce 4 of each cars per month, for €300,000 profit. Not bad at all, but we think we can do better for them.
This can be modelled as follows:
Maximise
Profit = 30,000A + 45,000B
Subject to:
A ≥ 0
B ≥ 0
3A + 4B  ≤ 30
5A + 6B  ≤ 60
1.5A + 3B  ≤ 21
End of explanation
"""


A = pulp.LpVariable('A', lowBound=0, cat='Integer')
B = pulp.LpVariable('B', lowBound=0, cat='Integer')

# Objective function
model += 30000 * A + 45000 * B, "Profit"

# Constraints
model += 3 * A + 4 * B <= 30
model += 5 * A + 6 * B <= 60
model += 1.5 * A + 3 * B <= 21

# Solve our problem
model.solve()
pulp.LpStatus[model.status]

# Print our decision variable values
print "Production of Car A = {}".format(A.varValue)
print "Production of Car B = {}".format(B.varValue)

# Print our objective function value
print pulp.value(model.objective)

"""
Explanation: Unlike our previous problem, the decision variables in this case won't be continuous (We can't sell half a car!), so the category is integer.
End of explanation
"""


