Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy conflict fails when model has parameters #2649

Closed
jd-lara opened this issue Jul 26, 2021 · 3 comments · Fixed by #2706
Closed

copy conflict fails when model has parameters #2649

jd-lara opened this issue Jul 26, 2021 · 3 comments · Fixed by #2706

Comments

@jd-lara
Copy link
Contributor

jd-lara commented Jul 26, 2021

It seems that models with ParameterJuMP parameters fail to copy and throw an error. Looks like a missing method error.

julia> new_model, reference_map = JuMP.copy_conflict(HAUC.internal.optimization_container.JuMPmodel)
ERROR: MethodError: no method matching copy_extension_data(::ParameterJuMP._ParameterData, ::JuMP.Model, ::JuMP.Model)
Stacktrace:
 [1] copy_model(model::JuMP.Model; filter_constraints::JuMP.var"#76#77"{JuMP.Model})
   @ JuMP ~/.julia/packages/JuMP/Xrr7O/src/copy.jl:171
 [2] copy_conflict(model::JuMP.Model)
   @ JuMP ~/.julia/packages/JuMP/Xrr7O/src/copy.jl:257
 [3] top-level scope
   @ REPL[19]:1
@odow
Copy link
Member

odow commented Jul 26, 2021

I don't think copying a model with parameters is going to work.

ParameterJuMP would need to implement

JuMP.jl/src/copy.jl

Lines 6 to 13 in 6901e8f

"""
copy_extension_data(data, new_model::AbstractModel, model::AbstractModel)
Return a copy of the extension data `data` of the model `model` to the extension
data of the new model `new_model`. A method should be added for any JuMP
extension storing data in the `ext` field.
"""
function copy_extension_data end

However, we should have some fallback so this doesn't error:

copy_extension_data(data, new_model, model) = missing

@odow odow added the Type: Bug label Jul 26, 2021
@jd-lara
Copy link
Contributor Author

jd-lara commented Jul 26, 2021

@odow FWIW I wasn't actually trying to copy the model, just playing with the conflict features to debug a model.

@odow
Copy link
Member

odow commented Jul 26, 2021

Copying the conflict is just copying a subset of the model, so it goes through the same system.

As a work-around, just add this to your script:

JuMP.copy_extension_data(::Any, ::Any, ::Any) = missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants