Warm starting in pulp?

998 views
Skip to first unread message

Christophe-Marie Duquesne

unread,
Mar 3, 2010, 6:25:30 PM3/3/10
to pulp-or-discuss
Hi,

I'm solving a slightly modified version of the same problem several
times and I found out that warm start was really suitable for me.
AFAIK, Warm starting is possible in at least two solvers, cplex and
Clp, and as it also available in the OSI library, I think this is a
must have feature in PuLP.

I did not find references about this, but I'm new to PuLP and python
so I'm still discovering the pyhon way to browse documentations. Is it
possible? If not, is it possible to add it?

Cheers!

Christophe-Marie
PhD student in OR

Stuart Mitchell

unread,
Mar 3, 2010, 7:10:09 PM3/3/10
to pulp-or...@googlegroups.com
There is a resolve capability but what it can handle is very solver
dependent.

Tell me exactly what you want to change in the problem and the solver
you want to use and I will tell
you if it is already in there or if I can add it easily.

Stu

Christophe-Marie Duquesne

unread,
Mar 4, 2010, 2:24:03 PM3/4/10
to pulp-or...@googlegroups.com
> Tell me exactly what you want to change in the problem and the solver you
> want to use and I will tell
> you if it is already in there or if I can add it easily.

What I would like exactly is to do the same as I do with OSI: be able
to get a generic warm start object once my problem is solved, so that
I can provide it to the solver next time I solve the problem.

I typically use the following methods:
http://www.coin-or.org/Doxygen/Osi/class_osi_solver_interface.html#243a73c2c4741788382cc5675c574214
http://www.coin-or.org/Doxygen/Osi/class_osi_solver_interface.html#f7dba660a92526fd4de6507bae3c6d2a

Christophe-Marie

Stuart Mitchell

unread,
Mar 4, 2010, 4:31:29 PM3/4/10
to pulp-or...@googlegroups.com
Yes osi has a warm start object, most other solvers have you keep a
reference to a specific solver model object and make you change that and
resolve. I would then have to write some framework to allow changes in
constraints to signal a solver object that there has been a change.

Saying that I would like to write an OSI interface for pulp. I have
thought that the best way to do that would be either to write a python
binding to OSI and submit that to the project, or write an c- interface
to OSI and then call it using c-types like I do for CoinMP and CPLEX.

Any volunteers for either of those jobs.

Vinaka
Stu

Christophe-Marie Duquesne

unread,
Mar 4, 2010, 4:44:11 PM3/4/10
to pulp-or...@googlegroups.com

I just recalled that I had already seen something about python and OSI
before. Here it is: http://code.google.com/p/pyosi/. It does not seem
like there is a lot of features, I have to admit I prefer the PuLP way
to say things.

--
Christophe-Marie Duquesne
06 84 14 26 82 - mobile
04 76 57 48 06 - g-scop
04 97 04 27 33 - amadeus

Stuart Mitchell

unread,
Mar 4, 2010, 4:58:43 PM3/4/10
to pulp-or...@googlegroups.com

Ok I'll bottom post,
Looks good, I can easily wrap that in pulp and support it as a solver. I
hope it has the capabilities you are looking for.

I also would want to wrap pyglpk might have a look at that this weekend.


Stu

Christophe-Marie Duquesne

unread,
Mar 4, 2010, 6:09:40 PM3/4/10
to pulp-or...@googlegroups.com
> Ok I'll bottom post,
> Looks good, I can easily wrap that in pulp and support it as a solver. I
> hope it has the capabilities you are looking for.
>
> I also would want to wrap pyglpk might have a look at that this weekend.
>
>
> Stu
>

Nice!

