[Scip] Setting a primal heuristic solution

Timo Berthold berthold at zib.de
Wed Aug 7 16:51:01 MEST 2013


Hi Rostislav,

is this the first solution that is added to SCIP (including those which
might been found by SCIP's default heuristic)?

In any case such a behavior might occur.
The variable might have been fixed by some dual presolving, because SCIP
could prove that there always is an optimal solution which has this
variable at zero (regardless whether there are other solutions having it
one). As a very simple example, imagine you have an arbitrary MIP to which
you add a single binary variable z, which does not occur in any
constraint.

If any other heuristic already found an optimal solution before yours,
this behavior might be amplified (in this case there often are a lot of
variables which can be fixed by dual reasoning).

Have you implemented your own constraint handler? If yes, a possible error
source might be that you did not add variable locks correctly. (see the
FAQ or the how to add conshdlrs on the SCIP HP).

If this is not the problem, you should check whether the value to which
you want to set the variable is still valid for the global bounds and/or
alter your heuristic in such a way that it respects them (e.g. when you
perform some graph algorithm, remove the corresponding edges/arcs).


Hope that helps,
Timo

> 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