scipopt / PySCIPOpt

Python interface for the SCIP Optimization Suite
https://pyscipopt.readthedocs.io/en/latest/
MIT License
813 stars 253 forks source link

How can I get the information about the solving phase when solving the instance? #817

Open hongxuanrui1999 opened 8 months ago

hongxuanrui1999 commented 8 months ago

I searched the document of the scip and found some information about the solving phase such as https://www.scipopt.org/doc-8.1.0/html/event__solvingphase_8c.php#a16d63e23b68a6d69d967a225693a3bd7. I want to get this information by pyscipopt. What do I need to add in scip.pyx and scip.pxd? Thank you very much!

Joao-Dionisio commented 8 months ago

Hey @hongxuanrui1999! Oh man, I had no idea this existed. I don't know if this is supposed to be accessed only by SCIP, though. Just to make sure, you want the solving phase, not the solving stage, right?

To do this, I think you need to add the corresponding SCIP function to scip.pxd, and then call the function in scip.pxi. Something like this:

In scip.pxd

SCIP_BOOL transitionPhase3(SCIP * scip, SCIP_EVENTHANDLRDATA * eventhandlrdata) 

In scip.pxi

def checkTransitionPhase3(self, Eventhdlr eventhdlr): # I think the event handler needs to be an argument
    eventhdlr_data = SCIPeventhdlrGetData(eventhdlr)
    return transitionPhase3(self.scip, eventhdlr_data)

In the end, it's always nice if you include a test in the tests folder, to make sure the addition is working. And also add a line to CHANGELOG for record-keeping :)

hongxuanrui1999 commented 8 months ago

Thank you for your reply! Yes, I want to get the solving phase information instead of the solving stage information. How should I declare the SCIP_BOOL transitionPhase3 function in scip.pxd? It is not included in event_solvingphase. h.

Joao-Dionisio commented 7 months ago

Hey @hongxuanrui1999! This turned out to be a bit more complicated than I first thought. @mmghannam and I have been looking at it, and what you really want is the attribute solvingphase in eventhdlrdata. However, it's difficult to access this from the python side. transitionPhase3 just tells whether you are in phase 3 or not (but the same problems remain). We'll be working on it, as it's something useful.