scipopt / scip

SCIP - Solving Constraint Integer Programs
Other
392 stars 63 forks source link

Insuppressible debug print from multithreaded SCIP runs #61

Open amotzop opened 1 year ago

amotzop commented 1 year ago

This is a problem I encountered when running SCIP using google's ortools (as I wasn't able to correctly install and run SCIP in as a standalone library). I posted it as an issue in the ortools repo (google/or-tools#3742), thinking it's a bug on their side, but from the response I got and looking at their code it seems like a bug in SCIP.

The problem is that when setting the SCIP message handler to be quiet and then running a multi-threaded solver, the individual threads do print messages when they are initialized/start/stop (as can be seen in the referenced issue).

Sorry for only giving a reference this problem when SCIP is being wrapped in another solver.

svigerske commented 1 year ago

This should help:

diff --git a/src/scip/concsolver_scip.c b/src/scip/concsolver_scip.c
index e8145ab5bf..8c42305361 100644
--- a/src/scip/concsolver_scip.c
+++ b/src/scip/concsolver_scip.c
@@ -272,6 +272,7 @@ SCIP_RETCODE initConcsolver(

    /* create the concurrent solver's SCIP instance and set up the problem */
    SCIP_CALL( SCIPcreate(&data->solverscip) );
+   SCIPsetMessagehdlrQuiet(data->solverscip, SCIPmessagehdlrIsQuiet(SCIPgetMessagehdlr(scip)));
    SCIP_CALL( SCIPhashmapCreate(&varmapfw, SCIPblkmem(data->solverscip), data->nvars) );
    SCIP_CALL( SCIPcopy(scip, data->solverscip, varmapfw, NULL, SCIPconcsolverGetName(concsolver), TRUE, FALSE, FALSE,
          FALSE, &valid) );

But the problem is actually that concsolver_scip.c shouldn't use the "solverscip"''s message handler, but the one from the main SCIP (which it doesn't have easy access to when printing these messages). Or it takes care of passing the solverscip's messages to the message handler of the main SCIP.