using pulp succesfuly by generating the .mps file and then loading the .sol file without the actual solving

1,071 views
Skip to first unread message

Franco Peschiera

unread,
May 3, 2017, 6:52:45 AM5/3/17
to pulp-or-discuss

Hello there,


My situation is the following:

  • I have my model built in my machine with pulp.
  • I have tested it with the CBC solver and it solves correctly small and medium size instances of my problem.
  • I want to use Gurobi for the big instances.

The thing is I have a Gurobi license but it’s in a different pc from the one I have the python project. I do not have the possibility to install python there.


So I would like to do the following:

  1. Generate the pulp model.
  2. Create the mps file using the writeLP function.
  3. Manually take the mps file to my other pc and solve it using Gurobi.
  4. Get back the .sol file and load the results into python/pulp variables via the GUROBI_CMD class and itsreadsol function.

I guess this is a similar case to using the NEOS server to solve the instance and then having to load back the results into pulp and/ or python.

I’ve already tested solving the mps model with Gurobi and it does so really well. My problem is loading it back into pulp.


What would be the best way to accomplish this? I’ve been checking the solvers.py file to understand how the files are generated and loaded but I’m still not sure how to handle the name mapping that happens inside pulp.

I would like to be able to use the variable[index].value() syntax after loading the solution file but I’d only have the model object and the solution file at that point.
Should I build a custom-made python parser for the solution file that gurobi returns? Or could I adapt pulp’s internal functions to load the solution file correctly?


Ideally the functions I would like to have would be:

  1. function that returns a pulp model object (this one I have).
  2. function that takes a pulp model object and a solution file from gurobi and returns values for all variables (this one I don’t).

thanks!

Franco

Stuart Mitchell

unread,
May 3, 2017, 5:27:52 PM5/3/17
to pulp-or...@googlegroups.com
I where you I would download the pulp source code from github and install it locally with 

$ python setup.py develop

then I would change this line of code 


to something like 

    print(cmd.split())
    input("Please copy the tmp files to your gurobi computer and run the cmdline printed above, then Press Enter to continue...")

And then follow those instructions

Stu

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



--
Stuart Mitchell
PhD Engineering Science
Extraordinary Freelance Programmer and Optimisation Guru

Franco Peschiera

unread,
May 4, 2017, 3:05:20 AM5/4/17
to pulp-or...@googlegroups.com
Hello Stu,

Thanks for the response.

I guess another alternative would be edit and to put a break point around that line and wait until I get the solution file and continue the execution.

I will attempt to do it in a less manual way. At least now I know it's not going to be so easy and I will always have that alternative in case I get impatient.

thanks again!

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/K651is30GF0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pulp-or-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages