[Scip] Setting a primal heuristic solution

Rostislav Stanek rostislav.stanek at uni-graz.at
Wed Aug 7 16:29:53 MEST 2013


Dear SCIP community,
I use an initial heuristics which should set an initial solution and 
which is called only once before starting the branching process. I call 
the inherited constructor of the class ObjHeur in the constructor 
definition of my class in the following way:

InitialTourHeuristic::InitialTourHeuristic(
         [my parameters]):
         ObjHeur(
                 sCIP,
                 [name],
                 [description],
                 'I',
                 -1000000,
                 0,
                 0,
                 0,
                 SCIP_HEURTIMING_BEFORENODE,
                 false),
                 [other initialisations] {
     [constructor body]
}.

Then I define

     virtual SCIP_DECL_HEUREXEC(scip_exec);

and

SCIP_DECL_HEUREXEC(InitialTourHeuristic::scip_exec) {
     [constructor body]
}.

Further, I have the initialised references on the variables

     std::vector<std::vector<SCIP_VAR *> > &x;.

In the body of the last method I set the solution in the following way:

     SCIP_CALL_EXC(SCIPcreateSol(sCIP, &heuristicSolutionSCIP, 0));

     [...]

     for ([a for cyclus]) {
         SCIP_CALL_EXC(SCIPsetSolVal(
                 sCIP,
                 heuristicSolutionSCIP,
                 x.at([an index]).at([an index]),
                 1));
     }

     [...]

     SCIP_Bool isTheSolutionFeasible;
     SCIP_CALL_EXC(SCIPtrySolFree(
             sCIP,
             &heuristicSolutionSCIP,
             true,
             true,
             true,
             false,
             &isTheSolutionFeasible));.

And the solving process usually works. But sometimes I get the following 
error:

[src/scip/sol.c:921] ERROR: cannot set solution value for variable 
<t_x#14#13> fixed to -0 to different value 1
[src/scip/scip.c:28611] ERROR: Error <-9> in function call
An error occurs by computing and by using the SCIP tool!

What I am doing wrong? I am sure that the solution I set is feasible; in 
fact it is an (maybe not unique) optimal solution.

Thank you for all your tips.

Yours faithfully,
Rostislav Stanek


More information about the Scip mailing list