[SCIP] R: R: Access Dual Values with SCIP

Enrico Calandrini e.calandrini at studenti.unipi.it
Tue Jan 28 16:11:23 CET 2025


Hello everyone,

Thank you so much for all your responses. Everything is much clearer now.

Best regards,
Enrico
________________________________
Da: Ambros Gleixner <ambros.gleixner at HTW-Berlin.de>
Inviato: lunedì 27 gennaio 2025 23:18
A: scip at zib.de <scip at zib.de>; Enrico Calandrini <e.calandrini at studenti.unipi.it>
Oggetto: Re: [SCIP] R: Access Dual Values with SCIP

Hi Enrico,

Marco is right that the transformed constraint is the one for which SCIP
stores the dual, but the method SCIPgetDualSolVal() internally already
converts original to transformed constraints automatically.  So using
SCIPgetTransformedCons() is correct, but should be unnecessary.

The real problem is indeed presolving.  You are right that for LPs it is
possible to retrieve dual solutions for the original constraints after a
stack of LP presolve reductions, and all decent LP solvers provide this
functionality.  However, SCIP's presolvers do not, since SCIP focuses on
the case that the input problem is nonconvex.

The option to retrieve duals from the underlying LP solver is hence only
safely possible if no other algorithms are configured to run before SCIP
calls the LP solver, i.e., presolving, propagation, and heuristics
should be disabled:

SCIP_CALL( SCIPsetPresolving(scip, SCIP_PARAMSETTING_OFF, TRUE) );
SCIP_CALL( SCIPsetIntParam("propagating/maxroundsroot", 0) );
SCIP_CALL( SCIPsetIntParam("propagating/maxrounds", 0) );
SCIP_CALL( SCIPsetHeuristics(scip, SCIP_PARAMSETTING_OFF, TRUE) );

Then SCIP channels the duals of the LP solver to the user.  This is not
too bad if parameter lp/presolving=TRUE (by default), because then the
underlying LP solver (in your case SoPlex) will apply its own presolving.

However, what will really not be possible with SCIP is to warm start the
LP solver from a previous basis after slightly modifying the problem.
If you are planning to solve a sequence of many LPs, then the overhead
through SCIP will be rather large.  As Alex said, it will then be best
to interface to SoPlex or an alternative LP solver directly.

Hope that helps,
Ambros


