Pyomo and ipopt - execution from Python

898 views
Skip to first unread message

Michele Pratusevich

unread,
Oct 25, 2015, 11:48:47 PM10/25/15
to Pyomo Forum
Hi all -

I am new to optimization and found Pyomo to be a good integration into my workflow. I am trying to solve a quadratic program with ipopt (I am no longer a student so I can't get licenses for the fancy solvers out there). 

I have defined a simple ConcreteModel:

model = ConcreteModel().....

And then have attempted to call the ipopt solver from Python, as follows:

ipopt_solver = pyomo.opt.solvers.SolverFactory('ipopt')
ipopt_solver.solve(model)

But the solver doesn't give me a solution back. However, when I use command-line pyomo: 

pyomo solve --solver=ipopt model_script.py

I get a solution back. I would really like to be able to call the solver directly from Python but can't seem to be able to. Any ideas?

Michele

Michael Bynum

unread,
Oct 26, 2015, 2:18:58 AM10/26/15
to pyomo...@googlegroups.com

Are you getting an error? If so, can you post the stack trace?

If you are not getting an error, are you saving the results? For example, you could do:

results = ipopt_solver.solve(model, tee=True)
model.load(results)
model.pprint()

The tee=True will show ipopt output.

Michael

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gabe Hackebeil

unread,
Oct 26, 2015, 1:19:39 PM10/26/15
to pyomo...@googlegroups.com
In older versions of Pyomo, the solution was found in the return value from "ipopt_solver.solve(model)". In more recent versions the solution is loaded into the model automatically. The return value still contains other useful information about the solver exit status and related messages. Try printing it to get an idea of the information it contains. Sometimes it is necessary for scripts to check this information when dealing with models that are potentially infeasible.

Gabe

> On Oct 25, 2015, at 8:01 PM, Michele Pratusevich <michelepr...@gmail.com> wrote:
>
> ipopt_solver.solve(model)
Reply all
Reply to author
Forward
0 new messages