I’m getting a strange behavior with deepcopy. Deepcopy is still not supported? There is any way to copy JuMP model?
using JuMP, Clp
m = Model(solver = ClpSolver())
@variable(m, 0 <= x <= 2 )
@variable(m, 0 <= y <= 30 )
@objective(m, Max, 5x + 3*y )
@constraint(m, 1x + 5y <= 3.0 )
status = solve(m)
status ≠ :Optimal && erro(" status ≠ :Optimal $(status)")
m2 = deepcopy(m)
@constraint(m, 10*x + 15*y <= 3.0 ) # Add constraint to original problem
status = solve(m2)
And getting this error:
Array length must match number of rows in the model
chg_row_lower(::Clp.ClpCInterface.ClpModel, ::Array{Float64,1}) at ClpCInterface.jl:452
setconstrLB!(::Clp.ClpMathProgSolverInterface.ClpMathProgModel, ::Array{Float64,1}) at ClpSolverInterface.jl:131
#build#119(::Bool, ::Bool, ::JuMP.ProblemTraits, ::Function, ::JuMP.Model) at solvers.jl:337
(::JuMP.#kw##build)(::Array{Any,1}, ::JuMP.#build, ::JuMP.Model) at <missing>:0
#solve#116(::Bool, ::Bool, ::Bool, ::Array{Any,1}, ::Function, ::JuMP.Model) at solvers.jl:168
solve(::JuMP.Model) at solvers.jl:150
include_string(::String, ::String) at loading.jl:522
include_string(::String, ::String, ::Int64) at eval.jl:30
include_string(::Module, ::String, ::String, ::Int64, ::Vararg{Int64,N} where N) at eval.jl:34
(::Atom.##102#107{String,Int64,String})() at eval.jl:82
withpath(::Atom.##102#107{String,Int64,String}, ::Void) at utils.jl:30
withpath(::Function, ::String) at eval.jl:38
hideprompt(::Atom.##101#106{String,Int64,String}) at repl.jl:62
macro expansion at eval.jl:80 [inlined]
(::Atom.##100#105{Dict{String,Any}})() at task.jl:80
This doesn’t happen with copy(m).