Trying to use FileFormats with JuMP

Following the example here, I’m trying to use JuMP to write a model to a file.

src = JuMP.Model(Clarabel.Optimizer)
filename = "my_model.lp"
dest = FileFormats.Model(filename = filename)
MOI.copy_to(dest, src)
MOI.write_to_file(dest, filename)

I get a “no method matching” error for MOI.write_to_file with suggestions of other inputs. So I’m pretty sure src, and by extension dest are not the correct format, but how do I get them into the correct format?

See Models · JuMP

It’s just:

model = Model(Clarabel.Optimizer)
write_to_file(model, "my_model.lp")

p.s., You’ve somehow found an old version of the MathOptInterface documentation :smile: Here’s a link to the official JuMP documentation:

https://jump.dev/JuMP.jl/stable/

You can also get there by going to https://jump.dev and clicking the “Documentation” link at the top.

1 Like