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

Writing model to file #379

Closed
fa-bien opened this issue Dec 17, 2020 · 2 comments
Closed

Writing model to file #379

fa-bien opened this issue Dec 17, 2020 · 2 comments

Comments

@fa-bien
Copy link
Contributor

fa-bien commented Dec 17, 2020

I just found out that there have been breaking changes, as described at https://discourse.julialang.org/t/ann-upcoming-breaking-changes-to-cplex-jl-and-gurobi-jl/47814/7

I am now upgrading "old" code to the new version but I cannot find how to write a model to a file. I used to do the following: write_model(backend(model).inner, filename)

Now my understanding is that I need to write something like
GRBwrite(model, filename)

However if I do that I get an error message:

ERROR: MethodError: no method matching write_to_file(::JuMP.Model, ::String) Closest candidates are: write_to_file(::Union{MathOptInterface.Utilities.UniversalFallback{MathOptInterface.FileFormats.MOF.InnerModel{Float64}}, MathOptInterface.FileFormats.CBF.Model, MathOptInterface.FileFormats.LP.Model, MathOptInterface.FileFormats.MPS.Model, MathOptInterface.FileFormats.SDPA.Model}, ::String) at /home/fabien/.julia/packages/MathOptInterface/ZJFKw/src/FileFormats/FileFormats.jl:99

@fa-bien
Copy link
Contributor Author

fa-bien commented Dec 17, 2020

Never mind, solved it by (i) using direct_model() and (ii) using GRBwrite(backend(model), filename)

@fa-bien fa-bien closed this as completed Dec 17, 2020
@odow
Copy link
Member

odow commented Dec 17, 2020

You should also be able to use JuMP.write_to_file:

using JuMP, Gurobi
model = Model(Gurobi.Optimizer)
# stuff...
write_to_file(model, "my_model.mps")

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

No branches or pull requests

2 participants