Unwated consistency of results when solving a model multiple time within a loop

112 views
Skip to first unread message

Yohan Fleuriot

unread,
Nov 29, 2023, 7:05:05 AM11/29/23
to Pyomo Forum

I'm using pyomo 6.6.4 and several solvers (Ipopt, Bonmin, Cbc,...) to solve different relatively complicated models (MINLP in general). Since my models have known infeasibility points I am solving them using several solvers or heuristics. In order to evaluate the quality of the results between different solvers or self defined solving heuristics I'm trying to build a solver comparison tool and noticed that when solving several time a model with a solver in a loop I'm always getting the same results whereas when using single runs, the results often differ.

I have tried to use different solver instances, model instances, to change the randomness generation seeds between iterations (for solvers which allow it) but nothing seems to do the trick. Any ideas?

Remo Andreoli

unread,
Nov 29, 2023, 8:00:29 AM11/29/23
to pyomo...@googlegroups.com
It definitely sounds like an implementation problem, posting some code would greatly help with the issue. Are you properly initializing the SolverFactory objects? 

On Wed, 29 Nov 2023, 13:05 Yohan Fleuriot, <yohan.f...@gmail.com> wrote:

I'm using pyomo 6.6.4 and several solvers (Ipopt, Bonmin, Cbc,...) to solve different relatively complicated models (MINLP in general). Since my models have known infeasibility points I am solving them using several solvers or heuristics. In order to evaluate the quality of the results between different solvers or self defined solving heuristics I'm trying to build a solver comparison tool and noticed that when solving several time a model with a solver in a loop I'm always getting the same results whereas when using single runs, the results often differ.

I have tried to use different solver instances, model instances, to change the randomness generation seeds between iterations (for solvers which allow it) but nothing seems to do the trick. Any ideas?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyomo-forum/d3c33314-63b4-4e09-8f69-9951007ab2c0n%40googlegroups.com.

Yohan Fleuriot

unread,
Nov 30, 2023, 9:45:25 AM11/30/23
to Pyomo Forum
I won't be able to post a lot of code. When it comes to the SolverFactory objects, I'm using solver precompiled binaries and I have a class for each solver with a solver property which returns SolverFactory(self.executable_name), self.executable_name being equal to "ipopt" for example. The paths to files containing the solver executable are added to os.environ[PATH].
To be a bit more clear a call to a solver would look like Ipopt().solver.solve(some_model). This implies that every call of the solver property returns a new SolverFactory object.
Thanks in advance

Peng Zedong

unread,
Dec 4, 2023, 12:48:10 PM12/4/23
to Pyomo Forum
It might be useful to try the following.
1. Check the termination condition of the solvers. If some runs converge to a locally optimal solution and others converge to the globally optimal solution, it might be worth trying a global solver instead of IPOPT.
2. Check if the model and the solver are the same in different runs. The model includes the objective and constraints, the initial point(important). If you provide different initial points, IPOPT might converge to different results.
Moreover, you need to check the solver versions and options.

Peng Zedong

unread,
Dec 4, 2023, 12:52:48 PM12/4/23
to Pyomo Forum
It might also be worth trying MindtPy to solve your MINLP problem.

Siirola, John

unread,
Dec 4, 2023, 1:00:02 PM12/4/23
to pyomo...@googlegroups.com

The Pyomo interfaces to nonlinear solvers will use the current variable values as the initial point for the solver, and by default, the solution returned by a solver is loaded back into the Pyomo model.  It sounds like you are solving the same model repeatedly using different solvers, so the final point returned by the previous solver is being used as the initial point by the subsequent solver.

 

John

 

 

From: pyomo...@googlegroups.com <pyomo...@googlegroups.com> On Behalf Of Remo Andreoli
Sent: Wednesday, November 29, 2023 6:00 AM
To: pyomo...@googlegroups.com
Subject: [EXTERNAL] Re: Unwated consistency of results when solving a model multiple time within a loop

 

You don't often get email from andreo...@gmail.com. Learn why this is important

Reply all
Reply to author
Forward
0 new messages