scipopt / PySCIPOpt

Python interface for the SCIP Optimization Suite
https://scipopt.github.io/PySCIPOpt
MIT License
801 stars 251 forks source link

How can I free the solution storage? #624

Open Joao-Dionisio opened 1 year ago

Joao-Dionisio commented 1 year ago

I am working on a pricer and my objective is to define the subproblem only once, in order to avoid unnecessary time with building the model every iteration. For this, I am adding the subMIP to the attributes of the class, and only change the objective function to reflect the changing dual values. However, throughout the iterations, the solution storage is not emptied when I use either freeTransform or freeReoptSolve.

I reproduced my problem with simpler code, using a Cutting Stock example of this repo. (The code doesn't terminate because I am not updating the objective function, it is not relevant for the issue.)

When I use freeTransform(), the solutions are kept: image

When I use freeReoptSolve(), the code crashes without an error message: image

This crash occurs on the next line, where I optimize the subproblem. Using freeSol also crashes the code.

code.zip

mmghannam commented 11 months ago

Hi @Joao-Dionisio, I think with the help of this method from SCIP we can build another convenience method to clear all solutions.

Joao-Dionisio commented 11 months ago

Hey @mmghannam, thanks for picking this up :)

Yeah, you're right, that would definitely be helpful! Although I think freeTransform should also do it, I think, and freeReoptSolve should definitely not crash the code.