PySCIPOpt icon indicating copy to clipboard operation
PySCIPOpt copied to clipboard

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

Open hongxuanrui1999 opened this issue 2 years ago • 4 comments

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!

hongxuanrui1999 avatar Mar 17 '24 07:03 hongxuanrui1999

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 :)

Joao-Dionisio avatar Mar 18 '24 09:03 Joao-Dionisio

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.

hongxuanrui1999 avatar Mar 19 '24 07:03 hongxuanrui1999

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.

Joao-Dionisio avatar Mar 24 '24 11:03 Joao-Dionisio

Hey @hongxuanrui1999 ! A little over 2 years after this issue was created, this is now possible after 8a9c2d1 :)

Joao-Dionisio avatar May 17 '26 10:05 Joao-Dionisio