[Clp] Clp_addRows causes incorrect solution for zero coefficient

John Forrest jjhforrest at gmail.com
Tue Nov 7 10:30:23 EST 2023


The simplest fix is to take out some code in ClpSimplex:;sanityCheck

so -

diff --git a/src/ClpSimplex.cpp b/src/ClpSimplex.cpp
index a51bc080..d7530748 100644
--- a/src/ClpSimplex.cpp
+++ b/src/ClpSimplex.cpp
@@ -7453,6 +7453,7 @@ ClpSimplex::valueIncomingDual() const
  // Sanity check on input data - returns true if okay
  bool ClpSimplex::sanityCheck()
  {
+#if 0 // can't say bad - just because empty
    // bad if empty
    if (!numberColumns_ || ((!numberRows_ || !matrix_->getNumElements()) 
&& objective_->type() < 2)) {
      int infeasNumber[2];
@@ -7464,6 +7465,7 @@ bool ClpSimplex::sanityCheck()
      sumPrimalInfeasibilities_ = infeasSum[1];
      return false;
    }
+#endif

This change is in master.  The new output is slightly different from the 
empty problem message - so you get
Clp0024I Matrix will be packed to eliminate 1 small elements
Clp0006I 0  Obj -84 Dual inf 1.999999 (1)
Clp0006I 1  Obj 84
Clp0000I Optimal - objective value 84




On 04/11/2023 11:05, coinor at henning-thielemann.de wrote:
>
> I have written a Haskell binding to COIN-OR/Clp and added a test-suite 
> with automated QuickCheck tests. It spot the following problem:
>   https://hydra.nixos.org/build/239790474/nixlog/2
>
> I think this is a bug in Clp_addRows. I have simplified the problem 
> and extracted a minimal example using the C interface, see attached code.
>
> It is a super simple problem consisting of one variable and one equation.
>
> With the 'if' clause you can switch between Clp_addRows and 
> Clp_loadProblem.
>
> Clp_addRows yields
>
> $ a.out
> Clp0024I Matrix will be packed to eliminate 1 small elements
> Clp0000I Optimal - objective value 0
>
> which is wrong.
>
>
> Clp_loadProblem yields
>
> $ a.out
> Clp3002W Empty problem - 1 rows, 1 columns and 0 elements
> Clp0000I Optimal - objective value 84
>
> which is right.
>
>
> Clp_addRows works correctly, when the coefficient is not zero or when 
> I specify no term for the row, at all.
>
> _______________________________________________
> Clp mailing list
> Clp at list.coin-or.org
> https://list.coin-or.org/mailman/listinfo/clp




More information about the Clp mailing list