Btw I just tried to build their package. I spotted errors in OSI
headers inclusion (OSI headers are usually installed in
/usr/include/coin/, but they #include "OsiSolverInterface.hpp". It
must be replaced with #include <coin/OsiSolverinterface.hpp>, and same
applies for other includes. I generated a patch (see attached). The
bad news is I know fail with a link error:
/usr/bin/ld: cannot find -lboost_python-gcc41-mt
boost python is installed on my system. Let me know if you are more
lucky than me.

Cheers!

pyosi.patch

Timo Kunz

unread,
Mar 18, 2018, 9:10:55 PM3/18/18
to pulp-or-discuss
Hi,
I am looking at an (integer) LpProblem and I am trying to provide an initial solution for a warm start. I am reading this post but I am new to Pulp and I can not find anything about this anywhere else.
Is there fucntionality to add a warm-start solution to a model?

Thanks for your help,
Timo   

Stuart Mitchell

unread,
Mar 18, 2018, 9:17:10 PM3/18/18
to pulp-or...@googlegroups.com
It depends on the solver,

If you use Gurobi you can warm start but not with cbc

Stu

Stuart Mitchell
PhD Engineering Science
Extraordinary Freelance Programmer and Optimisation Guru

--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pulp-or-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/pulp-or-discuss.
For more options, visit https://groups.google.com/d/optout.

Tomasz Gorecki

unread,
Aug 27, 2019, 5:41:34 PM8/27/19
to pulp-or-discuss
Hi
I suppose the previous comment still applies: no warm-starting with CBC through PULP. If i understand correctly it is a functionality of CBC though. Could you recommend the fastest way to try a warm start. rewriting the problem will already be intensive, but ok.. Suing something else than Python is not an option for me at the moment.
Should I try pyomo or another CBC python interface

Thx

Br

Stuart Mitchell

unread,
Aug 27, 2019, 5:43:14 PM8/27/19
to pulp-or...@googlegroups.com


Stuart Mitchell
PhD Engineering Science
Extraordinary Freelance Programmer and Optimisation Guru

--
New posters to this group are moderated which can take up to 48 hours, so please be patient if your first post takes a while to turn up.
---
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pulp-or-discuss/17d8ceef-a53a-4c13-9f98-4e7063274f2e%40googlegroups.com.

Tomasz Gorecki

unread,
Aug 28, 2019, 1:19:32 AM8/28/19
to pulp-or...@googlegroups.com
Thanks for the tip. I will give it a try.

Franco Peschiera

unread,
Aug 28, 2019, 5:32:52 AM8/28/19
to pulp-or-discuss
In fact, I have a branch of pulp with warm starts for CBC, CPLEX and GUROBI working:


Here is an example:


F.


El miércoles, 28 de agosto de 2019, 7:19:32 (UTC+2), Tomasz Gorecki escribió:
Thanks for the tip. I will give it a try.

Le mar. 27 août 2019 à 23:43, 'Stuart Mitchell' via pulp-or-discuss <pulp-or...@googlegroups.com> a écrit :
Maybe try



Stuart Mitchell
PhD Engineering Science
Extraordinary Freelance Programmer and Optimisation Guru


On Wed, Aug 28, 2019 at 9:41 AM Tomasz Gorecki <tomh....@gmail.com> wrote:
Hi
I suppose the previous comment still applies: no warm-starting with CBC through PULP. If i understand correctly it is a functionality of CBC though. Could you recommend the fastest way to try a warm start. rewriting the problem will already be intensive, but ok.. Suing something else than Python is not an option for me at the moment.
Should I try pyomo or another CBC python interface

Thx

Br

--
New posters to this group are moderated which can take up to 48 hours, so please be patient if your first post takes a while to turn up.
---
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or...@googlegroups.com.

--
New posters to this group are moderated which can take up to 48 hours, so please be patient if your first post takes a while to turn up.
---
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or...@googlegroups.com.

Tomasz Gorecki

unread,
Aug 28, 2019, 3:15:25 PM8/28/19
to pulp-or...@googlegroups.com
Thanks Franco,

I am trying and will let you know if it goes smooth.

T

To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pulp-or-discuss/b0e710f7-c9d5-474a-87aa-fe80125e13cc%40googlegroups.com.

Tomasz Gorecki

unread,
Sep 11, 2019, 10:47:31 AM9/11/19
to pulp-or...@googlegroups.com
Hi Francesco,

I managed to try a and make it work for a small problem. thamsk for the tip. Could you walk me through how it works ? I get the impression a initial solution file (e8aa3f26b600400ca9079cc935047686-pulp_init.sol) is created and read. At least according to CBC verbose output. Can you explain which step creates this file ? Could I control where and how this file is saved ?

Best,

Franco Peschiera

unread,
Sep 11, 2019, 12:55:10 PM9/11/19
to pulp-or...@googlegroups.com

Hey Tomasz,

Yeah, relevant changes are just a few lines, actually.

First of all, just like all other files that are created in pulp, if you use keepFiles=True as argument, you will keep the initial solution file that we pass to the solver (and it will not have a weird name).

For CBC, the actual file is created here and then given as argument to the solver:

if self.mip_start:
    self.writesol(tmpSol_init, lp, vs, variablesNames, constraintsNames)
    cmds += 'mips {} '.format(tmpSol_init)

The variable that stores the name of the file tmpSol_init is assigned here and depends on the argument keepFiles, as I said:

if not self.keepFiles:
    uuid = uuid4().hex
    tmpLp = os.path.join(self.tmpDir, "%s-pulp.lp" % uuid)
    tmpMps = os.path.join(self.tmpDir, "%s-pulp.mps" % uuid)
    tmpSol = os.path.join(self.tmpDir, "%s-pulp.sol" % uuid)
    tmpSol_init = os.path.join(self.tmpDir, "%s-pulp_init.sol" % uuid)
else:
    tmpLp = lp.name+"-pulp.lp"
    tmpMps = lp.name+"-pulp.mps"
    tmpSol = lp.name+"-pulp.sol"
    tmpSol_init = lp.name + "-pulp_init.sol"

Afterwards, we just delete it at the end with the rest of files we create.
For GUROBI_CMD and CPLEX_CMD the idea is very similar but the writesol method is different and the command line arguments to pass the file are different too.

Franco


You received this message because you are subscribed to a topic in the Google Groups "pulp-or-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pulp-or-discuss/nkEZHLmSt-s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pulp-or-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pulp-or-discuss/CAG%3DLVEBrz3sqp%2B-5YLY1ZQZnsSo4BJ8JNH1J5XX2MEmM%3DXo5nw%40mail.gmail.com.

Tomasz Gorecki

unread,
Sep 13, 2019, 4:42:47 AM9/13/19
to pulp-or...@googlegroups.com
Thanks for the reply. That makes sense

Tomasz Gorecki

unread,
Aug 12, 2020, 4:07:25 AM8/12/20
to pulp-or-discuss
Hello again, I have a follow up on this. I have tested the new commands in pulp 2.3 to call the warm start as described in the help.
I was wondering how can I confirm from the log that things went smooth, the output of the solver is

will open mipstart file .\C:\Users\TGi\AppData\Local\Temp\0ad96bc3659c47f0944f623a06df0535-pulp.mst.
seconds was changed from 1e+100 to 90
ratioGap was changed from 0 to 0.001
String of None is illegal for double parameter allowableGap value remains 0
String of None is illegal for integer parameter threads value remains 0
String of None is illegal for integer parameter strongBranching value remains 5
Option for gomoryCuts changed from ifmove to on
Option for knapsackCuts changed from ifmove to on
Continuous objective value is 9.06151 - 0.06 seconds
Cgl0003I 0 fixed, 0 tightened bounds, 14 strengthened rows, 0 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 5 strengthened rows, 0 substitutions
Cgl0004I processed model has 2154 rows, 1294 columns (575 integer (575 of which binary)) and 5762 elements
Cbc0038I Initial state - 283 integers unsatisfied sum - 23.7544
Cbc0038I Pass   1: suminf.    0.00000 (0) obj. 45875.7 iterations 1118
Cbc0038I Solution found of 45875.7
Cbc0038I Relaxing continuous gives 45875.7
etc

It says it will read the file, but I don't get the impression it confirms it did. And looking at the first solution found it looks to me like it did not use the warm start solution.

My second question may have to do with the solver more than PULP but here it is:
Can I warm start only part of the variables ? I have a large problem where I can compute a decent solution with a heuristic. It is easy to calculate the important variables. These pretty much determine the rest of the solution but it is tedious and tricky to calculate all variables of the problem from the few important ones. So I was hoping I can warm start just these few variables and the solver can figure the rest out. Will this work at all ?

T

Stuart Mitchell

unread,
Aug 12, 2020, 5:23:02 AM8/12/20
to pulp-or...@googlegroups.com
Warm starts are tricky.

For the problem you are talking about why don't you fix those variables to the values you have.

Then get a solution and use the objective value obtained as a upper bound on the unconstrained problem.
Then you can even use that first full solution as a warm start as well.

Stu

Stuart Mitchell
PhD Engineering Science
Extraordinary Freelance Programmer and Optimisation Guru

Tomasz Gorecki

unread,
Aug 18, 2020, 5:27:16 AM8/18/20
to pulp-or...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages