Tires are made by combining rubber, oil, and carbon.
To make a set of four tires, we require 100 pounds of total product (rubber, oil, carbon)
Chemical Engineers tell you that the tensile strength, elasticity, and hardness of tires made of $r$ pounds of rubber, $h$ pounds of oil, and $c$ pounds of carbon are $$ \begin{aligned} \text{tensile strength} &= 12.5 - 0.1h - 0.001 h^2 \\ \text{elasticity} &= 17 + .35 r - 0.04 h - 0.002 r^2 \\ \text{hardness} &= 34 + 0.1r + 0.06h - 0.3c + 0.01rh + 0.005 h^2 + 0.001 c^{1.95} \end{aligned} $$
The purchasing department says rubber costs $0.04/pound, oil costs $0.01/pound, and carbon costs $0.07/pound. What is the cheapest way to make tires that satisfies all the above specifications?
using JuMP, Ipopt
m = Model(solver = IpoptSolver(print_level=0))
@variable(m, 25 <= r <= 60)
@variable(m, h >= 0)
@variable(m, c >= 50)
@constraint(m, r + h + c == 100)
@NLconstraint(m, tensile, 12.5 - 0.1h - 0.001h^2 >= 12)
@NLconstraint(m, elasticity, 17 + 0.35r - 0.04h - 0.002r^2 >= 16)
@NLconstraint(m, hard_lo, 25 <= 34 + 0.1r + 0.06h - 0.3c + 0.01r*h + 0.005h^2 + 0.001*c^1.95)
@NLconstraint(m, hard_hi, 34 + 0.1r + 0.06h - 0.3c + 0.01r*h + 0.005h^2 + 0.001*c^1.95 <= 35)
@objective(m, Min, 0.04r + 0.01h + 0.07c )
solve(m)
# rubber, oil, and carbon
getvalue([r h c])
1×3 Array{Float64,2}: 45.2277 4.77226 50.0
getdual(tensile)
0.2738612850889135
getdual(elasticity)
1.9972134957021497e-10
getdual(hard_lo)
-7.901486691922423e-10
getdual(hard_hi)
-3.6717705463624503e-10
using JuMP, Ipopt
ph = 0.05
pr = 0.1
pc = 0.02
m = Model(solver = IpoptSolver(print_level=0))
@variable(m, 4.77 >= h >= 0)
@variable(m, c >= 50)
@constraint(m, 50 <= h+c <= 75)
@NLconstraint(m, elasticity, 32 + 0.05c - 0.002c^2 + 0.01h - 0.004c*h - 0.002h^2 >= 16)
@NLconstraint(m, hard_lo, 25 <= 44 + 0.96h - 0.4c - 0.01c*h + 0.005h^2 + 0.001*c^1.95)
@NLconstraint(m, hard_hi, 44 + 0.96h - 0.4c - 0.01c*h + 0.005h^2 + 0.001*c^1.95 <= 35)
@objective(m, Min, (ph-pr)*h + (pc-pr)*c )
solve(m)
# rubber, oil, and carbon
getvalue([100-h-c h c])
1×3 Array{Float64,2}: 35.8973 4.77 59.3327
getdual(elasticity)
2.322670703444062e-10
getdual(hard_lo)
-0.22639354712390333
getdual(hard_hi)
-2.5041427095986944e-10