The above problem has been solved according to your suggestion. But when I run the code, a new error has occurred.
using JuMP,JuMPeR,Gurobi
# Define problem parameters
I = 3 # Number of factories
T = 24 # Number of time periods
d_nom = 1000*[1 + 0.5*sin(π*(t-1)/12) for t in 1:T] # Nominal demand
θ = 0.20 # Uncertainty level
α = [1.0, 1.5, 2.0] # Production costs
c = [α[i] * (1 + 0.5*sin(π*(t-1)/12)) for i in 1:I, t in 1:T]
P = 567 # Maximimum production per period
Q = 13600 # Maximumum production over all
Vmin = 500 # Minimum inventory at warehouse
Vmax = 2000 # Maximum inventory at warehouse
v1 = Vmin # Initial inventory (not provided in paper)
# Setup robust model
invmgmt = RobustModel(solver=GurobiSolver(OutputFlag=0))
# Uncertain parameter: demand at each time stage lies in a interval
@uncertain(invmgmt, d_nom[t]*(1-θ) <= d[t=1:T] <= d_nom[t]*(1+θ))
# Decision: how much to produce at each factory at each time
# As this decision can be updated as demand is realized, we will use adaptive
# policy - in particular, an affine policy where production at time t is an
# affine function of the demand realized previously.
@adaptive(invmgmt, p[i=1:I,t=1:T], policy=Affine, depends_on=d[1:t-1])
# Objective: minimize total cost of production
@variable(invmgmt, F) # Overall cost
@objective(invmgmt, Min, F)
@constraint(invmgmt, F >= sum{c[i,t] * p[i,t], i=1:I, t=1:T})
# Constraint: cannot exceed production limits
for i in 1:I, t in 1:T
@constraint(invmgmt, p[i,t] >= 0)
@constraint(invmgmt, p[i,t] <= P)
end
for i in 1:I
@constraint(invmgmt, sum{p[i,t], t=1:T} <= Q)
end
# Constraint: cannot exceed inventory limits
for t in 1:T
@constraint(invmgmt,
v1 + sum{p[i,s], i=1:I, s=1:t} - sum{d[s],s=1:t} >= Vmin)
@constraint(invmgmt,
v1 + sum{p[i,s], i=1:I, s=1:t} - sum{d[s],s=1:t} <= Vmax)
end
# Solve
status = solve(invmgmt)
println(getobjectivevalue(invmgmt))
- ERROR
LoadError: The C API of Gurobi.jl has been rewritten to expose the complete C API, and
all old functions have been removed. For more information, see the Discourse
announcement: https://discourse.julialang.org/t/ann-upcoming-breaking-changes-to-cplex-jl-and-gurobi-jl
Here is a brief summary of the changes. - Constants have changed. For example
CB_MIPNODE
is nowGRB_CB_MIPNODE
to match the C API. - Function names have changed. For example
free_env(env)
is now
GRBfreeenv(env)
. - For users of
Gurobi.Optimizer()
,model.inner
is now a pointer to the C
model, instead of aGurobi.Model
object. However, conversion means that
you should always passmodel
instead ofmodel.inner
to the low-level
functions. For example:model = direct_model(Gurobi.Optimizer()) grb_model = backend(model) # grb_model is Gurobi.Optimizer # Old Gurobi.tune_model(grb_model.inner) # New GRBtunemodel(grb_model)
- Some functions have been removed entirely. For example:
is now:using JuMP, Gurobi model = direct_model(Gurobi.Optimizer()) optimize!(model) grb_model = backend(model) stat = Gurobi.get_status_code(grb_model.inner)
using JuMP, Gurobi model = direct_model(Gurobi.Optimizer()) optimize!(model) valueP = Ref{Cint}() grb_model = backend(model) ret = GRBgetintattr(grb_model, "Status", valueP) if ret != 0 # Do something because the call failed end stat = valueP[]
The new API is more verbose, but the names and function arguments are now
identical to the C API, documentation for which is available at:
To revert to the old API, use:
import Pkg
Pkg.add(Pkg.PackageSpec(name = “Gurobi”, version = v"0.8.1"))
Then restart Julia for the change to take effect.
in expression starting at untitled-254185b6f7c55e2fdb6293d5d74fc246:17
error(::String) at error.jl:33
GurobiSolver(; kwargs::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol},NamedTuple{(:OutputFlag,),Tuple{Int64}}}) at deprecated_functions.jl:548
(::Gurobi.var"#GurobiSolver##kw")(::NamedTuple{(:OutputFlag,),Tuple{Int64}}, ::typeof(GurobiSolver)) at deprecated_functions.jl:548
top-level scope at untitled-254185b6f7c55e2fdb6293d5d74fc246:17
include_string(::Function, ::Module, ::String, ::String) at loading.jl:1088