Ignore:
Timestamp:
Jan 6, 2019 2:43:06 PM (4 months ago)
Author:
unxusr
Message:

formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/AbcSimplex.cpp

    r2078 r2385  
    1010//#define ABC_DEBUG 2
    1111
    12 #if SLIM_CLP==2
     12#if SLIM_CLP == 2
    1313#define SLIM_NOIO
    1414#endif
     
    3939#include <iostream>
    4040//#############################################################################
    41 AbcSimplex::AbcSimplex (bool emptyMessages) :
    42  
     41AbcSimplex::AbcSimplex(bool emptyMessages)
     42  :
     43
    4344  ClpSimplex(emptyMessages)
    4445{
    4546  gutsOfDelete(0);
    46   gutsOfInitialize(0,0,true);
    47   assert (maximumAbcNumberRows_>=0);
     47  gutsOfInitialize(0, 0, true);
     48  assert(maximumAbcNumberRows_ >= 0);
    4849  //printf("XX %x AbcSimplex constructor\n",this);
    4950}
     
    5152//-----------------------------------------------------------------------------
    5253
    53 AbcSimplex::~AbcSimplex ()
     54AbcSimplex::~AbcSimplex()
    5455{
    5556  //printf("XX %x AbcSimplex destructor\n",this);
     
    5758}
    5859// Copy constructor.
    59 AbcSimplex::AbcSimplex(const AbcSimplex &rhs) :
    60   ClpSimplex(rhs)
     60AbcSimplex::AbcSimplex(const AbcSimplex &rhs)
     61  : ClpSimplex(rhs)
    6162{
    6263  //printf("XX %x AbcSimplex constructor from %x\n",this,&rhs);
    6364  gutsOfDelete(0);
    64   gutsOfInitialize(numberRows_,numberColumns_,false);
     65  gutsOfInitialize(numberRows_, numberColumns_, false);
    6566  gutsOfCopy(rhs);
    66   assert (maximumAbcNumberRows_>=0);
     67  assert(maximumAbcNumberRows_ >= 0);
    6768}
    6869#include "ClpDualRowSteepest.hpp"
     
    7071#include "ClpFactorization.hpp"
    7172// Copy constructor from model
    72 AbcSimplex::AbcSimplex(const ClpSimplex &rhs) :
    73   ClpSimplex(rhs)
     73AbcSimplex::AbcSimplex(const ClpSimplex &rhs)
     74  : ClpSimplex(rhs)
    7475{
    7576  //printf("XX %x AbcSimplex constructor from ClpSimplex\n",this);
    7677  gutsOfDelete(0);
    77   gutsOfInitialize(numberRows_,numberColumns_,true);
    78   gutsOfResize(numberRows_,numberColumns_);
     78  gutsOfInitialize(numberRows_, numberColumns_, true);
     79  gutsOfResize(numberRows_, numberColumns_);
    7980  // Set up row/column selection and factorization type
    80   ClpDualRowSteepest * pivot = dynamic_cast<ClpDualRowSteepest *>(rhs.dualRowPivot());
     81  ClpDualRowSteepest *pivot = dynamic_cast< ClpDualRowSteepest * >(rhs.dualRowPivot());
    8182  if (pivot) {
    8283    AbcDualRowSteepest steep(pivot->mode());
     
    8687    setDualRowPivotAlgorithm(dantzig);
    8788  }
    88   ClpPrimalColumnSteepest * pivotColumn = dynamic_cast<ClpPrimalColumnSteepest *>(rhs.primalColumnPivot());
     89  ClpPrimalColumnSteepest *pivotColumn = dynamic_cast< ClpPrimalColumnSteepest * >(rhs.primalColumnPivot());
    8990  if (pivotColumn) {
    9091    AbcPrimalColumnSteepest steep(pivotColumn->mode());
     
    9697  //if (rhs.factorization()->)
    9798  //factorization_->forceOtherFactorization();
    98   factorization()->synchronize(rhs.factorization(),this);
     99  factorization()->synchronize(rhs.factorization(), this);
    99100  //factorization_->setGoDenseThreshold(rhs.factorization()->goDenseThreshold());
    100101  //factorization_->setGoSmallThreshold(rhs.factorization()->goSmallThreshold());
    101   translate(DO_SCALE_AND_MATRIX|DO_BASIS_AND_ORDER|DO_STATUS|DO_SOLUTION);
    102   assert (maximumAbcNumberRows_>=0);
     102  translate(DO_SCALE_AND_MATRIX | DO_BASIS_AND_ORDER | DO_STATUS | DO_SOLUTION);
     103  assert(maximumAbcNumberRows_ >= 0);
    103104}
    104105// Assignment operator. This copies the data
    105106AbcSimplex &
    106 AbcSimplex::operator=(const AbcSimplex & rhs)
     107AbcSimplex::operator=(const AbcSimplex &rhs)
    107108{
    108109  if (this != &rhs) {
     
    110111    ClpSimplex::operator=(rhs);
    111112    gutsOfCopy(rhs);
    112     assert (maximumAbcNumberRows_>=0);
     113    assert(maximumAbcNumberRows_ >= 0);
    113114  }
    114115  return *this;
    115116}
    116117// fills in perturbationSaved_ from start with 0.5+random
    117 void
    118 AbcSimplex::fillPerturbation(int start, int number)
    119 {
    120   double * array = perturbationSaved_+start;
    121   for (int i=0;i<number;i++)
    122     array[i] = 0.5+0.5*randomNumberGenerator_.randomDouble();
     118void AbcSimplex::fillPerturbation(int start, int number)
     119{
     120  double *array = perturbationSaved_ + start;
     121  for (int i = 0; i < number; i++)
     122    array[i] = 0.5 + 0.5 * randomNumberGenerator_.randomDouble();
    123123}
    124124// Sets up all extra pointers
    125 void
    126 AbcSimplex::setupPointers(int maxRows,int maxColumns)
    127 {
    128   int numberTotal=maxRows+maxColumns;
    129   scaleToExternal_ = scaleFromExternal_+numberTotal;
    130   tempArray_=offset_+numberTotal;
    131   lowerSaved_=abcLower_+numberTotal;
    132   upperSaved_=abcUpper_+numberTotal;
    133   costSaved_=abcCost_+numberTotal;
    134   solutionSaved_=abcSolution_+numberTotal;
    135   djSaved_=abcDj_+numberTotal;
    136   internalStatusSaved_= internalStatus_+numberTotal;
    137   perturbationSaved_=abcPerturbation_+numberTotal;
    138   offsetRhs_=tempArray_+numberTotal;
    139   lowerBasic_=lowerSaved_+numberTotal;
    140   upperBasic_=upperSaved_+numberTotal;
    141   costBasic_=costSaved_+2*numberTotal;
    142   solutionBasic_=solutionSaved_+numberTotal;
    143   djBasic_=djSaved_+numberTotal;
    144   perturbationBasic_=perturbationSaved_+numberTotal;
    145   columnUseScale_ = scaleToExternal_+maxRows;
    146   inverseColumnUseScale_ = scaleFromExternal_+maxRows;
     125void AbcSimplex::setupPointers(int maxRows, int maxColumns)
     126{
     127  int numberTotal = maxRows + maxColumns;
     128  scaleToExternal_ = scaleFromExternal_ + numberTotal;
     129  tempArray_ = offset_ + numberTotal;
     130  lowerSaved_ = abcLower_ + numberTotal;
     131  upperSaved_ = abcUpper_ + numberTotal;
     132  costSaved_ = abcCost_ + numberTotal;
     133  solutionSaved_ = abcSolution_ + numberTotal;
     134  djSaved_ = abcDj_ + numberTotal;
     135  internalStatusSaved_ = internalStatus_ + numberTotal;
     136  perturbationSaved_ = abcPerturbation_ + numberTotal;
     137  offsetRhs_ = tempArray_ + numberTotal;
     138  lowerBasic_ = lowerSaved_ + numberTotal;
     139  upperBasic_ = upperSaved_ + numberTotal;
     140  costBasic_ = costSaved_ + 2 * numberTotal;
     141  solutionBasic_ = solutionSaved_ + numberTotal;
     142  djBasic_ = djSaved_ + numberTotal;
     143  perturbationBasic_ = perturbationSaved_ + numberTotal;
     144  columnUseScale_ = scaleToExternal_ + maxRows;
     145  inverseColumnUseScale_ = scaleFromExternal_ + maxRows;
    147146}
    148147// Copies all saved versions to working versions and may do something for perturbation
    149 void
    150 AbcSimplex::copyFromSaved(int which)
    151 {
    152   if ((which&1)!=0)
    153     CoinAbcMemcpy(abcSolution_,solutionSaved_,maximumNumberTotal_);
    154   if ((which&2)!=0)
    155     CoinAbcMemcpy(abcCost_,costSaved_,maximumNumberTotal_);
    156   if ((which&4)!=0)
    157     CoinAbcMemcpy(abcLower_,lowerSaved_,maximumNumberTotal_);
    158   if ((which&8)!=0)
    159     CoinAbcMemcpy(abcUpper_,upperSaved_,maximumNumberTotal_);
    160   if ((which&16)!=0)
    161     CoinAbcMemcpy(abcDj_,djSaved_,maximumNumberTotal_);
    162   if ((which&32)!=0) {
    163     CoinAbcMemcpy(abcLower_,abcPerturbation_,numberTotal_);
    164     CoinAbcMemcpy(abcUpper_,abcPerturbation_+numberTotal_,numberTotal_);
    165   }
    166 }
    167 void
    168 AbcSimplex::gutsOfCopy(const AbcSimplex & rhs)
     148void AbcSimplex::copyFromSaved(int which)
     149{
     150  if ((which & 1) != 0)
     151    CoinAbcMemcpy(abcSolution_, solutionSaved_, maximumNumberTotal_);
     152  if ((which & 2) != 0)
     153    CoinAbcMemcpy(abcCost_, costSaved_, maximumNumberTotal_);
     154  if ((which & 4) != 0)
     155    CoinAbcMemcpy(abcLower_, lowerSaved_, maximumNumberTotal_);
     156  if ((which & 8) != 0)
     157    CoinAbcMemcpy(abcUpper_, upperSaved_, maximumNumberTotal_);
     158  if ((which & 16) != 0)
     159    CoinAbcMemcpy(abcDj_, djSaved_, maximumNumberTotal_);
     160  if ((which & 32) != 0) {
     161    CoinAbcMemcpy(abcLower_, abcPerturbation_, numberTotal_);
     162    CoinAbcMemcpy(abcUpper_, abcPerturbation_ + numberTotal_, numberTotal_);
     163  }
     164}
     165void AbcSimplex::gutsOfCopy(const AbcSimplex &rhs)
    169166{
    170167#ifdef ABC_INHERIT
    171   abcSimplex_=this;
    172 #endif
    173   assert (numberRows_ == rhs.numberRows_);
    174   assert (numberColumns_ == rhs.numberColumns_);
     168  abcSimplex_ = this;
     169#endif
     170  assert(numberRows_ == rhs.numberRows_);
     171  assert(numberColumns_ == rhs.numberColumns_);
    175172  numberTotal_ = rhs.numberTotal_;
    176173  maximumNumberTotal_ = rhs.maximumNumberTotal_;
    177174  // special options here to be safe
    178   specialOptions_=rhs.specialOptions_;
     175  specialOptions_ = rhs.specialOptions_;
    179176  //assert (maximumInternalRows_ >= numberRows_);
    180177  //assert (maximumInternalColumns_ >= numberColumns_);
    181178  // Copy all scalars
    182   CoinAbcMemcpy(reinterpret_cast<int *>(&sumNonBasicCosts_),
    183             reinterpret_cast<const int *>(&rhs.sumNonBasicCosts_),
    184             (&swappedAlgorithm_-reinterpret_cast<int *>(&sumNonBasicCosts_))+1);
     179  CoinAbcMemcpy(reinterpret_cast< int * >(&sumNonBasicCosts_),
     180    reinterpret_cast< const int * >(&rhs.sumNonBasicCosts_),
     181    (&swappedAlgorithm_ - reinterpret_cast< int * >(&sumNonBasicCosts_)) + 1);
    185182  // could add 2 so can go off end
    186   int sizeArray=2*maximumNumberTotal_+maximumAbcNumberRows_;
    187   internalStatus_ = ClpCopyOfArray(rhs.internalStatus_,sizeArray+maximumNumberTotal_);
     183  int sizeArray = 2 * maximumNumberTotal_ + maximumAbcNumberRows_;
     184  internalStatus_ = ClpCopyOfArray(rhs.internalStatus_, sizeArray + maximumNumberTotal_);
    188185  abcLower_ = ClpCopyOfArray(rhs.abcLower_, sizeArray);
    189186  abcUpper_ = ClpCopyOfArray(rhs.abcUpper_, sizeArray);
    190   abcCost_ = ClpCopyOfArray(rhs.abcCost_, sizeArray+maximumNumberTotal_);
     187  abcCost_ = ClpCopyOfArray(rhs.abcCost_, sizeArray + maximumNumberTotal_);
    191188  abcDj_ = ClpCopyOfArray(rhs.abcDj_, sizeArray);
    192189
    193   abcSolution_ = ClpCopyOfArray(rhs.abcSolution_, sizeArray+maximumNumberTotal_);
    194   abcPerturbation_ = ClpCopyOfArray(rhs.abcPerturbation_,sizeArray);
    195   abcPivotVariable_ = ClpCopyOfArray(rhs.abcPivotVariable_,maximumAbcNumberRows_);
     190  abcSolution_ = ClpCopyOfArray(rhs.abcSolution_, sizeArray + maximumNumberTotal_);
     191  abcPerturbation_ = ClpCopyOfArray(rhs.abcPerturbation_, sizeArray);
     192  abcPivotVariable_ = ClpCopyOfArray(rhs.abcPivotVariable_, maximumAbcNumberRows_);
    196193  //fromExternal_ = ClpCopyOfArray(rhs.fromExternal_,sizeArray);
    197194  //toExternal_ = ClpCopyOfArray(rhs.toExternal_,sizeArray);
    198   scaleFromExternal_ = ClpCopyOfArray(rhs.scaleFromExternal_,sizeArray);
    199   offset_ = ClpCopyOfArray(rhs.offset_,sizeArray);
    200   setupPointers(maximumAbcNumberRows_,maximumAbcNumberColumns_);
     195  scaleFromExternal_ = ClpCopyOfArray(rhs.scaleFromExternal_, sizeArray);
     196  offset_ = ClpCopyOfArray(rhs.offset_, sizeArray);
     197  setupPointers(maximumAbcNumberRows_, maximumAbcNumberColumns_);
    201198  if (rhs.abcMatrix_)
    202199    abcMatrix_ = new AbcMatrix(*rhs.abcMatrix_);
     
    238235}
    239236// type == 0 nullify, 1 also delete
    240 void
    241 AbcSimplex::gutsOfDelete(int type)
     237void AbcSimplex::gutsOfDelete(int type)
    242238{
    243239  if (type) {
    244     delete [] abcLower_;
    245     delete [] abcUpper_;
    246     delete [] abcCost_;
    247     delete [] abcDj_;
    248     delete [] abcSolution_;
     240    delete[] abcLower_;
     241    delete[] abcUpper_;
     242    delete[] abcCost_;
     243    delete[] abcDj_;
     244    delete[] abcSolution_;
    249245    //delete [] fromExternal_ ;
    250246    //delete [] toExternal_ ;
    251     delete [] scaleFromExternal_ ;
     247    delete[] scaleFromExternal_;
    252248    //delete [] scaleToExternal_ ;
    253     delete [] offset_ ;
    254     delete [] internalStatus_ ;
    255     delete [] abcPerturbation_ ;
    256     delete abcMatrix_ ;
     249    delete[] offset_;
     250    delete[] internalStatus_;
     251    delete[] abcPerturbation_;
     252    delete abcMatrix_;
    257253    delete abcFactorization_;
    258254#ifdef EARLY_FACTORIZE
    259255    delete abcEarlyFactorization_;
    260256#endif
    261     delete [] abcPivotVariable_;
     257    delete[] abcPivotVariable_;
    262258    delete abcDualRowPivot_;
    263259    delete abcPrimalColumnPivot_;
     
    266262    delete abcNonLinearCost_;
    267263  }
    268   CoinAbcMemset0(reinterpret_cast<char *>(&scaleToExternal_),
    269              reinterpret_cast<char *>(&usefulArray_[0])-reinterpret_cast<char *>(&scaleToExternal_));
    270 }
    271 template <class T> T *
    272 newArray(T * /*nullArray*/, int size)
     264  CoinAbcMemset0(reinterpret_cast< char * >(&scaleToExternal_),
     265    reinterpret_cast< char * >(&usefulArray_[0]) - reinterpret_cast< char * >(&scaleToExternal_));
     266}
     267template < class T >
     268T *newArray(T * /*nullArray*/, int size)
    273269{
    274270  if (size) {
    275     T * arrayNew = new T[size];
     271    T *arrayNew = new T[size];
    276272#ifndef NDEBUG
    277     memset(arrayNew,'A',(size)*sizeof(T));
     273    memset(arrayNew, 'A', (size) * sizeof(T));
    278274#endif
    279275    return arrayNew;
     
    282278  }
    283279}
    284 template <class T> T *
    285 resizeArray( T * array, int oldSize1, int oldSize2, int newSize1, int newSize2,int extra)
    286 {
    287   if ((array||!oldSize1)&&(newSize1!=oldSize1||newSize2!=oldSize2)) {
    288     int newTotal=newSize1+newSize2;
    289     int oldTotal=oldSize1+oldSize2;
    290     T * arrayNew;
    291     if (newSize1>oldSize1||newSize2>oldSize2) {
    292       arrayNew = new T[2*newTotal+newSize1+extra];
     280template < class T >
     281T *resizeArray(T *array, int oldSize1, int oldSize2, int newSize1, int newSize2, int extra)
     282{
     283  if ((array || !oldSize1) && (newSize1 != oldSize1 || newSize2 != oldSize2)) {
     284    int newTotal = newSize1 + newSize2;
     285    int oldTotal = oldSize1 + oldSize2;
     286    T *arrayNew;
     287    if (newSize1 > oldSize1 || newSize2 > oldSize2) {
     288      arrayNew = new T[2 * newTotal + newSize1 + extra];
    293289#ifndef NDEBUG
    294       memset(arrayNew,'A',(2*newTotal+newSize1+extra)*sizeof(T));
    295 #endif
    296       CoinAbcMemcpy(arrayNew,array,oldSize1);
    297       CoinAbcMemcpy(arrayNew+newSize1,array+oldSize1,oldSize2);
     290      memset(arrayNew, 'A', (2 * newTotal + newSize1 + extra) * sizeof(T));
     291#endif
     292      CoinAbcMemcpy(arrayNew, array, oldSize1);
     293      CoinAbcMemcpy(arrayNew + newSize1, array + oldSize1, oldSize2);
    298294      // and second half
    299       CoinAbcMemcpy(arrayNew+newTotal,array,oldSize1+oldTotal);
    300       CoinAbcMemcpy(arrayNew+newSize1+newTotal,array+oldSize1+oldTotal,oldSize2);
    301       delete [] array;
     295      CoinAbcMemcpy(arrayNew + newTotal, array, oldSize1 + oldTotal);
     296      CoinAbcMemcpy(arrayNew + newSize1 + newTotal, array + oldSize1 + oldTotal, oldSize2);
     297      delete[] array;
    302298    } else {
    303       arrayNew=array;
    304       for (int i=0;i<newSize2;i++)
    305         array[newSize1+i]=array[oldSize1+i];
    306       for (int i=0;i<newSize1;i++)
    307         array[newTotal+i]=array[oldTotal+i];
    308       for (int i=0;i<newSize2;i++)
    309         array[newSize1+newTotal+i]=array[oldSize1+oldTotal+i];
     299      arrayNew = array;
     300      for (int i = 0; i < newSize2; i++)
     301        array[newSize1 + i] = array[oldSize1 + i];
     302      for (int i = 0; i < newSize1; i++)
     303        array[newTotal + i] = array[oldTotal + i];
     304      for (int i = 0; i < newSize2; i++)
     305        array[newSize1 + newTotal + i] = array[oldSize1 + oldTotal + i];
    310306    }
    311307    return arrayNew;
     
    315311}
    316312// Initializes arrays
    317 void
    318 AbcSimplex::gutsOfInitialize(int numberRows,int numberColumns,bool doMore)
     313void AbcSimplex::gutsOfInitialize(int numberRows, int numberColumns, bool doMore)
    319314{
    320315#ifdef ABC_INHERIT
    321   abcSimplex_=this;
     316  abcSimplex_ = this;
    322317#endif
    323318  // Zero all
    324   CoinAbcMemset0(&sumNonBasicCosts_,(reinterpret_cast<double *>(&usefulArray_[0])-&sumNonBasicCosts_));
     319  CoinAbcMemset0(&sumNonBasicCosts_, (reinterpret_cast< double * >(&usefulArray_[0]) - &sumNonBasicCosts_));
    325320  zeroTolerance_ = 1.0e-13;
    326321  bestObjectiveValue_ = -COIN_DBL_MAX;
     
    343338  lastGoodIteration_ = -100;
    344339  numberPrimalInfeasibilities_ = 100;
    345   numberRefinements_=1;
     340  numberRefinements_ = 1;
    346341  changeMade_ = 1;
    347342  forceFactorization_ = -1;
    348   if (perturbation_<50||(perturbation_>60&&perturbation_<100))
     343  if (perturbation_ < 50 || (perturbation_ > 60 && perturbation_ < 100))
    349344    perturbation_ = 50;
    350345  lastBadIteration_ = -999999;
     
    356351  //specialOptions_|=65536;
    357352  //ClpModel::startPermanentArrays();
    358   maximumInternalRows_ =0;
    359   maximumInternalColumns_ =0;
    360   numberRows_=numberRows;
    361   numberColumns_=numberColumns;
    362   numberTotal_=numberRows_+numberColumns_;
    363   maximumAbcNumberRows_=numberRows;
    364   maximumAbcNumberColumns_=numberColumns;
    365   maximumNumberTotal_=numberTotal_;
    366   int sizeArray=2*maximumNumberTotal_+maximumAbcNumberRows_;
     353  maximumInternalRows_ = 0;
     354  maximumInternalColumns_ = 0;
     355  numberRows_ = numberRows;
     356  numberColumns_ = numberColumns;
     357  numberTotal_ = numberRows_ + numberColumns_;
     358  maximumAbcNumberRows_ = numberRows;
     359  maximumAbcNumberColumns_ = numberColumns;
     360  maximumNumberTotal_ = numberTotal_;
     361  int sizeArray = 2 * maximumNumberTotal_ + maximumAbcNumberRows_;
    367362  if (doMore) {
    368363    // say Steepest pricing
    369364    abcDualRowPivot_ = new AbcDualRowSteepest();
    370365    abcPrimalColumnPivot_ = new AbcPrimalColumnSteepest();
    371     internalStatus_ = newArray(reinterpret_cast<unsigned char *>(NULL),
    372                                sizeArray+maximumNumberTotal_);
    373     abcLower_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
    374     abcUpper_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
    375     abcCost_ = newArray(reinterpret_cast<double *>(NULL),sizeArray+maximumNumberTotal_);
    376     abcDj_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
    377     abcSolution_ = newArray(reinterpret_cast<double *>(NULL),sizeArray+maximumNumberTotal_);
     366    internalStatus_ = newArray(reinterpret_cast< unsigned char * >(NULL),
     367      sizeArray + maximumNumberTotal_);
     368    abcLower_ = newArray(reinterpret_cast< double * >(NULL), sizeArray);
     369    abcUpper_ = newArray(reinterpret_cast< double * >(NULL), sizeArray);
     370    abcCost_ = newArray(reinterpret_cast< double * >(NULL), sizeArray + maximumNumberTotal_);
     371    abcDj_ = newArray(reinterpret_cast< double * >(NULL), sizeArray);
     372    abcSolution_ = newArray(reinterpret_cast< double * >(NULL), sizeArray + maximumNumberTotal_);
    378373    //fromExternal_ = newArray(reinterpret_cast<int *>(NULL),sizeArray);
    379374    //toExternal_ = newArray(reinterpret_cast<int *>(NULL),sizeArray);
    380     scaleFromExternal_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
    381     offset_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
    382     abcPerturbation_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
    383     abcPivotVariable_ = newArray(reinterpret_cast<int *>(NULL),maximumAbcNumberRows_);
     375    scaleFromExternal_ = newArray(reinterpret_cast< double * >(NULL), sizeArray);
     376    offset_ = newArray(reinterpret_cast< double * >(NULL), sizeArray);
     377    abcPerturbation_ = newArray(reinterpret_cast< double * >(NULL), sizeArray);
     378    abcPivotVariable_ = newArray(reinterpret_cast< int * >(NULL), maximumAbcNumberRows_);
    384379    // Fill perturbation array
    385     setupPointers(maximumAbcNumberRows_,maximumAbcNumberColumns_);
    386     fillPerturbation(0,maximumNumberTotal_);
     380    setupPointers(maximumAbcNumberRows_, maximumAbcNumberColumns_);
     381    fillPerturbation(0, maximumNumberTotal_);
    387382  }
    388383  // get an empty factorization so we can set tolerances etc
    389384  getEmptyFactorization();
    390   for (int i=0;i<ABC_NUMBER_USEFUL;i++)
    391     usefulArray_[i].reserve(CoinMax(CoinMax(numberTotal_,maximumAbcNumberRows_+200),2*numberRows_));
     385  for (int i = 0; i < ABC_NUMBER_USEFUL; i++)
     386    usefulArray_[i].reserve(CoinMax(CoinMax(numberTotal_, maximumAbcNumberRows_ + 200), 2 * numberRows_));
    392387  //savedStatus_ = internalStatus_+maximumNumberTotal_;
    393388  //startPermanentArrays();
    394389}
    395390// resizes arrays
    396 void
    397 AbcSimplex::gutsOfResize(int numberRows,int numberColumns)
     391void AbcSimplex::gutsOfResize(int numberRows, int numberColumns)
    398392{
    399393  if (!abcSolution_) {
    400     numberRows_=0;
    401     numberColumns_=0;
    402     numberTotal_=0;
    403     maximumAbcNumberRows_=0;
    404     maximumAbcNumberColumns_=0;
    405     maximumNumberTotal_=0;
    406   }
    407   if (numberRows==numberRows_&&numberColumns==numberColumns_)
     394    numberRows_ = 0;
     395    numberColumns_ = 0;
     396    numberTotal_ = 0;
     397    maximumAbcNumberRows_ = 0;
     398    maximumAbcNumberColumns_ = 0;
     399    maximumNumberTotal_ = 0;
     400  }
     401  if (numberRows == numberRows_ && numberColumns == numberColumns_)
    408402    return;
    409403  // can do on state bit
    410   int newSize1=CoinMax(numberRows,maximumAbcNumberRows_);
    411   if ((stateOfProblem_&ADD_A_BIT)!=0&&numberRows>maximumAbcNumberRows_)
    412     newSize1=CoinMax(numberRows,maximumAbcNumberRows_+CoinMin(100,numberRows_/10));
    413   int newSize2=CoinMax(numberColumns,maximumAbcNumberColumns_);
    414   numberRows_=numberRows;
    415   numberColumns_=numberColumns;
    416   numberTotal_=numberRows_+numberColumns_;
     404  int newSize1 = CoinMax(numberRows, maximumAbcNumberRows_);
     405  if ((stateOfProblem_ & ADD_A_BIT) != 0 && numberRows > maximumAbcNumberRows_)
     406    newSize1 = CoinMax(numberRows, maximumAbcNumberRows_ + CoinMin(100, numberRows_ / 10));
     407  int newSize2 = CoinMax(numberColumns, maximumAbcNumberColumns_);
     408  numberRows_ = numberRows;
     409  numberColumns_ = numberColumns;
     410  numberTotal_ = numberRows_ + numberColumns_;
    417411  //fromExternal_ = resizeArray(fromExternal_,maximumAbcNumberRows_,maximumAbcNumberColumns_,newSize1,newSize2,1);
    418412  //toExternal_ = resizeArray(toExternal_,maximumAbcNumberRows_,maximumAbcNumberColumns_,newSize1,newSize2,1,0);
    419   scaleFromExternal_ = resizeArray(scaleFromExternal_,maximumAbcNumberRows_,maximumAbcNumberColumns_,newSize1,newSize2,0);
     413  scaleFromExternal_ = resizeArray(scaleFromExternal_, maximumAbcNumberRows_, maximumAbcNumberColumns_, newSize1, newSize2, 0);
    420414  //scaleToExternal_ = resizeArray(scaleToExternal_,maximumAbcNumberRows_,maximumAbcNumberColumns_,newSize1,newSize2,1,0);
    421   internalStatus_ = resizeArray(internalStatus_,maximumAbcNumberRows_,
    422                                 maximumAbcNumberColumns_,
    423                                 newSize1,newSize2,numberTotal_);
    424   abcLower_ = resizeArray(abcLower_,maximumAbcNumberRows_,maximumAbcNumberColumns_,newSize1,newSize2,0);
    425   abcUpper_ = resizeArray(abcUpper_,maximumAbcNumberRows_,maximumAbcNumberColumns_,newSize1,newSize2,0);
    426   abcCost_ = resizeArray(abcCost_,maximumAbcNumberRows_,maximumAbcNumberColumns_,newSize1,newSize2,numberTotal_);
    427   abcDj_ = resizeArray(abcDj_,maximumAbcNumberRows_,maximumAbcNumberColumns_,newSize1,newSize2,0);
    428   abcSolution_ = resizeArray(abcSolution_,maximumAbcNumberRows_,maximumAbcNumberColumns_,newSize1,newSize2,numberTotal_);
    429   abcPerturbation_ = resizeArray(abcPerturbation_,maximumAbcNumberRows_,maximumAbcNumberColumns_,newSize1,newSize2,0);
    430   offset_ = resizeArray(offset_,maximumAbcNumberRows_,maximumAbcNumberColumns_,newSize1,newSize2,0);
    431   setupPointers(newSize1,newSize2);
     415  internalStatus_ = resizeArray(internalStatus_, maximumAbcNumberRows_,
     416    maximumAbcNumberColumns_,
     417    newSize1, newSize2, numberTotal_);
     418  abcLower_ = resizeArray(abcLower_, maximumAbcNumberRows_, maximumAbcNumberColumns_, newSize1, newSize2, 0);
     419  abcUpper_ = resizeArray(abcUpper_, maximumAbcNumberRows_, maximumAbcNumberColumns_, newSize1, newSize2, 0);
     420  abcCost_ = resizeArray(abcCost_, maximumAbcNumberRows_, maximumAbcNumberColumns_, newSize1, newSize2, numberTotal_);
     421  abcDj_ = resizeArray(abcDj_, maximumAbcNumberRows_, maximumAbcNumberColumns_, newSize1, newSize2, 0);
     422  abcSolution_ = resizeArray(abcSolution_, maximumAbcNumberRows_, maximumAbcNumberColumns_, newSize1, newSize2, numberTotal_);
     423  abcPerturbation_ = resizeArray(abcPerturbation_, maximumAbcNumberRows_, maximumAbcNumberColumns_, newSize1, newSize2, 0);
     424  offset_ = resizeArray(offset_, maximumAbcNumberRows_, maximumAbcNumberColumns_, newSize1, newSize2, 0);
     425  setupPointers(newSize1, newSize2);
    432426  // Fill gaps in perturbation array
    433   fillPerturbation(maximumAbcNumberRows_,newSize1-maximumAbcNumberRows_);
    434   fillPerturbation(newSize1+maximumAbcNumberColumns_,newSize2-maximumAbcNumberColumns_);
     427  fillPerturbation(maximumAbcNumberRows_, newSize1 - maximumAbcNumberRows_);
     428  fillPerturbation(newSize1 + maximumAbcNumberColumns_, newSize2 - maximumAbcNumberColumns_);
    435429  // Clean gap
    436430  //CoinIotaN(fromExternal_+maximumAbcNumberRows_,newSize1-maximumAbcNumberRows_,maximumAbcNumberRows_);
    437431  //CoinIotaN(toExternal_+maximumAbcNumberRows_,newSize1-maximumAbcNumberRows_,maximumAbcNumberRows_);
    438   CoinFillN(scaleFromExternal_+maximumAbcNumberRows_,newSize1-maximumAbcNumberRows_,1.0);
    439   CoinFillN(scaleToExternal_+maximumAbcNumberRows_,newSize1-maximumAbcNumberRows_,1.0);
    440   CoinFillN(internalStatusSaved_+maximumAbcNumberRows_,newSize1-maximumAbcNumberRows_,static_cast<unsigned char>(1));
    441   CoinFillN(lowerSaved_+maximumAbcNumberRows_,newSize1-maximumAbcNumberRows_,-COIN_DBL_MAX);
    442   CoinFillN(upperSaved_+maximumAbcNumberRows_,newSize1-maximumAbcNumberRows_,COIN_DBL_MAX);
    443   CoinFillN(costSaved_+maximumAbcNumberRows_,newSize1-maximumAbcNumberRows_,0.0);
    444   CoinFillN(djSaved_+maximumAbcNumberRows_,newSize1-maximumAbcNumberRows_,0.0);
    445   CoinFillN(solutionSaved_+maximumAbcNumberRows_,newSize1-maximumAbcNumberRows_,0.0);
    446   CoinFillN(offset_+maximumAbcNumberRows_,newSize1-maximumAbcNumberRows_,0.0);
    447   maximumAbcNumberRows_=newSize1;
    448   maximumAbcNumberColumns_=newSize2;
    449   maximumNumberTotal_=newSize1+newSize2;
    450   delete [] abcPivotVariable_;
     432  CoinFillN(scaleFromExternal_ + maximumAbcNumberRows_, newSize1 - maximumAbcNumberRows_, 1.0);
     433  CoinFillN(scaleToExternal_ + maximumAbcNumberRows_, newSize1 - maximumAbcNumberRows_, 1.0);
     434  CoinFillN(internalStatusSaved_ + maximumAbcNumberRows_, newSize1 - maximumAbcNumberRows_, static_cast< unsigned char >(1));
     435  CoinFillN(lowerSaved_ + maximumAbcNumberRows_, newSize1 - maximumAbcNumberRows_, -COIN_DBL_MAX);
     436  CoinFillN(upperSaved_ + maximumAbcNumberRows_, newSize1 - maximumAbcNumberRows_, COIN_DBL_MAX);
     437  CoinFillN(costSaved_ + maximumAbcNumberRows_, newSize1 - maximumAbcNumberRows_, 0.0);
     438  CoinFillN(djSaved_ + maximumAbcNumberRows_, newSize1 - maximumAbcNumberRows_, 0.0);
     439  CoinFillN(solutionSaved_ + maximumAbcNumberRows_, newSize1 - maximumAbcNumberRows_, 0.0);
     440  CoinFillN(offset_ + maximumAbcNumberRows_, newSize1 - maximumAbcNumberRows_, 0.0);
     441  maximumAbcNumberRows_ = newSize1;
     442  maximumAbcNumberColumns_ = newSize2;
     443  maximumNumberTotal_ = newSize1 + newSize2;
     444  delete[] abcPivotVariable_;
    451445  abcPivotVariable_ = new int[maximumAbcNumberRows_];
    452   for (int i=0;i<ABC_NUMBER_USEFUL;i++)
    453     usefulArray_[i].reserve(CoinMax(numberTotal_,maximumAbcNumberRows_+200));
    454 }
    455 void
    456 AbcSimplex::translate(int type)
     446  for (int i = 0; i < ABC_NUMBER_USEFUL; i++)
     447    usefulArray_[i].reserve(CoinMax(numberTotal_, maximumAbcNumberRows_ + 200));
     448}
     449void AbcSimplex::translate(int type)
    457450{
    458451  // clear bottom bits
    459   stateOfProblem_ &= ~(VALUES_PASS-1);
    460   if ((type&DO_SCALE_AND_MATRIX)!=0) {
     452  stateOfProblem_ &= ~(VALUES_PASS - 1);
     453  if ((type & DO_SCALE_AND_MATRIX) != 0) {
    461454    //stateOfProblem_ |= DO_SCALE_AND_MATRIX;
    462455    stateOfProblem_ |= DO_SCALE_AND_MATRIX;
    463456    delete abcMatrix_;
    464     abcMatrix_=new AbcMatrix(*matrix());
     457    abcMatrix_ = new AbcMatrix(*matrix());
    465458    abcMatrix_->setModel(this);
    466459    abcMatrix_->scale(scalingFlag_ ? 0 : -1);
    467460  }
    468   if ((type&DO_STATUS)!=0&&(type&DO_BASIS_AND_ORDER)==0) {
     461  if ((type & DO_STATUS) != 0 && (type & DO_BASIS_AND_ORDER) == 0) {
    469462    // from Clp enum to Abc enum (and bound flip)
    470     unsigned char lookupToAbcSlack[6]={4,6,0/*1*/,1/*0*/,5,7};
    471     unsigned char *  COIN_RESTRICT statusAbc=internalStatus_;
    472     const unsigned char *  COIN_RESTRICT statusClp=status_;
     463    unsigned char lookupToAbcSlack[6] = { 4, 6, 0 /*1*/, 1 /*0*/, 5, 7 };
     464    unsigned char *COIN_RESTRICT statusAbc = internalStatus_;
     465    const unsigned char *COIN_RESTRICT statusClp = status_;
    473466    int i;
    474     for (i=numberRows_-1;i>=0;i--) {
    475       unsigned char status=statusClp[i]&7;
    476       bool basicClp=status==1;
    477       bool basicAbc=(statusAbc[i]&7)==4;
    478       if (basicClp==basicAbc)
    479         statusAbc[i]=lookupToAbcSlack[status];
     467    for (i = numberRows_ - 1; i >= 0; i--) {
     468      unsigned char status = statusClp[i] & 7;
     469      bool basicClp = status == 1;
     470      bool basicAbc = (statusAbc[i] & 7) == 4;
     471      if (basicClp == basicAbc)
     472        statusAbc[i] = lookupToAbcSlack[status];
    480473      else
    481         break;
     474        break;
    482475    }
    483476    if (!i) {
    484477      // from Clp enum to Abc enum
    485       unsigned char lookupToAbc[6]={4,6,1,0,5,7};
    486       statusAbc+=maximumAbcNumberRows_;
    487       statusClp+=maximumAbcNumberRows_;
    488       for (i=numberColumns_-1;i>=0;i--) {
    489         unsigned char status=statusClp[i]&7;
    490         bool basicClp=status==1;
    491         bool basicAbc=(statusAbc[i]&7)==4;
    492         if (basicClp==basicAbc)
    493           statusAbc[i]=lookupToAbc[status];
    494         else
    495           break;
     478      unsigned char lookupToAbc[6] = { 4, 6, 1, 0, 5, 7 };
     479      statusAbc += maximumAbcNumberRows_;
     480      statusClp += maximumAbcNumberRows_;
     481      for (i = numberColumns_ - 1; i >= 0; i--) {
     482        unsigned char status = statusClp[i] & 7;
     483        bool basicClp = status == 1;
     484        bool basicAbc = (statusAbc[i] & 7) == 4;
     485        if (basicClp == basicAbc)
     486          statusAbc[i] = lookupToAbc[status];
     487        else
     488          break;
    496489      }
    497490      if (i)
    498         type |=DO_BASIS_AND_ORDER;
     491        type |= DO_BASIS_AND_ORDER;
    499492    } else {
    500       type |=DO_BASIS_AND_ORDER;
     493      type |= DO_BASIS_AND_ORDER;
    501494    }
    502495    stateOfProblem_ |= DO_STATUS;
    503496  }
    504   if ((type&DO_BASIS_AND_ORDER)!=0) {
     497  if ((type & DO_BASIS_AND_ORDER) != 0) {
    505498    permuteIn();
    506499    permuteBasis();
     
    508501    type &= ~DO_SOLUTION;
    509502  }
    510   if ((type&DO_SOLUTION)!=0) {
     503  if ((type & DO_SOLUTION) != 0) {
    511504    permuteBasis();
    512505    stateOfProblem_ |= DO_SOLUTION;
    513506  }
    514   if ((type&DO_JUST_BOUNDS)!=0) {
     507  if ((type & DO_JUST_BOUNDS) != 0) {
    515508    stateOfProblem_ |= DO_JUST_BOUNDS;
    516509  }
    517510  if (!type) {
    518511    // just move stuff down
    519     CoinAbcMemcpy(abcLower_,abcLower_+maximumNumberTotal_,numberTotal_);
    520     CoinAbcMemcpy(abcUpper_,abcUpper_+maximumNumberTotal_,numberTotal_);
    521     CoinAbcMemcpy(abcCost_,abcCost_+maximumNumberTotal_,numberTotal_);
     512    CoinAbcMemcpy(abcLower_, abcLower_ + maximumNumberTotal_, numberTotal_);
     513    CoinAbcMemcpy(abcUpper_, abcUpper_ + maximumNumberTotal_, numberTotal_);
     514    CoinAbcMemcpy(abcCost_, abcCost_ + maximumNumberTotal_, numberTotal_);
    522515  }
    523516}
    524517#ifdef ABC_SPRINT
    525518// Overwrite to create sub problem (just internal arrays) - save full stuff
    526 AbcSimplex * 
    527 AbcSimplex::createSubProblem(int numberColumns,const int * whichColumn)
     519AbcSimplex *
     520AbcSimplex::createSubProblem(int numberColumns, const int *whichColumn)
    528521{
    529522  int numberFullColumns = numberColumns_;
    530523  numberColumns_ = numberColumns;
    531   AbcSimplex * subProblem = this;
    532   AbcSimplex * fullProblem = reinterpret_cast<AbcSimplex *>(new char[sizeof(AbcSimplex)]);
    533   memset(fullProblem,0,sizeof(AbcSimplex));
     524  AbcSimplex *subProblem = this;
     525  AbcSimplex *fullProblem = reinterpret_cast< AbcSimplex * >(new char[sizeof(AbcSimplex)]);
     526  memset(fullProblem, 0, sizeof(AbcSimplex));
    534527  fullProblem->maximumAbcNumberRows_ = maximumAbcNumberRows_;
    535528  fullProblem->numberColumns_ = numberFullColumns;
     
    537530  fullProblem->maximumNumberTotal_ = maximumNumberTotal_;
    538531  fullProblem->numberTotalWithoutFixed_ = numberTotalWithoutFixed_;
    539   fullProblem->abcPrimalColumnPivot_ =   abcPrimalColumnPivot_;
    540   fullProblem->internalStatus_ =   internalStatus_;
    541   fullProblem->abcLower_ =   abcLower_;
    542   fullProblem->abcUpper_ =   abcUpper_;
    543   fullProblem->abcCost_ =   abcCost_;
    544   fullProblem->abcDj_ =   abcDj_;
    545   fullProblem->abcSolution_ =   abcSolution_;
    546   fullProblem->scaleFromExternal_ =   scaleFromExternal_;
    547   fullProblem->offset_ =   offset_;
    548   fullProblem->abcPerturbation_ =   abcPerturbation_;
    549   fullProblem->abcPivotVariable_ =   abcPivotVariable_;
    550   fullProblem->abcMatrix_ =   abcMatrix_;
     532  fullProblem->abcPrimalColumnPivot_ = abcPrimalColumnPivot_;
     533  fullProblem->internalStatus_ = internalStatus_;
     534  fullProblem->abcLower_ = abcLower_;
     535  fullProblem->abcUpper_ = abcUpper_;
     536  fullProblem->abcCost_ = abcCost_;
     537  fullProblem->abcDj_ = abcDj_;
     538  fullProblem->abcSolution_ = abcSolution_;
     539  fullProblem->scaleFromExternal_ = scaleFromExternal_;
     540  fullProblem->offset_ = offset_;
     541  fullProblem->abcPerturbation_ = abcPerturbation_;
     542  fullProblem->abcPivotVariable_ = abcPivotVariable_;
     543  fullProblem->abcMatrix_ = abcMatrix_;
    551544  fullProblem->abcNonLinearCost_ = abcNonLinearCost_;
    552   fullProblem->setupPointers(maximumAbcNumberRows_,numberFullColumns);
    553   subProblem->numberTotal_= maximumAbcNumberRows_+numberColumns;
    554   subProblem->maximumNumberTotal_= maximumAbcNumberRows_+numberColumns;
    555   subProblem->numberTotalWithoutFixed_= subProblem->numberTotal_;
    556   int sizeArray=2*subProblem->maximumNumberTotal_+maximumAbcNumberRows_;
    557   subProblem->internalStatus_ = newArray(reinterpret_cast<unsigned char *>(NULL),
    558                                          sizeArray+subProblem->maximumNumberTotal_);
    559   subProblem->abcLower_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
    560   subProblem->abcUpper_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
    561   subProblem->abcCost_ = newArray(reinterpret_cast<double *>(NULL),sizeArray+subProblem->maximumNumberTotal_);
    562   subProblem->abcDj_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
    563   subProblem->abcSolution_ = newArray(reinterpret_cast<double *>(NULL),sizeArray+subProblem->maximumNumberTotal_);
     545  fullProblem->setupPointers(maximumAbcNumberRows_, numberFullColumns);
     546  subProblem->numberTotal_ = maximumAbcNumberRows_ + numberColumns;
     547  subProblem->maximumNumberTotal_ = maximumAbcNumberRows_ + numberColumns;
     548  subProblem->numberTotalWithoutFixed_ = subProblem->numberTotal_;
     549  int sizeArray = 2 * subProblem->maximumNumberTotal_ + maximumAbcNumberRows_;
     550  subProblem->internalStatus_ = newArray(reinterpret_cast< unsigned char * >(NULL),
     551    sizeArray + subProblem->maximumNumberTotal_);
     552  subProblem->abcLower_ = newArray(reinterpret_cast< double * >(NULL), sizeArray);
     553  subProblem->abcUpper_ = newArray(reinterpret_cast< double * >(NULL), sizeArray);
     554  subProblem->abcCost_ = newArray(reinterpret_cast< double * >(NULL), sizeArray + subProblem->maximumNumberTotal_);
     555  subProblem->abcDj_ = newArray(reinterpret_cast< double * >(NULL), sizeArray);
     556  subProblem->abcSolution_ = newArray(reinterpret_cast< double * >(NULL), sizeArray + subProblem->maximumNumberTotal_);
    564557  //fromExternal_ = newArray(reinterpret_cast<int *>(NULL),sizeArray);
    565558  //toExternal_ = newArray(reinterpret_cast<int *>(NULL),sizeArray);
    566   subProblem->scaleFromExternal_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
    567   subProblem->offset_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
    568   subProblem->abcPerturbation_ = newArray(reinterpret_cast<double *>(NULL),sizeArray);
    569   subProblem->abcPivotVariable_ = newArray(reinterpret_cast<int *>(NULL),maximumAbcNumberRows_);
    570   subProblem->setupPointers(maximumAbcNumberRows_,numberColumns);
     559  subProblem->scaleFromExternal_ = newArray(reinterpret_cast< double * >(NULL), sizeArray);
     560  subProblem->offset_ = newArray(reinterpret_cast< double * >(NULL), sizeArray);
     561  subProblem->abcPerturbation_ = newArray(reinterpret_cast< double * >(NULL), sizeArray);
     562  subProblem->abcPivotVariable_ = newArray(reinterpret_cast< int * >(NULL), maximumAbcNumberRows_);
     563  subProblem->setupPointers(maximumAbcNumberRows_, numberColumns);
    571564  // could use arrays - but for now be safe
    572   int * backward = new int [numberFullColumns+numberRows_];
    573   int * whichRow = backward+numberFullColumns;
    574   for (int i=0;i<numberFullColumns;i++)
    575     backward[i]=-1;
    576   for (int i=0;i<numberColumns;i++)
    577     backward[whichColumn[i]]=i+numberRows_;
    578   for (int i=0;i<numberRows_;i++) {
    579     whichRow[i]=i;
     565  int *backward = new int[numberFullColumns + numberRows_];
     566  int *whichRow = backward + numberFullColumns;
     567  for (int i = 0; i < numberFullColumns; i++)
     568    backward[i] = -1;
     569  for (int i = 0; i < numberColumns; i++)
     570    backward[whichColumn[i]] = i + numberRows_;
     571  for (int i = 0; i < numberRows_; i++) {
     572    whichRow[i] = i;
    580573    int iPivot = fullProblem->abcPivotVariable_[i];
    581     if (iPivot<numberRows_) {
    582       subProblem->abcPivotVariable_[i]=iPivot;
     574    if (iPivot < numberRows_) {
     575      subProblem->abcPivotVariable_[i] = iPivot;
    583576    } else {
    584       assert(backward[iPivot-numberRows_]>=0);
    585       subProblem->abcPivotVariable_[i]=backward[iPivot-numberRows_];
     577      assert(backward[iPivot - numberRows_] >= 0);
     578      subProblem->abcPivotVariable_[i] = backward[iPivot - numberRows_];
    586579    }
    587580    subProblem->internalStatus_[i] = fullProblem->internalStatus_[i];
     
    606599    subProblem->djBasic_[i] = fullProblem->djBasic_[i];
    607600  }
    608   for (int i=0;i<numberColumns;i++) {
    609     int k=whichColumn[i];
    610     subProblem->internalStatus_[maximumAbcNumberRows_+i] =
    611       fullProblem->internalStatus_[maximumAbcNumberRows_+k];
    612     subProblem->internalStatus_[maximumAbcNumberRows_+i] = fullProblem->internalStatus_[maximumAbcNumberRows_+k];
    613     subProblem->abcLower_[maximumAbcNumberRows_+i] = fullProblem->abcLower_[maximumAbcNumberRows_+k];
    614     subProblem->abcUpper_[maximumAbcNumberRows_+i] = fullProblem->abcUpper_[maximumAbcNumberRows_+k];
    615     subProblem->abcCost_[maximumAbcNumberRows_+i] = fullProblem->abcCost_[maximumAbcNumberRows_+k];
    616     subProblem->abcDj_[maximumAbcNumberRows_+i] = fullProblem->abcDj_[maximumAbcNumberRows_+k];
    617     subProblem->abcSolution_[maximumAbcNumberRows_+i] = fullProblem->abcSolution_[maximumAbcNumberRows_+k];
    618     subProblem->abcPerturbation_[maximumAbcNumberRows_+i] = fullProblem->abcPerturbation_[maximumAbcNumberRows_+k];
    619     subProblem->internalStatusSaved_[maximumAbcNumberRows_+i] = fullProblem->internalStatusSaved_[maximumAbcNumberRows_+k];
    620     subProblem->perturbationSaved_[maximumAbcNumberRows_+i] = fullProblem->perturbationSaved_[maximumAbcNumberRows_+k];
    621     subProblem->lowerSaved_[maximumAbcNumberRows_+i] = fullProblem->lowerSaved_[maximumAbcNumberRows_+k];
    622     subProblem->upperSaved_[maximumAbcNumberRows_+i] = fullProblem->upperSaved_[maximumAbcNumberRows_+k];
    623     subProblem->costSaved_[maximumAbcNumberRows_+i] = fullProblem->costSaved_[maximumAbcNumberRows_+k];
    624     subProblem->djSaved_[maximumAbcNumberRows_+i] = fullProblem->djSaved_[maximumAbcNumberRows_+k];
    625     subProblem->solutionSaved_[maximumAbcNumberRows_+i] = fullProblem->solutionSaved_[maximumAbcNumberRows_+k];
    626     subProblem->offset_[maximumAbcNumberRows_+i] = fullProblem->offset_[maximumAbcNumberRows_+k];
    627   }
    628   subProblem->abcNonLinearCost_=new AbcNonLinearCost(subProblem);
     601  for (int i = 0; i < numberColumns; i++) {
     602    int k = whichColumn[i];
     603    subProblem->internalStatus_[maximumAbcNumberRows_ + i] = fullProblem->internalStatus_[maximumAbcNumberRows_ + k];
     604    subProblem->internalStatus_[maximumAbcNumberRows_ + i] = fullProblem->internalStatus_[maximumAbcNumberRows_ + k];
     605    subProblem->abcLower_[maximumAbcNumberRows_ + i] = fullProblem->abcLower_[maximumAbcNumberRows_ + k];
     606    subProblem->abcUpper_[maximumAbcNumberRows_ + i] = fullProblem->abcUpper_[maximumAbcNumberRows_ + k];
     607    subProblem->abcCost_[maximumAbcNumberRows_ + i] = fullProblem->abcCost_[maximumAbcNumberRows_ + k];
     608    subProblem->abcDj_[maximumAbcNumberRows_ + i] = fullProblem->abcDj_[maximumAbcNumberRows_ + k];
     609    subProblem->abcSolution_[maximumAbcNumberRows_ + i] = fullProblem->abcSolution_[maximumAbcNumberRows_ + k];
     610    subProblem->abcPerturbation_[maximumAbcNumberRows_ + i] = fullProblem->abcPerturbation_[maximumAbcNumberRows_ + k];
     611    subProblem->internalStatusSaved_[maximumAbcNumberRows_ + i] = fullProblem->internalStatusSaved_[maximumAbcNumberRows_ + k];
     612    subProblem->perturbationSaved_[maximumAbcNumberRows_ + i] = fullProblem->perturbationSaved_[maximumAbcNumberRows_ + k];
     613    subProblem->lowerSaved_[maximumAbcNumberRows_ + i] = fullProblem->lowerSaved_[maximumAbcNumberRows_ + k];
     614    subProblem->upperSaved_[maximumAbcNumberRows_ + i] = fullProblem->upperSaved_[maximumAbcNumberRows_ + k];
     615    subProblem->costSaved_[maximumAbcNumberRows_ + i] = fullProblem->costSaved_[maximumAbcNumberRows_ + k];
     616    subProblem->djSaved_[maximumAbcNumberRows_ + i] = fullProblem->djSaved_[maximumAbcNumberRows_ + k];
     617    subProblem->solutionSaved_[maximumAbcNumberRows_ + i] = fullProblem->solutionSaved_[maximumAbcNumberRows_ + k];
     618    subProblem->offset_[maximumAbcNumberRows_ + i] = fullProblem->offset_[maximumAbcNumberRows_ + k];
     619  }
     620  subProblem->abcNonLinearCost_ = new AbcNonLinearCost(subProblem);
    629621  subProblem->abcNonLinearCost_->checkInfeasibilities(0.0);
    630   subProblem->abcMatrix_ = new AbcMatrix(*fullProblem->abcMatrix_,numberRows_,whichRow,
    631                                          numberColumns,whichColumn);
     622  subProblem->abcMatrix_ = new AbcMatrix(*fullProblem->abcMatrix_, numberRows_, whichRow,
     623    numberColumns, whichColumn);
    632624  subProblem->abcMatrix_->setModel(subProblem);
    633625  subProblem->abcMatrix_->rebalance();
    634626  subProblem->abcPrimalColumnPivot_ = new AbcPrimalColumnSteepest();
    635   subProblem->abcPrimalColumnPivot_->saveWeights(subProblem,2);
    636   delete [] backward;
     627  subProblem->abcPrimalColumnPivot_->saveWeights(subProblem, 2);
     628  delete[] backward;
    637629  // swap
    638630  return fullProblem;
    639631}
    640632// Restore stuff from sub problem (and delete sub problem)
    641 void
    642 AbcSimplex::restoreFromSubProblem(AbcSimplex * fullProblem, const int * whichColumn)
    643 {
    644   AbcSimplex * subProblem = this;
    645   for (int i=0;i<numberRows_;i++) {
     633void AbcSimplex::restoreFromSubProblem(AbcSimplex *fullProblem, const int *whichColumn)
     634{
     635  AbcSimplex *subProblem = this;
     636  for (int i = 0; i < numberRows_; i++) {
    646637    int iPivot = subProblem->abcPivotVariable_[i];
    647     if (iPivot<numberRows_) {
    648       fullProblem->abcPivotVariable_[i]=iPivot;
     638    if (iPivot < numberRows_) {
     639      fullProblem->abcPivotVariable_[i] = iPivot;
    649640    } else {
    650       fullProblem->abcPivotVariable_[i]=whichColumn[iPivot-numberRows_]+numberRows_;
     641      fullProblem->abcPivotVariable_[i] = whichColumn[iPivot - numberRows_] + numberRows_;
    651642    }
    652643    fullProblem->internalStatus_[i] = subProblem->internalStatus_[i];
     
    672663  }
    673664  int numberColumns = subProblem->numberColumns_;
    674   for (int i=0;i<numberColumns;i++) {
    675     int k=whichColumn[i];
    676     fullProblem->internalStatus_[maximumAbcNumberRows_+k] = subProblem->internalStatus_[maximumAbcNumberRows_+i];
    677     fullProblem->abcLower_[maximumAbcNumberRows_+k] = subProblem->abcLower_[maximumAbcNumberRows_+i];
    678     fullProblem->abcUpper_[maximumAbcNumberRows_+k] = subProblem->abcUpper_[maximumAbcNumberRows_+i];
    679     fullProblem->abcCost_[maximumAbcNumberRows_+k] = subProblem->abcCost_[maximumAbcNumberRows_+i];
    680     fullProblem->abcDj_[maximumAbcNumberRows_+k] = subProblem->abcDj_[maximumAbcNumberRows_+i];
    681     fullProblem->abcSolution_[maximumAbcNumberRows_+k] = subProblem->abcSolution_[maximumAbcNumberRows_+i];
    682     fullProblem->abcPerturbation_[maximumAbcNumberRows_+k] = subProblem->abcPerturbation_[maximumAbcNumberRows_+i];
    683     fullProblem->internalStatusSaved_[maximumAbcNumberRows_+k] = subProblem->internalStatusSaved_[maximumAbcNumberRows_+i];
    684     fullProblem->perturbationSaved_[maximumAbcNumberRows_+k] = subProblem->perturbationSaved_[maximumAbcNumberRows_+i];
    685     fullProblem->lowerSaved_[maximumAbcNumberRows_+k] = subProblem->lowerSaved_[maximumAbcNumberRows_+i];
    686     fullProblem->upperSaved_[maximumAbcNumberRows_+k] = subProblem->upperSaved_[maximumAbcNumberRows_+i];
    687     fullProblem->costSaved_[maximumAbcNumberRows_+k] = subProblem->costSaved_[maximumAbcNumberRows_+i];
    688     fullProblem->djSaved_[maximumAbcNumberRows_+k] = subProblem->djSaved_[maximumAbcNumberRows_+i];
    689     fullProblem->solutionSaved_[maximumAbcNumberRows_+k] = subProblem->solutionSaved_[maximumAbcNumberRows_+i];
    690     fullProblem->offset_[maximumAbcNumberRows_+k] = subProblem->offset_[maximumAbcNumberRows_+i];
    691   }
    692   delete [] subProblem->internalStatus_;
    693   delete [] subProblem->abcPerturbation_;
     665  for (int i = 0; i < numberColumns; i++) {
     666    int k = whichColumn[i];
     667    fullProblem->internalStatus_[maximumAbcNumberRows_ + k] = subProblem->internalStatus_[maximumAbcNumberRows_ + i];
     668    fullProblem->abcLower_[maximumAbcNumberRows_ + k] = subProblem->abcLower_[maximumAbcNumberRows_ + i];
     669    fullProblem->abcUpper_[maximumAbcNumberRows_ + k] = subProblem->abcUpper_[maximumAbcNumberRows_ + i];
     670    fullProblem->abcCost_[maximumAbcNumberRows_ + k] = subProblem->abcCost_[maximumAbcNumberRows_ + i];
     671    fullProblem->abcDj_[maximumAbcNumberRows_ + k] = subProblem->abcDj_[maximumAbcNumberRows_ + i];
     672    fullProblem->abcSolution_[maximumAbcNumberRows_ + k] = subProblem->abcSolution_[maximumAbcNumberRows_ + i];
     673    fullProblem->abcPerturbation_[maximumAbcNumberRows_ + k] = subProblem->abcPerturbation_[maximumAbcNumberRows_ + i];
     674    fullProblem->internalStatusSaved_[maximumAbcNumberRows_ + k] = subProblem->internalStatusSaved_[maximumAbcNumberRows_ + i];
     675    fullProblem->perturbationSaved_[maximumAbcNumberRows_ + k] = subProblem->perturbationSaved_[maximumAbcNumberRows_ + i];
     676    fullProblem->lowerSaved_[maximumAbcNumberRows_ + k] = subProblem->lowerSaved_[maximumAbcNumberRows_ + i];
     677    fullProblem->upperSaved_[maximumAbcNumberRows_ + k] = subProblem->upperSaved_[maximumAbcNumberRows_ + i];
     678    fullProblem->costSaved_[maximumAbcNumberRows_ + k] = subProblem->costSaved_[maximumAbcNumberRows_ + i];
     679    fullProblem->djSaved_[maximumAbcNumberRows_ + k] = subProblem->djSaved_[maximumAbcNumberRows_ + i];
     680    fullProblem->solutionSaved_[maximumAbcNumberRows_ + k] = subProblem->solutionSaved_[maximumAbcNumberRows_ + i];
     681    fullProblem->offset_[maximumAbcNumberRows_ + k] = subProblem->offset_[maximumAbcNumberRows_ + i];
     682  }
     683  delete[] subProblem->internalStatus_;
     684  delete[] subProblem->abcPerturbation_;
    694685  delete subProblem->abcMatrix_;
    695   delete [] subProblem->abcLower_;
    696   delete [] subProblem->abcUpper_;
    697   delete [] subProblem->abcCost_;
    698   delete [] subProblem->abcSolution_;
    699   delete [] subProblem->abcDj_;
     686  delete[] subProblem->abcLower_;
     687  delete[] subProblem->abcUpper_;
     688  delete[] subProblem->abcCost_;
     689  delete[] subProblem->abcSolution_;
     690  delete[] subProblem->abcDj_;
    700691  delete subProblem->abcPrimalColumnPivot_;
    701   delete [] subProblem->scaleFromExternal_;
    702   delete [] subProblem->offset_;
    703   delete [] subProblem->abcPivotVariable_;
    704   delete [] subProblem->reversePivotVariable_;
     692  delete[] subProblem->scaleFromExternal_;
     693  delete[] subProblem->offset_;
     694  delete[] subProblem->abcPivotVariable_;
     695  delete[] subProblem->reversePivotVariable_;
    705696  delete subProblem->abcNonLinearCost_;
    706697  numberColumns_ = fullProblem->numberColumns_;
    707   numberTotal_ =   fullProblem->numberTotal_;
    708   maximumNumberTotal_ =   fullProblem->maximumNumberTotal_;
    709   numberTotalWithoutFixed_ =   fullProblem->numberTotalWithoutFixed_;
    710   abcPrimalColumnPivot_ =   fullProblem->abcPrimalColumnPivot_;
    711   internalStatus_ =   fullProblem->internalStatus_;
    712   abcLower_ =   fullProblem->abcLower_;
    713   abcUpper_ =   fullProblem->abcUpper_;
    714   abcCost_ =   fullProblem->abcCost_;
    715   abcDj_ =   fullProblem->abcDj_;
    716   abcSolution_ =   fullProblem->abcSolution_;
    717   scaleFromExternal_ =   fullProblem->scaleFromExternal_;
    718   offset_ =   fullProblem->offset_;
    719   abcPerturbation_ =   fullProblem->abcPerturbation_;
    720   abcPivotVariable_ =   fullProblem->abcPivotVariable_;
    721   abcMatrix_ =   fullProblem->abcMatrix_;
    722   setupPointers(maximumAbcNumberRows_,numberColumns);
     698  numberTotal_ = fullProblem->numberTotal_;
     699  maximumNumberTotal_ = fullProblem->maximumNumberTotal_;
     700  numberTotalWithoutFixed_ = fullProblem->numberTotalWithoutFixed_;
     701  abcPrimalColumnPivot_ = fullProblem->abcPrimalColumnPivot_;
     702  internalStatus_ = fullProblem->internalStatus_;
     703  abcLower_ = fullProblem->abcLower_;
     704  abcUpper_ = fullProblem->abcUpper_;
     705  abcCost_ = fullProblem->abcCost_;
     706  abcDj_ = fullProblem->abcDj_;
     707  abcSolution_ = fullProblem->abcSolution_;
     708  scaleFromExternal_ = fullProblem->scaleFromExternal_;
     709  offset_ = fullProblem->offset_;
     710  abcPerturbation_ = fullProblem->abcPerturbation_;
     711  abcPivotVariable_ = fullProblem->abcPivotVariable_;
     712  abcMatrix_ = fullProblem->abcMatrix_;
     713  setupPointers(maximumAbcNumberRows_, numberColumns);
    723714  // ? redo nonlinearcost
    724715  abcNonLinearCost_ = fullProblem->abcNonLinearCost_;
    725716  abcNonLinearCost_->refresh();
    726   delete [] reinterpret_cast<char *>(fullProblem);
     717  delete[] reinterpret_cast< char * >(fullProblem);
    727718}
    728719#endif
     
    732723   type 3 - as 2 but crash
    733724*/
    734 void
    735 AbcSimplex::setupDualValuesPass(const double * fakeDuals,
    736                                 const double * fakePrimals,
    737                                 int type)
     725void AbcSimplex::setupDualValuesPass(const double *fakeDuals,
     726  const double *fakePrimals,
     727  int type)
    738728{
    739729  // allslack basis
    740   memset(internalStatus_,6,numberRows_);
     730  memset(internalStatus_, 6, numberRows_);
    741731  // temp
    742   if (type==1) {
    743     bool allEqual=true;
    744     for (int i=0;i<numberRows_;i++) {
    745       if (rowUpper_[i]>rowLower_[i]) {
    746         allEqual=false;
    747         break;
     732  if (type == 1) {
     733    bool allEqual = true;
     734    for (int i = 0; i < numberRows_; i++) {
     735      if (rowUpper_[i] > rowLower_[i]) {
     736        allEqual = false;
     737        break;
    748738      }
    749739    }
    750740    if (allEqual) {
    751741      // just modify costs
    752       transposeTimes(-1.0,fakeDuals,objective());
     742      transposeTimes(-1.0, fakeDuals, objective());
    753743      return;
    754744    }
    755745  }
    756746  // compute unscaled djs
    757   CoinAbcMemcpy(djSaved_+maximumAbcNumberRows_,objective(),numberColumns_);
    758   matrix_->transposeTimes(-1.0,fakeDuals,djSaved_+maximumAbcNumberRows_);
     747  CoinAbcMemcpy(djSaved_ + maximumAbcNumberRows_, objective(), numberColumns_);
     748  matrix_->transposeTimes(-1.0, fakeDuals, djSaved_ + maximumAbcNumberRows_);
    759749  // save fake solution
    760   assert (solution_);
     750  assert(solution_);
    761751  //solution_ = new double[numberTotal_];
    762   CoinAbcMemset0(solution_,numberRows_);
    763   CoinAbcMemcpy(solution_+maximumAbcNumberRows_,fakePrimals,numberColumns_);
     752  CoinAbcMemset0(solution_, numberRows_);
     753  CoinAbcMemcpy(solution_ + maximumAbcNumberRows_, fakePrimals, numberColumns_);
    764754  // adjust
    765   for (int iSequence=maximumAbcNumberRows_;iSequence<numberTotal_;iSequence++)
    766     solution_[iSequence]-=offset_[iSequence];
    767   matrix_->times(-1.0,solution_+maximumAbcNumberRows_,solution_);
     755  for (int iSequence = maximumAbcNumberRows_; iSequence < numberTotal_; iSequence++)
     756    solution_[iSequence] -= offset_[iSequence];
     757  matrix_->times(-1.0, solution_ + maximumAbcNumberRows_, solution_);
    768758  double direction = optimizationDirection_;
    769   const double *  COIN_RESTRICT rowScale=scaleFromExternal_;
    770   const double *  COIN_RESTRICT inverseRowScale=scaleToExternal_;
    771   for (int iRow=0;iRow<numberRows_;iRow++) {
    772     djSaved_[iRow]=direction*fakeDuals[iRow]*inverseRowScale[iRow];
     759  const double *COIN_RESTRICT rowScale = scaleFromExternal_;
     760  const double *COIN_RESTRICT inverseRowScale = scaleToExternal_;
     761  for (int iRow = 0; iRow < numberRows_; iRow++) {
     762    djSaved_[iRow] = direction * fakeDuals[iRow] * inverseRowScale[iRow];
    773763    solution_[iRow] *= rowScale[iRow];
    774764  }
    775   const double *  COIN_RESTRICT columnScale=scaleToExternal_;
    776   for (int iColumn=maximumAbcNumberRows_;iColumn<numberTotal_;iColumn++)
    777     djSaved_[iColumn]*=direction*columnScale[iColumn];
     765  const double *COIN_RESTRICT columnScale = scaleToExternal_;
     766  for (int iColumn = maximumAbcNumberRows_; iColumn < numberTotal_; iColumn++)
     767    djSaved_[iColumn] *= direction * columnScale[iColumn];
    778768  // Set solution values
    779   const double * lower = abcLower_+maximumAbcNumberRows_;
    780   const double * upper = abcUpper_+maximumAbcNumberRows_;
    781   double * solution = abcSolution_+maximumAbcNumberRows_;
    782   const double * djs = djSaved_+maximumAbcNumberRows_;
    783   const double * inverseColumnScale=scaleFromExternal_+maximumAbcNumberRows_;
    784   for (int iColumn=0;iColumn<numberColumns_;iColumn++) {
    785     double thisValue=fakePrimals[iColumn];
    786     double thisLower=columnLower_[iColumn];
    787     double thisUpper=columnUpper_[iColumn];
    788     double thisDj=djs[iColumn];
    789     solution_[iColumn+maximumAbcNumberRows_]=solution_[iColumn+maximumAbcNumberRows_]*
    790       inverseColumnScale[iColumn];
    791     if (thisLower>-1.0e30) {
    792       if (thisUpper<1.0e30) {
    793         double gapUp=thisUpper-thisValue;
    794         double gapDown=thisValue-thisLower;
    795         bool goUp;
    796         if (gapUp>gapDown&&thisDj>-dualTolerance_) {
    797           goUp=false;
    798         } else if (gapUp<gapDown&&thisDj<dualTolerance_) {
    799           goUp=true;
    800         } else {
    801           // wild guess
    802           double badUp;
    803           double badDown;
    804           if (gapUp>gapDown) {
    805             badUp=gapUp*dualTolerance_;
    806             badDown=-gapDown*thisDj;
    807           } else {
    808             badUp=gapUp*thisDj;
    809             badDown=gapDown*dualTolerance_;
    810           }
    811           goUp=badDown>badUp;
    812         }
    813         if (goUp) {
    814           solution[iColumn]=upper[iColumn];
    815           setInternalStatus(iColumn+maximumAbcNumberRows_,atUpperBound);
    816           setStatus(iColumn,ClpSimplex::atUpperBound);
    817         } else {
    818           solution[iColumn]=lower[iColumn];
    819           setInternalStatus(iColumn+maximumAbcNumberRows_,atLowerBound);
    820           setStatus(iColumn,ClpSimplex::atLowerBound);
    821         }
     769  const double *lower = abcLower_ + maximumAbcNumberRows_;
     770  const double *upper = abcUpper_ + maximumAbcNumberRows_;
     771  double *solution = abcSolution_ + maximumAbcNumberRows_;
     772  const double *djs = djSaved_ + maximumAbcNumberRows_;
     773  const double *inverseColumnScale = scaleFromExternal_ + maximumAbcNumberRows_;
     774  for (int iColumn = 0; iColumn < numberColumns_; iColumn++) {
     775    double thisValue = fakePrimals[iColumn];
     776    double thisLower = columnLower_[iColumn];
     777    double thisUpper = columnUpper_[iColumn];
     778    double thisDj = djs[iColumn];
     779    solution_[iColumn + maximumAbcNumberRows_] = solution_[iColumn + maximumAbcNumberRows_] * inverseColumnScale[iColumn];
     780    if (thisLower > -1.0e30) {
     781      if (thisUpper < 1.0e30) {
     782        double gapUp = thisUpper - thisValue;
     783        double gapDown = thisValue - thisLower;
     784        bool goUp;
     785        if (gapUp > gapDown && thisDj > -dualTolerance_) {
     786          goUp = false;
     787        } else if (gapUp < gapDown && thisDj < dualTolerance_) {
     788          goUp = true;
     789        } else {
     790          // wild guess
     791          double badUp;
     792          double badDown;
     793          if (gapUp > gapDown) {
     794            badUp = gapUp * dualTolerance_;
     795            badDown = -gapDown * thisDj;
     796          } else {
     797            badUp = gapUp * thisDj;
     798            badDown = gapDown * dualTolerance_;
     799          }
     800          goUp = badDown > badUp;
     801        }
     802        if (goUp) {
     803          solution[iColumn] = upper[iColumn];
     804          setInternalStatus(iColumn + maximumAbcNumberRows_, atUpperBound);
     805          setStatus(iColumn, ClpSimplex::atUpperBound);
     806        } else {
     807          solution[iColumn] = lower[iColumn];
     808          setInternalStatus(iColumn + maximumAbcNumberRows_, atLowerBound);
     809          setStatus(iColumn, ClpSimplex::atLowerBound);
     810        }
    822811      } else {
    823         solution[iColumn]=lower[iColumn];
    824         setInternalStatus(iColumn+maximumAbcNumberRows_,atLowerBound);
    825         setStatus(iColumn,ClpSimplex::atLowerBound);
    826       }
    827     } else if (thisUpper<1.0e30) {
    828       solution[iColumn]=upper[iColumn];
    829       setInternalStatus(iColumn+maximumAbcNumberRows_,atUpperBound);
    830       setStatus(iColumn,ClpSimplex::atUpperBound);
     812        solution[iColumn] = lower[iColumn];
     813        setInternalStatus(iColumn + maximumAbcNumberRows_, atLowerBound);
     814        setStatus(iColumn, ClpSimplex::atLowerBound);
     815      }
     816    } else if (thisUpper < 1.0e30) {
     817      solution[iColumn] = upper[iColumn];
     818      setInternalStatus(iColumn + maximumAbcNumberRows_, atUpperBound);
     819      setStatus(iColumn, ClpSimplex::atUpperBound);
    831820    } else {
    832821      // free
    833       solution[iColumn]=thisValue*inverseColumnScale[iColumn];
    834       setInternalStatus(iColumn+maximumAbcNumberRows_,isFree);
    835       setStatus(iColumn,ClpSimplex::isFree);
     822      solution[iColumn] = thisValue * inverseColumnScale[iColumn];
     823      setInternalStatus(iColumn + maximumAbcNumberRows_, isFree);
     824      setStatus(iColumn, ClpSimplex::isFree);
    836825    }
    837826  }
     
    842831  case 2:
    843832    stateOfProblem_ |= VALUES_PASS2;
    844     delete [] solution_;
    845     solution_=NULL;
     833    delete[] solution_;
     834    solution_ = NULL;
    846835    break;
    847836  case 3:
     
    851840}
    852841//#############################################################################
    853 int
    854 AbcSimplex::computePrimals(CoinIndexedVector * arrayVector, CoinIndexedVector * previousVector)
    855 {
    856  
     842int AbcSimplex::computePrimals(CoinIndexedVector *arrayVector, CoinIndexedVector *previousVector)
     843{
     844
    857845  arrayVector->clear();
    858846  previousVector->clear();
    859847  // accumulate non basic stuff
    860   double *  COIN_RESTRICT array = arrayVector->denseVector();
    861   CoinAbcScatterZeroTo(abcSolution_,abcPivotVariable_,numberRows_);
     848  double *COIN_RESTRICT array = arrayVector->denseVector();
     849  CoinAbcScatterZeroTo(abcSolution_, abcPivotVariable_, numberRows_);
    862850  abcMatrix_->timesIncludingSlacks(-1.0, abcSolution_, array);
    863851#if 0
     
    870858  // Ftran adjusted RHS and iterate to improve accuracy
    871859  double lastError = COIN_DBL_MAX;
    872   CoinIndexedVector * thisVector = arrayVector;
    873   CoinIndexedVector * lastVector = previousVector;
     860  CoinIndexedVector *thisVector = arrayVector;
     861  CoinIndexedVector *lastVector = previousVector;
    874862  //if (arrayVector->getNumElements())
    875863#if 0
     
    903891  exit(0);
    904892#endif
    905   int numberRefinements=0;
     893  int numberRefinements = 0;
    906894  for (int iRefine = 0; iRefine < numberRefinements_ + 1; iRefine++) {
    907895    int numberIn = thisVector->getNumElements();
    908     const int *  COIN_RESTRICT indexIn = thisVector->getIndices();
    909     const double *  COIN_RESTRICT arrayIn = thisVector->denseVector();
    910     CoinAbcScatterToList(arrayIn,abcSolution_,indexIn,abcPivotVariable_,numberIn);
     896    const int *COIN_RESTRICT indexIn = thisVector->getIndices();
     897    const double *COIN_RESTRICT arrayIn = thisVector->denseVector();
     898    CoinAbcScatterToList(arrayIn, abcSolution_, indexIn, abcPivotVariable_, numberIn);
    911899    // check Ax == b  (for all)
    912900    abcMatrix_->timesIncludingSlacks(-1.0, abcSolution_, solutionBasic_);
     
    920908#endif
    921909    double multiplier = 131072.0;
    922     largestPrimalError_ = CoinAbcMaximumAbsElementAndScale(solutionBasic_,multiplier,numberRows_);
    923     double maxValue=0.0;
    924     for (int i=0;i<numberRows_;i++) {
    925       double value=fabs(solutionBasic_[i]);
    926       if (value>maxValue) {
     910    largestPrimalError_ = CoinAbcMaximumAbsElementAndScale(solutionBasic_, multiplier, numberRows_);
     911    double maxValue = 0.0;
     912    for (int i = 0; i < numberRows_; i++) {
     913      double value = fabs(solutionBasic_[i]);
     914      if (value > maxValue) {
    927915#if 0
    928916        if (xxxxxx==0)
     
    934922    if (largestPrimalError_ >= lastError) {
    935923      // restore
    936       CoinIndexedVector * temp = thisVector;
     924      CoinIndexedVector *temp = thisVector;
    937925      thisVector = lastVector;
    938926      lastVector = temp;
     
    944932      numberRefinements++;
    945933      // save this
    946       CoinIndexedVector * temp = thisVector;
     934      CoinIndexedVector *temp = thisVector;
    947935      thisVector = lastVector;
    948936      lastVector = temp;
    949       int *  COIN_RESTRICT indexOut = thisVector->getIndices();
     937      int *COIN_RESTRICT indexOut = thisVector->getIndices();
    950938      int number = 0;
    951939      array = thisVector->denseVector();
    952940      thisVector->clear();
    953941      for (int iRow = 0; iRow < numberRows_; iRow++) {
    954         double value = solutionBasic_[iRow];
    955         if (value) {
    956           array[iRow] = value;
    957           indexOut[number++] = iRow;
    958           solutionBasic_[iRow] = 0.0;
    959         }
     942        double value = solutionBasic_[iRow];
     943        if (value) {
     944          array[iRow] = value;
     945          indexOut[number++] = iRow;
     946          solutionBasic_[iRow] = 0.0;
     947        }
    960948      }
    961949      thisVector->setNumElements(number);
    962950      lastError = largestPrimalError_;
    963951      abcFactorization_->updateFullColumn(*thisVector);
    964       double * previous = lastVector->denseVector();
     952      double *previous = lastVector->denseVector();
    965953      number = 0;
    966       multiplier=1.0/multiplier;
     954      multiplier = 1.0 / multiplier;
    967955      for (int iRow = 0; iRow < numberRows_; iRow++) {
    968         double value = previous[iRow] + multiplier * array[iRow];
    969         if (value) {
    970           array[iRow] = value;
    971           indexOut[number++] = iRow;
    972         } else {
    973           array[iRow] = 0.0;
    974         }
     956        double value = previous[iRow] + multiplier * array[iRow];
     957        if (value) {
     958          array[iRow] = value;
     959          indexOut[number++] = iRow;
     960        } else {
     961          array[iRow] = 0.0;
     962        }
    975963      }
    976964      thisVector->setNumElements(number);
     
    979967    }
    980968  }
    981  
     969
    982970  // solution as accurate as we are going to get
    983971  //if (!goodSolution) {
    984   CoinAbcMemcpy(solutionBasic_,thisVector->denseVector(),numberRows_);
    985   CoinAbcScatterTo(solutionBasic_,abcSolution_,abcPivotVariable_,numberRows_);
     972  CoinAbcMemcpy(solutionBasic_, thisVector->denseVector(), numberRows_);
     973  CoinAbcScatterTo(solutionBasic_, abcSolution_, abcPivotVariable_, numberRows_);
    986974  arrayVector->clear();
    987975  previousVector->clear();
     
    989977}
    990978// Moves basic stuff to basic area
    991 void
    992 AbcSimplex::moveToBasic(int which)
    993 {
    994   if ((which&1)!=0)
    995     CoinAbcGatherFrom(abcSolution_,solutionBasic_,abcPivotVariable_,numberRows_);
    996   if ((which&2)!=0)
    997     CoinAbcGatherFrom(abcCost_,costBasic_,abcPivotVariable_,numberRows_);
    998   if ((which&4)!=0)
    999     CoinAbcGatherFrom(abcLower_,lowerBasic_,abcPivotVariable_,numberRows_);
    1000   if ((which&8)!=0)
    1001     CoinAbcGatherFrom(abcUpper_,upperBasic_,abcPivotVariable_,numberRows_);
     979void AbcSimplex::moveToBasic(int which)
     980{
     981  if ((which & 1) != 0)
     982    CoinAbcGatherFrom(abcSolution_, solutionBasic_, abcPivotVariable_, numberRows_);
     983  if ((which & 2) != 0)
     984    CoinAbcGatherFrom(abcCost_, costBasic_, abcPivotVariable_, numberRows_);
     985  if ((which & 4) != 0)
     986    CoinAbcGatherFrom(abcLower_, lowerBasic_, abcPivotVariable_, numberRows_);
     987  if ((which & 8) != 0)
     988    CoinAbcGatherFrom(abcUpper_, upperBasic_, abcPivotVariable_, numberRows_);
    1002989}
    1003990// now dual side
    1004 int
    1005 AbcSimplex::computeDuals(double * givenDjs, CoinIndexedVector * arrayVector, CoinIndexedVector * previousVector)
    1006 {
    1007   double *  COIN_RESTRICT array = arrayVector->denseVector();
    1008   int *  COIN_RESTRICT index = arrayVector->getIndices();
     991int AbcSimplex::computeDuals(double *givenDjs, CoinIndexedVector *arrayVector, CoinIndexedVector *previousVector)
     992{
     993  double *COIN_RESTRICT array = arrayVector->denseVector();
     994  int *COIN_RESTRICT index = arrayVector->getIndices();
    1009995  int number = 0;
    1010996  if (!givenDjs) {
     
    1012998      double value = costBasic_[iRow];
    1013999      if (value) {
    1014         array[iRow] = value;
    1015         index[number++] = iRow;
     1000        array[iRow] = value;
     1001        index[number++] = iRow;
    10161002      }
    10171003    }
     
    10221008      // make sure zero if done
    10231009      if (!pivoted(iPivot))
    1024         givenDjs[iPivot] = 0.0;
     1010        givenDjs[iPivot] = 0.0;
    10251011      double value = abcCost_[iPivot] - givenDjs[iPivot];
    10261012      if (value) {
    1027         array[iRow] = value;
    1028         index[number++] = iRow;
     1013        array[iRow] = value;
     1014        index[number++] = iRow;
    10291015      }
    10301016    }
     
    10331019  // Btran basic costs and get as accurate as possible
    10341020  double lastError = COIN_DBL_MAX;
    1035   CoinIndexedVector * thisVector = arrayVector;
    1036   CoinIndexedVector * lastVector = previousVector;
     1021  CoinIndexedVector *thisVector = arrayVector;
     1022  CoinIndexedVector *lastVector = previousVector;
    10371023  abcFactorization_->updateFullColumnTranspose(*thisVector);
    1038  
    1039   int numberRefinements=0;
    1040   for (int iRefine = 0; iRefine < numberRefinements_+1; iRefine++) {
     1024
     1025  int numberRefinements = 0;
     1026  for (int iRefine = 0; iRefine < numberRefinements_ + 1; iRefine++) {
    10411027    // check basic reduced costs zero
    10421028    // put reduced cost of basic into djBasic_
    1043     CoinAbcMemcpy(djBasic_,costBasic_,numberRows_);
    1044     abcMatrix_->transposeTimesBasic(-1.0,thisVector->denseVector(),djBasic_);
    1045     largestDualError_ = CoinAbcMaximumAbsElement(djBasic_,numberRows_);
     1029    CoinAbcMemcpy(djBasic_, costBasic_, numberRows_);
     1030    abcMatrix_->transposeTimesBasic(-1.0, thisVector->denseVector(), djBasic_);
     1031    largestDualError_ = CoinAbcMaximumAbsElement(djBasic_, numberRows_);
    10461032    if (largestDualError_ >= lastError) {
    10471033      // restore
    1048       CoinIndexedVector * temp = thisVector;
     1034      CoinIndexedVector *temp = thisVector;
    10491035      thisVector = lastVector;
    10501036      lastVector = temp;
     
    10521038    }
    10531039    if (iRefine < numberRefinements_ && largestDualError_ > 1.0e-10
    1054         && !givenDjs) {
     1040      && !givenDjs) {
    10551041      numberRefinements++;
    10561042      // try and make better
    10571043      // save this
    1058       CoinIndexedVector * temp = thisVector;
     1044      CoinIndexedVector *temp = thisVector;
    10591045      thisVector = lastVector;
    10601046      lastVector = temp;
     
    10621048      double multiplier = 131072.0;
    10631049      //array=djBasic_*multiplier
    1064       CoinAbcMultiplyAdd(djBasic_,numberRows_,multiplier,array,0.0);
     1050      CoinAbcMultiplyAdd(djBasic_, numberRows_, multiplier, array, 0.0);
    10651051      lastError = largestDualError_;
    1066       abcFactorization_->updateFullColumnTranspose( *thisVector);
     1052      abcFactorization_->updateFullColumnTranspose(*thisVector);
    10671053#if ABC_DEBUG
    10681054      thisVector->checkClean();
    10691055#endif
    10701056      multiplier = 1.0 / multiplier;
    1071       double *  COIN_RESTRICT previous = lastVector->denseVector();
     1057      double *COIN_RESTRICT previous = lastVector->denseVector();
    10721058      // array = array*multiplier+previous
    1073       CoinAbcMultiplyAdd(previous,numberRows_,1.0,array,multiplier);
     1059      CoinAbcMultiplyAdd(previous, numberRows_, 1.0, array, multiplier);
    10741060    } else {
    10751061      break;
     
    10771063  }
    10781064  // now look at dual solution
    1079   CoinAbcMemcpy(dual_,thisVector->denseVector(),numberRows_);
    1080   CoinAbcMemset0(thisVector->denseVector(),numberRows_);
     1065  CoinAbcMemcpy(dual_, thisVector->denseVector(), numberRows_);
     1066  CoinAbcMemset0(thisVector->denseVector(), numberRows_);
    10811067  thisVector->setNumElements(0);
    10821068  if (numberRefinements) {
    1083     CoinAbcMemset0(lastVector->denseVector(),numberRows_);
     1069    CoinAbcMemset0(lastVector->denseVector(), numberRows_);
    10841070    lastVector->setNumElements(0);
    10851071  }
    1086   CoinAbcMemcpy(abcDj_,abcCost_,numberTotal_);
    1087   abcMatrix_->transposeTimesNonBasic(-1.0, dual_,abcDj_);
     1072  CoinAbcMemcpy(abcDj_, abcCost_, numberTotal_);
     1073  abcMatrix_->transposeTimesNonBasic(-1.0, dual_, abcDj_);
    10881074  // If necessary - override results
    10891075  if (givenDjs) {
     
    11081094   Special case is numberRows_+1 -> all slack basis.
    11091095*/
    1110 int AbcSimplex::internalFactorize ( int solveType)
    1111 {
    1112   assert (status_);
    1113  
     1096int AbcSimplex::internalFactorize(int solveType)
     1097{
     1098  assert(status_);
     1099
    11141100  bool valuesPass = false;
    11151101  if (solveType >= 10) {
     
    11571143      if (abcSolution_[iSequence]<abcLower_[iSequence]) {
    11581144        numberOutside++;
    1159 #if ABC_NORMAL_DEBUG>1
     1145#if ABC_NORMAL_DEBUG > 1
    11601146        if (handler_->logLevel()==63)
    11611147          printf("%c%d below by %g\n",rowcol[isColumn(iSequence)],sequenceWithin(iSequence),
     
    11751161      if (abcSolution_[iSequence]>abcUpper_[iSequence]) {
    11761162        numberOutside++;
    1177 #if ABC_NORMAL_DEBUG>0
     1163#if ABC_NORMAL_DEBUG > 0
    11781164        if (handler_->logLevel()==63)
    11791165          printf("%c%d above by %g\n",rowcol[isColumn(iSequence)],sequenceWithin(iSequence),
     
    11931179    }
    11941180  }
    1195 #if ABC_NORMAL_DEBUG>0
     1181#if ABC_NORMAL_DEBUG > 0
    11961182  if (numberInside+numberOutside)
    11971183    printf("%d outside summing to %g (%d large), %d inside summing to %g (%d large)\n",
     
    12021188  // *** replace below by cleanStatus
    12031189  for (int iSequence = 0; iSequence < numberTotal_; iSequence++) {
    1204     AbcSimplex::Status status=getInternalStatus(iSequence);
    1205     if (status!= basic&&status!=isFixed&&abcUpper_[iSequence] == abcLower_[iSequence])
    1206       setInternalStatus(iSequence,isFixed);
    1207   }
    1208   if (numberIterations_==baseIteration_&&!valuesPass) {
     1190    AbcSimplex::Status status = getInternalStatus(iSequence);
     1191    if (status != basic && status != isFixed && abcUpper_[iSequence] == abcLower_[iSequence])
     1192      setInternalStatus(iSequence, isFixed);
     1193  }
     1194  if (numberIterations_ == baseIteration_ && !valuesPass) {
    12091195    double largeValue = this->largeValue();
    1210     double * COIN_RESTRICT solution = abcSolution_;
     1196    double *COIN_RESTRICT solution = abcSolution_;
    12111197    for (int iSequence = 0; iSequence < numberTotal_; iSequence++) {
    1212       AbcSimplex::Status status=getInternalStatus(iSequence);
    1213       if (status== superBasic) {
    1214         double lower = abcLower_[iSequence];
    1215         double upper = abcUpper_[iSequence];
    1216         double value = solution[iSequence];
    1217         AbcSimplex::Status thisStatus=isFree;
    1218         if (lower > -largeValue || upper < largeValue) {
    1219           if (lower!=upper) {
    1220             if (fabs(value - lower) < fabs(value - upper)) {
    1221               thisStatus=AbcSimplex::atLowerBound;
    1222               solution[iSequence] = lower;
    1223             } else {
    1224               thisStatus= AbcSimplex::atUpperBound;
    1225               solution[iSequence] = upper;
    1226             }
    1227           } else {
    1228             thisStatus= AbcSimplex::isFixed;
    1229             solution[iSequence] = upper;
    1230           }
    1231           setInternalStatus(iSequence,thisStatus);
    1232         }
     1198      AbcSimplex::Status status = getInternalStatus(iSequence);
     1199      if (status == superBasic) {
     1200        double lower = abcLower_[iSequence];
     1201        double upper = abcUpper_[iSequence];
     1202        double value = solution[iSequence];
     1203        AbcSimplex::Status thisStatus = isFree;
     1204        if (lower > -largeValue || upper < largeValue) {
     1205          if (lower != upper) {
     1206            if (fabs(value - lower) < fabs(value - upper)) {
     1207              thisStatus = AbcSimplex::atLowerBound;
     1208              solution[iSequence] = lower;
     1209            } else {
     1210              thisStatus = AbcSimplex::atUpperBound;
     1211              solution[iSequence] = upper;
     1212            }
     1213          } else {
     1214            thisStatus = AbcSimplex::isFixed;
     1215            solution[iSequence] = upper;
     1216          }
     1217          setInternalStatus(iSequence, thisStatus);
     1218        }
    12331219      }
    12341220    }
     
    12451231    for (int iRow = 0; iRow < numberRows_; iRow++) {
    12461232      if (getInternalStatus(iRow) == basic)
    1247         numberSlacks++;
     1233        numberSlacks++;
    12481234    }
    12491235    status = CoinMax(numberSlacks - numberRows_, 0);
    12501236    if (status)
    1251       printf("%d singularities\n",status);
     1237      printf("%d singularities\n", status);
    12521238    // special case if all slack
    12531239    if (numberSlacks == numberRows_) {
     
    12621248}
    12631249// Make sure no superbasic etc
    1264 void
    1265 AbcSimplex::cleanStatus(bool valuesPass)
     1250void AbcSimplex::cleanStatus(bool valuesPass)
    12661251{
    12671252  for (int iSequence = 0; iSequence < numberTotal_; iSequence++) {
    1268     AbcSimplex::Status status=getInternalStatus(iSequence);
    1269     if (status!= basic&&status!=isFixed&&abcUpper_[iSequence] == abcLower_[iSequence])
    1270       setInternalStatus(iSequence,isFixed);
    1271   }
    1272   if (numberIterations_==baseIteration_&&!valuesPass) {
     1253    AbcSimplex::Status status = getInternalStatus(iSequence);
     1254    if (status != basic && status != isFixed && abcUpper_[iSequence] == abcLower_[iSequence])
     1255      setInternalStatus(iSequence, isFixed);
     1256  }
     1257  if (numberIterations_ == baseIteration_ && !valuesPass) {
    12731258    double largeValue = this->largeValue();
    1274     double * COIN_RESTRICT solution = abcSolution_;
     1259    double *COIN_RESTRICT solution = abcSolution_;
    12751260    for (int iSequence = 0; iSequence < numberTotal_; iSequence++) {
    1276       AbcSimplex::Status status=getInternalStatus(iSequence);
    1277       if (status== superBasic) {
    1278         double lower = abcLower_[iSequence];
    1279         double upper = abcUpper_[iSequence];
    1280         double value = solution[iSequence];
    1281         AbcSimplex::Status thisStatus=isFree;
    1282         if (lower > -largeValue || upper < largeValue) {
    1283           if (lower!=upper) {
    1284             if (fabs(value - lower) < fabs(value - upper)) {
    1285               thisStatus=AbcSimplex::atLowerBound;
    1286               solution[iSequence] = lower;
    1287             } else {
    1288               thisStatus= AbcSimplex::atUpperBound;
    1289               solution[iSequence] = upper;
    1290             }
    1291           } else {
    1292             thisStatus= AbcSimplex::isFixed;
    1293             solution[iSequence] = upper;
    1294           }
    1295           setInternalStatus(iSequence,thisStatus);
    1296         }
     1261      AbcSimplex::Status status = getInternalStatus(iSequence);
     1262      if (status == superBasic) {
     1263        double lower = abcLower_[iSequence];
     1264        double upper = abcUpper_[iSequence];
     1265        double value = solution[iSequence];
     1266        AbcSimplex::Status thisStatus = isFree;
     1267        if (lower > -largeValue || upper < largeValue) {
     1268          if (lower != upper) {
     1269            if (fabs(value - lower) < fabs(value - upper)) {
     1270              thisStatus = AbcSimplex::atLowerBound;
     1271              solution[iSequence] = lower;
     1272            } else {
     1273              thisStatus = AbcSimplex::atUpperBound;
     1274              solution[iSequence] = upper;
     1275            }
     1276          } else {
     1277            thisStatus = AbcSimplex::isFixed;
     1278            solution[iSequence] = upper;
     1279          }
     1280          setInternalStatus(iSequence, thisStatus);
     1281        }
    12971282      }
    12981283    }
     
    13001285}
    13011286// Sets objectiveValue_ from rawObjectiveValue_
    1302 void
    1303 AbcSimplex::setClpSimplexObjectiveValue()
    1304 {
    1305   objectiveValue_ = rawObjectiveValue_/(objectiveScale_ * rhsScale_);
     1287void AbcSimplex::setClpSimplexObjectiveValue()
     1288{
     1289  objectiveValue_ = rawObjectiveValue_ / (objectiveScale_ * rhsScale_);
    13061290  objectiveValue_ += objectiveOffset_;
    13071291}
     
    13101294  Can also decide to re-factorize
    13111295*/
    1312 int
    1313 AbcSimplex::housekeeping()
     1296int AbcSimplex::housekeeping()
    13141297{
    13151298#define DELAYED_UPDATE
    13161299#ifdef DELAYED_UPDATE
    1317   if (algorithm_<0) {
     1300  if (algorithm_ < 0) {
    13181301    // modify dualout
    13191302    dualOut_ /= alpha_;
     
    13411324      valueOut_ = upperOut_;
    13421325    }
    1343 #if ABC_NORMAL_DEBUG>3
     1326#if ABC_NORMAL_DEBUG > 3
    13441327    if (rawObjectiveValue_ < oldobj - 1.0e-5 && (handler_->logLevel() & 16))
    13451328      printf("obj backwards %g %g\n", rawObjectiveValue_, oldobj);
     
    13711354    if (getInternalStatus(sequenceIn_) == isFree) {
    13721355      handler_->message(CLP_SIMPLEX_FREEIN, messages_)
    1373         << sequenceIn_
    1374         << CoinMessageEol;
     1356        << sequenceIn_
     1357        << CoinMessageEol;
    13751358    }
    13761359  }
    13771360  // change of incoming
    1378   char rowcol[] = {'R', 'C'};
     1361  char rowcol[] = { 'R', 'C' };
    13791362  if (abcUpper_[sequenceIn_] > 1.0e20 && abcLower_[sequenceIn_] < -1.0e20)
    13801363    progressFlag_ |= 2; // making real progress
     
    13881371      double value = fabs(alpha_);
    13891372      if (value > 1.0)
    1390         alphaAccuracy_ *= value;
     1373        alphaAccuracy_ *= value;
    13911374      else
    1392         alphaAccuracy_ /= value;
     1375        alphaAccuracy_ /= value;
    13931376    }
    13941377    setInternalStatus(sequenceIn_, basic);
     
    13971380      // Redo using value
    13981381      if (fabs(valueOut_ - abcLower_[sequenceOut_]) < fabs(valueOut_ - abcUpper_[sequenceOut_])) {
    1399         // going to lower
    1400         setInternalStatus(sequenceOut_, atLowerBound);
     1382        // going to lower
     1383        setInternalStatus(sequenceOut_, atLowerBound);
    14011384      } else {
    1402         // going to upper
    1403         setInternalStatus(sequenceOut_, atUpperBound);
     1385        // going to upper
     1386        setInternalStatus(sequenceOut_, atUpperBound);
    14041387      }
    14051388    } else {
     
    14101393    abcSolution_[sequenceOut_] = valueOut_;
    14111394#endif
    1412 #if PARTITION_ROW_COPY==1
     1395#if PARTITION_ROW_COPY == 1
    14131396    // move in row copy
    1414     abcMatrix_->inOutUseful(sequenceIn_,sequenceOut_);
     1397    abcMatrix_->inOutUseful(sequenceIn_, sequenceOut_);
    14151398#endif
    14161399  } else {
     
    14521435  int out = sequenceOut_;
    14531436  int cycle = abcProgress_.cycle(in, out,
    1454                               directionIn_, directionOut_);
    1455   if (cycle > 0 ) {
    1456 #if ABC_NORMAL_DEBUG>0
     1437    directionIn_, directionOut_);
     1438  if (cycle > 0) {
     1439#if ABC_NORMAL_DEBUG > 0
    14571440    if (handler_->logLevel() >= 63)
    14581441      printf("Cycle of %d\n", cycle);
     
    14611444    abcProgress_.startCheck();
    14621445    double random = randomNumberGenerator_.randomDouble();
    1463     int extra = static_cast<int> (9.999 * random);
    1464     int off[] = {1, 1, 1, 1, 2, 2, 2, 3, 3, 4};
     1446    int extra = static_cast< int >(9.999 * random);
     1447    int off[] = { 1, 1, 1, 1, 2, 2, 2, 3, 3, 4 };
    14651448    if (abcFactorization_->pivots() > cycle) {
    14661449      forceFactorization_ = CoinMax(1, cycle - off[extra]);
     
    14681451      // need to reject something
    14691452      int iSequence;
    1470       if (algorithm_<0) {
    1471         iSequence = sequenceIn_;
     1453      if (algorithm_ < 0) {
     1454        iSequence = sequenceIn_;
    14721455      } else {
    1473         /* should be better if don't reject incoming
     1456        /* should be better if don't reject incoming
    14741457         as it is in basis */
    1475         iSequence = sequenceOut_;
    1476         // so can't happen immediately again
    1477         sequenceOut_=-1;
     1458        iSequence = sequenceOut_;
     1459        // so can't happen immediately again
     1460        sequenceOut_ = -1;
    14781461      }
    14791462      char x = isColumn(iSequence) ? 'C' : 'R';
    14801463      if (handler_->logLevel() >= 63)
    1481         handler_->message(CLP_SIMPLEX_FLAG, messages_)
    1482           << x << sequenceWithin(iSequence)
    1483           << CoinMessageEol;
     1464        handler_->message(CLP_SIMPLEX_FLAG, messages_)
     1465          << x << sequenceWithin(iSequence)
     1466          << CoinMessageEol;
    14841467      setFlagged(iSequence);
    14851468      //printf("flagging %d\n",iSequence);
     
    14871470    return 1;
    14881471  }
    1489   int invertNow=0;
     1472  int invertNow = 0;
    14901473  // only time to re-factorize if one before real time
    14911474  // this is so user won't be surprised that maximumPivots has exact meaning
    14921475  int numberPivots = abcFactorization_->pivots();
    1493   if (algorithm_<0)
     1476  if (algorithm_ < 0)
    14941477    numberPivots++; // allow for update not done
    14951478  int maximumPivots = abcFactorization_->maximumPivots();
    14961479  int numberDense = 0; //abcFactorization_->numberDense();
    1497   bool dontInvert = ((specialOptions_ & 16384) != 0 && numberIterations_ * 3 >
    1498                      2 * maximumIterations());
    1499   if (numberPivots == maximumPivots ||
    1500       maximumPivots < 2) {
     1480  bool dontInvert = ((specialOptions_ & 16384) != 0 && numberIterations_ * 3 > 2 * maximumIterations());
     1481  if (numberPivots == maximumPivots || maximumPivots < 2) {
    15011482    // If dense then increase
    15021483    if (maximumPivots > 100 && numberDense > 1.5 * maximumPivots && false) {
     
    15041485    }
    15051486    //printf("ZZ maxpivots %d its %d\n",numberPivots,maximumPivots);
    1506 #if CLP_FACTORIZATION_NEW_TIMING>1
     1487#if CLP_FACTORIZATION_NEW_TIMING > 1
    15071488    abcFactorization_->statsRefactor('M');
    15081489#endif
    15091490    return 1;
    15101491  } else if ((abcFactorization_->timeToRefactorize() && !dontInvert)
    1511              ||invertNow) {
     1492    || invertNow) {
    15121493    //printf("ZZ time invertNow %s its %d\n",invertNow ? "yes":"no",numberPivots);
    1513 #if CLP_FACTORIZATION_NEW_TIMING>1
     1494#if CLP_FACTORIZATION_NEW_TIMING > 1
    15141495    abcFactorization_->statsRefactor('T');
    15151496#endif
     
    15171498  } else if (forceFactorization_ > 0 &&
    15181499#ifndef DELAYED_UPDATE
    1519              abcFactorization_->pivots()
     1500    abcFactorization_->pivots()
    15201501#else
    1521              abcFactorization_->pivots()+1
    1522 #endif 
    1523              >= forceFactorization_) {
     1502    abcFactorization_->pivots() + 1
     1503#endif
     1504      >= forceFactorization_) {
    15241505    // relax
    15251506    forceFactorization_ = (3 + 5 * forceFactorization_) / 4;
    15261507    if (forceFactorization_ > abcFactorization_->maximumPivots())
    15271508      forceFactorization_ = -1; //off
    1528     //printf("ZZ forceFactor %d its %d\n",forceFactorization_,numberPivots);
    1529 #if CLP_FACTORIZATION_NEW_TIMING>1
     1509      //printf("ZZ forceFactor %d its %d\n",forceFactorization_,numberPivots);
     1510#if CLP_FACTORIZATION_NEW_TIMING > 1
    15301511    abcFactorization_->statsRefactor('F');
    15311512#endif
     
    15351516    int numberTooManyIterations = numberIterations_ - 10 * (numberRows_ + (numberColumns_ >> 2));
    15361517    double random = randomNumberGenerator_.randomDouble();
    1537     int window = numberTooManyIterations%5000;
    1538     if (window<2*maximumPivots)
    1539       random = 0.2*random+0.8; // randomly re-factorize but not too soon
     1518    int window = numberTooManyIterations % 5000;
     1519    if (window < 2 * maximumPivots)
     1520      random = 0.2 * random + 0.8; // randomly re-factorize but not too soon
    15401521    else
    1541       random=1.0; // switch off if not in window of opportunity
     1522      random = 1.0; // switch off if not in window of opportunity
    15421523    int maxNumber = (forceFactorization_ < 0) ? maximumPivots : CoinMin(forceFactorization_, maximumPivots);
    15431524    if (abcFactorization_->pivots() >= random * maxNumber) {
    15441525      //printf("ZZ cycling a %d\n",numberPivots);
    15451526      return 1;
    1546     } else if (numberIterations_ > 1000000 + 10 * (numberRows_ + (numberColumns_ >> 2)) &&
    1547                numberIterations_ < 1000010 + 10 * (numberRows_ + (numberColumns_ >> 2))) {
     1527    } else if (numberIterations_ > 1000000 + 10 * (numberRows_ + (numberColumns_ >> 2)) && numberIterations_ < 1000010 + 10 * (numberRows_ + (numberColumns_ >> 2))) {
    15481528      //printf("ZZ cycling b %d\n",numberPivots);
    15491529      return 1;
     
    15571537  }
    15581538}
    1559 // Swaps primal stuff
    1560 void
    1561 AbcSimplex::swapPrimalStuff()
    1562 {
    1563   if (sequenceOut_<0)
     1539// Swaps primal stuff
     1540void AbcSimplex::swapPrimalStuff()
     1541{
     1542  if (sequenceOut_ < 0)
    15641543    return;
    1565   assert (sequenceIn_>=0);
     1544  assert(sequenceIn_ >= 0);
    15661545  abcSolution_[sequenceOut_] = valueOut_;
    15671546  abcSolution_[sequenceIn_] = valueIn_;
    1568   solutionBasic_[pivotRow_]=valueIn_;
    1569   if (algorithm_<0) {
     1547  solutionBasic_[pivotRow_] = valueIn_;
     1548  if (algorithm_ < 0) {
    15701549    // and set bounds correctly
    1571     static_cast<AbcSimplexDual *> (this)->originalBound(sequenceIn_);
    1572     static_cast<AbcSimplexDual *> (this)->changeBound(sequenceOut_);
     1550    static_cast< AbcSimplexDual * >(this)->originalBound(sequenceIn_);
     1551    static_cast< AbcSimplexDual * >(this)->changeBound(sequenceOut_);
    15731552  } else {
    1574 #if ABC_NORMAL_DEBUG>2
    1575     if (handler_->logLevel()==63)
     1553#if ABC_NORMAL_DEBUG > 2
     1554    if (handler_->logLevel() == 63)
    15761555      printf("Code swapPrimalStuff for primal\n");
    15771556#endif
    15781557  }
    1579   if (pivotRow_>=0) { // may be flip in primal
    1580     lowerBasic_[pivotRow_]=abcLower_[sequenceIn_];
    1581     upperBasic_[pivotRow_]=abcUpper_[sequenceIn_];
    1582     costBasic_[pivotRow_]=abcCost_[sequenceIn_];
     1558  if (pivotRow_ >= 0) { // may be flip in primal
     1559    lowerBasic_[pivotRow_] = abcLower_[sequenceIn_];
     1560    upperBasic_[pivotRow_] = abcUpper_[sequenceIn_];
     1561    costBasic_[pivotRow_] = abcCost_[sequenceIn_];
    15831562    abcPivotVariable_[pivotRow_] = sequenceIn_;
    15841563  }
    15851564}
    15861565// Swaps dual stuff
    1587 void
    1588 AbcSimplex::swapDualStuff(int lastSequenceOut,int lastDirectionOut)
     1566void AbcSimplex::swapDualStuff(int lastSequenceOut, int lastDirectionOut)
    15891567{
    15901568  // outgoing
    15911569  // set dj to zero unless values pass
    1592   if (lastSequenceOut>=0) {
    1593     if ((stateOfProblem_&VALUES_PASS)==0) {
     1570  if (lastSequenceOut >= 0) {
     1571    if ((stateOfProblem_ & VALUES_PASS) == 0) {
    15941572      if (lastDirectionOut > 0) {
    1595         abcDj_[lastSequenceOut] = theta_;
     1573        abcDj_[lastSequenceOut] = theta_;
    15961574      } else {
    1597         abcDj_[lastSequenceOut] = -theta_;
     1575        abcDj_[lastSequenceOut] = -theta_;
    15981576      }
    15991577    } else {
    16001578      if (lastDirectionOut > 0) {
    1601         abcDj_[lastSequenceOut] -= theta_;
     1579        abcDj_[lastSequenceOut] -= theta_;
    16021580      } else {
    1603         abcDj_[lastSequenceOut] += theta_;
    1604       }
    1605     }
    1606   }
    1607   if (sequenceIn_>=0) {
    1608     abcDj_[sequenceIn_]=0.0;
     1581        abcDj_[lastSequenceOut] += theta_;
     1582      }
     1583    }
     1584  }
     1585  if (sequenceIn_ >= 0) {
     1586    abcDj_[sequenceIn_] = 0.0;
    16091587    //costBasic_[pivotRow_]=abcCost_[sequenceIn_];
    16101588  }
    16111589}
    1612 static void solveMany(int number,ClpSimplex ** simplex)
    1613 {
    1614   for (int i=0;i<number-1;i++)
     1590static void solveMany(int number, ClpSimplex **simplex)
     1591{
     1592  for (int i = 0; i < number - 1; i++)
    16151593    cilk_spawn simplex[i]->dual(0);
    1616   simplex[number-1]->dual(0);
     1594  simplex[number - 1]->dual(0);
    16171595  cilk_sync;
    16181596}
    1619 void
    1620 AbcSimplex::crash (int type)
     1597void AbcSimplex::crash(int type)
    16211598{
    16221599  int i;
    1623   for (i=0;i<numberRows_;i++) {
    1624     if (getInternalStatus(i)!=basic)
     1600  for (i = 0; i < numberRows_; i++) {
     1601    if (getInternalStatus(i) != basic)
    16251602      break;
    16261603  }
    1627   if (i<numberRows_)
     1604  if (i < numberRows_)
    16281605    return;
    16291606  // all slack
    1630   if (type==3) {
     1607  if (type == 3) {
    16311608    // decomposition crash
    16321609    if (!abcMatrix_->gotRowCopy())
    16331610      abcMatrix_->createRowCopy();
    16341611    //const double * element = abcMatrix_->getPackedMatrix()->getElements();
    1635     const CoinBigIndex * columnStart = abcMatrix_->getPackedMatrix()->getVectorStarts();
    1636     const int * row = abcMatrix_->getPackedMatrix()->getIndices();
     1612    const CoinBigIndex *columnStart = abcMatrix_->getPackedMatrix()->getVectorStarts();
     1613    const int *row = abcMatrix_->getPackedMatrix()->getIndices();
    16371614    //const double * elementByRow = abcMatrix_->rowElements();
    1638     const CoinBigIndex * rowStart = abcMatrix_->rowStart();
    1639     const CoinBigIndex * rowEnd = abcMatrix_->rowEnd();
    1640     const int * column = abcMatrix_->rowColumns();
    1641     int * blockStart = usefulArray_[0].getIndices();
    1642     int * columnBlock = blockStart+numberRows_;
    1643     int * nextColumn = usefulArray_[1].getIndices();
    1644     int * blockCount = nextColumn+numberColumns_;
    1645     int direction[2]={-1,1};
    1646     int bestBreak=-1;
    1647     double bestValue=0.0;
    1648     int iPass=0;
    1649     int halfway=(numberRows_+1)/2;
    1650     int firstMaster=-1;
    1651     int lastMaster=-2;
    1652     int numberBlocks=0;
    1653     int largestRows=0;
    1654     int largestColumns=0;
    1655     int numberEmpty=0;
    1656     int numberMaster=0;
    1657     int numberEmptyColumns=0;
    1658     int numberMasterColumns=0;
    1659     while (iPass<2) {
    1660       int increment=direction[iPass];
    1661       int start= increment>0 ? 0 : numberRows_-1;
    1662       int stop=increment>0 ? numberRows_ : -1;
    1663       numberBlocks=0;
    1664       int thisBestBreak=-1;
    1665       double thisBestValue=COIN_DBL_MAX;
    1666       int numberRowsDone=0;
    1667       int numberMarkedColumns=0;
    1668       int maximumBlockSize=0;
    1669       for (int i=0;i<numberRows_;i++) {
    1670         blockStart[i]=-1;
    1671         blockCount[i]=0;
    1672       }
    1673       for (int i=0;i<numberColumns_;i++) {
    1674         columnBlock[i]=-1;
    1675         nextColumn[i]=-1;
    1676       }
    1677       for (int iRow=start;iRow!=stop;iRow+=increment) {
    1678         int iBlock = -1;
    1679         for (CoinBigIndex j=rowStart[iRow];j<rowEnd[iRow];j++) {
    1680           int iColumn=column[j]-maximumAbcNumberRows_;
    1681           int whichColumnBlock=columnBlock[iColumn];
    1682           if (whichColumnBlock>=0) {
    1683             // column marked
    1684             if (iBlock<0) {
    1685               // put row in that block
    1686               iBlock=whichColumnBlock;
    1687             } else if (iBlock!=whichColumnBlock) {
    1688               // merge
    1689               blockCount[iBlock]+=blockCount[whichColumnBlock];
    1690               blockCount[whichColumnBlock]=0;
    1691               int jColumn=blockStart[whichColumnBlock];
     1615    const CoinBigIndex *rowStart = abcMatrix_->rowStart();
     1616    const CoinBigIndex *rowEnd = abcMatrix_->rowEnd();
     1617    const int *column = abcMatrix_->rowColumns();
     1618    int *blockStart = usefulArray_[0].getIndices();
     1619    int *columnBlock = blockStart + numberRows_;
     1620    int *nextColumn = usefulArray_[1].getIndices();
     1621    int *blockCount = nextColumn + numberColumns_;
     1622    int direction[2] = { -1, 1 };
     1623    int bestBreak = -1;
     1624    double bestValue = 0.0;
     1625    int iPass = 0;
     1626    int halfway = (numberRows_ + 1) / 2;
     1627    int firstMaster = -1;
     1628    int lastMaster = -2;
     1629    int numberBlocks = 0;
     1630    int largestRows = 0;
     1631    int largestColumns = 0;
     1632    int numberEmpty = 0;
     1633    int numberMaster = 0;
     1634    int numberEmptyColumns = 0;
     1635    int numberMasterColumns = 0;
     1636    while (iPass < 2) {
     1637      int increment = direction[iPass];
     1638      int start = increment > 0 ? 0 : numberRows_ - 1;
     1639      int stop = increment > 0 ? numberRows_ : -1;
     1640      numberBlocks = 0;
     1641      int thisBestBreak = -1;
     1642      double thisBestValue = COIN_DBL_MAX;
     1643      int numberRowsDone = 0;
     1644      int numberMarkedColumns = 0;
     1645      int maximumBlockSize = 0;
     1646      for (int i = 0; i < numberRows_; i++) {
     1647        blockStart[i] = -1;
     1648        blockCount[i] = 0;
     1649      }
     1650      for (int i = 0; i < numberColumns_; i++) {
     1651        columnBlock[i] = -1;
     1652        nextColumn[i] = -1;
     1653      }
     1654      for (int iRow = start; iRow != stop; iRow += increment) {
     1655        int iBlock = -1;
     1656        for (CoinBigIndex j = rowStart[iRow]; j < rowEnd[iRow]; j++) {
     1657          int iColumn = column[j] - maximumAbcNumberRows_;
     1658          int whichColumnBlock = columnBlock[iColumn];
     1659          if (whichColumnBlock >= 0) {
     1660            // column marked
     1661            if (iBlock < 0) {
     1662              // put row in that block
     1663              iBlock = whichColumnBlock;
     1664            } else if (iBlock != whichColumnBlock) {
     1665              // merge
     1666              blockCount[iBlock] += blockCount[whichColumnBlock];
     1667              blockCount[whichColumnBlock] = 0;
     1668              int jColumn = blockStart[whichColumnBlock];
    16921669#ifndef NDEBUG
    1693               int iiColumn=iColumn;
    1694 #endif
    1695               while (jColumn>=0) {
    1696                 assert (columnBlock[jColumn]==whichColumnBlock);
    1697                 columnBlock[jColumn]=iBlock;
     1670              int iiColumn = iColumn;
     1671#endif
     1672              while (jColumn >= 0) {
     1673                assert(columnBlock[jColumn] == whichColumnBlock);
     1674                columnBlock[jColumn] = iBlock;
    16981675#ifndef NDEBUG
    1699                 if (jColumn==iiColumn)
    1700                   iiColumn=-1;
    1701 #endif
    1702                 iColumn=jColumn;
    1703                 jColumn=nextColumn[jColumn];
    1704               }
     1676                if (jColumn == iiColumn)
     1677                  iiColumn = -1;
     1678#endif
     1679                iColumn = jColumn;
     1680                jColumn = nextColumn[jColumn];
     1681              }
    17051682#ifndef NDEBUG
    1706               assert (iiColumn==-1);
    1707 #endif
    1708               nextColumn[iColumn]=blockStart[iBlock];
    1709               blockStart[iBlock]=blockStart[whichColumnBlock];
    1710               blockStart[whichColumnBlock]=-1;
    1711             }
    1712           }
    1713         }
    1714         int n=numberMarkedColumns;
    1715         if (iBlock<0) {
    1716           //new block
    1717           if (rowEnd[iRow]>rowStart[iRow]) {
    1718             numberBlocks++;
    1719             iBlock=numberBlocks;
    1720             int jColumn=column[rowStart[iRow]]-maximumAbcNumberRows_;
    1721             columnBlock[jColumn]=iBlock;
    1722             blockStart[iBlock]=jColumn;
    1723             numberMarkedColumns++;
    1724             for (CoinBigIndex j=rowStart[iRow]+1;j<rowEnd[iRow];j++) {
    1725               int iColumn=column[j]-maximumAbcNumberRows_;
    1726               columnBlock[iColumn]=iBlock;
    1727               numberMarkedColumns++;
    1728               nextColumn[jColumn]=iColumn;
    1729               jColumn=iColumn;
    1730             }
    1731             blockCount[iBlock]=numberMarkedColumns-n;
    1732           } else {
    1733             // empty
    1734           }
    1735         } else {
    1736           // put in existing block
    1737           int jColumn=blockStart[iBlock];
    1738           for (CoinBigIndex j=rowStart[iRow];j<rowEnd[iRow];j++) {
    1739             int iColumn=column[j]-maximumAbcNumberRows_;
    1740             assert (columnBlock[iColumn]<0||columnBlock[iColumn]==iBlock);
    1741             if (columnBlock[iColumn]<0) {
    1742               columnBlock[iColumn]=iBlock;
    1743               numberMarkedColumns++;
    1744               nextColumn[iColumn]=jColumn;
    1745               jColumn=iColumn;
    1746             }
    1747           }
    1748           blockStart[iBlock]=jColumn;
    1749           blockCount[iBlock]+=numberMarkedColumns-n;
    1750         }
    1751         if (iBlock>=0)
    1752           maximumBlockSize=CoinMax(maximumBlockSize,blockCount[iBlock]);
    1753         numberRowsDone++;
    1754         if (thisBestValue*numberRowsDone > maximumBlockSize&&numberRowsDone>halfway) {
    1755           thisBestBreak=iRow;
    1756           thisBestValue=static_cast<double>(maximumBlockSize)/
    1757             static_cast<double>(numberRowsDone);
    1758         }
    1759       }
    1760       if (thisBestBreak==stop)
    1761         thisBestValue=COIN_DBL_MAX;
     1683              assert(iiColumn == -1);
     1684#endif
     1685              nextColumn[iColumn] = blockStart[iBlock];
     1686              blockStart[iBlock] = blockStart[whichColumnBlock];
     1687              blockStart[whichColumnBlock] = -1;
     1688            }
     1689          }
     1690        }
     1691        int n = numberMarkedColumns;
     1692        if (iBlock < 0) {
     1693          //new block
     1694          if (rowEnd[iRow] > rowStart[iRow]) {
     1695            numberBlocks++;
     1696            iBlock = numberBlocks;
     1697            int jColumn = column[rowStart[iRow]] - maximumAbcNumberRows_;
     1698            columnBlock[jColumn] = iBlock;
     1699            blockStart[iBlock] = jColumn;
     1700            numberMarkedColumns++;
     1701            for (CoinBigIndex j = rowStart[iRow] + 1; j < rowEnd[iRow]; j++) {
     1702              int iColumn = column[j] - maximumAbcNumberRows_;
     1703              columnBlock[iColumn] = iBlock;
     1704              numberMarkedColumns++;
     1705              nextColumn[jColumn] = iColumn;
     1706              jColumn = iColumn;
     1707            }
     1708            blockCount[iBlock] = numberMarkedColumns - n;
     1709          } else {
     1710            // empty
     1711          }
     1712        } else {
     1713          // put in existing block
     1714          int jColumn = blockStart[iBlock];
     1715          for (CoinBigIndex j = rowStart[iRow]; j < rowEnd[iRow]; j++) {
     1716            int iColumn = column[j] - maximumAbcNumberRows_;
     1717            assert(columnBlock[iColumn] < 0 || columnBlock[iColumn] == iBlock);
     1718            if (columnBlock[iColumn] < 0) {
     1719              columnBlock[iColumn] = iBlock;
     1720              numberMarkedColumns++;
     1721              nextColumn[iColumn] = jColumn;
     1722              jColumn = iColumn;
     1723            }
     1724          }
     1725          blockStart[iBlock] = jColumn;
     1726          blockCount[iBlock] += numberMarkedColumns - n;
     1727        }
     1728        if (iBlock >= 0)
     1729          maximumBlockSize = CoinMax(maximumBlockSize, blockCount[iBlock]);
     1730        numberRowsDone++;
     1731        if (thisBestValue * numberRowsDone > maximumBlockSize && numberRowsDone > halfway) {
     1732          thisBestBreak = iRow;
     1733          thisBestValue = static_cast< double >(maximumBlockSize) / static_cast< double >(numberRowsDone);
     1734        }
     1735      }
     1736      if (thisBestBreak == stop)
     1737        thisBestValue = COIN_DBL_MAX;
    17621738      iPass++;
    1763       if (iPass==1) {
    1764         bestBreak=thisBestBreak;
    1765         bestValue=thisBestValue;
     1739      if (iPass == 1) {
     1740        bestBreak = thisBestBreak;
     1741        bestValue = thisBestValue;
    17661742      } else {
    1767         if (bestValue<thisBestValue) {
    1768           firstMaster=0;
    1769           lastMaster=bestBreak;
    1770         } else {
    1771           firstMaster=thisBestBreak; // ? +1
    1772           lastMaster=numberRows_;
    1773         }
    1774       }
    1775     }
    1776     bool useful=false;
    1777     if (firstMaster<lastMaster) {
    1778       for (int i=0;i<numberRows_;i++)
    1779         blockStart[i]=-1;
    1780       for (int i=firstMaster;i<lastMaster;i++)
    1781         blockStart[i]=-2;
    1782       for (int i=0;i<numberColumns_;i++)
    1783         columnBlock[i]=-1;
    1784       int firstRow=0;
    1785       numberBlocks=-1;
     1743        if (bestValue < thisBestValue) {
     1744          firstMaster = 0;
     1745          lastMaster = bestBreak;
     1746        } else {
     1747          firstMaster = thisBestBreak; // ? +1
     1748          lastMaster = numberRows_;
     1749        }
     1750      }
     1751    }
     1752    bool useful = false;
     1753    if (firstMaster < lastMaster) {
     1754      for (int i = 0; i < numberRows_; i++)
     1755        blockStart[i] = -1;
     1756      for (int i = firstMaster; i < lastMaster; i++)
     1757        blockStart[i] = -2;
     1758      for (int i = 0; i < numberColumns_; i++)
     1759        columnBlock[i] = -1;
     1760      int firstRow = 0;
     1761      numberBlocks = -1;
    17861762      while (true) {
    1787         for (;firstRow<numberRows_;firstRow++) {
    1788           if (blockStart[firstRow]==-1)
    1789             break;
    1790         }
    1791         if (firstRow==numberRows_)
    1792           break;
    1793         int nRows=0;
    1794         numberBlocks++;
    1795         int numberStack=1;
    1796         blockCount[0] = firstRow;
    1797         while (numberStack) {
    1798           int iRow=blockCount[--numberStack];
    1799           for (CoinBigIndex j=rowStart[iRow];j<rowEnd[iRow];j++) {
    1800             int iColumn=column[j]-maximumAbcNumberRows_;
    1801             int iBlock=columnBlock[iColumn];
    1802             if (iBlock<0) {
    1803               columnBlock[iColumn]=numberBlocks;
    1804               for (CoinBigIndex k=columnStart[iColumn];
    1805                    k<columnStart[iColumn+1];k++) {
    1806                 int jRow=row[k];
    1807                 int rowBlock=blockStart[jRow];
    1808                 if (rowBlock==-1) {
    1809                   nRows++;
    1810                   blockStart[jRow]=numberBlocks;
    1811                   blockCount[numberStack++]=jRow;
    1812                 }
    1813               }
    1814             }
    1815           }
    1816         }
    1817         if (!nRows) {
    1818           // empty!!
    1819           numberBlocks--;
    1820         }
    1821         firstRow++;
    1822       }
    1823       // adjust 
     1763        for (; firstRow < numberRows_; firstRow++) {
     1764          if (blockStart[firstRow] == -1)
     1765            break;
     1766        }
     1767        if (firstRow == numberRows_)
     1768          break;
     1769        int nRows = 0;
     1770        numberBlocks++;
     1771        int numberStack = 1;
     1772        blockCount[0] = firstRow;
     1773        while (numberStack) {
     1774          int iRow = blockCount[--numberStack];
     1775          for (CoinBigIndex j = rowStart[iRow]; j < rowEnd[iRow]; j++) {
     1776            int iColumn = column[j] - maximumAbcNumberRows_;
     1777            int iBlock = columnBlock[iColumn];
     1778            if (iBlock < 0) {
     1779              columnBlock[iColumn] = numberBlocks;
     1780              for (CoinBigIndex k = columnStart[iColumn];
     1781                   k < columnStart[iColumn + 1]; k++) {
     1782                int jRow = row[k];
     1783                int rowBlock = blockStart[jRow];
     1784                if (rowBlock == -1) {
     1785                  nRows++;
     1786                  blockStart[jRow] = numberBlocks;
     1787                  blockCount[numberStack++] = jRow;
     1788                }
     1789              }
     1790            }
     1791          }
     1792        }
     1793        if (!nRows) {
     1794          // empty!!
     1795          numberBlocks--;
     1796        }
     1797        firstRow++;
     1798      }
     1799      // adjust
    18241800      numberBlocks++;
    1825       for (int i=0;i<numberBlocks;i++) {
    1826         blockCount[i]=0;
    1827         nextColumn[i]=0;
     1801      for (int i = 0; i < numberBlocks; i++) {
     1802        blockCount[i] = 0;
     1803        nextColumn[i] = 0;
    18281804      }
    18291805      for (int iRow = 0; iRow < numberRows_; iRow++) {
    1830         int iBlock=blockStart[iRow];
    1831         if (iBlock>=0) {
    1832           blockCount[iBlock]++;
    1833         } else {
    1834           if (iBlock==-2)
    1835             numberMaster++;
    1836           else
    1837             numberEmpty++;
    1838         }
     1806        int iBlock = blockStart[iRow];
     1807        if (iBlock >= 0) {
     1808          blockCount[iBlock]++;
     1809        } else {
     1810          if (iBlock == -2)
     1811            numberMaster++;
     1812          else
     1813            numberEmpty++;
     1814        }
    18391815      }
    18401816      for (int iColumn = 0; iColumn < numberColumns_; iColumn++) {
    1841         int iBlock=columnBlock[iColumn];
    1842         if (iBlock>=0) {
    1843           nextColumn[iBlock]++;
    1844         } else {
    1845           if (columnStart[iColumn+1]>columnStart[iColumn])
    1846             numberMasterColumns++;
    1847           else
    1848             numberEmptyColumns++;
    1849         }
    1850       }
    1851       for (int i=0;i<numberBlocks;i++) {
    1852         if (blockCount[i]+nextColumn[i]>largestRows+largestColumns) {
    1853           largestRows=blockCount[i];
    1854           largestColumns=nextColumn[i];
    1855         }
    1856       }
    1857       useful=true;
    1858       if (numberMaster>halfway||largestRows*3>numberRows_)
    1859         useful=false;
     1817        int iBlock = columnBlock[iColumn];
     1818        if (iBlock >= 0) {
     1819          nextColumn[iBlock]++;
     1820        } else {
     1821          if (columnStart[iColumn + 1] > columnStart[iColumn])
     1822            numberMasterColumns++;
     1823          else
     1824            numberEmptyColumns++;
     1825        }
     1826      }
     1827      for (int i = 0; i < numberBlocks; i++) {
     1828        if (blockCount[i] + nextColumn[i] > largestRows + largestColumns) {
     1829          largestRows = blockCount[i];
     1830          largestColumns = nextColumn[i];
     1831        }
     1832      }
     1833      useful = true;
     1834      if (numberMaster > halfway || largestRows * 3 > numberRows_)
     1835        useful = false;
    18601836    }
    18611837    if (useful) {
    1862 #if ABC_NORMAL_DEBUG>0
    1863       if (logLevel()>=2)
    1864         printf("%d master rows %d <= < %d\n",lastMaster-firstMaster,
    1865                firstMaster,lastMaster);
     1838#if ABC_NORMAL_DEBUG > 0
     1839      if (logLevel() >= 2)
     1840        printf("%d master rows %d <= < %d\n", lastMaster - firstMaster,
     1841          firstMaster, lastMaster);
    18661842      printf("%s %d blocks (largest %d,%d), %d master rows (%d empty) out of %d, %d master columns (%d empty) out of %d\n",
    1867              useful ? "**Useful" : "NoGood",
    1868              numberBlocks,largestRows,largestColumns,numberMaster,numberEmpty,numberRows_,
    1869              numberMasterColumns,numberEmptyColumns,numberColumns_);
    1870       if (logLevel()>=2) {
    1871         for (int i=0;i<numberBlocks;i++)
    1872           printf("Block %d has %d rows and %d columns\n",
    1873                i,blockCount[i],nextColumn[i]);
     1843        useful ? "**Useful" : "NoGood",
     1844        numberBlocks, largestRows, largestColumns, numberMaster, numberEmpty, numberRows_,
     1845        numberMasterColumns, numberEmptyColumns, numberColumns_);
     1846      if (logLevel() >= 2) {
     1847        for (int i = 0; i < numberBlocks; i++)
     1848          printf("Block %d has %d rows and %d columns\n",
     1849            i, blockCount[i], nextColumn[i]);
    18741850      }
    18751851#endif
    18761852#define NUMBER_DW_BLOCKS 20
    1877       int minSize1=(numberRows_-numberMaster+NUMBER_DW_BLOCKS-1)/NUMBER_DW_BLOCKS;
    1878       int minSize2=(numberRows_-numberMaster+2*NUMBER_DW_BLOCKS-1)/(2*NUMBER_DW_BLOCKS);
    1879       int * backRow = usefulArray_[1].getIndices();
     1853      int minSize1 = (numberRows_ - numberMaster + NUMBER_DW_BLOCKS - 1) / NUMBER_DW_BLOCKS;
     1854      int minSize2 = (numberRows_ - numberMaster + 2 * NUMBER_DW_BLOCKS - 1) / (2 * NUMBER_DW_BLOCKS);
     1855      int *backRow = usefulArray_[1].getIndices();
    18801856      // first sort
    1881       for (int i=0;i<numberBlocks;i++) {
    1882         backRow[i]=-(3*blockCount[i]+0*nextColumn[i]);
    1883         nextColumn[i]=i;
    1884       }
    1885       CoinSort_2(backRow,backRow+numberBlocks,nextColumn);
     1857      for (int i = 0; i < numberBlocks; i++) {
     1858        backRow[i] = -(3 * blockCount[i] + 0 * nextColumn[i]);
     1859        nextColumn[i] = i;
     1860      }
     1861      CoinSort_2(backRow, backRow + numberBlocks, nextColumn);
    18861862      // keep if >minSize2 or sum >minSize1;
    1887       int n=0;
    1888       for (int i=0;i<numberBlocks;i++) {
    1889         int originalBlock=nextColumn[i];
    1890         if (blockCount[originalBlock]<minSize2)
    1891           break;
    1892         n++;
    1893       }
    1894       int size=minSize1;
    1895       for (int i=n;i<numberBlocks;i++) {
    1896         int originalBlock=nextColumn[i];
    1897         size-=blockCount[originalBlock];
    1898         if (size>0&&i<numberBlocks-1) {
    1899           blockCount[originalBlock]=-1;
    1900         } else {
    1901           size=minSize1;
    1902           n++;
    1903         }
    1904       }
    1905       int n2=numberBlocks;
    1906       numberBlocks=n;
    1907       for (int i=n2-1;i>=0;i--) {
    1908         int originalBlock=nextColumn[i];
    1909         if (blockCount[originalBlock]>0)
    1910           n--;
    1911         blockCount[originalBlock]=n;
    1912       }
    1913       assert (!n);
     1863      int n = 0;
     1864      for (int i = 0; i < numberBlocks; i++) {
     1865        int originalBlock = nextColumn[i];
     1866        if (blockCount[originalBlock] < minSize2)
     1867          break;
     1868        n++;
     1869      }
     1870      int size = minSize1;
     1871      for (int i = n; i < numberBlocks; i++) {
     1872        int originalBlock = nextColumn[i];
     1873        size -= blockCount[originalBlock];
     1874        if (size > 0 && i < numberBlocks - 1) {
     1875          blockCount[originalBlock] = -1;
     1876        } else {
     1877          size = minSize1;
     1878          n++;
     1879        }
     1880      }
     1881      int n2 = numberBlocks;
     1882      numberBlocks = n;
     1883      for (int i = n2 - 1; i >= 0; i--) {
     1884        int originalBlock = nextColumn[i];
     1885        if (blockCount[originalBlock] > 0)
     1886          n--;
     1887        blockCount[originalBlock] = n;
     1888      }
     1889      assert(!n);
    19141890      for (int iRow = 0; iRow < numberRows_; iRow++) {
    1915         int iBlock=blockStart[iRow];
    1916         if (iBlock>=0)
    1917           blockStart[iRow]=blockCount[iBlock];
     1891        int iBlock = blockStart[iRow];
     1892        if (iBlock >= 0)
     1893          blockStart[iRow] = blockCount[iBlock];
    19181894      }
    19191895      for (int iColumn = 0; iColumn < numberColumns_; iColumn++) {
    1920         int iBlock=columnBlock[iColumn];
    1921         if (iBlock>=0)
    1922           columnBlock[iColumn]=blockCount[iBlock];
     1896        int iBlock = columnBlock[iColumn];
     1897        if (iBlock >= 0)
     1898          columnBlock[iColumn] = blockCount[iBlock];
    19231899      }
    19241900      // stick to Clp for now
    1925       ClpSimplex ** simplex = new ClpSimplex * [numberBlocks];
    1926       for (int iBlock=0;iBlock<numberBlocks;iBlock++) {
    1927         int nRow=0;
    1928         int nColumn=0;
    1929         for (int iRow=0;iRow<numberRows_;iRow++) {
    1930           if (blockStart[iRow]==iBlock)
    1931             blockCount[nRow++]=iRow;
    1932         }
    1933         for (int iColumn=0;iColumn<numberColumns_;iColumn++) {
    1934           if (columnBlock[iColumn]==iBlock)
    1935             nextColumn[nColumn++]=iColumn;
    1936         }
    1937         simplex[iBlock]=new ClpSimplex(this,nRow,blockCount,nColumn,nextColumn);
    1938         simplex[iBlock]->setSpecialOptions(simplex[iBlock]->specialOptions()&(~65536));
    1939         if (logLevel()<2)
    1940           simplex[iBlock]->setLogLevel(0);
    1941       }
    1942       solveMany(numberBlocks,simplex);
    1943       int numberBasic=numberMaster;
    1944       int numberStructurals=0;
    1945       for (int i=0;i<numberMaster;i++)
    1946         abcPivotVariable_[i]=i+firstMaster;
    1947       for (int iBlock=0;iBlock<numberBlocks;iBlock++) {
    1948         int nRow=0;
    1949         int nColumn=0;
    1950         // from Clp enum to Abc enum (and bound flip)
    1951         unsigned char lookupToAbcSlack[6]={4,6,0/*1*/,1/*0*/,5,7};
    1952         unsigned char *  COIN_RESTRICT getStatus = simplex[iBlock]->statusArray()+
    1953           simplex[iBlock]->numberColumns();
    1954         double *  COIN_RESTRICT solutionSaved=solutionSaved_;
    1955         double *  COIN_RESTRICT lowerSaved=lowerSaved_;
    1956         double *  COIN_RESTRICT upperSaved=upperSaved_;
    1957         for (int iRow=0;iRow<numberRows_;iRow++) {
    1958           if (blockStart[iRow]==iBlock) {
    1959             unsigned char status=getStatus[nRow++]&7;
    1960             AbcSimplex::Status abcStatus=static_cast<AbcSimplex::Status>(lookupToAbcSlack[status]);
    1961             if (status!=ClpSimplex::basic) {
    1962               double lowerValue=lowerSaved[iRow];
    1963               double upperValue=upperSaved[iRow];
    1964               if (lowerValue==-COIN_DBL_MAX) {
    1965                 if(upperValue==COIN_DBL_MAX) {
    1966                   // free
    1967                   abcStatus=isFree;
    1968                 } else {
    1969                   abcStatus=atUpperBound;
    1970                 }
    1971               } else if (upperValue==COIN_DBL_MAX) {
    1972                 abcStatus=atLowerBound;
    1973               } else if (lowerValue==upperValue) {
    1974                 abcStatus=isFixed;
    1975               }
    1976               switch (abcStatus) {
    1977               case isFixed:
    1978               case atLowerBound:
    1979                 solutionSaved[iRow]=lowerValue;
    1980                 break;
    1981               case atUpperBound:
    1982                 solutionSaved[iRow]=upperValue;
    1983                 break;
    1984               default:
    1985                 break;
    1986               }
    1987             } else {
    1988               // basic
    1989               abcPivotVariable_[numberBasic++]=iRow;
    1990             }
    1991             internalStatus_[iRow]=abcStatus;
    1992           }
    1993         }
    1994         // from Clp enum to Abc enum
    1995         unsigned char lookupToAbc[6]={4,6,1,0,5,7};
    1996         unsigned char *  COIN_RESTRICT putStatus=internalStatus_+maximumAbcNumberRows_;
    1997         getStatus = simplex[iBlock]->statusArray();
    1998         solutionSaved+= maximumAbcNumberRows_;
    1999         lowerSaved+= maximumAbcNumberRows_;
    2000         upperSaved+= maximumAbcNumberRows_;
    2001         int numberSaved=numberBasic;
    2002         for (int iColumn=0;iColumn<numberColumns_;iColumn++) {
    2003           if (columnBlock[iColumn]==iBlock) {
    2004             unsigned char status=getStatus[nColumn++]&7;
    2005             AbcSimplex::Status abcStatus=static_cast<AbcSimplex::Status>(lookupToAbc[status]);
    2006             if (status!=ClpSimplex::basic) {
    2007               double lowerValue=lowerSaved[iColumn];
    2008               double upperValue=upperSaved[iColumn];
    2009               if (lowerValue==-COIN_DBL_MAX) {
    2010                 if(upperValue==COIN_DBL_MAX) {
    2011                   // free
    2012                   abcStatus=isFree;
    2013                 } else {
    2014                   abcStatus=atUpperBound;
    2015                 }
    2016               } else if (upperValue==COIN_DBL_MAX) {
    2017                 abcStatus=atLowerBound;
    2018               } else if (lowerValue==upperValue) {
    2019                 abcStatus=isFixed;
    2020               } else if (abcStatus==isFree) {
    2021                 abcStatus=superBasic;
    2022               }
    2023               switch (abcStatus) {
    2024               case isFixed:
    2025               case atLowerBound:
    2026                 solutionSaved[iColumn]=lowerValue;
    2027                 break;
    2028               case atUpperBound:
    2029                 solutionSaved[iColumn]=upperValue;
    2030                 break;
    2031             default:
    2032               break;
    2033               }
    2034             } else {
    2035               // basic
    2036               if (numberBasic<numberRows_)
    2037                 abcPivotVariable_[numberBasic++]=iColumn+maximumAbcNumberRows_;
    2038               else
    2039                 abcStatus=superBasic;
    2040             }
    2041             putStatus[iColumn]=abcStatus;
    2042           }
    2043         }
    2044         numberStructurals+=numberBasic-numberSaved;
    2045         delete simplex[iBlock];
    2046       }
    2047 #if ABC_NORMAL_DEBUG>0
    2048       printf("%d structurals put into basis\n",numberStructurals);
    2049 #endif
    2050       if (numberBasic<numberRows_) {
    2051         for (int iRow=0;iRow<numberRows_;iRow++) {
    2052           AbcSimplex::Status status=getInternalStatus(iRow);
    2053           if (status!=AbcSimplex::basic) {
    2054             abcPivotVariable_[numberBasic++]=iRow;
    2055             setInternalStatus(iRow,basic);
    2056             if (numberBasic==numberRows_)
    2057               break;
    2058           }
    2059         }
    2060       }
    2061       assert (numberBasic==numberRows_);
     1901      ClpSimplex **simplex = new ClpSimplex *[numberBlocks];
     1902      for (int iBlock = 0; iBlock < numberBlocks; iBlock++) {
     1903        int nRow = 0;
     1904        int nColumn = 0;
     1905        for (int iRow = 0; iRow < numberRows_; iRow++) {
     1906          if (blockStart[iRow] == iBlock)
     1907            blockCount[nRow++] = iRow;
     1908        }
     1909        for (int iColumn = 0; iColumn < numberColumns_; iColumn++) {
     1910          if (columnBlock[iColumn] == iBlock)
     1911            nextColumn[nColumn++] = iColumn;
     1912        }
     1913        simplex[iBlock] = new ClpSimplex(this, nRow, blockCount, nColumn, nextColumn);
     1914        simplex[iBlock]->setSpecialOptions(simplex[iBlock]->specialOptions() & (~65536));
     1915        if (logLevel() < 2)
     1916          simplex[iBlock]->setLogLevel(0);
     1917      }
     1918      solveMany(numberBlocks, simplex);
     1919      int numberBasic = numberMaster;
     1920      int numberStructurals = 0;
     1921      for (int i = 0; i < numberMaster; i++)
     1922        abcPivotVariable_[i] = i + firstMaster;
     1923      for (int iBlock = 0; iBlock < numberBlocks; iBlock++) {
     1924        int nRow = 0;
     1925        int nColumn = 0;
     1926        // from Clp enum to Abc enum (and bound flip)
     1927        unsigned char lookupToAbcSlack[6] = { 4, 6, 0 /*1*/, 1 /*0*/, 5, 7 };
     1928        unsigned char *COIN_RESTRICT getStatus = simplex[iBlock]->statusArray() + simplex[iBlock]->numberColumns();
     1929        double *COIN_RESTRICT solutionSaved = solutionSaved_;
     1930        double *COIN_RESTRICT lowerSaved = lowerSaved_;
     1931        double *COIN_RESTRICT upperSaved = upperSaved_;
     1932        for (int iRow = 0; iRow < numberRows_; iRow++) {
     1933          if (blockStart[iRow] == iBlock) {
     1934            unsigned char status = getStatus[nRow++] & 7;
     1935            AbcSimplex::Status abcStatus = static_cast< AbcSimplex::Status >(lookupToAbcSlack[status]);
     1936            if (status != ClpSimplex::basic) {
     1937              double lowerValue = lowerSaved[iRow];
     1938              double upperValue = upperSaved[iRow];
     1939              if (lowerValue == -COIN_DBL_MAX) {
     1940                if (upperValue == COIN_DBL_MAX) {
     1941                  // free
     1942                  abcStatus = isFree;
     1943                } else {
     1944                  abcStatus = atUpperBound;
     1945                }
     1946              } else if (upperValue == COIN_DBL_MAX) {
     1947                abcStatus = atLowerBound;
     1948              } else if (lowerValue == upperValue) {
     1949                abcStatus = isFixed;
     1950              }
     1951              switch (abcStatus) {
     1952              case isFixed:
     1953              case atLowerBound:
     1954                solutionSaved[iRow] = lowerValue;
     1955                break;
     1956              case atUpperBound:
     1957                solutionSaved[iRow] = upperValue;
     1958                break;
     1959              default:
     1960                break;
     1961              }
     1962            } else {
     1963              // basic
     1964              abcPivotVariable_[numberBasic++] = iRow;
     1965            }
     1966            internalStatus_[iRow] = abcStatus;
     1967          }
     1968        }
     1969        // from Clp enum to Abc enum
     1970        unsigned char lookupToAbc[6] = { 4, 6, 1, 0, 5, 7 };
     1971        unsigned char *COIN_RESTRICT putStatus = internalStatus_ + maximumAbcNumberRows_;
     1972        getStatus = simplex[iBlock]->statusArray();
     1973        solutionSaved += maximumAbcNumberRows_;
     1974        lowerSaved += maximumAbcNumberRows_;
     1975        upperSaved += maximumAbcNumberRows_;
     1976        int numberSaved = numberBasic;
     1977        for (int iColumn = 0; iColumn < numberColumns_; iColumn++) {
     1978          if (columnBlock[iColumn] == iBlock) {
     1979            unsigned char status = getStatus[nColumn++] & 7;
     1980            AbcSimplex::Status abcStatus = static_cast< AbcSimplex::Status >(lookupToAbc[status]);
     1981            if (status != ClpSimplex::basic) {
     1982              double lowerValue = lowerSaved[iColumn];
     1983              double upperValue = upperSaved[iColumn];
     1984              if (lowerValue == -COIN_DBL_MAX) {
     1985                if (upperValue == COIN_DBL_MAX) {
     1986                  // free
     1987                  abcStatus = isFree;
     1988                } else {
     1989                  abcStatus = atUpperBound;
     1990                }
     1991              } else if (upperValue == COIN_DBL_MAX) {
     1992                abcStatus = atLowerBound;
     1993              } else if (lowerValue == upperValue) {
     1994                abcStatus = isFixed;
     1995              } else if (abcStatus == isFree) {
     1996                abcStatus = superBasic;
     1997              }
     1998              switch (abcStatus) {
     1999              case isFixed:
     2000              case atLowerBound:
     2001                solutionSaved[iColumn] = lowerValue;
     2002                break;
     2003              case atUpperBound:
     2004                solutionSaved[iColumn] = upperValue;
     2005                break;
     2006              default:
     2007                break;
     2008              }
     2009            } else {
     2010              // basic
     2011              if (numberBasic < numberRows_)
     2012                abcPivotVariable_[numberBasic++] = iColumn + maximumAbcNumberRows_;
     2013              else
     2014                abcStatus = superBasic;
     2015            }
     2016            putStatus[iColumn] = abcStatus;
     2017          }
     2018        }
     2019        numberStructurals += numberBasic - numberSaved;
     2020        delete simplex[iBlock];
     2021      }
     2022#if ABC_NORMAL_DEBUG > 0
     2023      printf("%d structurals put into basis\n", numberStructurals);
     2024#endif
     2025      if (numberBasic < numberRows_) {
     2026        for (int iRow = 0; iRow < numberRows_; iRow++) {
     2027          AbcSimplex::Status status = getInternalStatus(iRow);
     2028          if (status != AbcSimplex::basic) {
     2029            abcPivotVariable_[numberBasic++] = iRow;
     2030            setInternalStatus(iRow, basic);
     2031            if (numberBasic == numberRows_)
     2032              break;
     2033          }
     2034        }
     2035      }
     2036      assert(numberBasic == numberRows_);
    20622037#if 0
    20632038      int n2=0;
     
    20742049      }
    20752050#endif
    2076       delete [] simplex;
     2051      delete[] simplex;
    20772052      return;
    20782053    } else {
    20792054      // try another
    2080       type=2;
    2081     }
    2082   }
    2083   if (type==1) {
    2084     const double * linearObjective = abcCost_+maximumAbcNumberRows_;
    2085     double gamma=0.0;
    2086     int numberTotal=numberRows_+numberColumns_;
    2087     double * q = new double [numberTotal];
    2088     double * v = q+numberColumns_;
    2089     int * which = new int [numberTotal+3*numberRows_];
    2090     int * ii = which+numberColumns_;
    2091     int * r = ii+numberRows_;
    2092     int * pivoted = r+numberRows_;
     2055      type = 2;
     2056    }
     2057  }
     2058  if (type == 1) {
     2059    const double *linearObjective = abcCost_ + maximumAbcNumberRows_;
     2060    double gamma = 0.0;
     2061    int numberTotal = numberRows_ + numberColumns_;
     2062    double *q = new double[numberTotal];
     2063    double *v = q + numberColumns_;
     2064    int *which = new int[numberTotal + 3 * numberRows_];
     2065    int *ii = which + numberColumns_;
     2066    int *r = ii + numberRows_;
     2067    int *pivoted = r + numberRows_;
    20932068    for (int iColumn = 0; iColumn < numberColumns_; iColumn++) {
    2094       gamma=CoinMax(gamma,linearObjective[iColumn]);
     2069      gamma = CoinMax(gamma, linearObjective[iColumn]);
    20952070    }
    20962071    for (int iRow = 0; iRow < numberRows_; iRow++) {
    20972072      double lowerBound = abcLower_[iRow];
    20982073      double upperBound = abcUpper_[iRow];
    2099       pivoted[iRow]=-1;
    2100       ii[iRow]=0;
    2101       r[iRow]=0;
    2102       v[iRow]=COIN_DBL_MAX;
    2103       if (lowerBound==upperBound)
    2104         continue;
    2105       if (lowerBound<=0.0&&upperBound>=0.0) {
    2106         pivoted[iRow]=iRow;
    2107         ii[iRow]=1;
    2108         r[iRow]=1;
    2109       }
    2110     }
    2111     int nPossible=0;
    2112     int lastPossible=0;
     2074      pivoted[iRow] = -1;
     2075      ii[iRow] = 0;
     2076      r[iRow] = 0;
     2077      v[iRow] = COIN_DBL_MAX;
     2078      if (lowerBound == upperBound)
     2079        continue;
     2080      if (lowerBound <= 0.0 && upperBound >= 0.0) {
     2081        pivoted[iRow] = iRow;
     2082        ii[iRow] = 1;
     2083        r[iRow] = 1;
     2084      }
     2085    }
     2086    int nPossible = 0;
     2087    int lastPossible = 0;
    21132088    double cMaxDiv;
    21142089    if (gamma)
    2115       cMaxDiv=1.0/(1000.0*gamma);
     2090      cMaxDiv = 1.0 / (1000.0 * gamma);
    21162091    else
    2117       cMaxDiv=1.0;
    2118     const double * columnLower = abcLower_+maximumAbcNumberRows_;
    2119     const double * columnUpper = abcUpper_+maximumAbcNumberRows_;
    2120     for (int iPass=0;iPass<3;iPass++) {
     2092      cMaxDiv = 1.0;
     2093    const double *columnLower = abcLower_ + maximumAbcNumberRows_;
     2094    const double *columnUpper = abcUpper_ + maximumAbcNumberRows_;
     2095    for (int iPass = 0; iPass < 3; iPass++) {
    21212096      for (int iColumn = 0; iColumn < numberColumns_; iColumn++) {
    2122         double lowerBound = columnLower[iColumn];
    2123         double upperBound = columnUpper[iColumn];
    2124         if (lowerBound==upperBound)
    2125           continue;
    2126         double qValue;
    2127         if (lowerBound > -1.0e20 ) {
    2128           if (upperBound < 1.0e20) {
    2129             // both
    2130             qValue=lowerBound-upperBound;
    2131             if (iPass!=2)
    2132               qValue=COIN_DBL_MAX;
    2133           } else {
    2134             // just lower
    2135             qValue=lowerBound;
    2136             if (iPass!=1)
    2137               qValue=COIN_DBL_MAX;
    2138           }
    2139         } else {
    2140           if (upperBound < 1.0e20) {
    2141             // just upper
    2142             qValue=-upperBound;
    2143             if (iPass!=1)
    2144               qValue=COIN_DBL_MAX;
    2145           } else {
    2146             // free
    2147             qValue=0.0;
    2148             if (iPass!=0)
    2149               qValue=COIN_DBL_MAX;
    2150           }
    2151         }
    2152         if (qValue!=COIN_DBL_MAX) {
    2153           which[nPossible]=iColumn;
    2154           q[nPossible++]=qValue+linearObjective[iColumn]*cMaxDiv;;
    2155         }
    2156       }
    2157       CoinSort_2(q+lastPossible,q+nPossible,which+lastPossible);
    2158       lastPossible=nPossible;
    2159     }
    2160     const double * element = abcMatrix_->getPackedMatrix()->getElements();
    2161     const CoinBigIndex * columnStart = abcMatrix_->getPackedMatrix()->getVectorStarts();
     2097        double lowerBound = columnLower[iColumn];
     2098        double upperBound = columnUpper[iColumn];
     2099        if (lowerBound == upperBound)
     2100          continue;
     2101        double qValue;
     2102        if (lowerBound > -1.0e20) {
     2103          if (upperBound < 1.0e20) {
     2104            // both
     2105            qValue = lowerBound - upperBound;
     2106            if (iPass != 2)
     2107              qValue = COIN_DBL_MAX;
     2108          } else {
     2109            // just lower
     2110            qValue = lowerBound;
     2111            if (iPass != 1)
     2112              qValue = COIN_DBL_MAX;
     2113          }
     2114        } else {
     2115          if (upperBound < 1.0e20) {
     2116            // just upper
     2117            qValue = -upperBound;
     2118            if (iPass != 1)
     2119              qValue = COIN_DBL_MAX;
     2120          } else {
     2121            // free
     2122            qValue = 0.0;
     2123            if (iPass != 0)
     2124              qValue = COIN_DBL_MAX;
     2125          }
     2126        }
     2127        if (qValue != COIN_DBL_MAX) {
     2128          which[nPossible] = iColumn;
     2129          q[nPossible++] = qValue + linearObjective[iColumn] * cMaxDiv;
     2130          ;
     2131        }
     2132      }
     2133      CoinSort_2(q + lastPossible, q + nPossible, which + lastPossible);
     2134      lastPossible = nPossible;
     2135    }
     2136    const double *element = abcMatrix_->getPackedMatrix()->getElements();
     2137    const CoinBigIndex *columnStart = abcMatrix_->getPackedMatrix()->getVectorStarts();
    21622138    //const int * columnLength = abcMatrix_->getPackedMatrix()->getVectorLengths();
    2163     const int * row = abcMatrix_->getPackedMatrix()->getIndices();
    2164     int nPut=0;
    2165     for (int i=0;i<nPossible;i++) {
    2166       int iColumn=which[i];
    2167       double maxAlpha=0.0;
    2168       int kRow=-1;
    2169       double alternativeAlpha=0.0;
    2170       int jRow=-1;
    2171       bool canTake=true;
    2172       for (CoinBigIndex j=columnStart[iColumn];j<columnStart[iColumn+1];j++) {
    2173         int iRow=row[j];
    2174         double alpha=fabs(element[j]);
    2175         if (alpha>0.01*v[iRow]) {
    2176           canTake=false;
    2177         } else if (!ii[iRow]&&alpha>alternativeAlpha) {
    2178           alternativeAlpha=alpha;
    2179           jRow=iRow;
    2180         }
    2181         if (!r[iRow]&&alpha>maxAlpha) {
    2182           maxAlpha=alpha;
    2183           kRow=iRow;
    2184         }
     2139    const int *row = abcMatrix_->getPackedMatrix()->getIndices();
     2140    int nPut = 0;
     2141    for (int i = 0; i < nPossible; i++) {
     2142      int iColumn = which[i];
     2143      double maxAlpha = 0.0;
     2144      int kRow = -1;
     2145      double alternativeAlpha = 0.0;
     2146      int jRow = -1;
     2147      bool canTake = true;
     2148      for (CoinBigIndex j = columnStart[iColumn]; j < columnStart[iColumn + 1]; j++) {
     2149        int iRow = row[j];
     2150        double alpha = fabs(element[j]);
     2151        if (alpha > 0.01 * v[iRow]) {
     2152          canTake = false;
     2153        } else if (!ii[iRow] && alpha > alternativeAlpha) {
     2154          alternativeAlpha = alpha;
     2155          jRow = iRow;
     2156        }
     2157        if (!r[iRow] && alpha > maxAlpha) {
     2158          maxAlpha = alpha;
     2159          kRow = iRow;
     2160        }
    21852161      }
    21862162      // only really works if scaled
    2187       if (maxAlpha>0.99) {
    2188         pivoted[kRow]=iColumn+maximumAbcNumberRows_;
    2189         v[kRow]=maxAlpha;
    2190         ii[kRow]=1;
    2191         for (CoinBigIndex j=columnStart[iColumn];j<columnStart[iColumn+1];j++) {
    2192           int iRow=row[j];
    2193           r[iRow]++;
    2194         }
    2195         nPut++;
    2196       } else if (canTake&&jRow>=0) {
    2197         pivoted[jRow]=iColumn+maximumAbcNumberRows_;
    2198         v[jRow]=maxAlpha;
    2199         ii[jRow]=1;
    2200         for (CoinBigIndex j=columnStart[iColumn];j<columnStart[iColumn+1];j++) {
    2201           int iRow=row[j];
    2202           r[iRow]++;
    2203         }
    2204         nPut++;
    2205       }
    2206     }
    2207     for (int iRow=0;iRow<numberRows_;iRow++) {
    2208       int iSequence=pivoted[iRow];
    2209       if (iSequence>=0&&iSequence<numberColumns_) {
    2210         abcPivotVariable_[iRow]=iSequence;
    2211         if (fabs(abcLower_[iRow])<fabs(abcUpper_[iRow])) {
    2212           setInternalStatus(iRow,atLowerBound);
    2213           abcSolution_[iRow]=abcLower_[iRow];
    2214           solutionSaved_[iRow]=abcLower_[iRow];
    2215         } else {
    2216           setInternalStatus(iRow,atUpperBound);
    2217           abcSolution_[iRow]=abcUpper_[iRow];
    2218           solutionSaved_[iRow]=abcUpper_[iRow];
    2219         }
    2220         setInternalStatus(iSequence,basic);
    2221       }
    2222     }
    2223 #if ABC_NORMAL_DEBUG>0
    2224     printf("%d put into basis\n",nPut);
    2225 #endif
    2226     delete [] q;
    2227     delete [] which;
    2228   } else if (type==2) {
     2163      if (maxAlpha > 0.99) {
     2164        pivoted[kRow] = iColumn + maximumAbcNumberRows_;
     2165        v[kRow] = maxAlpha;
     2166        ii[kRow] = 1;
     2167        for (CoinBigIndex j = columnStart[iColumn]; j < columnStart[iColumn + 1]; j++) {
     2168          int iRow = row[j];
     2169          r[iRow]++;
     2170        }
     2171        nPut++;
     2172      } else if (canTake && jRow >= 0) {
     2173        pivoted[jRow] = iColumn + maximumAbcNumberRows_;
     2174        v[jRow] = maxAlpha;
     2175        ii[jRow] = 1;
     2176        for (CoinBigIndex j = columnStart[iColumn]; j < columnStart[iColumn + 1]; j++) {
     2177          int iRow = row[j];
     2178          r[iRow]++;
     2179        }
     2180        nPut++;
     2181      }
     2182    }
     2183    for (int iRow = 0; iRow < numberRows_; iRow++) {
     2184      int iSequence = pivoted[iRow];
     2185      if (iSequence >= 0 && iSequence < numberColumns_) {
     2186        abcPivotVariable_[iRow] = iSequence;
     2187        if (fabs(abcLower_[iRow]) < fabs(abcUpper_[iRow])) {
     2188          setInternalStatus(iRow, atLowerBound);
     2189          abcSolution_[iRow] = abcLower_[iRow];
     2190          solutionSaved_[iRow] = abcLower_[iRow];
     2191        } else {
     2192          setInternalStatus(iRow, atUpperBound);
     2193          abcSolution_[iRow] = abcUpper_[iRow];
     2194          solutionSaved_[iRow] = abcUpper_[iRow];
     2195        }
     2196        setInternalStatus(iSequence, basic);
     2197      }
     2198    }
     2199#if ABC_NORMAL_DEBUG > 0
     2200    printf("%d put into basis\n", nPut);
     2201#endif
     2202    delete[] q;
     2203    delete[] which;
     2204  } else if (type == 2) {
    22292205    //return;
    2230     int numberBad=0;
    2231     CoinAbcMemcpy(abcDj_,abcCost_,numberTotal_);
     2206    int numberBad = 0;
     2207    CoinAbcMemcpy(abcDj_, abcCost_, numberTotal_);
    22322208    // Work on savedSolution and current
    2233     int iVector=getAvailableArray();
     2209    int iVector = getAvailableArray();
    22342210#define ALLOW_BAD_DJS
    22352211#ifdef ALLOW_BAD_DJS
    2236     double * modDj = usefulArray_[iVector].denseVector();
    2237 #endif
    2238     for (int iSequence=maximumAbcNumberRows_;iSequence<numberTotal_;iSequence++) {
    2239       double dj=abcDj_[iSequence];
    2240       modDj[iSequence]=0.0;
    2241       if (getInternalStatus(iSequence)==atLowerBound) {
    2242         if (dj<-dualTolerance_) {
    2243           double costThru=-dj*(abcUpper_[iSequence]-abcLower_[iSequence]);
    2244           if (costThru<dualBound_) {
    2245             // flip
    2246             setInternalStatus(iSequence,atUpperBound);
    2247             solutionSaved_[iSequence]=abcUpper_[iSequence];
    2248             abcSolution_[iSequence]=abcUpper_[iSequence];
    2249           } else {
    2250             numberBad++;
     2212    double *modDj = usefulArray_[iVector].denseVector();
     2213#endif
     2214    for (int iSequence = maximumAbcNumberRows_; iSequence < numberTotal_; iSequence++) {
     2215      double dj = abcDj_[iSequence];
     2216      modDj[iSequence] = 0.0;
     2217      if (getInternalStatus(iSequence) == atLowerBound) {
     2218        if (dj < -dualTolerance_) {
     2219          double costThru = -dj * (abcUpper_[iSequence] - abcLower_[iSequence]);
     2220          if (costThru < dualBound_) {
     2221            // flip
     2222            setInternalStatus(iSequence, atUpperBound);
     2223            solutionSaved_[iSequence] = abcUpper_[iSequence];
     2224            abcSolution_[iSequence] = abcUpper_[iSequence];
     2225          } else {
     2226            numberBad++;
    22512227#ifdef ALLOW_BAD_DJS
    2252             modDj[iSequence]=dj;
    2253             dj=0.0;
     2228            modDj[iSequence] = dj;
     2229            dj = 0.0;
    22542230#else
    2255             break;
    2256 #endif
    2257           }
    2258         } else {
    2259           dj=CoinMax(dj,0.0);
    2260         }
    2261       } else if (getInternalStatus(iSequence)==atLowerBound) {
    2262         if (dj>dualTolerance_) {
    2263           double costThru=dj*(abcUpper_[iSequence]-abcLower_[iSequence]);
    2264           if (costThru<dualBound_) {
    2265             assert (abcUpper_[iSequence]-abcLower_[iSequence]<1.0e10);
    2266             // flip
    2267             setInternalStatus(iSequence,atLowerBound);
    2268             solutionSaved_[iSequence]=abcLower_[iSequence];
    2269             abcSolution_[iSequence]=abcLower_[iSequence];
    2270           } else {
    2271             numberBad++;
     2231            break;
     2232#endif
     2233          }
     2234        } else {
     2235          dj = CoinMax(dj, 0.0);
     2236        }
     2237      } else if (getInternalStatus(iSequence) == atLowerBound) {
     2238        if (dj > dualTolerance_) {
     2239          double costThru = dj * (abcUpper_[iSequence] - abcLower_[iSequence]);
     2240          if (costThru < dualBound_) {
     2241            assert(abcUpper_[iSequence] - abcLower_[iSequence] < 1.0e10);
     2242            // flip
     2243            setInternalStatus(iSequence, atLowerBound);
     2244            solutionSaved_[iSequence] = abcLower_[iSequence];
     2245            abcSolution_[iSequence] = abcLower_[iSequence];
     2246          } else {
     2247            numberBad++;
    22722248#ifdef ALLOW_BAD_DJS
    2273             modDj[iSequence]=dj;
    2274             dj=0.0;
     2249            modDj[iSequence] = dj;
     2250            dj = 0.0;
    22752251#else
    2276             break;
    2277 #endif
    2278           }
    2279         } else {
    2280           dj=CoinMin(dj,0.0);
    2281         }
     2252            break;
     2253#endif
     2254          }
     2255        } else {
     2256          dj = CoinMin(dj, 0.0);
     2257        }
    22822258      } else {
    2283         if (fabs(dj)<dualTolerance_) {
    2284           dj=0.0;
    2285         } else {
    2286           numberBad++;
     2259        if (fabs(dj) < dualTolerance_) {
     2260          dj = 0.0;
     2261        } else {
     2262          numberBad++;
    22872263#ifdef ALLOW_BAD_DJS
    2288           modDj[iSequence]=dj;
    2289           dj=0.0;
     2264          modDj[iSequence] = dj;
     2265          dj = 0.0;
    22902266#else
    2291           break;
    2292 #endif
    2293         }
    2294       }
    2295       abcDj_[iSequence]=dj;
     2267          break;
     2268#endif
     2269        }
     2270      }
     2271      abcDj_[iSequence] = dj;
    22962272    }
    22972273#ifndef ALLOW_BAD_DJS
    22982274    if (numberBad) {
    22992275      //CoinAbcMemset0(modDj+maximumAbcNumberRows_,numberColumns_);
    2300       return ;
     2276      return;
    23012277    }
    23022278#endif
     
    23042280      abcMatrix_->createRowCopy();
    23052281    //const double * element = abcMatrix_->getPackedMatrix()->getElements();
    2306     const CoinBigIndex * columnStart = abcMatrix_->getPackedMatrix()->getVectorStarts()-maximumAbcNumberRows_;
    2307     const int * row = abcMatrix_->getPackedMatrix()->getIndices();
    2308     const double * elementByRow = abcMatrix_->rowElements();
    2309     const CoinBigIndex * rowStart = abcMatrix_->rowStart();
    2310     const CoinBigIndex * rowEnd = abcMatrix_->rowEnd();
    2311     const int * column = abcMatrix_->rowColumns();
    2312     CoinAbcMemset0(solutionBasic_,numberRows_);
    2313     CoinAbcMemcpy(lowerBasic_,abcLower_,numberRows_);
    2314     CoinAbcMemcpy(upperBasic_,abcUpper_,numberRows_);
    2315     abcMatrix_->timesIncludingSlacks(-1.0,solutionSaved_,solutionBasic_);
    2316     const double multiplier[] = { 1.0, -1.0};
    2317     int nBasic=0;
    2318     int * index=usefulArray_[iVector].getIndices();
    2319     int iVector2=getAvailableArray();
    2320     int * index2=usefulArray_[iVector2].getIndices();
    2321     double * sort =usefulArray_[iVector2].denseVector();
    2322     int average = CoinMax(5,rowEnd[numberRows_-1]/(8*numberRows_));
    2323     int nPossible=0;
    2324     if (numberRows_>10000) {
     2282    const CoinBigIndex *columnStart = abcMatrix_->getPackedMatrix()->getVectorStarts() - maximumAbcNumberRows_;
     2283    const int *row = abcMatrix_->getPackedMatrix()->getIndices();
     2284    const double *elementByRow = abcMatrix_->rowElements();
     2285    const CoinBigIndex *rowStart = abcMatrix_->rowStart();
     2286    const CoinBigIndex *rowEnd = abcMatrix_->rowEnd();
     2287    const int *column = abcMatrix_->rowColumns();
     2288    CoinAbcMemset0(solutionBasic_, numberRows_);
     2289    CoinAbcMemcpy(lowerBasic_, abcLower_, numberRows_);
     2290    CoinAbcMemcpy(upperBasic_, abcUpper_, numberRows_);
     2291    abcMatrix_->timesIncludingSlacks(-1.0, solutionSaved_, solutionBasic_);
     2292    const double multiplier[] = { 1.0, -1.0 };
     2293    int nBasic = 0;
     2294    int *index = usefulArray_[iVector].getIndices();
     2295    int iVector2 = getAvailableArray();
     2296    int *index2 = usefulArray_[iVector2].getIndices();
     2297    double *sort = usefulArray_[iVector2].denseVector();
     2298    int average = CoinMax(5, rowEnd[numberRows_ - 1] / (8 * numberRows_));
     2299    int nPossible = 0;
     2300    if (numberRows_ > 10000) {
    23252301      // allow more
    2326       for (int iRow=0;iRow<numberRows_;iRow++) {
    2327         double solutionValue=solutionBasic_[iRow];
    2328         double infeasibility=0.0;
    2329         double lowerValue=lowerBasic_[iRow];
    2330         double upperValue=upperBasic_[iRow];
    2331         if (solutionValue<lowerValue-primalTolerance_) {
    2332           infeasibility=-(lowerValue-solutionValue);
    2333         } else if (solutionValue>upperValue+primalTolerance_) {
    2334           infeasibility=upperValue-solutionValue;
    2335         }
    2336         int length=rowEnd[iRow]-rowStart[iRow];
    2337         if (infeasibility)
    2338           index2[nPossible++]=length;
    2339       }
    2340       std::sort(index2,index2+nPossible);
     2302      for (int iRow = 0; iRow < numberRows_; iRow++) {
     2303        double solutionValue = solutionBasic_[iRow];
     2304        double infeasibility = 0.0;
     2305        double lowerValue = lowerBasic_[iRow];
     2306        double upperValue = upperBasic_[iRow];
     2307        if (solutionValue < lowerValue - primalTolerance_) {
     2308          infeasibility = -(lowerValue - solutionValue);
     2309        } else if (solutionValue > upperValue + primalTolerance_) {
     2310          infeasibility = upperValue - solutionValue;
     2311        }
     2312        int length = rowEnd[iRow] - rowStart[iRow];
     2313        if (infeasibility)
     2314          index2[nPossible++] = length;
     2315      }
     2316      std::sort(index2, index2 + nPossible);
    23412317      // see how much we need to get numberRows/10 or nPossible/3
    2342       average=CoinMax(average,index2[CoinMin(numberRows_/10,nPossible/3)]);
    2343       nPossible=0;
    2344     }
    2345     for (int iRow=0;iRow<numberRows_;iRow++) {
    2346       double solutionValue=solutionBasic_[iRow];
    2347       double infeasibility=0.0;
    2348       double lowerValue=lowerBasic_[iRow];
    2349       double upperValue=upperBasic_[iRow];
    2350       if (solutionValue<lowerValue-primalTolerance_) {
    2351         infeasibility=-(lowerValue-solutionValue);
    2352       } else if (solutionValue>upperValue+primalTolerance_) {
    2353         infeasibility=upperValue-solutionValue;
    2354       }
    2355       int length=rowEnd[iRow]-rowStart[iRow];
    2356       if (infeasibility&&length<average) {
    2357         index2[nPossible]=iRow;
    2358         sort[nPossible++]=1.0e5*infeasibility-iRow;
    2359         //sort[nPossible++]=1.0e9*length-iRow;//infeasibility;
    2360       }
    2361     }
    2362     CoinSort_2(sort,sort+nPossible,index2);
    2363     for (int iWhich=0;iWhich<nPossible;iWhich++) {
     2318      average = CoinMax(average, index2[CoinMin(numberRows_ / 10, nPossible / 3)]);
     2319      nPossible = 0;
     2320    }
     2321    for (int iRow = 0; iRow < numberRows_; iRow++) {
     2322      double solutionValue = solutionBasic_[iRow];
     2323      double infeasibility = 0.0;
     2324      double lowerValue = lowerBasic_[iRow];
     2325      double upperValue = upperBasic_[iRow];
     2326      if (solutionValue < lowerValue - primalTolerance_) {
     2327        infeasibility = -(lowerValue - solutionValue);
     2328      } else if (solutionValue > upperValue + primalTolerance_) {
     2329        infeasibility = upperValue - solutionValue;
     2330      }
     2331      int length = rowEnd[iRow] - rowStart[iRow];
     2332      if (infeasibility && length < average) {
     2333        index2[nPossible] = iRow;
     2334        sort[nPossible++] = 1.0e5 * infeasibility - iRow;
     2335        //sort[nPossible++]=1.0e9*length-iRow;//infeasibility;
     2336      }
     2337    }
     2338    CoinSort_2(sort, sort + nPossible, index2);
     2339    for (int iWhich = 0; iWhich < nPossible; iWhich++) {
    23642340      int iRow = index2[iWhich];
    2365       sort[iWhich]=0.0;
     2341      sort[iWhich] = 0.0;
    23662342      if (abcDj_[iRow])
    2367         continue; // marked as invalid
    2368       double solutionValue=solutionBasic_[iRow];
    2369       double infeasibility=0.0;
    2370       double lowerValue=lowerBasic_[iRow];
    2371       double upperValue=upperBasic_[iRow];
    2372       if (solutionValue<lowerValue-primalTolerance_) {
    2373         infeasibility=lowerValue-solutionValue;
    2374       } else if (solutionValue>upperValue+primalTolerance_) {
    2375         infeasibility=upperValue-solutionValue;
    2376       }
    2377       assert (infeasibility);
    2378       double direction = infeasibility >0 ? 1.0 : -1.0;
     2343        continue; // marked as invalid
     2344      double solutionValue = solutionBasic_[iRow];
     2345      double infeasibility = 0.0;
     2346      double lowerValue = lowerBasic_[iRow];
     2347      double upperValue = upperBasic_[iRow];
     2348      if (solutionValue < lowerValue - primalTolerance_) {
     2349        infeasibility = lowerValue - solutionValue;
     2350      } else if (solutionValue > upperValue + primalTolerance_) {
     2351        infeasibility = upperValue - solutionValue;
     2352      }
     2353      assert(infeasibility);
     2354      double direction = infeasibility > 0 ? 1.0 : -1.0;
    23792355      infeasibility *= direction;
    2380       int whichColumn=-1;
    2381       double upperTheta=1.0e30;
    2382       int whichColumn2=-1;
    2383       double upperTheta2=1.0e30;
    2384       double costThru=0.0;
    2385       int nThru=0;
    2386       for (CoinBigIndex j=rowStart[iRow];j<rowEnd[iRow];j++) {
    2387         int iSequence=column[j];
    2388         assert (iSequence>=maximumAbcNumberRows_);
    2389         double dj = abcDj_[iSequence];
    2390         double tableauValue=-elementByRow[j]*direction;
    2391         unsigned char iStatus=internalStatus_[iSequence]&7;
    2392         if ((iStatus&4)==0) {
    2393           double mult = multiplier[iStatus];
    2394           double alpha = tableauValue * mult;
    2395           double oldValue = dj * mult;
    2396           assert (oldValue>-1.0e-2);
    2397           double value = oldValue - upperTheta * alpha;
    2398           if (value < 0.0) {
    2399             upperTheta2=upperTheta;
    2400             whichColumn2=whichColumn;
    2401             costThru=alpha*(abcUpper_[iSequence]-abcLower_[iSequence]);
    2402             nThru=0;
    2403             upperTheta = oldValue / alpha;
    2404             whichColumn=iSequence;
    2405           } else if (oldValue-upperTheta2*alpha<0.0) {
    2406             costThru+=alpha*(abcUpper_[iSequence]-abcLower_[iSequence]);
    2407             index[nThru++]=iSequence;
    2408           }
    2409         } else if (iStatus<6) {
    2410           upperTheta=-1.0;
    2411           upperTheta2=elementByRow[j];
    2412           whichColumn=iSequence;
    2413           break;
    2414         }
    2415       }
    2416       if (whichColumn<0)
    2417         continue;
    2418       if (upperTheta!=-1.0) {
    2419         assert (upperTheta>=0.0);
    2420         if (costThru<infeasibility&&whichColumn2>=0) {
    2421           index[nThru++]=whichColumn;
    2422           for (int i=0;i<nThru;i++) {
    2423             int iSequence=index[i];
    2424             assert (abcUpper_[iSequence]-abcLower_[iSequence]<1.0e10);
    2425             // flip and use previous
    2426             if (getInternalStatus(iSequence)==atLowerBound) {
    2427               setInternalStatus(iSequence,atUpperBound);
    2428               solutionSaved_[iSequence]=abcUpper_[iSequence];
    2429               abcSolution_[iSequence]=abcUpper_[iSequence];
    2430             } else {
    2431               setInternalStatus(iSequence,atLowerBound);
    2432               solutionSaved_[iSequence]=abcLower_[iSequence];
    2433               abcSolution_[iSequence]=abcLower_[iSequence];
    2434             }
    2435           }
    2436           whichColumn=whichColumn2;
    2437           upperTheta=upperTheta2;
    2438         }
     2356      int whichColumn = -1;
     2357      double upperTheta = 1.0e30;
     2358      int whichColumn2 = -1;
     2359      double upperTheta2 = 1.0e30;
     2360      double costThru = 0.0;
     2361      int nThru = 0;
     2362      for (CoinBigIndex j = rowStart[iRow]; j < rowEnd[iRow]; j++) {
     2363        int iSequence = column[j];
     2364        assert(iSequence >= maximumAbcNumberRows_);
     2365        double dj = abcDj_[iSequence];
     2366        double tableauValue = -elementByRow[j] * direction;
     2367        unsigned char iStatus = internalStatus_[iSequence] & 7;
     2368        if ((iStatus & 4) == 0) {
     2369          double mult = multiplier[iStatus];
     2370          double alpha = tableauValue * mult;
     2371          double oldValue = dj * mult;
     2372          assert(oldValue > -1.0e-2);
     2373          double value = oldValue - upperTheta * alpha;
     2374          if (value < 0.0) {
     2375            upperTheta2 = upperTheta;
     2376            whichColumn2 = whichColumn;
     2377            costThru = alpha * (abcUpper_[iSequence] - abcLower_[iSequence]);
     2378            nThru = 0;
     2379            upperTheta = oldValue / alpha;
     2380            whichColumn = iSequence;
     2381          } else if (oldValue - upperTheta2 * alpha < 0.0) {
     2382            costThru += alpha * (abcUpper_[iSequence] - abcLower_[iSequence]);
     2383            index[nThru++] = iSequence;
     2384          }
     2385        } else if (iStatus < 6) {
     2386          upperTheta = -1.0;
     2387          upperTheta2 = elementByRow[j];
     2388          whichColumn = iSequence;
     2389          break;
     2390        }
     2391      }
     2392      if (whichColumn < 0)
     2393        continue;
     2394      if (upperTheta != -1.0) {
     2395        assert(upperTheta >= 0.0);
     2396        if (costThru < infeasibility && whichColumn2 >= 0) {
     2397          index[nThru++] = whichColumn;
     2398          for (int i = 0; i < nThru; i++) {
     2399            int iSequence = index[i];
     2400            assert(abcUpper_[iSequence] - abcLower_[iSequence] < 1.0e10);
     2401            // flip and use previous
     2402            if (getInternalStatus(iSequence) == atLowerBound) {
     2403              setInternalStatus(iSequence, atUpperBound);
     2404              solutionSaved_[iSequence] = abcUpper_[iSequence];
     2405              abcSolution_[iSequence] = abcUpper_[iSequence];
     2406            } else {
     2407              setInternalStatus(iSequence, atLowerBound);
     2408              solutionSaved_[iSequence] = abcLower_[iSequence];
     2409              abcSolution_[iSequence] = abcLower_[iSequence];
     2410            }
     2411          }
     2412          whichColumn = whichColumn2;
     2413          upperTheta = upperTheta2;
     2414        }
    24392415      } else {
    2440         // free coming in
    2441         upperTheta=(abcDj_[whichColumn]*direction)/upperTheta2;
     2416        // free coming in
     2417        upperTheta = (abcDj_[whichColumn] * direction) / upperTheta2;
    24422418      }
    24432419      // update djs
    24442420      upperTheta *= -direction;
    2445       for (CoinBigIndex j=rowStart[iRow];j<rowEnd[iRow];j++) {
    2446         int iSequence=column[j];
    2447         double dj = abcDj_[iSequence];
    2448         double tableauValue=elementByRow[j];
    2449         dj -= upperTheta*tableauValue;
    2450         unsigned char iStatus=internalStatus_[iSequence]&7;
    2451         if ((iStatus&4)==0) {
    2452           if (!iStatus) {
    2453             assert (dj>-1.0e-2);
    2454             dj = CoinMax(dj,0.0);
     2421      for (CoinBigIndex j = rowStart[iRow]; j < rowEnd[iRow]; j++) {
     2422        int iSequence = column[j];
     2423        double dj = abcDj_[iSequence];
     2424        double tableauValue = elementByRow[j];
     2425        dj -= upperTheta * tableauValue;
     2426        unsigned char iStatus = internalStatus_[iSequence] & 7;
     2427        if ((iStatus & 4) == 0) {
     2428          if (!iStatus) {
     2429            assert(dj > -1.0e-2);
     2430            dj = CoinMax(dj, 0.0);
    24552431#ifdef ALLOW_BAD_DJS
    2456             if (numberBad&&modDj[iSequence]) {
    2457               double bad=modDj[iSequence];
    2458               if (dj+bad>=0.0) {
    2459                 numberBad--;
    2460                 modDj[iSequence]=0.0;
    2461                 dj += bad;
    2462               } else {
    2463                 modDj[iSequence]+=dj;
    2464                 dj =0.0;
    2465               }
    2466             }
    2467 #endif
    2468           } else {
    2469             assert (dj<1.0e-2);
    2470             dj = CoinMin(dj,0.0);
     2432            if (numberBad && modDj[iSequence]) {
     2433              double bad = modDj[iSequence];
     2434              if (dj + bad >= 0.0) {
     2435                numberBad--;
     2436                modDj[iSequence] = 0.0;
     2437                dj += bad;
     2438              } else {
     2439                modDj[iSequence] += dj;
     2440                dj = 0.0;
     2441              }
     2442            }
     2443#endif
     2444          } else {
     2445            assert(dj < 1.0e-2);
     2446            dj = CoinMin(dj, 0.0);
    24712447#ifdef ALLOW_BAD_DJS
    2472             if (numberBad&&modDj[iSequence]) {
    2473               double bad=modDj[iSequence];
    2474               if (dj+bad<=0.0) {
    2475                 numberBad--;
    2476                 modDj[iSequence]=0.0;
    2477                 dj += bad;
    2478               } else {
    2479                 modDj[iSequence]+=dj;
    2480                 dj =0.0;
    2481               }
    2482             }
    2483 #endif
    2484           }
    2485         } else if (iStatus<6) {
    2486           assert (fabs(dj)<1.0e-4);
    2487           dj = 0.0;
    2488         }
    2489         abcDj_[iSequence]=dj;
     2448            if (numberBad && modDj[iSequence]) {
     2449              double bad = modDj[iSequence];
     2450              if (dj + bad <= 0.0) {
     2451                numberBad--;
     2452                modDj[iSequence] = 0.0;
     2453                dj += bad;
     2454              } else {
     2455                modDj[iSequence] += dj;
     2456                dj = 0.0;
     2457              }
     2458            }
     2459#endif
     2460          }
     2461        } else if (iStatus < 6) {
     2462          assert(fabs(dj) < 1.0e-4);
     2463          dj = 0.0;
     2464        }
     2465        abcDj_[iSequence] = dj;
    24902466      }
    24912467      // do basis
    2492       if (direction>0.0) {
    2493         if (upperBasic_[iRow]>lowerBasic_[iRow])
    2494           setInternalStatus(iRow,atLowerBound);
    2495         else
    2496           setInternalStatus(iRow,isFixed);
    2497         solutionSaved_[iRow]=abcLower_[iRow];
    2498         abcSolution_[iRow]=abcLower_[iRow];
     2468      if (direction > 0.0) {
     2469        if (upperBasic_[iRow] > lowerBasic_[iRow])
     2470          setInternalStatus(iRow, atLowerBound);
     2471        else
     2472          setInternalStatus(iRow, isFixed);
     2473        solutionSaved_[iRow] = abcLower_[iRow];
     2474        abcSolution_[iRow] = abcLower_[iRow];
    24992475      } else {
    2500         if (upperBasic_[iRow]>lowerBasic_[iRow])
    2501           setInternalStatus(iRow,atUpperBound);
    2502         else
    2503           setInternalStatus(iRow,isFixed);
    2504         solutionSaved_[iRow]=abcUpper_[iRow];
    2505         abcSolution_[iRow]=abcUpper_[iRow];
    2506       }
    2507       setInternalStatus(whichColumn,basic);
    2508       abcPivotVariable_[iRow]=whichColumn;
     2476        if (upperBasic_[iRow] > lowerBasic_[iRow])
     2477          setInternalStatus(iRow, atUpperBound);
     2478        else
     2479          setInternalStatus(iRow, isFixed);
     2480        solutionSaved_[iRow] = abcUpper_[iRow];
     2481        abcSolution_[iRow] = abcUpper_[iRow];
     2482      }
     2483      setInternalStatus(whichColumn, basic);
     2484      abcPivotVariable_[iRow] = whichColumn;
    25092485      nBasic++;
    25102486      // mark rows
    2511       for (CoinBigIndex j=columnStart[whichColumn];j<columnStart[whichColumn+1];j++) {
    2512         int jRow=row[j];
    2513         abcDj_[jRow]=1.0;
     2487      for (CoinBigIndex j = columnStart[whichColumn]; j < columnStart[whichColumn + 1]; j++) {
     2488        int jRow = row[j];
     2489        abcDj_[jRow] = 1.0;
    25142490      }
    25152491    }
    25162492#ifdef ALLOW_BAD_DJS
    2517     CoinAbcMemset0(modDj+maximumAbcNumberRows_,numberColumns_);
     2493    CoinAbcMemset0(modDj + maximumAbcNumberRows_, numberColumns_);
    25182494#endif
    25192495    setAvailableArray(iVector);
    25202496    setAvailableArray(iVector2);
    2521 #if ABC_NORMAL_DEBUG>0
    2522     printf("dual crash put %d in basis\n",nBasic);
     2497#if ABC_NORMAL_DEBUG > 0
     2498    printf("dual crash put %d in basis\n", nBasic);
    25232499#endif
    25242500  } else {
    2525     assert ((stateOfProblem_&VALUES_PASS2)!=0);
     2501    assert((stateOfProblem_ & VALUES_PASS2) != 0);
    25262502    // The idea is to put as many likely variables into basis as possible
    2527     int n=0;
    2528     int iVector=getAvailableArray();
    2529     int * index=usefulArray_[iVector].getIndices();
    2530     double * array = usefulArray_[iVector].denseVector();
    2531     int iVector2=getAvailableArray();
    2532     int * index2=usefulArray_[iVector].getIndices();
    2533     for (int iSequence=0;iSequence<numberTotal_;iSequence++) {
     2503    int n = 0;
     2504    int iVector = getAvailableArray();
     2505    int *index = usefulArray_[iVector].getIndices();
     2506    double *array = usefulArray_[iVector].denseVector();
     2507    int iVector2 = getAvailableArray();
     2508    int *index2 = usefulArray_[iVector].getIndices();
     2509    for (int iSequence = 0; iSequence < numberTotal_; iSequence++) {
    25342510      double dj = djSaved_[iSequence];
    25352511      double value = solution_[iSequence];
    25362512      double lower = abcLower_[iSequence];
    25372513      double upper = abcUpper_[iSequence];
    2538       double gapUp=CoinMin(1.0e3,upper-value);
    2539       assert (gapUp>=-1.0e-3);
    2540       gapUp=CoinMax(gapUp,0.0);
    2541       double gapDown=CoinMin(1.0e3,value-lower);
    2542       assert (gapDown>=-1.0e-3);
    2543       gapDown=CoinMax(gapDown,0.0);
    2544       double measure = (CoinMin(gapUp,gapDown)+1.0e-6)/(fabs(dj)+1.0e-6);
    2545       if (gapUp<primalTolerance_*10.0&&dj<dualTolerance_) {
    2546         // set to ub
    2547         setInternalStatus(iSequence,atUpperBound);
    2548         solutionSaved_[iSequence]=abcUpper_[iSequence];
    2549         abcSolution_[iSequence]=abcUpper_[iSequence];
    2550       } else if (gapDown<primalTolerance_*10.0&&dj>-dualTolerance_) {
    2551         // set to lb
    2552         setInternalStatus(iSequence,atLowerBound);
    2553         solutionSaved_[iSequence]=abcLower_[iSequence];
    2554         abcSolution_[iSequence]=abcLower_[iSequence];
    2555       } else if (upper>lower) {
    2556         // set to nearest
    2557         if (gapUp<gapDown) {
    2558           // set to ub
    2559           setInternalStatus(iSequence,atUpperBound);
    2560           solutionSaved_[iSequence]=abcUpper_[iSequence];
    2561           abcSolution_[iSequence]=abcUpper_[iSequence];
    2562         } else {
    2563           // set to lb
    2564           setInternalStatus(iSequence,atLowerBound);
    2565           solutionSaved_[iSequence]=abcLower_[iSequence];
    2566           abcSolution_[iSequence]=abcLower_[iSequence];
    2567         }
    2568         array[n]=-measure;
    2569         index[n++]=iSequence;
     2514      double gapUp = CoinMin(1.0e3, upper - value);
     2515      assert(gapUp >= -1.0e-3);
     2516      gapUp = CoinMax(gapUp, 0.0);
     2517      double gapDown = CoinMin(1.0e3, value - lower);
     2518      assert(gapDown >= -1.0e-3);
     2519      gapDown = CoinMax(gapDown, 0.0);
     2520      double measure = (CoinMin(gapUp, gapDown) + 1.0e-6) / (fabs(dj) + 1.0e-6);
     2521      if (gapUp < primalTolerance_ * 10.0 && dj < dualTolerance_) {
     2522        // set to ub
     2523        setInternalStatus(iSequence, atUpperBound);
     2524        solutionSaved_[iSequence] = abcUpper_[iSequence];
     2525        abcSolution_[iSequence] = abcUpper_[iSequence];
     2526      } else if (gapDown < primalTolerance_ * 10.0 && dj > -dualTolerance_) {
     2527        // set to lb
     2528        setInternalStatus(iSequence, atLowerBound);
     2529        solutionSaved_[iSequence] = abcLower_[iSequence];
     2530        abcSolution_[iSequence] = abcLower_[iSequence];
     2531      } else if (upper > lower) {
     2532        // set to nearest
     2533        if (gapUp < gapDown) {
     2534          // set to ub
     2535          setInternalStatus(iSequence, atUpperBound);
     2536          solutionSaved_[iSequence] = abcUpper_[iSequence];
     2537          abcSolution_[iSequence] = abcUpper_[iSequence];
     2538        } else {
     2539          // set to lb
     2540          setInternalStatus(iSequence, atLowerBound);
     2541          solutionSaved_[iSequence] = abcLower_[iSequence];
     2542          abcSolution_[iSequence] = abcLower_[iSequence];
     2543        }
     2544        array[n] = -measure;
     2545        index[n++] = iSequence;
    25702546      }
    25712547    }
    25722548    // set slacks basic
    2573     memset(internalStatus_,6,numberRows_);
    2574     CoinSort_2(solution_,solution_+n,index);
    2575     CoinAbcMemset0(array,n);
    2576     for (int i=0;i<numberRows_;i++)
    2577       index2[i]=0;
     2549    memset(internalStatus_, 6, numberRows_);
     2550    CoinSort_2(solution_, solution_ + n, index);
     2551    CoinAbcMemset0(array, n);
     2552    for (int i = 0; i < numberRows_; i++)
     2553      index2[i] = 0;
    25782554    // first put all possible slacks in
    2579     int n2=0;
    2580     for (int i=0;i<n;i++) {
    2581       int iSequence=index[i];
    2582       if (iSequence<numberRows_) {
    2583         index2[iSequence]=numberRows_;
     2555    int n2 = 0;
     2556    for (int i = 0; i < n; i++) {
     2557      int iSequence = index[i];
     2558      if (iSequence < numberRows_) {
     2559        index2[iSequence] = numberRows_;
    25842560      } else {
    2585         index[n2++]=iSequence;
    2586       }
    2587     }
    2588     n=n2;
    2589     int numberIn=0;
    2590     const CoinBigIndex * columnStart = abcMatrix_->getPackedMatrix()->getVectorStarts()-
    2591       maximumAbcNumberRows_;
     2561        index[n2++] = iSequence;
     2562      }
     2563    }
     2564    n = n2;
     2565    int numberIn = 0;
     2566    const CoinBigIndex *columnStart = abcMatrix_->getPackedMatrix()->getVectorStarts() - maximumAbcNumberRows_;
    25922567    //const int * columnLength = abcMatrix_->getPackedMatrix()->getVectorLengths();
    2593     const int * row = abcMatrix_->getPackedMatrix()->getIndices();
     2568    const int *row = abcMatrix_->getPackedMatrix()->getIndices();
    25942569    if (!abcMatrix_->gotRowCopy())
    25952570      abcMatrix_->createRowCopy();
    25962571    //const CoinBigIndex * rowStart = abcMatrix_->rowStart();
    25972572    //const CoinBigIndex * rowEnd = abcMatrix_->rowEnd();
    2598     for (int i=0;i<n;i++) {
    2599       int iSequence=index[i];
    2600       int bestRow=-1;
    2601       int bestCount=numberRows_+1;
    2602       for (CoinBigIndex j=columnStart[iSequence];j<columnStart[iSequence+1];j++) {
    2603         int iRow=row[j];
    2604     if (!abcMatrix_->gotRowCopy())
    2605       abcMatrix_->createRowCopy();
    2606     const CoinBigIndex * rowStart = abcMatrix_->rowStart();
    2607     const CoinBigIndex * rowEnd = abcMatrix_->rowEnd();
    2608         if (!index2[iRow]) {
    2609           int length=rowEnd[iRow]-rowStart[iRow];
    2610           if (length<bestCount) {
    2611             bestCount=length;
    2612             bestRow=iRow;
    2613           }
    2614         }
    2615       }
    2616       if (bestRow>=0) {
    2617         numberIn++;
    2618         for (CoinBigIndex j=columnStart[iSequence];j<columnStart[iSequence+1];j++) {
    2619           int iRow=row[j];
    2620           index2[iRow]++;
    2621         }
    2622         setInternalStatus(iSequence,basic);
    2623         abcPivotVariable_[bestRow]=iSequence;
    2624         double dj = djSaved_[bestRow];
    2625         double value = solution_[bestRow];
    2626         double lower = abcLower_[bestRow];
    2627         double upper = abcUpper_[bestRow];
    2628         double gapUp=CoinMax(CoinMin(1.0e3,upper-value),0.0);
    2629         double gapDown=CoinMax(CoinMin(1.0e3,value-lower),0.0);
    2630         //double measure = (CoinMin(gapUp,gapDown)+1.0e-6)/(fabs(dj)+1.0e-6);
    2631         if (gapUp<primalTolerance_*10.0&&dj<dualTolerance_) {
    2632           // set to ub
    2633           setInternalStatus(bestRow,atUpperBound);
    2634           solutionSaved_[bestRow]=abcUpper_[bestRow];
    2635           abcSolution_[bestRow]=abcUpper_[bestRow];
    2636         } else if (gapDown<primalTolerance_*10.0&&dj>-dualTolerance_) {
    2637           // set to lb
    2638           setInternalStatus(bestRow,atLowerBound);
    2639           solutionSaved_[bestRow]=abcLower_[bestRow];
    2640           abcSolution_[bestRow]=abcLower_[bestRow];
    2641         } else if (upper>lower) {
    2642           // set to nearest
    2643           if (gapUp<gapDown) {
    2644             // set to ub
    2645             setInternalStatus(bestRow,atUpperBound);
    2646             solutionSaved_[bestRow]=abcUpper_[bestRow];
    2647             abcSolution_[bestRow]=abcUpper_[bestRow];
    2648           } else {
    2649             // set to lb
    2650             setInternalStatus(bestRow,atLowerBound);
    2651             solutionSaved_[bestRow]=abcLower_[bestRow];
    2652             abcSolution_[bestRow]=abcLower_[bestRow];
    2653           }
    2654         }
    2655       }
    2656     }
    2657 #if ABC_NORMAL_DEBUG>0
    2658     printf("Idiot crash put %d in basis\n",numberIn);
     2573    for (int i = 0; i < n; i++) {
     2574      int iSequence = index[i];
     2575      int bestRow = -1;
     2576      int bestCount = numberRows_ + 1;
     2577      for (CoinBigIndex j = columnStart[iSequence]; j < columnStart[iSequence + 1]; j++) {
     2578        int iRow = row[j];
     2579        if (!abcMatrix_->gotRowCopy())
     2580          abcMatrix_->createRowCopy();
     2581        const CoinBigIndex *rowStart = abcMatrix_->rowStart();
     2582        const CoinBigIndex *rowEnd = abcMatrix_->rowEnd();
     2583        if (!index2[iRow]) {
     2584          int length = rowEnd[iRow] - rowStart[iRow];
     2585          if (length < bestCount) {
     2586            bestCount = length;
     2587            bestRow = iRow;
     2588          }
     2589        }
     2590      }
     2591      if (bestRow >= 0) {
     2592        numberIn++;
     2593        for (CoinBigIndex j = columnStart[iSequence]; j < columnStart[iSequence + 1]; j++) {
     2594          int iRow = row[j];
     2595          index2[iRow]++;
     2596        }
     2597        setInternalStatus(iSequence, basic);
     2598        abcPivotVariable_[bestRow] = iSequence;
     2599        double dj = djSaved_[bestRow];
     2600        double value = solution_[bestRow];
     2601        double lower = abcLower_[bestRow];
     2602        double upper = abcUpper_[bestRow];
     2603        double gapUp = CoinMax(CoinMin(1.0e3, upper - value), 0.0);
     2604        double gapDown = CoinMax(CoinMin(1.0e3, value - lower), 0.0);
     2605        //double measure = (CoinMin(gapUp,gapDown)+1.0e-6)/(fabs(dj)+1.0e-6);
     2606        if (gapUp < primalTolerance_ * 10.0 && dj < dualTolerance_) {
     2607          // set to ub
     2608          setInternalStatus(bestRow, atUpperBound);
     2609          solutionSaved_[bestRow] = abcUpper_[bestRow];
     2610          abcSolution_[bestRow] = abcUpper_[bestRow];
     2611        } else if (gapDown < primalTolerance_ * 10.0 && dj > -dualTolerance_) {
     2612          // set to lb
     2613          setInternalStatus(bestRow, atLowerBound);
     2614          solutionSaved_[bestRow] = abcLower_[bestRow];
     2615          abcSolution_[bestRow] = abcLower_[bestRow];
     2616        } else if (upper > lower) {
     2617          // set to nearest
     2618          if (gapUp < gapDown) {
     2619            // set to ub
     2620            setInternalStatus(bestRow, atUpperBound);
     2621            solutionSaved_[bestRow] = abcUpper_[bestRow];
     2622            abcSolution_[bestRow] = abcUpper_[bestRow];
     2623          } else {
     2624            // set to lb
     2625            setInternalStatus(bestRow, atLowerBound);
     2626            solutionSaved_[bestRow] = abcLower_[bestRow];
     2627            abcSolution_[bestRow] = abcLower_[bestRow];
     2628          }
     2629        }
     2630      }
     2631    }
     2632#if ABC_NORMAL_DEBUG > 0
     2633    printf("Idiot crash put %d in basis\n", numberIn);
    26592634#endif
    26602635    setAvailableArray(iVector);
    26612636    setAvailableArray(iVector2);
    2662     delete [] solution_;
    2663     solution_=NULL;
     2637    delete[] solution_;
     2638    solution_ = NULL;
    26642639  }
    26652640}
     
    26682643   2 bit set - don't bother staying triangular
    26692644*/
    2670 void
    2671 AbcSimplex::putStuffInBasis(int type)
     2645void AbcSimplex::putStuffInBasis(int type)
    26722646{
    26732647  int i;
    2674   for (i=0;i<numberRows_;i++) {
    2675     if (getInternalStatus(i)!=basic)
     2648  for (i = 0; i < numberRows_; i++) {
     2649    if (getInternalStatus(i) != basic)
    26762650      break;
    26772651  }
    2678   if (i<numberRows_&&(type&1)==0)
     2652  if (i < numberRows_ && (type & 1) == 0)
    26792653    return;
    2680   int iVector=getAvailableArray();
     2654  int iVector = getAvailableArray();
    26812655  // Column part is mustColumnIn
    2682   int * COIN_RESTRICT mustRowOut = usefulArray_[iVector].getIndices();
     2656  int *COIN_RESTRICT mustRowOut = usefulArray_[iVector].getIndices();
    26832657  if (!abcMatrix_->gotRowCopy())
    26842658    abcMatrix_->createRowCopy();
    2685   const double * elementByRow = abcMatrix_->rowElements();
    2686   const CoinBigIndex * rowStart = abcMatrix_->rowStart();
    2687   const CoinBigIndex * rowEnd = abcMatrix_->rowEnd();
    2688   const int * column = abcMatrix_->rowColumns();
    2689   for (int i=0;i<numberTotal_;i++)
    2690     mustRowOut[i]=-1;
    2691   int nPossible=0;
     2659  const double *elementByRow = abcMatrix_->rowElements();
     2660  const CoinBigIndex *rowStart = abcMatrix_->rowStart();
     2661  const CoinBigIndex *rowEnd = abcMatrix_->rowEnd();
     2662  const int *column = abcMatrix_->rowColumns();
     2663  for (int i = 0; i < numberTotal_; i++)
     2664    mustRowOut[i] = -1;
     2665  int nPossible = 0;
    26922666  // find equality rows with effective nonzero rhs
    2693   for (int iRow=0;iRow<numberRows_;iRow++) {
    2694     if (abcUpper_[iRow]>abcLower_[iRow]||getInternalStatus(iRow)!=basic) {
    2695       mustRowOut[iRow]=-2;
     2667  for (int iRow = 0; iRow < numberRows_; iRow++) {
     2668    if (abcUpper_[iRow] > abcLower_[iRow] || getInternalStatus(iRow) != basic) {
     2669      mustRowOut[iRow] = -2;
    26962670      continue;
    26972671    }
    2698     int chooseColumn[2]={-1,-1};
    2699     for (CoinBigIndex j=rowStart[iRow];j<rowEnd[iRow];j++) {
    2700       int iColumn=column[j];
    2701       if (elementByRow[j]>0.0) {
    2702         if (chooseColumn[0]==-1)
    2703           chooseColumn[0]=iColumn;
    2704         else
    2705           chooseColumn[0]=-2;
     2672    int chooseColumn[2] = { -1, -1 };
     2673    for (CoinBigIndex j = rowStart[iRow]; j < rowEnd[iRow]; j++) {
     2674      int iColumn = column[j];
     2675      if (elementByRow[j] > 0.0) {
     2676        if (chooseColumn[0] == -1)
     2677          chooseColumn[0] = iColumn;
     2678        else
     2679          chooseColumn[0] = -2;
    27062680      } else {
    2707         if (chooseColumn[1]==-1)
    2708           chooseColumn[1]=iColumn;
    2709         else
    2710           chooseColumn[1]=-2;
    2711       }
    2712     }
    2713     for (int iTry=0;iTry<2;iTry++) {
    2714       int jColumn=chooseColumn[iTry];
    2715       if (jColumn>=0&&getInternalStatus(jColumn)!=basic) {
    2716         // see if has to be basic
    2717         double lowerValue=-abcUpper_[iRow]; // check swap
    2718         double upperValue=-abcLower_[iRow];
    2719         int lowerInf=0;
    2720         int upperInf=0;
    2721         double alpha=0.0;
    2722         for (CoinBigIndex j=rowStart[iRow];j<rowEnd[iRow];j++) {
    2723           int iColumn=column[j];
    2724           if (iColumn!=jColumn) {
    2725             if (abcLower_[iColumn]>-1.0e20)
    2726               lowerValue -= abcLower_[iColumn]*elementByRow[j];
    2727             else
    2728               lowerInf ++;
    2729             if (abcUpper_[iColumn]<1.0e20)
    2730               upperValue -= abcUpper_[iColumn]*elementByRow[j];
    2731             else
    2732               upperInf ++;
    2733           } else {
    2734             alpha=elementByRow[j];
    2735           }
    2736         }
    2737         // find values column must lie between (signs again)
    2738         if (upperInf)
    2739           upperValue=COIN_DBL_MAX;
    2740         else
    2741           upperValue /=alpha;
    2742         if (lowerInf)
    2743           lowerValue=-COIN_DBL_MAX;
    2744         else
    2745           lowerValue /=alpha;
    2746         if (iTry) {
    2747           // swap
    2748           double temp=lowerValue;
    2749           lowerValue=upperValue;
    2750           upperValue=temp;
    2751         }
    2752         if (lowerValue>abcLower_[jColumn]+10.0*primalTolerance_&&
    2753             upperValue<abcUpper_[jColumn]-10.0*primalTolerance_) {
    2754           nPossible++;
    2755           if (mustRowOut[jColumn]>=0) {
    2756             // choose one ???
    2757             //printf("Column %d already selected on row %d now on %d\n",
    2758             //     jColumn,mustRowOut[jColumn],iRow);
    2759             continue;
    2760           }
    2761           mustRowOut[jColumn]=iRow;
    2762           mustRowOut[iRow]=jColumn;
    2763         }
     2681        if (chooseColumn[1] == -1)
     2682          chooseColumn[1] = iColumn;
     2683        else
     2684          chooseColumn[1] = -2;
     2685      }
     2686    }
     2687    for (int iTry = 0; iTry < 2; iTry++) {
     2688      int jColumn = chooseColumn[iTry];
     2689      if (jColumn >= 0 && getInternalStatus(jColumn) != basic) {
     2690        // see if has to be basic
     2691        double lowerValue = -abcUpper_[iRow]; // check swap
     2692        double upperValue = -abcLower_[iRow];
     2693        int lowerInf = 0;
     2694        int upperInf = 0;
     2695        double alpha = 0.0;
     2696        for (CoinBigIndex j = rowStart[iRow]; j < rowEnd[iRow]; j++) {
     2697          int iColumn = column[j];
     2698          if (iColumn != jColumn) {
     2699            if (abcLower_[iColumn] > -1.0e20)
     2700              lowerValue -= abcLower_[iColumn] * elementByRow[j];
     2701            else
     2702              lowerInf++;
     2703            if (abcUpper_[iColumn] < 1.0e20)
     2704              upperValue -= abcUpper_[iColumn] * elementByRow[j];
     2705            else
     2706              upperInf++;
     2707          } else {
     2708            alpha = elementByRow[j];
     2709          }
     2710        }
     2711        // find values column must lie between (signs again)
     2712        if (upperInf)
     2713          upperValue = COIN_DBL_MAX;
     2714        else
     2715          upperValue /= alpha;
     2716        if (lowerInf)
     2717          lowerValue = -COIN_DBL_MAX;
     2718        else
     2719          lowerValue /= alpha;
     2720        if (iTry) {
     2721          // swap
     2722          double temp = lowerValue;
     2723          lowerValue = upperValue;
     2724          upperValue = temp;
     2725        }
     2726        if (lowerValue > abcLower_[jColumn] + 10.0 * primalTolerance_ && upperValue < abcUpper_[jColumn] - 10.0 * primalTolerance_) {
     2727          nPossible++;
     2728          if (mustRowOut[jColumn] >= 0) {
     2729            // choose one ???
     2730            //printf("Column %d already selected on row %d now on %d\n",
     2731            //     jColumn,mustRowOut[jColumn],iRow);
     2732            continue;
     2733          }
     2734          mustRowOut[jColumn] = iRow;
     2735          mustRowOut[iRow] = jColumn;
     2736        }
    27642737      }
    27652738    }
    27662739  }
    27672740  if (nPossible) {
    2768 #if ABC_NORMAL_DEBUG>0
    2769     printf("%d possible candidates\n",nPossible);
    2770 #endif
    2771     if ((type&2)==0) {
     2741#if ABC_NORMAL_DEBUG > 0
     2742    printf("%d possible candidates\n", nPossible);
     2743#endif
     2744    if ((type & 2) == 0) {
    27722745      // triangular
    2773       int iVector2=getAvailableArray();
    2774       int * COIN_RESTRICT counts = usefulArray_[iVector2].getIndices();
    2775       CoinAbcMemset0(counts,numberRows_);
    2776       for (int iRow=0;iRow<numberRows_;iRow++) {
    2777         int n=0;
    2778         for (CoinBigIndex j=rowStart[iRow];j<rowEnd[iRow];j++) {
    2779           int iColumn=column[j];
    2780           if (getInternalStatus(iColumn)==basic)
    2781             n++;
    2782         }
    2783         counts[iRow]=n;
    2784       }
    2785       const CoinBigIndex * columnStart = abcMatrix_->getPackedMatrix()->getVectorStarts()
    2786         -maximumAbcNumberRows_;
    2787       const int * row = abcMatrix_->getPackedMatrix()->getIndices();
    2788       for (int iRow=0;iRow<numberRows_;iRow++) {
    2789         if (!counts[iRow]) {
    2790           int iColumn=mustRowOut[iRow];
    2791           if (iColumn>=0) {
    2792             setInternalStatus(iRow,isFixed);
    2793             solutionSaved_[iRow]=abcLower_[iRow];
    2794             setInternalStatus(iColumn,basic);
    2795             for (CoinBigIndex j=columnStart[iColumn];j<columnStart[iColumn+1];j++) {
    2796               int jRow=row[j];
    2797               counts[jRow]++;
    2798             }
    2799           }
    2800         }
     2746      int iVector2 = getAvailableArray();
     2747      int *COIN_RESTRICT counts = usefulArray_[iVector2].getIndices();
     2748      CoinAbcMemset0(counts, numberRows_);
     2749      for (int iRow = 0; iRow < numberRows_; iRow++) {
     2750        int n = 0;
     2751        for (CoinBigIndex j = rowStart[iRow]; j < rowEnd[iRow]; j++) {
     2752          int iColumn = column[j];
     2753          if (getInternalStatus(iColumn) == basic)
     2754            n++;
     2755        }
     2756        counts[iRow] = n;
     2757      }
     2758      const CoinBigIndex *columnStart = abcMatrix_->getPackedMatrix()->getVectorStarts()
     2759        - maximumAbcNumberRows_;
     2760      const int *row = abcMatrix_->getPackedMatrix()->getIndices();
     2761      for (int iRow = 0; iRow < numberRows_; iRow++) {
     2762        if (!counts[iRow]) {
     2763          int iColumn = mustRowOut[iRow];
     2764          if (iColumn >= 0) {
     2765            setInternalStatus(iRow, isFixed);
     2766            solutionSaved_[iRow] = abcLower_[iRow];
     2767            setInternalStatus(iColumn, basic);
     2768            for (CoinBigIndex j = columnStart[iColumn]; j < columnStart[iColumn + 1]; j++) {
     2769              int jRow = row[j];
     2770              counts[jRow]++;
     2771            }
     2772          }
     2773        }
    28012774      }
    28022775      setAvailableArray(iVector2);
    28032776    } else {
    28042777      // all
    2805       for (int iRow=0;iRow<numberRows_;iRow++) {
    2806         int iColumn=mustRowOut[iRow];
    2807         if (iColumn>=0) {
    2808           setInternalStatus(iRow,isFixed);
    2809           solutionSaved_[iRow]=abcLower_[iRow];
    2810           setInternalStatus(iColumn,basic);
    2811         }
     2778      for (int iRow = 0; iRow < numberRows_; iRow++) {
     2779        int iColumn = mustRowOut[iRow];
     2780        if (iColumn >= 0) {
     2781          setInternalStatus(iRow, isFixed);
     2782          solutionSaved_[iRow] = abcLower_[iRow];
     2783          setInternalStatus(iColumn, basic);
     2784        }
    28122785      }
    28132786    }
    28142787    // redo pivot array
    2815     int numberBasic=0;
    2816     for (int iSequence=0;iSequence<numberTotal_;iSequence++) {
    2817       if (getInternalStatus(iSequence)==basic)
    2818         abcPivotVariable_[numberBasic++]=iSequence;
    2819     }
    2820     assert (numberBasic==numberRows_);
     2788    int numberBasic = 0;
     2789    for (int iSequence = 0; iSequence < numberTotal_; iSequence++) {
     2790      if (getInternalStatus(iSequence) == basic)
     2791        abcPivotVariable_[numberBasic++] = iSequence;
     2792    }
     2793    assert(numberBasic == numberRows_);
    28212794  }
    28222795  setAvailableArray(iVector);
    28232796}
    28242797// Computes nonbasic cost and total cost
    2825 void
    2826 AbcSimplex::computeObjective ()
     2798void AbcSimplex::computeObjective()
    28272799{
    28282800  sumNonBasicCosts_ = 0.0;
    28292801  rawObjectiveValue_ = 0.0;
    28302802  for (int iSequence = 0; iSequence < numberTotal_; iSequence++) {
    2831     double value = abcSolution_[iSequence]*abcCost_[iSequence];
     2803    double value = abcSolution_[iSequence] * abcCost_[iSequence];
    28322804    rawObjectiveValue_ += value;
    2833     if (getInternalStatus(iSequence)!=basic)
     2805    if (getInternalStatus(iSequence) != basic)
    28342806      sumNonBasicCosts_ += value;
    28352807  }
     
    28372809}
    28382810// This sets largest infeasibility and most infeasible
    2839 void
    2840 AbcSimplex::checkPrimalSolution(bool justBasic)
    2841 {
    2842   rawObjectiveValue_ = CoinAbcInnerProduct(costBasic_,numberRows_,solutionBasic_);
    2843   //rawObjectiveValue_ += sumNonBasicCosts_; 
     2811void AbcSimplex::checkPrimalSolution(bool justBasic)
     2812{
     2813  rawObjectiveValue_ = CoinAbcInnerProduct(costBasic_, numberRows_, solutionBasic_);
     2814  //rawObjectiveValue_ += sumNonBasicCosts_;
    28442815  setClpSimplexObjectiveValue();
    28452816  // now look at primal solution
     
    28492820  double relaxedTolerance = primalTolerance_;
    28502821  // we can't really trust infeasibilities if there is primal error
    2851   double error = CoinMin(1.0e-2, CoinMax(largestPrimalError_,5.0*primalTolerance_));
     2822  double error = CoinMin(1.0e-2, CoinMax(largestPrimalError_, 5.0 * primalTolerance_));
    28522823  // allow tolerance at least slightly bigger than standard
    2853   relaxedTolerance = relaxedTolerance +  error;
     2824  relaxedTolerance = relaxedTolerance + error;
    28542825  sumOfRelaxedPrimalInfeasibilities_ = 0.0;
    2855   const double *  COIN_RESTRICT lowerBasic = lowerBasic_;
    2856   const double *  COIN_RESTRICT upperBasic = upperBasic_;
    2857   const double *  COIN_RESTRICT solutionBasic = solutionBasic_;
     2826  const double *COIN_RESTRICT lowerBasic = lowerBasic_;
     2827  const double *COIN_RESTRICT upperBasic = upperBasic_;
     2828  const double *COIN_RESTRICT solutionBasic = solutionBasic_;
    28582829  if (justBasic) {
    28592830    for (int iRow = 0; iRow < numberRows_; iRow++) {
    28602831      double infeasibility = 0.0;
    28612832      if (solutionBasic[iRow] > upperBasic[iRow]) {
    2862         infeasibility = solutionBasic[iRow] - upperBasic[iRow];
     2833        infeasibility = solutionBasic[iRow] - upperBasic[iRow];
    28632834      } else if (solutionBasic[iRow] < lowerBasic[iRow]) {
    2864         infeasibility = lowerBasic[iRow] - solutionBasic[iRow];
     2835        infeasibility = lowerBasic[iRow] - solutionBasic[iRow];
    28652836      }
    28662837      if (infeasibility > primalTolerance) {
    2867         sumPrimalInfeasibilities_ += infeasibility - primalTolerance_;
    2868         if (infeasibility > relaxedTolerance)
    2869           sumOfRelaxedPrimalInfeasibilities_ += infeasibility - relaxedTolerance;
    2870         numberPrimalInfeasibilities_ ++;
     2838        sumPrimalInfeasibilities_ += infeasibility - primalTolerance_;
     2839        if (infeasibility > relaxedTolerance)
     2840          sumOfRelaxedPrimalInfeasibilities_ += infeasibility - relaxedTolerance;
     2841        numberPrimalInfeasibilities_++;
    28712842      }
    28722843    }
     
    28752846      double infeasibility = 0.0;
    28762847      if (abcSolution_[iSequence] > abcUpper_[iSequence]) {
    2877         infeasibility = abcSolution_[iSequence] - abcUpper_[iSequence];
     2848        infeasibility = abcSolution_[iSequence] - abcUpper_[iSequence];
    28782849      } else if (abcSolution_[iSequence] < abcLower_[iSequence]) {
    2879         infeasibility = abcLower_[iSequence] - abcSolution_[iSequence];
     2850        infeasibility = abcLower_[iSequence] - abcSolution_[iSequence];
    28802851      }
    28812852      if (infeasibility > primalTolerance) {
    2882         //assert (getInternalStatus(iSequence)==basic);
    2883         sumPrimalInfeasibilities_ += infeasibility - primalTolerance_;
    2884         if (infeasibility > relaxedTolerance)
    2885           sumOfRelaxedPrimalInfeasibilities_ += infeasibility - relaxedTolerance;
    2886         numberPrimalInfeasibilities_ ++;
    2887       }
    2888     }
    2889   }
    2890 }
    2891 void
    2892 AbcSimplex::checkDualSolution()
    2893 {
    2894  
     2853        //assert (getInternalStatus(iSequence)==basic);
     2854        sumPrimalInfeasibilities_ += infeasibility - primalTolerance_;
     2855        if (infeasibility > relaxedTolerance)
     2856          sumOfRelaxedPrimalInfeasibilities_ += infeasibility - relaxedTolerance;
     2857        numberPrimalInfeasibilities_++;
     2858      }
     2859    }
     2860  }
     2861}
     2862void AbcSimplex::checkDualSolution()
     2863{
     2864
    28952865  sumDualInfeasibilities_ = 0.0;
    28962866  numberDualInfeasibilities_ = 0;
     
    29002870  bestPossibleImprovement_ = 0.0;
    29012871  // we can't really trust infeasibilities if there is dual error
    2902   double error = CoinMin(1.0e-2, CoinMax(largestDualError_,5.0*dualTolerance_));
     2872  double error = CoinMin(1.0e-2, CoinMax(largestDualError_, 5.0 * dualTolerance_));
    29032873  // allow tolerance at least slightly bigger than standard
    2904   double relaxedTolerance = currentDualTolerance_ +  error;
     2874  double relaxedTolerance = currentDualTolerance_ + error;
    29052875  // allow bigger tolerance for possible improvement
    29062876  double possTolerance = 5.0 * relaxedTolerance;
    29072877  sumOfRelaxedDualInfeasibilities_ = 0.0;
    2908   int numberNeedToMove=0;
     2878  int numberNeedToMove = 0;
    29092879  for (int iSequence = 0; iSequence < numberTotal_; iSequence++) {
    29102880    if (getInternalStatus(iSequence) != basic && !flagged(iSequence)) {
     
    29142884      double value = abcDj_[iSequence];
    29152885      if (distanceUp > primalTolerance_) {
    2916         // Check if "free"
    2917         if (distanceDown <= primalTolerance_) {
    2918           // should not be negative
    2919           if (value < 0.0) {
    2920             value = - value;
    2921             if (value > currentDualTolerance_) {
    2922               sumDualInfeasibilities_ += value - currentDualTolerance_;
    2923               if (value > possTolerance)
    2924                 bestPossibleImprovement_ += CoinMin(distanceUp, 1.0e10) * value;
    2925               if (value > relaxedTolerance)
    2926                 sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance;
    2927               numberDualInfeasibilities_ ++;
    2928             }
    2929           }
    2930         } else {
    2931           // free
    2932           value=fabs(value);
    2933           if (value > 1.0 * relaxedTolerance) {
    2934             numberSuperBasicWithDj++;
    2935             if (firstFreeDual < 0)
    2936               firstFreeDual = iSequence;
    2937           }
    2938           if (value > currentDualTolerance_||getInternalStatus(iSequence)!=AbcSimplex::isFree) {
    2939             numberNeedToMove++;
    2940             if (firstFreePrimal < 0)
    2941               firstFreePrimal = iSequence;
    2942             sumDualInfeasibilities_ += value - currentDualTolerance_;
    2943             if (value > possTolerance)
    2944               bestPossibleImprovement_ += CoinMin(distanceUp, 1.0e10) * value;
    2945             if (value > relaxedTolerance)
    2946               sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance;
    2947             numberDualInfeasibilities_ ++;
    2948           }
    2949         }
     2886        // Check if "free"
     2887        if (distanceDown <= primalTolerance_) {
     2888          // should not be negative
     2889          if (value < 0.0) {
     2890            value = -value;
     2891            if (value > currentDualTolerance_) {
     2892              sumDualInfeasibilities_ += value - currentDualTolerance_;
     2893              if (value > possTolerance)
     2894                bestPossibleImprovement_ += CoinMin(distanceUp, 1.0e10) * value;
     2895              if (value > relaxedTolerance)
     2896                sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance;
     2897              numberDualInfeasibilities_++;
     2898            }
     2899          }
     2900        } else {
     2901          // free
     2902          value = fabs(value);
     2903          if (value > 1.0 * relaxedTolerance) {
     2904            numberSuperBasicWithDj++;
     2905            if (firstFreeDual < 0)
     2906              firstFreeDual = iSequence;
     2907          }
     2908          if (value > currentDualTolerance_ || getInternalStatus(iSequence) != AbcSimplex::isFree) {
     2909            numberNeedToMove++;
     2910            if (firstFreePrimal < 0)
     2911              firstFreePrimal = iSequence;
     2912            sumDualInfeasibilities_ += value - currentDualTolerance_;
     2913            if (value > possTolerance)
     2914              bestPossibleImprovement_ += CoinMin(distanceUp, 1.0e10) * value;
     2915            if (value > relaxedTolerance)
     2916              sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance;
     2917            numberDualInfeasibilities_++;
     2918          }
     2919        }
    29502920      } else if (distanceDown > primalTolerance_) {
    2951         // should not be positive
    2952         if (value > 0.0) {
    2953           if (value > currentDualTolerance_) {
    2954             sumDualInfeasibilities_ += value - currentDualTolerance_;
    2955             if (value > possTolerance)
    2956               bestPossibleImprovement_ += value * CoinMin(distanceDown, 1.0e10);
    2957             if (value > relaxedTolerance)
    2958               sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance;
    2959             numberDualInfeasibilities_ ++;
    2960           }
    2961         }
    2962       }
    2963     }
    2964   }
    2965   numberDualInfeasibilitiesWithoutFree_ = numberDualInfeasibilities_-numberSuperBasicWithDj;
     2921        // should not be positive
     2922        if (value > 0.0) {
     2923          if (value > currentDualTolerance_) {
     2924            sumDualInfeasibilities_ += value - currentDualTolerance_;
     2925            if (value > possTolerance)
     2926              bestPossibleImprovement_ += value * CoinMin(distanceDown, 1.0e10);
     2927            if (value > relaxedTolerance)
     2928              sumOfRelaxedDualInfeasibilities_ += value - relaxedTolerance;
     2929            numberDualInfeasibilities_++;
     2930          }
     2931        }
     2932      }
     2933    }
     2934  }
     2935  numberDualInfeasibilitiesWithoutFree_ = numberDualInfeasibilities_ - numberSuperBasicWithDj;
    29662936  if (algorithm_ < 0 && firstFreeDual >= 0) {
    29672937    // dual
    29682938    firstFree_ = firstFreeDual;
    2969   } else if (numberSuperBasicWithDj||numberNeedToMove) {
     2939  } else if (numberSuperBasicWithDj || numberNeedToMove) {
    29702940    //(abcProgress_.lastIterationNumber(0) <= 0)) {
    29712941    firstFree_ = firstFreePrimal;
    29722942    if (!sumDualInfeasibilities_)
    2973       sumDualInfeasibilities_=1.0e-8;
     2943      sumDualInfeasibilities_ = 1.0e-8;
    29742944  }
    29752945}
    29762946/* This sets sum and number of infeasibilities (Dual and Primal) */
    2977 void
    2978 AbcSimplex::checkBothSolutions()
    2979 {
    2980     // old way
     2947void AbcSimplex::checkBothSolutions()
     2948{
     2949  // old way
    29812950  checkPrimalSolution(true);
    29822951  checkDualSolution();
     
    29852954  Unpacks one column of the matrix into indexed array
    29862955*/
    2987 void
    2988 AbcSimplex::unpack(CoinIndexedVector & rowArray, int sequence) const
    2989 {
    2990   abcMatrix_->unpack(rowArray,sequence);
     2956void AbcSimplex::unpack(CoinIndexedVector &rowArray, int sequence) const
     2957{
     2958  abcMatrix_->unpack(rowArray, sequence);
    29912959}
    29922960// Sets row pivot choice algorithm in dual
    2993 void
    2994 AbcSimplex::setDualRowPivotAlgorithm(AbcDualRowPivot & choice)
     2961void AbcSimplex::setDualRowPivotAlgorithm(AbcDualRowPivot &choice)
    29952962{
    29962963  delete abcDualRowPivot_;
     
    29992966}
    30002967// Sets column pivot choice algorithm in primal
    3001 void
    3002 AbcSimplex::setPrimalColumnPivotAlgorithm(AbcPrimalColumnPivot & choice)
     2968void AbcSimplex::setPrimalColumnPivotAlgorithm(AbcPrimalColumnPivot &choice)
    30032969{
    30042970  delete abcPrimalColumnPivot_;
     
    30062972  abcPrimalColumnPivot_->setModel(this);
    30072973}
    3008 void
    3009 AbcSimplex::setFactorization( AbcSimplexFactorization & factorization)
     2974void AbcSimplex::setFactorization(AbcSimplexFactorization &factorization)
    30102975{
    30112976  if (abcFactorization_)
     
    30132978  else
    30142979    abcFactorization_ = new AbcSimplexFactorization(factorization,
    3015                                           numberRows_);
     2980      numberRows_);
    30162981}
    30172982
    30182983// Swaps factorization
    30192984AbcSimplexFactorization *
    3020 AbcSimplex::swapFactorization( AbcSimplexFactorization * factorization)
    3021 {
    3022   AbcSimplexFactorization * swap = abcFactorization_;
     2985AbcSimplex::swapFactorization(AbcSimplexFactorization *factorization)
     2986{
     2987  AbcSimplexFactorization *swap = abcFactorization_;
    30232988  abcFactorization_ = factorization;
    30242989  return swap;
     
    30302995   with a presolve.  Returns non-zero if problem infeasible
    30312996*/
    3032 int
    3033 AbcSimplex::tightenPrimalBounds()
    3034 {
    3035   int tightenType=1;
    3036   if (maximumIterations()>=1000000&&maximumIterations()<1000010)
    3037     tightenType=maximumIterations()-1000000;
     2997int AbcSimplex::tightenPrimalBounds()
     2998{
     2999  int tightenType = 1;
     3000  if (maximumIterations() >= 1000000 && maximumIterations() < 1000010)
     3001    tightenType = maximumIterations() - 1000000;
    30383002  if (!tightenType)
    30393003    return 0;
    30403004  if (integerType_) {
    3041 #if ABC_NORMAL_DEBUG>0
     3005#if ABC_NORMAL_DEBUG > 0
    30423006    printf("Redo tighten to relax by 1 for integers (and don't be shocked by infeasibility)\n");
    30433007#endif
    30443008    return 0;
    30453009  }
    3046   // This needs to work on scaled matrix - then replace   
     3010  // This needs to work on scaled matrix - then replace
    30473011  // Get a row copy in standard format
    30483012  CoinPackedMatrix copy;
     
    30513015  copy.reverseOrderedCopyOf(*abcMatrix_->matrix());
    30523016  // get matrix data pointers
    3053   const int *  COIN_RESTRICT column = copy.getIndices();
    3054   const CoinBigIndex *  COIN_RESTRICT rowStart = copy.getVectorStarts();
    3055   const int *  COIN_RESTRICT rowLength = copy.getVectorLengths();
    3056   const double *  COIN_RESTRICT element = copy.getElements();
     3017  const int *COIN_RESTRICT column = copy.getIndices();
     3018  const CoinBigIndex *COIN_RESTRICT rowStart = copy.getVectorStarts();
     3019  const int *COIN_RESTRICT rowLength = copy.getVectorLengths();
     3020  const double *COIN_RESTRICT element = copy.getElements();
    30573021  int numberChanged = 1, iPass = 0;
    30583022  double large = largeValue(); // treat bounds > this as infinite
     
    30623026  int numberInfeasible = 0;
    30633027  int totalTightened = 0;
    3064  
     3028
    30653029  double tolerance = primalTolerance();
    3066  
    3067  
     3030
    30683031  // A copy of bounds is up at top
    30693032  translate(0); // move down
    3070  
     3033
    30713034#define MAXPASS 10
    3072  
     3035
    30733036  // Loop round seeing if we can tighten bounds
    30743037  // Would be faster to have a stack of possible rows
     
    30763039  int numberCheck = -1;
    30773040  // temp swap signs so can use existing code
    3078   double *  COIN_RESTRICT rowLower=abcLower_;
    3079   double *  COIN_RESTRICT rowUpper=abcUpper_;
    3080   for (int iRow=0;iRow<numberRows_;iRow++) {
    3081     double value=-rowLower[iRow];
    3082     rowLower[iRow]=-rowUpper[iRow];
    3083     rowUpper[iRow]=value;
     3041  double *COIN_RESTRICT rowLower = abcLower_;
     3042  double *COIN_RESTRICT rowUpper = abcUpper_;
     3043  for (int iRow = 0; iRow < numberRows_; iRow++) {
     3044    double value = -rowLower[iRow];
     3045    rowLower[iRow] = -rowUpper[iRow];
     3046    rowUpper[iRow] = value;
    30843047  }
    30853048  // Keep lower and upper for rows
    30863049  int whichArray[5];
    3087   for (int i=0;i<5;i++)
    3088     whichArray[i]=getAvailableArray();
    3089   double * COIN_RESTRICT minRhs = usefulArray_[whichArray[0]].denseVector();
    3090   double * COIN_RESTRICT maxRhs = usefulArray_[whichArray[1]].denseVector();
    3091   int * COIN_RESTRICT changedList = usefulArray_[whichArray[0]].getIndices();
    3092   int * COIN_RESTRICT changedListNext = usefulArray_[whichArray[1]].getIndices();
    3093   char * COIN_RESTRICT changed = reinterpret_cast<char*>(usefulArray_[whichArray[2]].getIndices());
     3050  for (int i = 0; i < 5; i++)
     3051    whichArray[i] = getAvailableArray();
     3052  double *COIN_RESTRICT minRhs = usefulArray_[whichArray[0]].denseVector();
     3053  double *COIN_RESTRICT maxRhs = usefulArray_[whichArray[1]].denseVector();
     3054  int *COIN_RESTRICT changedList = usefulArray_[whichArray[0]].getIndices();
     3055  int *COIN_RESTRICT changedListNext = usefulArray_[whichArray[1]].getIndices();
     3056  char *COIN_RESTRICT changed = reinterpret_cast< char * >(usefulArray_[whichArray[2]].getIndices());
    30943057  // -1 no infinite, -2 more than one infinite >=0 column
    3095   int * COIN_RESTRICT whichInfiniteDown = usefulArray_[whichArray[3]].getIndices();
    3096   int * COIN_RESTRICT whichInfiniteUp = usefulArray_[whichArray[3]].getIndices();
    3097   int numberToDoNext=0;
    3098   for (int iRow=0;iRow<numberRows_;iRow++) {
     3058  int *COIN_RESTRICT whichInfiniteDown = usefulArray_[whichArray[3]].getIndices();
     3059  int *COIN_RESTRICT whichInfiniteUp = usefulArray_[whichArray[3]].getIndices();
     3060  int numberToDoNext = 0;
     3061  for (int iRow = 0; iRow < numberRows_; iRow++) {
    30993062    if (rowLower[iRow] > -large || rowUpper[iRow] < large) {
    3100       changedListNext[numberToDoNext++]=iRow;
    3101       whichInfiniteDown[iRow]=-1;
    3102       whichInfiniteUp[iRow]=-1;
     3063      changedListNext[numberToDoNext++] = iRow;
     3064      whichInfiniteDown[iRow] = -1;
     3065      whichInfiniteUp[iRow] = -1;
    31033066    } else {
    3104       minRhs[iRow]=-COIN_DBL_MAX;
    3105       maxRhs[iRow]=COIN_DBL_MAX;
    3106       whichInfiniteDown[iRow]=-2;
    3107       whichInfiniteUp[iRow]=-2;
    3108     }
    3109   }
    3110   const int * COIN_RESTRICT row = abcMatrix_->matrix()->getIndices();
    3111   const CoinBigIndex * COIN_RESTRICT columnStart = abcMatrix_->matrix()->getVectorStarts();
    3112   const double * COIN_RESTRICT elementByColumn = abcMatrix_->matrix()->getElements();
    3113  
    3114   double *  COIN_RESTRICT columnLower=abcLower_+maximumAbcNumberRows_;
    3115   double *  COIN_RESTRICT columnUpper=abcUpper_+maximumAbcNumberRows_;
    3116   while(numberChanged > numberCheck) {
    3117     int numberToDo=numberToDoNext;
    3118     numberToDoNext=0;
    3119     int * COIN_RESTRICT temp=changedList;
    3120     changedList=changedListNext;
    3121     changedListNext=temp;
    3122     CoinAbcMemset0(changed,numberRows_);
    3123    
     3067      minRhs[iRow] = -COIN_DBL_MAX;
     3068      maxRhs[iRow] = COIN_DBL_MAX;
     3069      whichInfiniteDown[iRow] = -2;
     3070      whichInfiniteUp[iRow] = -2;
     3071    }
     3072  }
     3073  const int *COIN_RESTRICT row = abcMatrix_->matrix()->getIndices();
     3074  const CoinBigIndex *COIN_RESTRICT columnStart = abcMatrix_->matrix()->getVectorStarts();
     3075  const double *COIN_RESTRICT elementByColumn = abcMatrix_->matrix()->getElements();
     3076
     3077  double *COIN_RESTRICT columnLower = abcLower_ + maximumAbcNumberRows_;
     3078  double *COIN_RESTRICT columnUpper = abcUpper_ + maximumAbcNumberRows_;
     3079  while (numberChanged > numberCheck) {
     3080    int numberToDo = numberToDoNext;
     3081    numberToDoNext = 0;
     3082    int *COIN_RESTRICT temp = changedList;
     3083    changedList = changedListNext;
     3084    changedListNext = temp;
     3085    CoinAbcMemset0(changed, numberRows_);
     3086
    31243087    numberChanged = 0; // Bounds tightened this pass
    3125    
    3126     if (iPass == MAXPASS) break;
     3088
     3089    if (iPass == MAXPASS)
     3090      break;
    31273091    iPass++;
    3128     for (int k=0;k<numberToDo;k++) {
    3129       int iRow=changedList[k];
     3092    for (int k = 0; k < numberToDo; k++) {
     3093      int iRow = changedList[k];
    31303094      // possible row
    31313095      int infiniteUpper = 0;
    31323096      int infiniteLower = 0;
    3133       int firstInfiniteUpper=-1;
    3134       int firstInfiniteLower=-1;
     3097      int firstInfiniteUpper = -1;
     3098      int firstInfiniteLower = -1;
    31353099      double maximumUp = 0.0;
    31363100      double maximumDown = 0.0;
     
    31403104      CoinBigIndex j;
    31413105      // Compute possible lower and upper ranges
    3142      
     3106
    31433107      for (j = rStart; j < rEnd; ++j) {
    3144         double value = element[j];
    3145         int iColumn = column[j];
    3146         if (value > 0.0) {
    3147           if (columnUpper[iColumn] >= large) {
    3148             firstInfiniteUpper=iColumn;
    3149             ++infiniteUpper;
    3150           } else {
    3151             maximumUp += columnUpper[iColumn] * value;
    3152           }
    3153           if (columnLower[iColumn] <= -large) {
    3154             firstInfiniteLower=iColumn;
    3155             ++infiniteLower;
    3156           } else {
    3157             maximumDown += columnLower[iColumn] * value;
    3158           }
    3159         } else if (value < 0.0) {
    3160           if (columnUpper[iColumn] >= large) {
    3161             firstInfiniteLower=iColumn;
    3162             ++infiniteLower;
    3163           } else {
    3164             maximumDown += columnUpper[iColumn] * value;
    3165           }
    3166           if (columnLower[iColumn] <= -large) {
    3167             firstInfiniteUpper=iColumn;
    3168             ++infiniteUpper;
    3169           } else {
    3170             maximumUp += columnLower[iColumn] * value;
    3171           }
    3172         }
     3108        double value = element[j];
     3109        int iColumn = column[j];
     3110        if (value > 0.0) {
     3111          if (columnUpper[iColumn] >= large) {
     3112            firstInfiniteUpper = iColumn;
     3113            ++infiniteUpper;
     3114          } else {
     3115            maximumUp += columnUpper[iColumn] * value;
     3116          }
     3117          if (columnLower[iColumn] <= -large) {
     3118            firstInfiniteLower = iColumn;
     3119            ++infiniteLower;
     3120          } else {
     3121            maximumDown += columnLower[iColumn] * value;
     3122          }
     3123        } else if (value < 0.0) {
     3124          if (columnUpper[iColumn] >= large) {
     3125            firstInfiniteLower = iColumn;
     3126            ++infiniteLower;
     3127          } else {
     3128            maximumDown += columnUpper[iColumn] * value;
     3129          }
     3130          if (columnLower[iColumn] <= -large) {
     3131            firstInfiniteUpper = iColumn;
     3132            ++infiniteUpper;
     3133          } else {
     3134            maximumUp += columnLower[iColumn] * value;
     3135          }
     3136        }
    31733137      }
    31743138      // Build in a margin of error
     
    31773141      double maxUp = maximumUp + infiniteUpper * 1.0e31;
    31783142      double maxDown = maximumDown - infiniteLower * 1.0e31;
    3179       minRhs[iRow]=infiniteLower ? -COIN_DBL_MAX : maximumDown;
    3180       maxRhs[iRow]=infiniteUpper ? COIN_DBL_MAX : maximumUp;
    3181       if (infiniteLower==0)
    3182         whichInfiniteDown[iRow]=-1;
    3183       else if (infiniteLower==1)
    3184         whichInfiniteDown[iRow]=firstInfiniteLower;
     3143      minRhs[iRow] = infiniteLower ? -COIN_DBL_MAX : maximumDown;
     3144      maxRhs[iRow] = infiniteUpper ? COIN_DBL_MAX : maximumUp;
     3145      if (infiniteLower == 0)
     3146        whichInfiniteDown[iRow] = -1;
     3147      else if (infiniteLower == 1)
     3148        whichInfiniteDown[iRow] = firstInfiniteLower;
    31853149      else
    3186         whichInfiniteDown[iRow]=-2;
    3187       if (infiniteUpper==0)
    3188         whichInfiniteUp[iRow]=-1;
    3189       else if (infiniteUpper==1)
    3190         whichInfiniteUp[iRow]=firstInfiniteUpper;
     3150        whichInfiniteDown[iRow] = -2;
     3151      if (infiniteUpper == 0)
     3152        whichInfiniteUp[iRow] = -1;
     3153      else if (infiniteUpper == 1)
     3154        whichInfiniteUp[iRow] = firstInfiniteUpper;
    31913155      else
    3192         whichInfiniteUp[iRow]=-2;
    3193       if (maxUp <= rowUpper[iRow] + tolerance &&
    3194           maxDown >= rowLower[iRow] - tolerance) {
    3195        
    3196         // Row is redundant - make totally free
    3197         // NO - can't do this for postsolve
    3198         // rowLower[iRow]=-COIN_DBL_MAX;
    3199         // rowUpper[iRow]=COIN_DBL_MAX;
    3200         //printf("Redundant row in presolveX %d\n",iRow);
    3201        
     3156        whichInfiniteUp[iRow] = -2;
     3157      if (maxUp <= rowUpper[iRow] + tolerance && maxDown >= rowLower[iRow] - tolerance) {
     3158
     3159        // Row is redundant - make totally free
     3160        // NO - can't do this for postsolve
     3161        // rowLower[iRow]=-COIN_DBL_MAX;
     3162        // rowUpper[iRow]=COIN_DBL_MAX;
     3163        //printf("Redundant row in presolveX %d\n",iRow);
     3164
    32023165      } else {
    3203         if (maxUp < rowLower[iRow] - 100.0 * tolerance ||
    3204             maxDown > rowUpper[iRow] + 100.0 * tolerance) {
    3205           // problem is infeasible - exit at once
    3206           numberInfeasible++;
    3207           break;
    3208         }
    3209         double lower = rowLower[iRow];
    3210         double upper = rowUpper[iRow];
    3211         for (j = rStart; j < rEnd; ++j) {
    3212           double value = element[j];
    3213           int iColumn = column[j];
    3214           double nowLower = columnLower[iColumn];
    3215           double nowUpper = columnUpper[iColumn];
    3216           if (value > 0.0) {
    3217             // positive value
    3218             if (lower > -large) {
    3219               if (!infiniteUpper) {
    3220                 assert(nowUpper < large2);
    3221                 newBound = nowUpper +
    3222                   (lower - maximumUp) / value;
    3223                 // relax if original was large
    3224                 if (fabs(maximumUp) > 1.0e8)
    3225                   newBound -= 1.0e-12 * fabs(maximumUp);
    3226               } else if (infiniteUpper == 1 && nowUpper > large) {
    3227                 newBound = (lower - maximumUp) / value;
    3228                 // relax if original was large
    3229                 if (fabs(maximumUp) > 1.0e8)
    3230                   newBound -= 1.0e-12 * fabs(maximumUp);
    3231               } else {
    3232                 newBound = -COIN_DBL_MAX;
    3233               }
    3234               if (newBound > nowLower + 1.0e-12 && newBound > -large) {
    3235                 // Tighten the lower bound
    3236                 numberChanged++;
    3237                 // check infeasible (relaxed)
    3238                 if (nowUpper < newBound) {
    3239                   if (nowUpper - newBound <
    3240                       -100.0 * tolerance)
    3241                     numberInfeasible++;
    3242                   else
    3243                     newBound = nowUpper;
    3244                 }
    3245                 columnLower[iColumn] = newBound;
    3246                 for (CoinBigIndex j1=columnStart[iColumn];j1<columnStart[iColumn+1];j1++) {
    3247                   int jRow=row[j1];
    3248                   if (!changed[jRow]) {
    3249                     changed[jRow]=1;
    3250                     changedListNext[numberToDoNext++]=jRow;
    3251                   }
    3252                 }
    3253                 // adjust
    3254                 double now;
    3255                 if (nowLower < -large) {
    3256                   now = 0.0;
    3257                   infiniteLower--;
    3258                 } else {
    3259                   now = nowLower;
    3260                 }
    3261                 maximumDown += (newBound - now) * value;
    3262                 nowLower = newBound;
    3263               }
    3264             }
    3265             if (upper < large) {
    3266               if (!infiniteLower) {
    3267                 assert(nowLower > - large2);
    3268                 newBound = nowLower +
    3269                   (upper - maximumDown) / value;
    3270                 // relax if original was large
    3271                 if (fabs(maximumDown) > 1.0e8)
    3272                   newBound += 1.0e-12 * fabs(maximumDown);
    3273               } else if (infiniteLower == 1 && nowLower < -large) {
    3274                 newBound =   (upper - maximumDown) / value;
    3275                 // relax if original was large
    3276                 if (fabs(maximumDown) > 1.0e8)
    3277                   newBound += 1.0e-12 * fabs(maximumDown);
    3278               } else {
    3279                 newBound = COIN_DBL_MAX;
    3280               }
    3281               if (newBound < nowUpper - 1.0e-12 && newBound < large) {
    3282                 // Tighten the upper bound
    3283                 numberChanged++;
    3284                 // check infeasible (relaxed)
    3285                 if (nowLower > newBound) {
    3286                   if (newBound - nowLower <
    3287                       -100.0 * tolerance)
    3288                     numberInfeasible++;
    3289                   else
    3290                     newBound = nowLower;
    3291                 }
    3292                 columnUpper[iColumn] = newBound;
    3293                 for (CoinBigIndex j1=columnStart[iColumn];j1<columnStart[iColumn+1];j1++) {
    3294                   int jRow=row[j1];
    3295                   if (!changed[jRow]) {
    3296                     changed[jRow]=1;
    3297                     changedListNext[numberToDoNext++]=jRow;
    3298                   }
    3299                 }
    3300                 // adjust
    3301                 double now;
    3302                 if (nowUpper > large) {
    3303                   now = 0.0;
    3304                   infiniteUpper--;
    3305                 } else {
    3306                   now = nowUpper;
    3307                 }
    3308                 maximumUp += (newBound - now) * value;
    3309                 nowUpper = newBound;
    3310               }
    3311             }
    3312           } else {
    3313             // negative value
    3314             if (lower > -large) {
    3315               if (!infiniteUpper) {
    3316                 assert(nowLower < large2);
    3317                 newBound = nowLower +
    3318                   (lower - maximumUp) / value;
    3319                 // relax if original was large
    3320                 if (fabs(maximumUp) > 1.0e8)
    3321                   newBound += 1.0e-12 * fabs(maximumUp);
    3322               } else if (infiniteUpper == 1 && nowLower < -large) {
    3323                 newBound = (lower - maximumUp) / value;
    3324                 // relax if original was large
    3325                 if (fabs(maximumUp) > 1.0e8)
    3326                   newBound += 1.0e-12 * fabs(maximumUp);
    3327               } else {
    3328                 newBound = COIN_DBL_MAX;
    3329               }
    3330               if (newBound < nowUpper - 1.0e-12 && newBound < large) {
    3331                 // Tighten the upper bound
    3332                 numberChanged++;
    3333                 // check infeasible (relaxed)
    3334                 if (nowLower > newBound) {
    3335                   if (newBound - nowLower <
    3336                       -100.0 * tolerance)
    3337                     numberInfeasible++;
    3338                   else
    3339                     newBound = nowLower;
    3340                 }
    3341                 columnUpper[iColumn] = newBound;
    3342                 for (CoinBigIndex j1=columnStart[iColumn];j1<columnStart[iColumn+1];j1++) {
    3343                   int jRow=row[j1];
    3344                   if (!changed[jRow]) {
    3345                     changed[jRow]=1;
    3346                     changedListNext[numberToDoNext++]=jRow;
    3347                   }
    3348                 }
    3349                 // adjust
    3350                 double now;
    3351                 if (nowUpper > large) {
    3352                   now = 0.0;
    3353                   infiniteLower--;
    3354                 } else {
    3355                   now = nowUpper;
    3356                 }
    3357                 maximumDown += (newBound - now) * value;
    3358                 nowUpper = newBound;
    3359               }
    3360             }
    3361             if (upper < large) {
    3362               if (!infiniteLower) {
    3363                 assert(nowUpper < large2);
    3364                 newBound = nowUpper +
    3365                   (upper - maximumDown) / value;
    3366                 // relax if original was large
    3367                 if (fabs(maximumDown) > 1.0e8)
    3368                   newBound -= 1.0e-12 * fabs(maximumDown);
    3369               } else if (infiniteLower == 1 && nowUpper > large) {
    3370                 newBound =   (upper - maximumDown) / value;
    3371                 // relax if original was large
    3372                 if (fabs(maximumDown) > 1.0e8)
    3373                   newBound -= 1.0e-12 * fabs(maximumDown);
    3374               } else {
    3375                 newBound = -COIN_DBL_MAX;
    3376               }
    3377               if (newBound > nowLower + 1.0e-12 && newBound > -large) {
    3378                 // Tighten the lower bound
    3379                 numberChanged++;
    3380                 // check infeasible (relaxed)
    3381                 if (nowUpper < newBound) {
    3382                   if (nowUpper - newBound <
    3383                       -100.0 * tolerance)
    3384                     numberInfeasible++;
    3385                   else
    3386                     newBound = nowUpper;
    3387                 }
    3388                 columnLower[iColumn] = newBound;
    3389                 for (CoinBigIndex j1=columnStart[iColumn];j1<columnStart[iColumn+1];j1++) {
    3390                   int jRow=row[j1];
    3391                   if (!changed[jRow]) {
    3392                     changed[jRow]=1;
    3393                     changedListNext[numberToDoNext++]=jRow;
    3394                   }
    3395                 }
    3396                 // adjust
    3397                 double now;
    3398                 if (nowLower < -large) {
    3399                   now = 0.0;
    3400                   infiniteUpper--;
    3401                 } else {
    3402                   now = nowLower;
    3403                 }
    3404                 maximumUp += (newBound - now) * value;
    3405                 nowLower = newBound;
    3406               }
    3407             }
    3408           }
    3409         }
     3166        if (maxUp < rowLower[iRow] - 100.0 * tolerance || maxDown > rowUpper[iRow] + 100.0 * tolerance) {
     3167          // problem is infeasible - exit at once
     3168          numberInfeasible++;
     3169          break;
     3170        }
     3171        double lower = rowLower[iRow];
     3172        double upper = rowUpper[iRow];
     3173        for (j = rStart; j < rEnd; ++j) {
     3174          double value = element[j];
     3175          int iColumn = column[j];
     3176          double nowLower = columnLower[iColumn];
     3177          double nowUpper = columnUpper[iColumn];
     3178          if (value > 0.0) {
     3179            // positive value
     3180            if (lower > -large) {
     3181              if (!infiniteUpper) {
     3182                assert(nowUpper < large2);
     3183                newBound = nowUpper + (lower - maximumUp) / value;
     3184                // relax if original was large
     3185                if (fabs(maximumUp) > 1.0e8)
     3186                  newBound -= 1.0e-12 * fabs(maximumUp);
     3187              } else if (infiniteUpper == 1 && nowUpper > large) {
     3188                newBound = (lower - maximumUp) / value;
     3189                // relax if original was large
     3190                if (fabs(maximumUp) > 1.0e8)
     3191                  newBound -= 1.0e-12 * fabs(maximumUp);
     3192              } else {
     3193                newBound = -COIN_DBL_MAX;
     3194              }
     3195              if (newBound > nowLower + 1.0e-12 && newBound > -large) {
     3196                // Tighten the lower bound
     3197                numberChanged++;
     3198                // check infeasible (relaxed)
     3199                if (nowUpper < newBound) {
     3200                  if (nowUpper - newBound < -100.0 * tolerance)
     3201                    numberInfeasible++;
     3202                  else
     3203                    newBound = nowUpper;
     3204                }
     3205                columnLower[iColumn] = newBound;
     3206                for (CoinBigIndex j1 = columnStart[iColumn]; j1 < columnStart[iColumn + 1]; j1++) {
     3207                  int jRow = row[j1];
     3208                  if (!changed[jRow]) {
     3209                    changed[jRow] = 1;
     3210                    changedListNext[numberToDoNext++] = jRow;
     3211                  }
     3212                }
     3213                // adjust
     3214                double now;
     3215                if (nowLower < -large) {
     3216                  now = 0.0;
     3217                  infiniteLower--;
     3218                } else {
     3219                  now = nowLower;
     3220                }
     3221                maximumDown += (newBound - now) * value;
     3222                nowLower = newBound;
     3223              }
     3224            }
     3225            if (upper < large) {
     3226              if (!infiniteLower) {
     3227                assert(nowLower > -large2);
     3228                newBound = nowLower + (upper - maximumDown) / value;
     3229                // relax if original was large
     3230                if (fabs(maximumDown) > 1.0e8)
     3231                  newBound += 1.0e-12 * fabs(maximumDown);
     3232              } else if (infiniteLower == 1 && nowLower < -large) {
     3233                newBound = (upper - maximumDown) / value;
     3234                // relax if original was large
     3235                if (fabs(maximumDown) > 1.0e8)
     3236                  newBound += 1.0e-12 * fabs(maximumDown);
     3237              } else {
     3238                newBound = COIN_DBL_MAX;
     3239              }
     3240              if (newBound < nowUpper - 1.0e-12 && newBound < large) {
     3241                // Tighten the upper bound
     3242                numberChanged++;
     3243                // check infeasible (relaxed)
     3244                if (nowLower > newBound) {
     3245                  if (newBound - nowLower < -100.0 * tolerance)
     3246                    numberInfeasible++;
     3247                  else
     3248                    newBound = nowLower;
     3249                }
     3250                columnUpper[iColumn] = newBound;
     3251                for (CoinBigIndex j1 = columnStart[iColumn]; j1 < columnStart[iColumn + 1]; j1++) {
     3252                  int jRow = row[j1];
     3253                  if (!changed[jRow]) {
     3254                    changed[jRow] = 1;
     3255                    changedListNext[numberToDoNext++] = jRow;
     3256                  }
     3257                }
     3258                // adjust
     3259                double now;
     3260                if (nowUpper > large) {
     3261                  now = 0.0;
     3262                  infiniteUpper--;
     3263                } else {
     3264                  now = nowUpper;
     3265                }
     3266                maximumUp += (newBound - now) * value;
     3267                nowUpper = newBound;
     3268              }
     3269            }
     3270          } else {
     3271            // negative value
     3272            if (lower > -large) {
     3273              if (!infiniteUpper) {
     3274                assert(nowLower < large2);
     3275                newBound = nowLower + (lower - maximumUp) / value;
     3276                // relax if original was large
     3277                if (fabs(maximumUp) > 1.0e8)
     3278                  newBound += 1.0e-12 * fabs(maximumUp);
     3279              } else if (infiniteUpper == 1 && nowLower < -large) {
     3280                newBound = (lower - maximumUp) / value;
     3281                // relax if original was large
     3282                if (fabs(maximumUp) > 1.0e8)
     3283                  newBound += 1.0e-12 * fabs(maximumUp);
     3284              } else {
     3285                newBound = COIN_DBL_MAX;
     3286              }
     3287              if (newBound < nowUpper - 1.0e-12 && newBound < large) {
     3288                // Tighten the upper bound
     3289                numberChanged++;
     3290                // check infeasible (relaxed)
     3291                if (nowLower > newBound) {
     3292                  if (newBound - nowLower < -100.0 * tolerance)
     3293                    numberInfeasible++;
     3294                  else
     3295                    newBound = nowLower;
     3296                }
     3297                columnUpper[iColumn] = newBound;
     3298                for (CoinBigIndex j1 = columnStart[iColumn]; j1 < columnStart[iColumn + 1]; j1++) {
     3299                  int jRow = row[j1];
     3300                  if (!changed[jRow]) {
     3301                    changed[jRow] = 1;
     3302                    changedListNext[numberToDoNext++] = jRow;
     3303                  }
     3304                }
     3305                // adjust
     3306                double now;
     3307                if (nowUpper > large) {
     3308                  now = 0.0;
     3309                  infiniteLower--;
     3310                } else {
     3311                  now = nowUpper;
     3312                }
     3313                maximumDown += (newBound - now) * value;
     3314                nowUpper = newBound;
     3315              }
     3316            }
     3317            if (upper < large) {
     3318              if (!infiniteLower) {
     3319                assert(nowUpper < large2);
     3320                newBound = nowUpper + (upper - maximumDown) / value;
     3321                // relax if original was large
     3322                if (fabs(maximumDown) > 1.0e8)
     3323                  newBound -= 1.0e-12 * fabs(maximumDown);
     3324              } else if (infiniteLower == 1 && nowUpper > large) {
     3325                newBound = (upper - maximumDown) / value;
     3326                // relax if original was large
     3327                if (fabs(maximumDown) > 1.0e8)
     3328                  newBound -= 1.0e-12 * fabs(maximumDown);
     3329              } else {
     3330                newBound = -COIN_DBL_MAX;
     3331              }
     3332              if (newBound > nowLower + 1.0e-12 && newBound > -large) {
     3333                // Tighten the lower bound
     3334                numberChanged++;
     3335                // check infeasible (relaxed)
     3336                if (nowUpper < newBound) {
     3337                  if (nowUpper - newBound < -100.0 * tolerance)
     3338                    numberInfeasible++;
     3339                  else
     3340                    newBound = nowUpper;
     3341                }
     3342                columnLower[iColumn] = newBound;
     3343                for (CoinBigIndex j1 = columnStart[iColumn]; j1 < columnStart[iColumn + 1]; j1++) {
     3344                  int jRow = row[j1];
     3345                  if (!changed[jRow]) {
     3346                    changed[jRow] = 1;
     3347                    changedListNext[numberToDoNext++] = jRow;
     3348                  }
     3349                }
     3350                // adjust
     3351                double now;
     3352                if (nowLower < -large) {
     3353                  now = 0.0;
     3354                  infiniteUpper--;
     3355                } else {
     3356                  now = nowLower;
     3357                }
     3358                maximumUp += (newBound - now) * value;
     3359                nowLower = newBound;
     3360              }
     3361            }
     3362          }
     3363        }
    34103364      }
    34113365    }
     
    34303384    if (iPass == 1)
    34313385      numberCheck = numberChanged >> 4;
    3432     if (numberInfeasible) break;
    3433   }
    3434   const double *  COIN_RESTRICT saveLower = abcLower_+maximumNumberTotal_+maximumAbcNumberRows_;
    3435   const double *  COIN_RESTRICT saveUpper = abcUpper_+maximumNumberTotal_+maximumAbcNumberRows_;
     3386    if (numberInfeasible)
     3387      break;
     3388  }
     3389  const double *COIN_RESTRICT saveLower = abcLower_ + maximumNumberTotal_ + maximumAbcNumberRows_;
     3390  const double *COIN_RESTRICT saveUpper = abcUpper_ + maximumNumberTotal_ + maximumAbcNumberRows_;
    34363391  if (!numberInfeasible) {
    34373392    handler_->message(CLP_SIMPLEX_BOUNDTIGHTEN, messages_)
    34383393      << totalTightened
    34393394      << CoinMessageEol;
    3440     int numberLowerChanged=0;
    3441     int numberUpperChanged=0;
     3395    int numberLowerChanged = 0;
     3396    int numberUpperChanged = 0;
    34423397    if (!integerType_) {
    3443     // Set bounds slightly loose
    3444     // tighten rows as well
     3398      // Set bounds slightly loose
     3399      // tighten rows as well
    34453400      //#define PRINT_TIGHTEN_PROGRESS 0
    3446     for (int iRow = 0; iRow < numberRows_; iRow++) {
    3447       assert (maxRhs[iRow]>=rowLower[iRow]);
    3448       assert (minRhs[iRow]<=rowUpper[iRow]);
    3449       rowLower[iRow]=CoinMax(rowLower[iRow],minRhs[iRow]);
    3450       rowUpper[iRow]=CoinMin(rowUpper[iRow],maxRhs[iRow]);
    3451 #if PRINT_TIGHTEN_PROGRESS>3
    3452       if (handler_->logLevel()>5)
    3453         printf("Row %d min %g max %g lower %g upper %g\n",
    3454                iRow,minRhs[iRow],maxRhs[iRow],rowLower[iRow],rowUpper[iRow]);
    3455 #endif
    3456     }
     3401      for (int iRow = 0; iRow < numberRows_; iRow++) {
     3402        assert(maxRhs[iRow] >= rowLower[iRow]);
     3403        assert(minRhs[iRow] <= rowUpper[iRow]);
     3404        rowLower[iRow] = CoinMax(rowLower[iRow], minRhs[iRow]);
     3405        rowUpper[iRow] = CoinMin(rowUpper[iRow], maxRhs[iRow]);
     3406#if PRINT_TIGHTEN_PROGRESS > 3
     3407        if (handler_->logLevel() > 5)
     3408          printf("Row %d min %g max %g lower %g upper %g\n",
     3409            iRow, minRhs[iRow], maxRhs[iRow], rowLower[iRow], rowUpper[iRow]);
     3410#endif
     3411      }
    34573412#if 0
    34583413    double useTolerance = 1.0e-4;
     
    34683423          int iRow=row[j];
    34693424          double value=elementByColumn[j];
    3470 #if PRINT_TIGHTEN_PROGRESS>3
     3425#if PRINT_TIGHTEN_PROGRESS > 3
    34713426          if (handler_->logLevel()>5)
    34723427            printf("row %d element %g\n",iRow,value);
     
    35083463        if (awayFromLower>gap||awayFromUpper>gap) {
    35093464          if (fabs(columnUpper[iColumn]-upper)>1.0e-5) {
    3510 #if PRINT_TIGHTEN_PROGRESS>1
     3465#if PRINT_TIGHTEN_PROGRESS > 1
    35113466            printf("YYchange upper bound on %d from %g (original %g) to %g (awayFromLower %g) - cost %g\n",iColumn,
    35123467                   columnUpper[iColumn],saveUpper[iColumn],upper,awayFromLower,cost[iColumn]);
     
    35153470          }
    35163471          if (fabs(columnLower[iColumn]-lower)>1.0e-5) {
    3517 #if PRINT_TIGHTEN_PROGRESS>1
     3472#if PRINT_TIGHTEN_PROGRESS > 1
    35183473            printf("YYchange lower bound on %d from %g (original %g) to %g (awayFromUpper %g) - cost %g\n",iColumn,
    35193474                   columnLower[iColumn],saveLower[iColumn],lower,awayFromUpper,cost[iColumn]);
     
    35373492          // doesn't want to be too positive
    35383493          if (fabs(columnUpper[iColumn]-upper)>1.0e-5) {
    3539 #if PRINT_TIGHTEN_PROGRESS>2
     3494#if PRINT_TIGHTEN_PROGRESS > 2
    35403495            if (handler_->logLevel()>1)
    35413496              printf("change upper bound on %d from %g (original %g) to %g (awayFromLower %g) - cost %g\n",iColumn,
     
    35613516          // doesn't want to be too negative
    35623517          if (fabs(columnLower[iColumn]-lower)>1.0e-5) {
    3563 #if PRINT_TIGHTEN_PROGRESS>2
     3518#if PRINT_TIGHTEN_PROGRESS > 2
    35643519            if (handler_->logLevel()>1)
    35653520              printf("change lower bound on %d from %g (original %g) to %g (awayFromUpper %g) - cost %g\n",iColumn,
     
    36903645#endif
    36913646    } else {
    3692 #if ABC_NORMAL_DEBUG>0
     3647#if ABC_NORMAL_DEBUG > 0
    36933648      printf("Redo tighten to relax by 1 for integers\n");
    36943649#endif
    36953650    }
    3696 #if ABC_NORMAL_DEBUG>0
     3651#if ABC_NORMAL_DEBUG > 0
    36973652    printf("Tighten - phase1 %d bounds changed, phase2 %d lower, %d upper\n",
    3698            totalTightened,numberLowerChanged,numberUpperChanged);
     3653      totalTightened, numberLowerChanged, numberUpperChanged);
    36993654#endif
    37003655    if (integerType_) {
    3701       const double * columnScale=scaleToExternal_+maximumAbcNumberRows_;
    3702       const double * inverseColumnScale=scaleFromExternal_+maximumAbcNumberRows_;
     3656      const double *columnScale = scaleToExternal_ + maximumAbcNumberRows_;
     3657      const double *inverseColumnScale = scaleFromExternal_ + maximumAbcNumberRows_;
    37033658      for (int iColumn = 0; iColumn < numberColumns_; iColumn++) {
    3704         if (integerType_[iColumn]) {
    3705           double value;
    3706           double lower = columnLower[iColumn]*inverseColumnScale[iColumn];
    3707           double upper = columnUpper[iColumn]*inverseColumnScale[iColumn];
    3708           value = floor(lower + 0.5);
    3709           if (fabs(value - lower) > primalTolerance_)
    3710             value = ceil(lower);
    3711           columnLower_[iColumn] = value;
    3712           columnLower[iColumn]=value*columnScale[iColumn];
    3713           value = floor(upper + 0.5);
    3714           if (fabs(value - upper) > primalTolerance_)
    3715             value = floor(upper);
    3716           columnUpper_[iColumn] = value;
    3717           columnUpper[iColumn]=value*columnScale[iColumn];
    3718           if (columnLower_[iColumn] > columnUpper_[iColumn])
    3719             numberInfeasible++;
    3720         }
     3659        if (integerType_[iColumn]) {
     3660          double value;
     3661          double lower = columnLower[iColumn] * inverseColumnScale[iColumn];
     3662          double upper = columnUpper[iColumn] * inverseColumnScale[iColumn];
     3663          value = floor(lower + 0.5);
     3664          if (fabs(value - lower) > primalTolerance_)
     3665            value = ceil(lower);
     3666          columnLower_[iColumn] = value;
     3667          columnLower[iColumn] = value * columnScale[iColumn];
     3668          value = floor(upper + 0.5);
     3669          if (fabs(value - upper) > primalTolerance_)
     3670            value = floor(upper);
     3671          columnUpper_[iColumn] = value;
     3672          columnUpper[iColumn] = value * columnScale[iColumn];
     3673          if (columnLower_[iColumn] > columnUpper_[iColumn])
     3674            numberInfeasible++;
     3675        }
    37213676      }
    37223677      if (numberInfeasible) {
    3723         handler_->message(CLP_SIMPLEX_INFEASIBILITIES, messages_)
    3724           << numberInfeasible
    3725           << CoinMessageEol;
    3726         // restore column bounds
    3727         CoinMemcpyN(saveLower, numberColumns_, columnLower_);
    3728         CoinMemcpyN(saveUpper, numberColumns_, columnUpper_);
     3678        handler_->message(CLP_SIMPLEX_INFEASIBILITIES, messages_)
     3679          << numberInfeasible
     3680          << CoinMessageEol;
     3681        // restore column bounds
     3682        CoinMemcpyN(saveLower, numberColumns_, columnLower_);
     3683        CoinMemcpyN(saveUpper, numberColumns_, columnUpper_);
    37293684      }
    37303685    }
     
    37413696    for (int iRow = 0; iRow < numberRows_; iRow++) {
    37423697      if (rowLower[iRow] > -large || rowUpper[iRow] < large) {
    3743         // possible row
    3744         int infiniteUpper = 0;
    3745         int infiniteLower = 0;
    3746         double maximumUp = 0.0;
    3747         double maximumDown = 0.0;
    3748         CoinBigIndex rStart = rowStart[iRow];
    3749         CoinBigIndex rEnd = rowStart[iRow] + rowLength[iRow];
    3750         CoinBigIndex j;
    3751         // Compute possible lower and upper ranges
    3752         for (j = rStart; j < rEnd; ++j) {
    3753           double value = element[j];
    3754           int iColumn = column[j];
    3755           if (value > 0.0) {
    3756             if (columnUpper[iColumn] >= large) {
    3757               ++infiniteUpper;
    3758             } else {
    3759               maximumUp += columnUpper[iColumn] * value;
    3760             }
    3761             if (columnLower[iColumn] <= -large) {
    3762               ++infiniteLower;
    3763             } else {
    3764               maximumDown += columnLower[iColumn] * value;
    3765             }
    3766           } else if (value < 0.0) {
    3767             if (columnUpper[iColumn] >= large) {
    3768               ++infiniteLower;
    3769             } else {
    3770               maximumDown += columnUpper[iColumn] * value;
    3771             }
    3772             if (columnLower[iColumn] <= -large) {
    3773               ++infiniteUpper;
    3774             } else {
    3775               maximumUp += columnLower[iColumn] * value;
    3776             }
    3777           }
    3778         }
    3779         // Build in a margin of error
    3780         double maxUp = maximumUp+1.0e-8 * fabs(maximumUp);
    3781         double maxDown = maximumDown-1.0e-8 * fabs(maximumDown);
    3782         if (!infiniteUpper&&maxUp < rowUpper[iRow] - tolerance) {
    3783           if (rowUpper[iRow]!=COIN_DBL_MAX||maximumUp<1.0e5)
    3784             rowUpper[iRow]=maximumUp;
    3785         }
    3786         if (!infiniteLower&&maxDown > rowLower[iRow] + tolerance) {
    3787           if (rowLower[iRow]!=-COIN_DBL_MAX||maximumDown>-1.0e5)
    3788             rowLower[iRow]=maximumDown;
    3789         }
    3790         assert(rowLower[iRow]<=rowUpper[iRow]);
    3791         if(rowUpper[iRow]-rowLower[iRow]<1.0e-12) {
    3792           if (fabs(rowLower[iRow])>fabs(rowUpper[iRow]))
    3793             rowLower[iRow]=rowUpper[iRow];
    3794           else
    3795             rowUpper[iRow]=rowLower[iRow];
    3796         }
     3698        // possible row
     3699        int infiniteUpper = 0;
     3700        int infiniteLower = 0;
     3701        double maximumUp = 0.0;
     3702        double maximumDown = 0.0;
     3703        CoinBigIndex rStart = rowStart[iRow];
     3704        CoinBigIndex rEnd = rowStart[iRow] + rowLength[iRow];
     3705        CoinBigIndex j;
     3706        // Compute possible lower and upper ranges
     3707        for (j = rStart; j < rEnd; ++j) {
     3708          double value = element[j];
     3709          int iColumn = column[j];
     3710          if (value > 0.0) {
     3711            if (columnUpper[iColumn] >= large) {
     3712              ++infiniteUpper;
     3713            } else {
     3714              maximumUp += columnUpper[iColumn] * value;
     3715            }
     3716            if (columnLower[iColumn] <= -large) {
     3717              ++infiniteLower;
     3718            } else {
     3719              maximumDown += columnLower[iColumn] * value;
     3720            }
     3721          } else if (value < 0.0) {
     3722            if (columnUpper[iColumn] >= large) {
     3723              ++infiniteLower;
     3724            } else {
     3725              maximumDown += columnUpper[iColumn] * value;
     3726            }
     3727            if (columnLower[iColumn] <= -large) {
     3728              ++infiniteUpper;
     3729            } else {
     3730              maximumUp += columnLower[iColumn] * value;
     3731            }
     3732          }
     3733        }
     3734        // Build in a margin of error
     3735        double maxUp = maximumUp + 1.0e-8 * fabs(maximumUp);
     3736        double maxDown = maximumDown - 1.0e-8 * fabs(maximumDown);
     3737        if (!infiniteUpper && maxUp < rowUpper[iRow] - tolerance) {
     3738          if (rowUpper[iRow] != COIN_DBL_MAX || maximumUp < 1.0e5)
     3739            rowUpper[iRow] = maximumUp;
     3740        }
     3741        if (!infiniteLower && maxDown > rowLower[iRow] + tolerance) {
     3742          if (rowLower[iRow] != -COIN_DBL_MAX || maximumDown > -1.0e5)
     3743            rowLower[iRow] = maximumDown;
     3744        }
     3745        assert(rowLower[iRow] <= rowUpper[iRow]);
     3746        if (rowUpper[iRow] - rowLower[iRow] < 1.0e-12) {
     3747          if (fabs(rowLower[iRow]) > fabs(rowUpper[iRow]))
     3748            rowLower[iRow] = rowUpper[iRow];
     3749          else
     3750            rowUpper[iRow] = rowLower[iRow];
     3751        }
    37973752      }
    37983753    }
    37993754    // flip back
    3800     for (int iRow=0;iRow<numberRows_;iRow++) {
    3801       double value=-rowLower[iRow];
    3802       rowLower[iRow]=-rowUpper[iRow];
    3803       rowUpper[iRow]=value;
     3755    for (int iRow = 0; iRow < numberRows_; iRow++) {
     3756      double value = -rowLower[iRow];
     3757      rowLower[iRow] = -rowUpper[iRow];
     3758      rowUpper[iRow] = value;
    38043759    }
    38053760    // move back - relaxed unless integer
    38063761    if (!integerType_) {
    3807       double * COIN_RESTRICT lowerSaved = abcLower_+maximumNumberTotal_;
    3808       double * COIN_RESTRICT upperSaved = abcUpper_+maximumNumberTotal_;
    3809       double tolerance=2.0*primalTolerance_;
    3810       for (int i=0;i<numberTotal_;i++) {
    3811         double lower=abcLower_[i];
    3812         double upper=abcUpper_[i];
    3813         if (lower!=upper) {
    3814           lower=CoinMax(lower-tolerance,lowerSaved[i]);
    3815           upper=CoinMin(upper+tolerance,upperSaved[i]);
    3816         }
    3817         abcLower_[i]=lower;
    3818         lowerSaved[i]=lower;
    3819         abcUpper_[i]=upper;
    3820         upperSaved[i]=upper;
     3762      double *COIN_RESTRICT lowerSaved = abcLower_ + maximumNumberTotal_;
     3763      double *COIN_RESTRICT upperSaved = abcUpper_ + maximumNumberTotal_;
     3764      double tolerance = 2.0 * primalTolerance_;
     3765      for (int i = 0; i < numberTotal_; i++) {
     3766        double lower = abcLower_[i];
     3767        double upper = abcUpper_[i];
     3768        if (lower != upper) {
     3769          lower = CoinMax(lower - tolerance, lowerSaved[i]);
     3770          upper = CoinMin(upper + tolerance, upperSaved[i]);
     3771        }
     3772        abcLower_[i] = lower;
     3773        lowerSaved[i] = lower;
     3774        abcUpper_[i] = upper;
     3775        upperSaved[i] = upper;
    38213776      }
    38223777    } else {
    3823       CoinAbcMemcpy(abcLower_+maximumNumberTotal_,abcLower_,numberTotal_);
    3824       CoinAbcMemcpy(abcUpper_+maximumNumberTotal_,abcUpper_,numberTotal_);
     3778      CoinAbcMemcpy(abcLower_ + maximumNumberTotal_, abcLower_, numberTotal_);
     3779      CoinAbcMemcpy(abcUpper_ + maximumNumberTotal_, abcUpper_, numberTotal_);
    38253780    }
    38263781#if 0
     
    38363791    permuteBasis();
    38373792    // move solution
    3838     CoinAbcMemcpy(abcSolution_,solutionSaved_,numberTotal_);
    3839   }
    3840   CoinAbcMemset0(minRhs,numberRows_);
    3841   CoinAbcMemset0(maxRhs,numberRows_);
    3842   for (int i=0;i<5;i++)
     3793    CoinAbcMemcpy(abcSolution_, solutionSaved_, numberTotal_);
     3794  }
     3795