Hi! I am working through the introductory exercises of “Linear Programming & Network Flows” by Bazaraa et.al by writing and solving them as JuMP programs. Actually, my question is about an example from the Introduction.
The problem is basically this:
# A company wishes to determine the production rate over the planning
# horizon of the next T weeks such that the known demand is satisfied
# and the total production and inventory cost is minimized.
and the mathematical formulation is:
which we can discretize as:
and this is the linear program I am trying to write.
To be honest, I haven’t tried a lot to do this, but I got this far:
using JuMP
using Clp
m=Model(with_optimizer(Clp.Optimizer))
T = 4 # 4 weeks horizon
@expression(m, g[t=0:T], -t+5)
@variable(m, 0 <= x[0:T] <= 0.8)
@variable(m, 0 <= y[0:T] <= 0.9, start=0.0)
@objective(m, Min, 2*sum(x) + 3*sum(y))
@constraint(m, [t in 0:(T-1)], y[t+1] == y[t] + (x[t+1] - g[t+1]))
JuMP.optimize!(m)
println("Objective value: ", JuMP.objective_value(m))
where I didn’t really discretize time (or discretized it in 1-year intervals…) but I still got an error:
ERROR: LoadError: KeyError: key MathOptInterface.VariableIndex(1) not found
Is this something that can be easily corrected? Am I missing something essential about JuMP? This is the first time I am using it.