Am 27.01.2025 um 22:39 schrieb Marco Lübbecke:
> Hi Enrico,
>
> when I am not totally mistaken: yes, this is a classical source of
> errors: http://listserv.zib.de/pipermail/scip/2013-March/001314.html
> <http://listserv.zib.de/pipermail/scip/2013-March/001314.html>
>
> Take care, Marco
>
>
> Am Mo., 27. Jan. 2025 um 22:26 Uhr schrieb Enrico Calandrini
> <e.calandrini at studenti.unipi.it <mailto:e.calandrini at studenti.unipi.it>>:
>
>     Dear Marco,
>
>     Thank you for your quick reply.
>
>     To clarify, I am currently storing the constraints I initially
>     created in a structure called /cons/, and I retrieve the dual values
>     of the i-th constraint using the following approach:
>
>     /SCIPgetDualSolVal(scip, cons[i], &pi[i], NULL);/
>
>     So, I am not querying the /transformed/ constraint for dual
>     variables. Would it be more appropriate to first use the method /
>     SCIPgetTransformedCons/ to retrieve the transformed constraints and
>     then query the dual values? This is why I am not getting any dual
>     values?
>
>     Thank you for your help!
>
>     Best regards,
>     Enrico
>
>     ------------------------------------------------------------------------
>     *Da:* Marco Lübbecke <marco.luebbecke at rwth-aachen.de
>     <mailto:marco.luebbecke at rwth-aachen.de>>
>     *Inviato:* lunedì 27 gennaio 2025 22:12
>     *A:* Enrico Calandrini <e.calandrini at studenti.unipi.it
>     <mailto:e.calandrini at studenti.unipi.it>>
>     *Cc:* Hoen, Alexander <hoen at zib.de <mailto:hoen at zib.de>>;
>     scip at zib.de <mailto:scip at zib.de> <scip at zib.de <mailto:scip at zib.de>>
>     *Oggetto:* Re: [SCIP] R: Access Dual Values with SCIP
>     Hi Enrico,
>
>     do you query the *transformed* constraints for dual variables?
>
>     All the best, Marco
>
>
>     Am Mo., 27. Jan. 2025 um 21:26 Uhr schrieb Enrico Calandrini
>     <e.calandrini at studenti.unipi.it
>     <mailto:e.calandrini at studenti.unipi.it>>:
>
>         Dear Alexander,
>
>         First of all, thank you very much for your response.
>
>         To provide a bit more context, I’m working with the SCIP C-API
>         and creating the LP model using the basic methods (e.g., /
>         SCIPcreateConsBasicLinear/, /SCIPaddCoefLinear/, etc.). After
>         constructing the model, I simply call /SCIPSolve/ to solve it.
>         As far as I understand, this should automatically use /
>         Soplex/ to solve the problem.
>
>         However, I’ve encountered an issue: when I run the model without
>         disabling presolve, SCIP is unable to provide dual solutions. In
>         contrast, when I disable presolving, the computation slows down,
>         but I do receive the dual values. I’m curious to understand
>         whether it is always necessary to disable presolve in order to
>         retrieve the dual solutions, or if there is another way to
>         obtain them.
>
>         Thank you again for your time and assistance!
>
>         Best regards,
>         Enrico
>
>         ------------------------------------------------------------------------
>         *Da:* Hoen, Alexander <hoen at zib.de <mailto:hoen at zib.de>>
>         *Inviato:* lunedì 27 gennaio 2025 20:34
>         *A:* Enrico Calandrini <e.calandrini at studenti.unipi.it
>         <mailto:e.calandrini at studenti.unipi.it>>; scip at zib.de
>         <mailto:scip at zib.de> <scip at zib.de <mailto:scip at zib.de>>
>         *Oggetto:* Re: Access Dual Values with SCIP
>
>         Dear Enrico,
>
>         for pure LP dual values are well-defined. Dual values represent
>         the change in the objective function per unit increase in the
>         right-hand side of a constraint, assuming the constraint remains
>         binding.
>
>
>         For MIP, the situation is more complex and the definition of the
>         duality no longer holds due to the variables' integrality.
>         Therefore, SCIP typically does not care about these dual values.
>
>
>         If you want to solve LPs directly you can use the underlying LP
>         Solver Soplex to obtain the dual solution of the LP.
>
>         Best,
>         Alexander
>
>         ------------------------------------------------------------------------
>         *From:* Scip <scip-bounces at zib.de <mailto:scip-bounces at zib.de>>
>         on behalf of Enrico Calandrini <e.calandrini at studenti.unipi.it
>         <mailto:e.calandrini at studenti.unipi.it>>
>         *Sent:* Monday, January 27, 2025 6:52:18 PM
>         *To:* scip at zib.de <mailto:scip at zib.de>
>         *Subject:* [SCIP] Access Dual Values with SCIP
>         Hi everyone,
>         I hope this message finds you well.
>
>         I am currently working with SCIP and have a question regarding
>         the retrieval of dual values. Specifically, I would like to
>         confirm whether it is necessary to disable presolve in order to
>         access dual values reliably.
>
>         Could you kindly clarify how presolve interacts with dual value
>         computation and if there are any recommended settings to ensure
>         the dual values can be retrieved without issue?
>
>         Thank you very much for your time and assistance. I appreciate
>         the incredible work you’ve done with SCIP!
>
>         Looking forward to your response.
>
>         Best regards,
>         Enrico Calandrini
>         University of Pisa, Department of Computer Science
>
>         _______________________________________________
>         Scip mailing list
>         Scip at zib.de <mailto:Scip at zib.de>
>         https://listserv.zib.de/mailman/listinfo/scip <https://
>         listserv.zib.de/mailman/listinfo/scip>
>
>
>
>     --
>     Prof. Dr. Marco Lübbecke
>     RWTH Aachen University
>     Chair of Operations Research
>     Kackertstrasse 7
>     D-52072 Aachen
>     Germany
>
>     fon / fax: +49 241 80-93362 / 92369
>     marco.luebbecke at rwth-aachen.de <mailto:marco.luebbecke at rwth-aachen.de>
>     www.or.rwth-aachen.de/luebbecke<http://www.or.rwth-aachen.de/luebbecke> <http://www.or.rwth-aachen.de/luebbecke>
>
>
>
> --
> Prof. Dr. Marco Lübbecke
> RWTH Aachen University
> Chair of Operations Research
> Kackertstrasse 7
> D-52072 Aachen
> Germany
>
> fon / fax: +49 241 80-93362 / 92369
> marco.luebbecke at rwth-aachen.de <mailto:marco.luebbecke at rwth-aachen.de>
> www.or.rwth-aachen.de/luebbecke<http://www.or.rwth-aachen.de/luebbecke> <http://www.or.rwth-aachen.de/luebbecke>
>
>
> _______________________________________________
> Scip mailing list
> Scip at zib.de
> https://listserv.zib.de/mailman/listinfo/scip

--
Prof. Dr. Ambros Gleixner - HTW & Zuse Institute Berlin
https://www.htw-berlin.de/hochschule/personen/person/?eid=12822

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.zib.de/pipermail/scip/attachments/20250128/892ff570/attachment.html>


More information about the Scip mailing list