I want to store a feasible solution from an event handler that catches the SCIP_EVENTTYPE_BESTSOLFOUND
event, and later I would like to give this solution as an heuristic solution to another SCIP instance that is optimizing the same problem but with different parameter settings (this could be in a subsequent optimization or in parallel).
My problem is that the solution I get from using SCIPgetBestSol()
will be in terms of the transformed problem, which can be different from the transformed problem in the second SCIP instance.
Would turning presolve off (using SCIPsetPresolving()
) be enough for ensuring that SCIP is always referring to the original variables within callback functions?
Is there a particular way that you would recomend for doing this?
Thanks!
Make sure that your event handler can access the array of original variables (SCIPget(N)OrigVars()
does the trick). You can always query solution values of original variables, even from transformed solutions, using SCIPgetSolVal()
, and store the values in a solution created via SCIPcreateOrigSol()
.
In order to feed this solution into a different SCIP instance, you have to get the mapping between variables of the primary and secondary SCIP instance right. Create a new solution for the secondary SCIP instance, and set the solution value of a variable to the value of its (pre-)image variable in the primary SCIP.