[Osi] OsiCpx deleteCols does not update names properly

Matthew Galati matthew.galati at gmail.com
Sat Jan 22 09:05:14 EST 2011


OsiCpx deleteCols does not update column names which can cause issues later
on if one uses getColNames().

OsiClp has some code that takes care of this.

Please apply this patch (note, this also includes the patch from my fix sent
last week).

A perhaps cleaner approach is to take the code used in OsiClp to delete a
(non-sequential) array of column names and put that into an overloaded
OsiSolverInterface::deleteColNames and then call that base function from
OsiCpx deleteCols (and any other OsiXxx that is missing it).

I can't file a ticket - the server is down.


magh at shark:~/COIN/coin-Dip/Osi/src/OsiCpx$ svn diff
Index: OsiCpxSolverInterface.cpp
===================================================================
--- OsiCpxSolverInterface.cpp   (revision 1661)
+++ OsiCpxSolverInterface.cpp   (working copy)
@@ -514,6 +514,9 @@
       else
        retval = false;
       break;
+    case OsiNameDiscipline:
+       retval = OsiSolverInterface::setIntParam(key,value);
+       break;
     case OsiLastIntParam:
       retval = false;
       break;
@@ -605,6 +608,9 @@
       value = hotStartMaxIteration_;
       retval = true;
       break;
+    case OsiNameDiscipline:
+       retval  = OsiSolverInterface::getIntParam(key,value);
+       break;
     case OsiLastIntParam:
       retval = false;
       break;
@@ -2233,6 +2239,37 @@
   }

   delete[] delstat;
+
+  //---
+  //--- MVG: took from OsiClp for updating names
+  //---
+  int nameDiscipline;
+  getIntParam(OsiNameDiscipline,nameDiscipline) ;
+  if (num&&nameDiscipline) {
+     // Very clumsy (and inefficient) - need to sort and then go backwards
in ? chunks
+     int * indices = CoinCopyOfArray(columnIndices,num);
+     std::sort(indices,indices+num);
+     int num2=num;
+     while(num2) {
+       int next = indices[num2-1];
+       int firstDelete = num2-1;
+       int i;
+       for (i=num2-2;i>=0;i--) {
+          if (indices[i]+1==next) {
+             next --;
+             firstDelete=i;
+          } else {
+             break;
+          }
+       }
+
OsiSolverInterface::deleteColNames(indices[firstDelete],num2-firstDelete);
+       num2 = firstDelete;
+      assert (num2>=0);
+     }
+     delete [] indices;
+  }
+
+
 }
 //-----------------------------------------------------------------------------
 void
@@ -2768,6 +2805,8 @@
 }


+
+
 //-----------------------------------------------------------------------------
 // Write mps files
 //-----------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/osi/attachments/20110122/2e0bca6e/attachment.html>


More information about the Osi mailing list