[Scip] Setting a primal heuristic solution

Gerald Gamrath gamrath at zib.de
Wed Aug 7 16:56:59 MEST 2013


Hi  Rostislav,

your issue is quite similar to the one by Daniel discussed on the
mailing list yesterday. If you create a solution during solving by
SCIPcreateSol(), this solution is defined on the active problem
variables and you should only set values for those.
In your case, presolving did some reductions, in particular fixed
x#14#13 to 0. This is probably a dual reduction, so SCIP detected that
there is at least one optimal solution with this variable set to 1.

It sounds like your heuristic works on the original problem and does not
take into account presolving reductions. If this is the case, you should
create a solution in the original space via SCIPcreateOrigSol(), see
http://scip.zib.de/doc/html/scip_8h.shtml#a84ea192b17b635835e7841762e3281ba
When you do this, you should set the solution values of the original
variables for this solution. By this, you can ignore any changes on
variables done by presolve, e.g., fixings or (multi)aggregations.

Best,
Gerald

On 07.08.2013 16:29, Rostislav Stanek wrote:
> 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
> _______________________________________________
> Scip mailing list
> Scip at zib.de
> http://listserv.zib.de/mailman/listinfo/scip



More information about the Scip mailing list