[SCIP] How to get stored solution

André Filipe Lanca Serrano andre.serrano at tuhh.de
Fri Apr 20 16:53:52 CEST 2018


Hi all,

I'm using SCIP to solve my BIP problem and I'm using my own heuristic  
in the solution process. At some point in my heuristic, I'm setting a  
feasible solution using the SCIPsetSolVal method. Afterwards, I want  
to store in a array the solution values of variables using  
SCIPgetSolVals and then populate a vector with each solution value of  
variable. Every time I run i my program crashes. I tried only to print  
those solution values of variables without population the vector but  
still crashes.

The execution method of my heuristic goes like this:

[...] //Headers, properties...

SCIP_SOL* sol

[...]

SCIP_CALL(SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, NULL, NULL, NULL));

[...]

SCIP_CALL(SCIPcreateSol(scip, &sol, heur));


for(int=0; i<nvars; i++)
{
	//setting the solution values of variables "solval"
	[...]

	SCIP_CALL(SCIPsetSolVal(scip, sol, vars[i], solval));
}

SCIP_Real* vals;

SCIPgetSolVals(scip, sol, nvars, vars, vals);


for (int i = 0; i < nvars; i++)
{
	printf(" %i\n", vals[i]);
}

SCIP_CALL(SCIPfreeSol(scip, &sol));

return SCIP_OKAY;


And then it creates the heuristic and includes it in SCIP. What's  
wrong here? I'm really stuck at this point and I would appreciate very  
much any help.

Thanks in advance.

Cheers,
André








More information about the Scip mailing list