4

I would like to see the progress of pulp cbc solver on a jupyter notebook.

I am trying to solve a very large lp problem with pulp cbc solver, and as it takes hours and even days to find an optimal answer, I would like to know how far the solver has come and how much more it has to go, thus I have to wait.

Currently, I am running the solver with below code, but nothing shows on the notebook or logs.

m.solve(pulp.PULP_CBC_CMD(threads = 24, msg=1))

If I understand correctly, msg=1 part of the code is supposed to show me something, but I am getting nothing... No logs, no message or anything on the notebook.

I would like to see the progress of the solver in form of a number, percentage bar or anything. ie) how many answers it is going to check, how many it did check, estimated time to solve, elapsed time, etc

Kevin Lee
  • 83
  • 6

1 Answers1

0

I have done it using a workaround, by saving the problem to pickle and then reading it back in a %%python cell. However, this only outputs the log after solving is complete.

import pickle
with open("[path]", 'wb') as handle:
    pickle.dump(prob, handle, protocol=pickle.HIGHEST_PROTOCOL)

To solve:

%%python

import pickle
import pulp
import pandas as pd

with open("[path]", 'rb') as handle:

    prob = pickle.load(handle)

    #Optimization
    prob.solve(pulp.PULP_CBC_CMD(msg=True))

You can also save the results to local disk within the %%python cell and read them back in jupyter notebook.

GsB
  • 75
  • 4