[Scip] Fwd: Accessing dual variables and the number of fixed variables.

Gerald Gamrath gamrath at zib.de
Tue Mar 25 12:38:00 CET 2014


Dear Jan,

SCIP copies the complete problem before starting the solving process,
and works only on the copied instance afterwards (called transformed
problem). If you want to get information about variables or constraints
during solving, you should always ask the transformed constraint. You
can get it by calling SCIPtransformCons() in the INIT-callback of your
plugin. Then, you should get the correct numbers of (fixed) variables
and the dual solution for the constraint.

By the way: although SCIPgetNVarsSetppc() returned the correct number,
you should better ask the transformed constraint for that, because the
number of variables in the constraint might change during presolving.

You can only get the dual values on the solving stage, more precise, you
can only get it, if an LP was solved before, i.e., SCIPgetLPSolstat()
should return SCIP_LPSOLSTAT_OPTIMAL or SCIP_LPSOLSTAT_OBJLIMIT.

Best,
Gerald

On 24.03.2014 14:50, Jan Berling wrote:
> Dear SCIP mailing list,
>
> thanks for the programming session at the Column Generation Spring School!
>
> I have some problems accessing the dual variables and the number of
> fixed variables in a constraint.
>
> My SCIP 3.0.1 is built as a Matlab mex file. The variables and
> constraints are generated and successfully linked. The input LP is
> solved correctly. When some variables are fixed, the solution changes
> accordingly.
>
> The number of fixed variables of a constraint is allegedly always
> zero. The dual variables are allegedly zero, too.
>
> SCIPgetNVarsSetppc(scip, consFlights[n]);              // correct output
> SCIPgetNFixedzerosSetppc(scip, consFlights[n]);   // outputs 0(*).
> SCIPgetDualsolSetppc(scip,consFlights[n]);             // outputs 0(**).
>
>
> (*) To fix the variables, following code is used:
>
> #define vars(f,d) vars[(f)*MAX_DELAY + d]                 // to access
> vars in 2D
> SCIP_Bool infeasible;
> SCIP_Bool fixed;
> SCIP_ERR( SCIPfixVar(scip, vars(f,d), 0.0, &infeasible, &fixed),
> "Error fixing variable" );
>
> After SCIPfixVar(), the value of infeasible is 0 and fixed is 1. I'm
> pretty sure, that the variables are fixed.
>
> I tried to fix the variable before adding it to a constraint and
> afterwards, SCIPgetNFixedzerosSetppc() still outputs zero.
> SCIPgetNFixedonesSetppc() outputs zero too, even if there are some
> variables fixed to 1.
> I also used the functions before and after solve(scip), but they still
> give only zeros as output...
> How can I get the number of fixed variables? Is there anything I have
> overlooked?
>
>
> (**) Is it only possible to get the dual variables in the solving
> stage for example in SCIP_STAGE_SOLVING?
>
>
> Best regards
> Jan
> _______________________________________________
> Scip mailing list
> Scip at zib.de
> http://listserv.zib.de/mailman/listinfo/scip



More information about the Scip mailing list