Re: how to acess all encountered solutions in the solving process

831 views
Skip to first unread message
Message has been deleted

Gabriel Hackebeil

unread,
May 4, 2016, 4:14:50 PM5/4/16
to pyomo...@googlegroups.com
I can interpret this question in a number of ways:

(1) You are performing a sequence of solves, and you want to plot the solution for a particular variable as a function of iteration number.
(2) You have a collection of variables in your model that represent a time series, and you want to plot the solution over that time series.

There is no shortage of examples on stackoverflow and the matplotlib website that describe how to generate plots. On the pyomo side, it simply comes down to extracting values from the model variables and storing them into lists (or numpy arrays) that you can pass into the matplotlib plot functions. For case (2), this might look like:

x = list()
y = list()
for t in sorted(model.TIME):
    x.append(t)
    y.append(model.some_variable[t].value)

… plot y vs. x

Gabe

On May 4, 2016, at 2:25 AM, Abdelhakim BENDJABEUR <bendjabeur...@gmail.com> wrote:

Hi everyone,
I'm currently using pyomo (cplex and cbc as main solvers for my experiments), and I want to plot all encountered solutions over time !

what's the best way to get the list of solutions and the corresponding time ?

Thank you all in advance,

Best regards,
Hakim

Note : I'm using jupyter notebook (ipython, python 3)

--
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.

Message has been deleted

David Woodruff

unread,
May 6, 2016, 7:34:45 PM5/6/16
to pyomo...@googlegroups.com
There is nothing built into Pyomo to capture intermediate solutions (or objective function values, which seems to be what you really want) during a MIP branch and bound. There are various ways to get these data. One way is ask pyomo to output the solver log and you can capture that and then parse it to get what to you want.

If you are using the pyomo command, you could add --stream-solver

if you are scripting, add tee=true to your solve call, as in
results = opt.solve(instance, tee=True)

Needless to say, if you go this route, you would want to redirect output to a file (or filter it with your own program) so you could post-process the solver output.
  Dave


On Fri, May 6, 2016 at 3:02 AM, Abdelhakim BENDJABEUR <bendjabeur...@gmail.com> wrote:
Thank you for you answer Gabriel.
I think that my question was a bit vague, and thus, open to interpretation !
Say I have an instance I'm about to solve.
The solver, while performing  the B&B will encounter some solutions on its way to the optimal solution.
I want the list of these solutions and the time at which the solver has found each one of them !
for example, [(solution1, time1), (solution2, time2), ..., (optimal_solution, total_runtime)]

Thank you in advance,
Reply all
Reply to author
Forward
0 new messages