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

Display or print model to LP file #735

Closed
fnbillimoria opened this issue Jul 10, 2020 · 2 comments
Closed

Display or print model to LP file #735

fnbillimoria opened this issue Jul 10, 2020 · 2 comments

Comments

@fnbillimoria
Copy link

Hi - is there any way to access the underlying PowerModels JuMP model either after instantiation or solving? I would like either to see the model on screen or write it to an LP file?

@ccoffrin
Copy link
Member

The simplest way is to pass in a JuMP model from your context like this,

using PowerModels; using JuMP; using Ipopt
m = Model()
result = run_dc_opf("some_case.m", Ipopt.Optimizer, jump_model=m)

Once this command is complete you can do things like,

println(m)
write_to_file(m, "model.lp")

Note that println will always work, the output of write_to_file depends on the type of model you generate with run_opf and not all models may be supported.

In this case you solve the model and then look at the model after. There are more complex workflows where you build the JuMP model without solving it. For example,

pm = instantiate_model("some_case.m", DCPPowerModel, PowerModels.build_opf)
print(pm.model)
write_to_file(pm.model, "model.lp")

Does that answer the question?

@fnbillimoria
Copy link
Author

Thank you - that is perfect!!

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

No branches or pull requests

2 participants