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/AbcDualRowSteepest.cpp

    r1910 r2385  
    2020// Default Constructor
    2121//-------------------------------------------------------------------
    22 AbcDualRowSteepest::AbcDualRowSteepest (int mode)
    23   : AbcDualRowPivot(),
    24     norm_(0.0),
    25     factorizationRatio_(10.0),
    26     state_(-1),
    27     mode_(mode),
    28     persistence_(normal),
    29     weights_(NULL),
    30     infeasible_(NULL),
    31     savedWeights_(NULL)
     22AbcDualRowSteepest::AbcDualRowSteepest(int mode)
     23  : AbcDualRowPivot()
     24  , norm_(0.0)
     25  , factorizationRatio_(10.0)
     26  , state_(-1)
     27  , mode_(mode)
     28  , persistence_(normal)
     29  , weights_(NULL)
     30  , infeasible_(NULL)
     31  , savedWeights_(NULL)
    3232{
    3333  type_ = 2 + 64 * mode;
     
    3838// Copy constructor
    3939//-------------------------------------------------------------------
    40 AbcDualRowSteepest::AbcDualRowSteepest (const AbcDualRowSteepest & rhs)
     40AbcDualRowSteepest::AbcDualRowSteepest(const AbcDualRowSteepest &rhs)
    4141  : AbcDualRowPivot(rhs)
    4242{
     
    7777// Destructor
    7878//-------------------------------------------------------------------
    79 AbcDualRowSteepest::~AbcDualRowSteepest ()
     79AbcDualRowSteepest::~AbcDualRowSteepest()
    8080{
    8181  //printf("XX %x AbcDualRowSteepest destructor\n",this);
     
    8989//-------------------------------------------------------------------
    9090AbcDualRowSteepest &
    91 AbcDualRowSteepest::operator=(const AbcDualRowSteepest& rhs)
     91AbcDualRowSteepest::operator=(const AbcDualRowSteepest &rhs)
    9292{
    9393  if (this != &rhs) {
     
    125125}
    126126// Fill most values
    127 void
    128 AbcDualRowSteepest::fill(const AbcDualRowSteepest& rhs)
     127void AbcDualRowSteepest::fill(const AbcDualRowSteepest &rhs)
    129128{
    130129  norm_ = rhs.norm_;
     
    133132  mode_ = rhs.mode_;
    134133  persistence_ = rhs.persistence_;
    135   assert (model_->numberRows() == rhs.model_->numberRows());
     134  assert(model_->numberRows() == rhs.model_->numberRows());
    136135  model_ = rhs.model_;
    137136  assert(model_);
     
    166165}
    167166#ifdef CHECK_NUMBER_WANTED
    168 static int xTimes=0;
    169 static int xWanted=0;
    170 #endif
    171 #if ABC_PARALLEL==2
     167static int xTimes = 0;
     168static int xWanted = 0;
     169#endif
     170#if ABC_PARALLEL == 2
    172171#define DO_REDUCE 2
    173172#ifdef DO_REDUCE
    174 #if DO_REDUCE==1
     173#if DO_REDUCE == 1
    175174#include <cilk/reducer_max.h>
    176 static void choose(int & chosenRow,double & largest, int n,
    177                    const int * index, const double * infeas,
    178                    const double * weights,double tolerance)
    179 {
    180   cilk::reducer_max_index<int,double> maximumIndex(chosenRow,largest);
    181 #pragma cilk_grainsize=128
    182   cilk_for (int i = 0; i < n; i++) {
     175static void choose(int &chosenRow, double &largest, int n,
     176  const int *index, const double *infeas,
     177  const double *weights, double tolerance)
     178{
     179  cilk::reducer_max_index< int, double > maximumIndex(chosenRow, largest);
     180#pragma cilk_grainsize = 128
     181  cilk_for(int i = 0; i < n; i++)
     182  {
    183183    int iRow = index[i];
    184184    double value = infeas[iRow];
    185185    if (value > tolerance) {
    186186      double thisWeight = CoinMin(weights[iRow], 1.0e50);
    187       maximumIndex.calc_max(iRow,value/thisWeight);
    188     }
    189   }
    190   chosenRow=maximumIndex.get_index();
    191   largest=maximumIndex.get_value();
     187      maximumIndex.calc_max(iRow, value / thisWeight);
     188    }
     189  }
     190  chosenRow = maximumIndex.get_index();
     191  largest = maximumIndex.get_value();
    192192}
    193193#else
    194 static void choose(AbcDualRowSteepest * steepest,
    195                    int & chosenRowSave,double & largestSave, int first, int last,
    196                    double tolerance)
    197 {
    198   if (last-first>256) {
    199     int mid=(last+first)>>1;
    200     int chosenRow2=chosenRowSave;
    201     double largest2=largestSave;
    202     cilk_spawn choose(steepest,chosenRow2,largest2, first, mid,
    203                       tolerance);
    204     choose(steepest,chosenRowSave,largestSave, mid, last,
    205            tolerance);
     194static void choose(AbcDualRowSteepest *steepest,
     195  int &chosenRowSave, double &largestSave, int first, int last,
     196  double tolerance)
     197{
     198  if (last - first > 256) {
     199    int mid = (last + first) >> 1;
     200    int chosenRow2 = chosenRowSave;
     201    double largest2 = largestSave;
     202    cilk_spawn choose(steepest, chosenRow2, largest2, first, mid,
     203      tolerance);
     204    choose(steepest, chosenRowSave, largestSave, mid, last,
     205      tolerance);
    206206    cilk_sync;
    207     if (largest2>largestSave) {
    208       largestSave=largest2;
    209       chosenRowSave=chosenRow2;
     207    if (largest2 > largestSave) {
     208      largestSave = largest2;
     209      chosenRowSave = chosenRow2;
    210210    }
    211211  } else {
    212     const int * index=steepest->infeasible()->getIndices();
    213      const double * infeas=steepest->infeasible()->denseVector();
    214     const double * weights=steepest->weights()->denseVector();
    215     double largest=largestSave;
    216     int chosenRow=chosenRowSave;
    217     if ((steepest->model()->stateOfProblem()&VALUES_PASS2)==0) {
     212    const int *index = steepest->infeasible()->getIndices();
     213    const double *infeas = steepest->infeasible()->denseVector();
     214    const double *weights = steepest->weights()->denseVector();
     215    double largest = largestSave;
     216    int chosenRow = chosenRowSave;
     217    if ((steepest->model()->stateOfProblem() & VALUES_PASS2) == 0) {
    218218      for (int i = first; i < last; i++) {
    219         int iRow = index[i];
    220         double value = infeas[iRow];
    221         if (value > tolerance) {
    222           double thisWeight = CoinMin(weights[iRow], 1.0e50);
    223           if (value>largest*thisWeight) {
    224             largest=value/thisWeight;
    225             chosenRow=iRow;
    226           }
    227         }
     219        int iRow = index[i];
     220        double value = infeas[iRow];
     221        if (value > tolerance) {
     222          double thisWeight = CoinMin(weights[iRow], 1.0e50);
     223          if (value > largest * thisWeight) {
     224            largest = value / thisWeight;
     225            chosenRow = iRow;
     226          }
     227        }
    228228      }
    229229    } else {
    230       const double * fakeDjs = steepest->model()->fakeDjs();
    231       const int * pivotVariable = steepest->model()->pivotVariable();
     230      const double *fakeDjs = steepest->model()->fakeDjs();
     231      const int *pivotVariable = steepest->model()->pivotVariable();
    232232      for (int i = first; i < last; i++) {
    233         int iRow = index[i];
    234         double value = infeas[iRow];
    235         if (value > tolerance) {
    236           int iSequence=pivotVariable[iRow];
    237           value *=(fabs(fakeDjs[iSequence])+1.0e-6);
    238           double thisWeight = CoinMin(weights[iRow], 1.0e50);
    239           /*
     233        int iRow = index[i];
     234        double value = infeas[iRow];
     235        if (value > tolerance) {
     236          int iSequence = pivotVariable[iRow];
     237          value *= (fabs(fakeDjs[iSequence]) + 1.0e-6);
     238          double thisWeight = CoinMin(weights[iRow], 1.0e50);
     239          /*
    240240            Ideas
    241241            always use fake
     
    244244            how to switch off if cilking - easiest at saveWeights
    245245           */
    246           if (value>largest*thisWeight) {
    247             largest=value/thisWeight;
    248             chosenRow=iRow;
    249           }
    250         }
    251       }
    252     }
    253     chosenRowSave=chosenRow;
    254     largestSave=largest;
    255   }
    256 }
    257 static void choose2(AbcDualRowSteepest * steepest,
    258                    int & chosenRowSave,double & largestSave, int first, int last,
    259                    double tolerance)
    260 {
    261   if (last-first>256) {
    262     int mid=(last+first)>>1;
    263     int chosenRow2=chosenRowSave;
    264     double largest2=largestSave;
    265     cilk_spawn choose2(steepest,chosenRow2,largest2, first, mid,
    266                       tolerance);
    267     choose2(steepest,chosenRowSave,largestSave, mid, last,
    268            tolerance);
     246          if (value > largest * thisWeight) {
     247            largest = value / thisWeight;
     248            chosenRow = iRow;
     249          }
     250        }
     251      }
     252    }
     253    chosenRowSave = chosenRow;
     254    largestSave = largest;
     255  }
     256}
     257static void choose2(AbcDualRowSteepest *steepest,
     258  int &chosenRowSave, double &largestSave, int first, int last,
     259  double tolerance)
     260{
     261  if (last - first > 256) {
     262    int mid = (last + first) >> 1;
     263    int chosenRow2 = chosenRowSave;
     264    double largest2 = largestSave;
     265    cilk_spawn choose2(steepest, chosenRow2, largest2, first, mid,
     266      tolerance);
     267    choose2(steepest, chosenRowSave, largestSave, mid, last,
     268      tolerance);
    269269    cilk_sync;
    270     if (largest2>largestSave) {
    271       largestSave=largest2;
    272       chosenRowSave=chosenRow2;
     270    if (largest2 > largestSave) {
     271      largestSave = largest2;
     272      chosenRowSave = chosenRow2;
    273273    }
    274274  } else {
    275     const int * index=steepest->infeasible()->getIndices();
    276     const double * infeas=steepest->infeasible()->denseVector();
    277     double largest=largestSave;
    278     int chosenRow=chosenRowSave;
     275    const int *index = steepest->infeasible()->getIndices();
     276    const double *infeas = steepest->infeasible()->denseVector();
     277    double largest = largestSave;
     278    int chosenRow = chosenRowSave;
    279279    for (int i = first; i < last; i++) {
    280280      int iRow = index[i];
    281281      double value = infeas[iRow];
    282282      if (value > largest) {
    283         largest=value;
    284         chosenRow=iRow;
    285       }
    286     }
    287     chosenRowSave=chosenRow;
    288     largestSave=largest;
     283        largest = value;
     284        chosenRow = iRow;
     285      }
     286    }
     287    chosenRowSave = chosenRow;
     288    largestSave = largest;
    289289  }
    290290}
     
    293293#endif
    294294// Returns pivot row, -1 if none
    295 int
    296 AbcDualRowSteepest::pivotRow()
     295int AbcDualRowSteepest::pivotRow()
    297296{
    298297  assert(model_);
    299   double *  COIN_RESTRICT infeas = infeasible_->denseVector();
    300   int *  COIN_RESTRICT index = infeasible_->getIndices();
     298  double *COIN_RESTRICT infeas = infeasible_->denseVector();
     299  int *COIN_RESTRICT index = infeasible_->getIndices();
    301300  int number = infeasible_->getNumElements();
    302301  int lastPivotRow = model_->lastPivotRow();
    303   assert (lastPivotRow < model_->numberRows());
     302  assert(lastPivotRow < model_->numberRows());
    304303  double tolerance = model_->currentPrimalTolerance();
    305304  // we can't really trust infeasibilities if there is primal error
     
    307306  double error = CoinMin(1.0e-2, model_->largestPrimalError());
    308307  // allow tolerance at least slightly bigger than standard
    309   tolerance = tolerance +  error;
     308  tolerance = tolerance + error;
    310309  // But cap
    311310  tolerance = CoinMin(1000.0, tolerance);
    312311  tolerance *= tolerance; // as we are using squares
    313312  bool toleranceChanged = false;
    314   const double *  COIN_RESTRICT solutionBasic = model_->solutionBasic();
    315   const double *  COIN_RESTRICT lowerBasic = model_->lowerBasic();
    316   const double *  COIN_RESTRICT upperBasic = model_->upperBasic();
     313  const double *COIN_RESTRICT solutionBasic = model_->solutionBasic();
     314  const double *COIN_RESTRICT lowerBasic = model_->lowerBasic();
     315  const double *COIN_RESTRICT upperBasic = model_->upperBasic();
    317316  // do last pivot row one here
    318317  if (lastPivotRow >= 0 && lastPivotRow < model_->numberRows()) {
     
    325324      // store square in list
    326325      if (infeas[lastPivotRow])
    327         infeas[lastPivotRow] = value; // already there
     326        infeas[lastPivotRow] = value; // already there
    328327      else
    329         infeasible_->quickAdd(lastPivotRow, value);
     328        infeasible_->quickAdd(lastPivotRow, value);
    330329    } else if (value < lower - tolerance) {
    331330      value -= lower;
     
    333332      // store square in list
    334333      if (infeas[lastPivotRow])
    335         infeas[lastPivotRow] = value; // already there
     334        infeas[lastPivotRow] = value; // already there
    336335      else
    337         infeasible_->add(lastPivotRow, value);
     336        infeasible_->add(lastPivotRow, value);
    338337    } else {
    339338      // feasible - was it infeasible - if so set tiny
    340339      if (infeas[lastPivotRow])
    341         infeas[lastPivotRow] = COIN_INDEXED_REALLY_TINY_ELEMENT;
     340        infeas[lastPivotRow] = COIN_INDEXED_REALLY_TINY_ELEMENT;
    342341    }
    343342    number = infeasible_->getNumElements();
    344343  }
    345   if(model_->numberIterations() < model_->lastBadIteration() + 200) {
     344  if (model_->numberIterations() < model_->lastBadIteration() + 200) {
    346345    // we can't really trust infeasibilities if there is dual error
    347346    if (model_->largestDualError() > model_->largestPrimalError()) {
     
    351350  }
    352351  int numberWanted;
    353   if (mode_ < 2 ) {
     352  if (mode_ < 2) {
    354353    numberWanted = number + 1;
    355354  } else {
    356     if (model_->factorization()->pivots()==0) {
     355    if (model_->factorization()->pivots() == 0) {
    357356      int numberElements = model_->factorization()->numberElements();
    358357      int numberRows = model_->numberRows();
     
    362361        static_cast<double> (numberRows+1-numberSlacks);
    363362#else
    364       factorizationRatio_ = static_cast<double> (numberElements) /
    365         static_cast<double> (numberRows);
     363      factorizationRatio_ = static_cast< double >(numberElements) / static_cast< double >(numberRows);
    366364#endif
    367365      //printf("%d iterations, numberElements %d ratio %g\n",
    368366      //     model_->numberIterations(),numberElements,factorizationRatio_);
    369367      // Bias so less likely to go to steepest if large
    370       double weights[]={1.0,2.0,5.0};
     368      double weights[] = { 1.0, 2.0, 5.0 };
    371369      double modifier;
    372       if (numberRows<100000)
    373         modifier=weights[0];
    374       else if (numberRows<200000)
    375         modifier=weights[1];
     370      if (numberRows < 100000)
     371        modifier = weights[0];
     372      else if (numberRows < 200000)
     373        modifier = weights[1];
    376374      else
    377         modifier=weights[2];
    378       if (mode_==2&&factorizationRatio_>modifier) {
    379         // switch from dantzig to steepest
    380         mode_=3;
    381         saveWeights(model_,5);
     375        modifier = weights[2];
     376      if (mode_ == 2 && factorizationRatio_ > modifier) {
     377        // switch from dantzig to steepest
     378        mode_ = 3;
     379        saveWeights(model_, 5);
    382380      }
    383381    }
     
    407405    }
    408406#endif
    409     numberWanted=CoinMin(numberWanted,number+1);
     407    numberWanted = CoinMin(numberWanted, number + 1);
    410408  }
    411409  if (model_->largestPrimalError() > 1.0e-3)
    412410    numberWanted = number + 1; // be safe
    413411#ifdef CHECK_NUMBER_WANTED
    414   xWanted+=numberWanted;
     412  xWanted += numberWanted;
    415413  xTimes++;
    416   if ((xTimes%1000)==0)
    417     printf("time %d average wanted %g\n",xTimes,static_cast<double>(xWanted)/xTimes);
     414  if ((xTimes % 1000) == 0)
     415    printf("time %d average wanted %g\n", xTimes, static_cast< double >(xWanted) / xTimes);
    418416#endif
    419417  int iPass;
     
    422420  start[1] = number;
    423421  start[2] = 0;
    424   double dstart = static_cast<double> (number) * model_->randomNumberGenerator()->randomDouble();
    425   start[0] = static_cast<int> (dstart);
     422  double dstart = static_cast< double >(number) * model_->randomNumberGenerator()->randomDouble();
     423  start[0] = static_cast< int >(dstart);
    426424  start[3] = start[0];
    427425  //double largestWeight=0.0;
    428426  //double smallestWeight=1.0e100;
    429   const double * weights = weights_->denseVector();
    430   const int * pivotVariable = model_->pivotVariable();
    431   double savePivotWeight=weights_->denseVector()[lastPivotRow];
     427  const double *weights = weights_->denseVector();
     428  const int *pivotVariable = model_->pivotVariable();
     429  double savePivotWeight = weights_->denseVector()[lastPivotRow];
    432430  weights_->denseVector()[lastPivotRow] *= 1.0e10;
    433431  double largest = 0.0;
    434432  int chosenRow = -1;
    435   int saveNumberWanted=numberWanted;
     433  int saveNumberWanted = numberWanted;
    436434#ifdef DO_REDUCE
    437   bool doReduce=true;
    438   int lastChosen=-1;
    439   double lastLargest=0.0;
     435  bool doReduce = true;
     436  int lastChosen = -1;
     437  double lastLargest = 0.0;
    440438#endif
    441439  for (iPass = 0; iPass < 2; iPass++) {
    442     int endThis = start[2*iPass+1];
    443     int startThis=start[2*iPass];
    444     while (startThis<endThis) {
    445       int end = CoinMin(endThis,startThis+numberWanted);
    446 #ifdef DO_REDUCE 
     440    int endThis = start[2 * iPass + 1];
     441    int startThis = start[2 * iPass];
     442    while (startThis < endThis) {
     443      int end = CoinMin(endThis, startThis + numberWanted);
     444#ifdef DO_REDUCE
    447445      if (doReduce) {
    448 #if DO_REDUCE==1
    449         choose(chosenRow,largest,end-startThis,
    450                index+startThis,infeas,weights,tolerance);
     446#if DO_REDUCE == 1
     447        choose(chosenRow, largest, end - startThis,
     448          index + startThis, infeas, weights, tolerance);
    451449#else
    452         if (mode_!=2)
    453           choose(this,chosenRow,largest,startThis,end,tolerance);
    454         else
    455           choose2(this,chosenRow,largest,startThis,end,tolerance);
    456 #endif
    457         if (chosenRow!=lastChosen) {
    458           assert (chosenRow>=0);
    459           if (model_->flagged(pivotVariable[chosenRow])||
    460               (solutionBasic[chosenRow] <= upperBasic[chosenRow] + tolerance &&
    461                solutionBasic[chosenRow] >= lowerBasic[chosenRow] - tolerance)) {
    462             doReduce=false;
    463             chosenRow=lastChosen;
    464             largest=lastLargest;
    465           } else {
    466             lastChosen=chosenRow;
    467             lastLargest=largest;
    468           }
    469         }
     450        if (mode_ != 2)
     451          choose(this, chosenRow, largest, startThis, end, tolerance);
     452        else
     453          choose2(this, chosenRow, largest, startThis, end, tolerance);
     454#endif
     455        if (chosenRow != lastChosen) {
     456          assert(chosenRow >= 0);
     457          if (model_->flagged(pivotVariable[chosenRow]) || (solutionBasic[chosenRow] <= upperBasic[chosenRow] + tolerance && solutionBasic[chosenRow] >= lowerBasic[chosenRow] - tolerance)) {
     458            doReduce = false;
     459            chosenRow = lastChosen;
     460            largest = lastLargest;
     461          } else {
     462            lastChosen = chosenRow;
     463            lastLargest = largest;
     464          }
     465        }
    470466      }
    471467      if (!doReduce) {
    472468#endif
    473       for (int i = startThis; i < end; i++) {
    474         int iRow = index[i];
    475         double value = infeas[iRow];
    476         if (value > tolerance) {
    477           //#define OUT_EQ
     469        for (int i = startThis; i < end; i++) {
     470          int iRow = index[i];
     471          double value = infeas[iRow];
     472          if (value > tolerance) {
     473            //#define OUT_EQ
    478474#ifdef OUT_EQ
    479           if (upper[iRow] == lower[iRow])
    480             value *= 2.0;
    481 #endif
    482           double thisWeight = CoinMin(weights[iRow], 1.0e50);
    483           //largestWeight = CoinMax(largestWeight,weight);
    484           //smallestWeight = CoinMin(smallestWeight,weight);
    485           //double dubious = dubiousWeights_[iRow];
    486           //weight *= dubious;
    487           //if (value>2.0*largest*weight||(value>0.5*largest*weight&&value*largestWeight>dubious*largest*weight)) {
    488           if (value > largest * thisWeight) {
    489             // make last pivot row last resort choice
    490             //if (iRow == lastPivotRow) {
    491             //if (value * 1.0e-10 < largest * thisWeight)
    492             //  continue;
    493             //else
    494             //  value *= 1.0e-10;
    495             //}
    496             if (!model_->flagged(pivotVariable[iRow])) {
    497               //#define CLP_DEBUG 3
     475            if (upper[iRow] == lower[iRow])
     476              value *= 2.0;
     477#endif
     478            double thisWeight = CoinMin(weights[iRow], 1.0e50);
     479            //largestWeight = CoinMax(largestWeight,weight);
     480            //smallestWeight = CoinMin(smallestWeight,weight);
     481            //double dubious = dubiousWeights_[iRow];
     482            //weight *= dubious;
     483            //if (value>2.0*largest*weight||(value>0.5*largest*weight&&value*largestWeight>dubious*largest*weight)) {
     484            if (value > largest * thisWeight) {
     485              // make last pivot row last resort choice
     486              //if (iRow == lastPivotRow) {
     487              //if (value * 1.0e-10 < largest * thisWeight)
     488              //  continue;
     489              //else
     490              //  value *= 1.0e-10;
     491              //}
     492              if (!model_->flagged(pivotVariable[iRow])) {
     493                //#define CLP_DEBUG 3
    498494#ifdef CLP_DEBUG
    499               double value2 = 0.0;
    500               if (solutionBasic[iRow] > upperBasic[iRow] + tolerance)
    501                 value2 = solutionBasic[iRow] - upperBasic[iRow];
    502               else if (solutionBasic[iRow] < lowerBasic[iRow] - tolerance)
    503                 value2 = solutionBasic[iRow] - lowerBasic[iRow];
    504               assert(fabs(value2 * value2 - infeas[iRow]) < 1.0e-8 * CoinMin(value2 * value2, infeas[iRow]));
    505 #endif
    506               if (solutionBasic[iRow] > upperBasic[iRow] + tolerance ||
    507                   solutionBasic[iRow] < lowerBasic[iRow] - tolerance) {
    508                 chosenRow = iRow;
    509                 largest = value / thisWeight;
    510                 //largestWeight = dubious;
    511               }
    512             }
    513           }
    514         }
    515       }
     495                double value2 = 0.0;
     496                if (solutionBasic[iRow] > upperBasic[iRow] + tolerance)
     497                  value2 = solutionBasic[iRow] - upperBasic[iRow];
     498                else if (solutionBasic[iRow] < lowerBasic[iRow] - tolerance)
     499                  value2 = solutionBasic[iRow] - lowerBasic[iRow];
     500                assert(fabs(value2 * value2 - infeas[iRow]) < 1.0e-8 * CoinMin(value2 * value2, infeas[iRow]));
     501#endif
     502                if (solutionBasic[iRow] > upperBasic[iRow] + tolerance || solutionBasic[iRow] < lowerBasic[iRow] - tolerance) {
     503                  chosenRow = iRow;
     504                  largest = value / thisWeight;
     505                  //largestWeight = dubious;
     506                }
     507              }
     508            }
     509          }
     510        }
    516511#ifdef DO_REDUCE
    517512      }
    518513#endif
    519       numberWanted-=(end-startThis);
     514      numberWanted -= (end - startThis);
    520515      if (!numberWanted) {
    521         if(chosenRow>=0)
    522           break;
    523         else
    524           numberWanted=(saveNumberWanted+1)>>1;
    525       }
    526       startThis=end;
     516        if (chosenRow >= 0)
     517          break;
     518        else
     519          numberWanted = (saveNumberWanted + 1) >> 1;
     520      }
     521      startThis = end;
    527522    }
    528523    if (!numberWanted) {
    529       if(chosenRow>=0)
    530         break;
     524      if (chosenRow >= 0)
     525        break;
    531526      else
    532         numberWanted=(saveNumberWanted+1)>>1;
    533     }
    534   }
    535   weights_->denseVector()[lastPivotRow]=savePivotWeight;
     527        numberWanted = (saveNumberWanted + 1) >> 1;
     528    }
     529  }
     530  weights_->denseVector()[lastPivotRow] = savePivotWeight;
    536531  //printf("smallest %g largest %g\n",smallestWeight,largestWeight);
    537532  if (chosenRow < 0 && toleranceChanged) {
     
    548543      int iRow = index[i];
    549544      if (fabs(infeas[iRow]) > 1.0e-50) {
    550         index[nLeft++] = iRow;
     545        index[nLeft++] = iRow;
    551546      } else {
    552         infeas[iRow] = 0.0;
     547        infeas[iRow] = 0.0;
    553548      }
    554549    }
     
    556551    model_->setNumberPrimalInfeasibilities(nLeft);
    557552  }
    558   if (true&&(model_->stateOfProblem()&VALUES_PASS2)!=0) {
    559     if (chosenRow>=0) {
    560       double * fakeDjs = model_->fakeDjs();
     553  if (true && (model_->stateOfProblem() & VALUES_PASS2) != 0) {
     554    if (chosenRow >= 0) {
     555      double *fakeDjs = model_->fakeDjs();
    561556      //const int * pivotVariable = model_->pivotVariable();
    562       fakeDjs[pivotVariable[chosenRow]]=0.0;
     557      fakeDjs[pivotVariable[chosenRow]] = 0.0;
    563558    }
    564559  }
     
    567562//#define PRINT_WEIGHTS_FREQUENCY
    568563#ifdef PRINT_WEIGHTS_FREQUENCY
    569 int xweights1=0;
    570 int xweights2=0;
    571 int xweights3=0;
     564int xweights1 = 0;
     565int xweights2 = 0;
     566int xweights3 = 0;
    572567#endif
    573568/* Updates weights and returns pivot alpha.
    574569   Also does FT update */
    575570double
    576 AbcDualRowSteepest::updateWeights(CoinIndexedVector & input,
    577                                   CoinIndexedVector & updateColumn)
    578 {
    579    double *  COIN_RESTRICT weights = weights_->denseVector();
    580 #if CLP_DEBUG>2
     571AbcDualRowSteepest::updateWeights(CoinIndexedVector &input,
     572  CoinIndexedVector &updateColumn)
     573{
     574  double *COIN_RESTRICT weights = weights_->denseVector();
     575#if CLP_DEBUG > 2
    581576  // Very expensive debug
    582577  {
     
    584579    CoinIndexedVector temp;
    585580    temp.reserve(numberRows);
    586     double * array = temp.denseVector();
    587     int * which = temp.getIndices();
     581    double *array = temp.denseVector();
     582    int *which = temp.getIndices();
    588583    for (int i = 0; i < numberRows; i++) {
    589584      double value = 0.0;
     
    594589      int number = temp.getNumElements();
    595590      for (int j = 0; j < number; j++) {
    596         int iRow = which[j];
    597         value += array[iRow] * array[iRow];
    598         array[iRow] = 0.0;
     591        int iRow = which[j];
     592        value += array[iRow] * array[iRow];
     593        array[iRow] = 0.0;
    599594      }
    600595      temp.setNumElements(0);
    601596      double w = CoinMax(weights[i], value) * .1;
    602597      if (fabs(weights[i] - value) > w) {
    603         printf("%d old %g, true %g\n", i, weights[i], value);
    604         weights[i] = value; // to reduce printout
     598        printf("%d old %g, true %g\n", i, weights[i], value);
     599        weights[i] = value; // to reduce printout
    605600      }
    606601    }
     
    610605  double norm = 0.0;
    611606  int i;
    612   double *  COIN_RESTRICT work2 = input.denseVector();
     607  double *COIN_RESTRICT work2 = input.denseVector();
    613608  int numberNonZero = input.getNumElements();
    614   int *  COIN_RESTRICT which = input.getIndices();
    615  
     609  int *COIN_RESTRICT which = input.getIndices();
     610
    616611  //compute norm
    617   for (int i = 0; i < numberNonZero; i ++ ) {
     612  for (int i = 0; i < numberNonZero; i++) {
    618613    int iRow = which[i];
    619614    double value = work2[iRow];
     
    622617  // Do FT update
    623618  if (true) {
    624     model_->factorization()->updateTwoColumnsFT(updateColumn,input);
    625 #if CLP_DEBUG>3
     619    model_->factorization()->updateTwoColumnsFT(updateColumn, input);
     620#if CLP_DEBUG > 3
    626621    printf("REGION after %d els\n", input.getNumElements());
    627622    input.print();
     
    635630  numberNonZero = input.getNumElements();
    636631  int pivotRow = model_->lastPivotRow();
    637   assert (model_->pivotRow()==model_->lastPivotRow());
     632  assert(model_->pivotRow() == model_->lastPivotRow());
    638633#ifdef CLP_DEBUG
    639   if ( model_->logLevel (  ) > 4  &&
    640        fabs(norm - weights[pivotRow]) > 1.0e-2 * (1.0 + norm))
     634  if (model_->logLevel() > 4 && fabs(norm - weights[pivotRow]) > 1.0e-2 * (1.0 + norm))
    641635    printf("on row %d, true weight %g, old %g\n",
    642            pivotRow, sqrt(norm), sqrt(weights[pivotRow]));
     636      pivotRow, sqrt(norm), sqrt(weights[pivotRow]));
    643637#endif
    644638  // could re-initialize here (could be expensive)
     
    649643#ifdef PRINT_WEIGHTS_FREQUENCY
    650644  xweights1++;
    651   if ((xweights1+xweights2+xweights3)%100==0) {
     645  if ((xweights1 + xweights2 + xweights3) % 100 == 0) {
    652646    printf("ZZ iteration %d sum weights %d - %d %d %d\n",
    653            model_->numberIterations(),xweights1+xweights2+xweights3,xweights1,xweights2,xweights3);
    654     assert(abs(model_->numberIterations()-(xweights1+xweights2+xweights3))<=1);
     647      model_->numberIterations(), xweights1 + xweights2 + xweights3, xweights1, xweights2, xweights3);
     648    assert(abs(model_->numberIterations() - (xweights1 + xweights2 + xweights3)) <= 1);
    655649  }
    656650#endif
    657651  // look at updated column
    658   double *  COIN_RESTRICT work = updateColumn.denseVector();
     652  double *COIN_RESTRICT work = updateColumn.denseVector();
    659653  numberNonZero = updateColumn.getNumElements();
    660654  which = updateColumn.getIndices();
    661  
     655
    662656  // pivot element
    663   alpha=work[pivotRow];
     657  alpha = work[pivotRow];
    664658  for (i = 0; i < numberNonZero; i++) {
    665659    int iRow = which[i];
     
    669663    //which3[nSave++] = iRow;
    670664    double value = work2[iRow];
    671     devex +=  theta * (theta * norm + value * multiplier);
     665    devex += theta * (theta * norm + value * multiplier);
    672666    if (devex < DEVEX_TRY_NORM)
    673667      devex = DEVEX_TRY_NORM;
     
    688682  return alpha;
    689683}
    690 double 
    691 AbcDualRowSteepest::updateWeights1(CoinIndexedVector & input,CoinIndexedVector & updateColumn)
    692 {
    693   if (mode_==2) {
     684double
     685AbcDualRowSteepest::updateWeights1(CoinIndexedVector &input, CoinIndexedVector &updateColumn)
     686{
     687  if (mode_ == 2) {
    694688    abort();
    695689    // no update
     
    699693    double alpha = 0.0;
    700694    // look at updated column
    701     double * work = updateColumn.denseVector();
     695    double *work = updateColumn.denseVector();
    702696    int pivotRow = model_->lastPivotRow();
    703     assert (pivotRow == model_->pivotRow());
    704    
    705     assert (!updateColumn.packedMode());
     697    assert(pivotRow == model_->pivotRow());
     698
     699    assert(!updateColumn.packedMode());
    706700    alpha = work[pivotRow];
    707701    return alpha;
    708702  }
    709 #if CLP_DEBUG>2
     703#if CLP_DEBUG > 2
    710704  // Very expensive debug
    711705  {
    712     double * weights = weights_->denseVector();
     706    double *weights = weights_->denseVector();
    713707    int numberRows = model_->numberRows();
    714     const int * pivotVariable = model_->pivotVariable();
     708    const int *pivotVariable = model_->pivotVariable();
    715709    CoinIndexedVector temp;
    716710    temp.reserve(numberRows);
    717     double * array = temp.denseVector();
    718     int * which = temp.getIndices();
     711    double *array = temp.denseVector();
     712    int *which = temp.getIndices();
    719713    for (int i = 0; i < numberRows; i++) {
    720714      double value = 0.0;
     
    725719      int number = temp.getNumElements();
    726720      for (int j = 0; j < number; j++) {
    727         int iRow = which[j];
    728         value += array[iRow] * array[iRow];
    729         array[iRow] = 0.0;
     721        int iRow = which[j];
     722        value += array[iRow] * array[iRow];
     723        array[iRow] = 0.0;
    730724      }
    731725      temp.setNumElements(0);
    732726      double w = CoinMax(weights[i], value) * .1;
    733727      if (fabs(weights[i] - value) > w) {
    734         printf("XX row %d (variable %d) old %g, true %g\n", i, pivotVariable[i],
    735                weights[i], value);
    736         weights[i] = value; // to reduce printout
     728        printf("XX row %d (variable %d) old %g, true %g\n", i, pivotVariable[i],
     729          weights[i], value);
     730        weights[i] = value; // to reduce printout
    737731      }
    738732    }
     
    740734#endif
    741735  norm_ = 0.0;
    742   double *  COIN_RESTRICT work2 = input.denseVector();
     736  double *COIN_RESTRICT work2 = input.denseVector();
    743737  int numberNonZero = input.getNumElements();
    744   int *  COIN_RESTRICT which = input.getIndices();
    745  
     738  int *COIN_RESTRICT which = input.getIndices();
     739
    746740  //compute norm
    747   for (int i = 0; i < numberNonZero; i ++ ) {
     741  for (int i = 0; i < numberNonZero; i++) {
    748742    int iRow = which[i];
    749743    double value = work2[iRow];
     
    752746  // Do FT update
    753747  if (true) {
    754     model_->factorization()->updateTwoColumnsFT(updateColumn,input);
    755 #if CLP_DEBUG>3
     748    model_->factorization()->updateTwoColumnsFT(updateColumn, input);
     749#if CLP_DEBUG > 3
    756750    printf("REGION after %d els\n", input.getNumElements());
    757751    input.print();
     
    763757  }
    764758  // pivot element
    765   assert (model_->pivotRow()==model_->lastPivotRow());
     759  assert(model_->pivotRow() == model_->lastPivotRow());
    766760  return updateColumn.denseVector()[model_->lastPivotRow()];
    767761}
    768 void AbcDualRowSteepest::updateWeightsOnly(CoinIndexedVector & input)
    769 {
    770   if (mode_==2)
     762void AbcDualRowSteepest::updateWeightsOnly(CoinIndexedVector &input)
     763{
     764  if (mode_ == 2)
    771765    return;
    772766  norm_ = 0.0;
    773   double *  COIN_RESTRICT work2 = input.denseVector();
     767  double *COIN_RESTRICT work2 = input.denseVector();
    774768  int numberNonZero = input.getNumElements();
    775   int *  COIN_RESTRICT which = input.getIndices();
    776  
     769  int *COIN_RESTRICT which = input.getIndices();
     770
    777771  //compute norm
    778   for (int i = 0; i < numberNonZero; i ++ ) {
     772  for (int i = 0; i < numberNonZero; i++) {
    779773    int iRow = which[i];
    780774    double value = work2[iRow];
     
    784778}
    785779// Actually updates weights
    786 void AbcDualRowSteepest::updateWeights2(CoinIndexedVector & input,CoinIndexedVector & updateColumn)
    787 {
    788   if (mode_==2)
     780void AbcDualRowSteepest::updateWeights2(CoinIndexedVector &input, CoinIndexedVector &updateColumn)
     781{
     782  if (mode_ == 2)
    789783    return;
    790   double *  COIN_RESTRICT weights = weights_->denseVector();
    791   const double *  COIN_RESTRICT work2 = input.denseVector();
     784  double *COIN_RESTRICT weights = weights_->denseVector();
     785  const double *COIN_RESTRICT work2 = input.denseVector();
    792786  int pivotRow = model_->lastPivotRow();
    793   assert (model_->pivotRow()==model_->lastPivotRow());
     787  assert(model_->pivotRow() == model_->lastPivotRow());
    794788#ifdef CLP_DEBUG
    795   if ( model_->logLevel (  ) > 4  &&
    796        fabs(norm_ - weights[pivotRow]) > 1.0e-2 * (1.0 + norm_))
     789  if (model_->logLevel() > 4 && fabs(norm_ - weights[pivotRow]) > 1.0e-2 * (1.0 + norm_))
    797790    printf("on row %d, true weight %g, old %g\n",
    798            pivotRow, sqrt(norm_), sqrt(weights[pivotRow]));
     791      pivotRow, sqrt(norm_), sqrt(weights[pivotRow]));
    799792#endif
    800793  // pivot element
    801   double alpha=model_->alpha();
     794  double alpha = model_->alpha();
    802795  // could re-initialize here (could be expensive)
    803796  norm_ /= alpha * alpha;
     
    806799  double multiplier = 2.0 / alpha;
    807800  // look at updated column
    808   const double *  COIN_RESTRICT work = updateColumn.denseVector();
     801  const double *COIN_RESTRICT work = updateColumn.denseVector();
    809802  int numberNonZero = updateColumn.getNumElements();
    810   const int * which = updateColumn.getIndices();
    811   double multiplier2=1.0;
     803  const int *which = updateColumn.getIndices();
     804  double multiplier2 = 1.0;
    812805#ifdef PRINT_WEIGHTS_FREQUENCY
    813806  xweights2++;
    814   if ((xweights1+xweights2+xweights3)%100==0) {
     807  if ((xweights1 + xweights2 + xweights3) % 100 == 0) {
    815808    printf("ZZ iteration %d sum weights %d - %d %d %d\n",
    816            model_->numberIterations(),xweights1+xweights2+xweights3,xweights1,xweights2,xweights3);
    817     assert(abs(model_->numberIterations()-(xweights1+xweights2+xweights3))<=1);
    818   }
    819 #endif
    820   if (model_->directionOut()<0) {
     809      model_->numberIterations(), xweights1 + xweights2 + xweights3, xweights1, xweights2, xweights3);
     810    assert(abs(model_->numberIterations() - (xweights1 + xweights2 + xweights3)) <= 1);
     811  }
     812#endif
     813  if (model_->directionOut() < 0) {
    821814#ifdef ABC_DEBUG
    822     printf("Minus out in %d %d, out %d %d\n",model_->sequenceIn(),model_->directionIn(),
    823            model_->sequenceOut(),model_->directionOut());
    824 #endif
    825     multiplier2=-1.0;
     815    printf("Minus out in %d %d, out %d %d\n", model_->sequenceIn(), model_->directionIn(),
     816      model_->sequenceOut(), model_->directionOut());
     817#endif
     818    multiplier2 = -1.0;
    826819  }
    827820  for (int i = 0; i < numberNonZero; i++) {
    828821    int iRow = which[i];
    829     double theta = multiplier2*work[iRow];
     822    double theta = multiplier2 * work[iRow];
    830823    double devex = weights[iRow];
    831824    double value = work2[iRow];
    832     devex +=  theta * (theta * norm_ + value * multiplier);
     825    devex += theta * (theta * norm_ + value * multiplier);
    833826    if (devex < DEVEX_TRY_NORM)
    834827      devex = DEVEX_TRY_NORM;
     
    850843   Computes change in objective function
    851844*/
    852 void
    853 AbcDualRowSteepest::updatePrimalSolution(
    854                                          CoinIndexedVector & primalUpdate,
    855                                          double primalRatio)
    856 {
    857   double * COIN_RESTRICT work = primalUpdate.denseVector();
     845void AbcDualRowSteepest::updatePrimalSolution(
     846  CoinIndexedVector &primalUpdate,
     847  double primalRatio)
     848{
     849  double *COIN_RESTRICT work = primalUpdate.denseVector();
    858850  int number = primalUpdate.getNumElements();
    859   int * COIN_RESTRICT which = primalUpdate.getIndices();
     851  int *COIN_RESTRICT which = primalUpdate.getIndices();
    860852  double tolerance = model_->currentPrimalTolerance();
    861   double * COIN_RESTRICT infeas = infeasible_->denseVector();
    862   double * COIN_RESTRICT solutionBasic = model_->solutionBasic();
    863   const double * COIN_RESTRICT lowerBasic = model_->lowerBasic();
    864   const double * COIN_RESTRICT upperBasic = model_->upperBasic();
    865   assert (!primalUpdate.packedMode());
     853  double *COIN_RESTRICT infeas = infeasible_->denseVector();
     854  double *COIN_RESTRICT solutionBasic = model_->solutionBasic();
     855  const double *COIN_RESTRICT lowerBasic = model_->lowerBasic();
     856  const double *COIN_RESTRICT upperBasic = model_->upperBasic();
     857  assert(!primalUpdate.packedMode());
    866858  for (int i = 0; i < number; i++) {
    867859    int iRow = which[i];
     
    879871#ifdef CLP_DUAL_FIXED_COLUMN_MULTIPLIER
    880872      if (lower == upper)
    881         value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
     873        value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
    882874#endif
    883875      // store square in list
    884876      if (infeas[iRow])
    885         infeas[iRow] = value; // already there
     877        infeas[iRow] = value; // already there
    886878      else
    887         infeasible_->quickAdd(iRow, value);
     879        infeasible_->quickAdd(iRow, value);
    888880    } else if (value > upper + tolerance) {
    889881      value -= upper;
     
    891883#ifdef CLP_DUAL_FIXED_COLUMN_MULTIPLIER
    892884      if (lower == upper)
    893         value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
     885        value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
    894886#endif
    895887      // store square in list
    896888      if (infeas[iRow])
    897         infeas[iRow] = value; // already there
     889        infeas[iRow] = value; // already there
    898890      else
    899         infeasible_->quickAdd(iRow, value);
     891        infeasible_->quickAdd(iRow, value);
    900892    } else {
    901893      // feasible - was it infeasible - if so set tiny
    902894      if (infeas[iRow])
    903         infeas[iRow] = COIN_INDEXED_REALLY_TINY_ELEMENT;
     895        infeas[iRow] = COIN_INDEXED_REALLY_TINY_ELEMENT;
    904896    }
    905897  }
    906898  // Do pivot row
    907899  int iRow = model_->lastPivotRow();
    908   assert (model_->pivotRow()==model_->lastPivotRow());
     900  assert(model_->pivotRow() == model_->lastPivotRow());
    909901  // feasible - was it infeasible - if so set tiny
    910902  //assert (infeas[iRow]);
     
    913905  primalUpdate.setNumElements(0);
    914906}
    915 #if ABC_PARALLEL==2
     907#if ABC_PARALLEL == 2
    916908static void update(int first, int last,
    917                    const int * COIN_RESTRICT which, double * COIN_RESTRICT work,
    918                    const double * COIN_RESTRICT work2, double * COIN_RESTRICT weights,
    919                    const double * COIN_RESTRICT lowerBasic,double * COIN_RESTRICT solutionBasic,
    920                    const double * COIN_RESTRICT upperBasic,
    921                    double multiplier,double multiplier2,
    922                    double norm,double theta,double tolerance)
    923 {
    924   if (last-first>256) {
    925     int mid=(last+first)>>1;
    926     cilk_spawn update(first,mid,which,work,work2,weights,lowerBasic,solutionBasic,
    927                       upperBasic,multiplier,multiplier2,norm,theta,tolerance);
    928     update(mid,last,which,work,work2,weights,lowerBasic,solutionBasic,
    929            upperBasic,multiplier,multiplier2,norm,theta,tolerance);
     909  const int *COIN_RESTRICT which, double *COIN_RESTRICT work,
     910  const double *COIN_RESTRICT work2, double *COIN_RESTRICT weights,
     911  const double *COIN_RESTRICT lowerBasic, double *COIN_RESTRICT solutionBasic,
     912  const double *COIN_RESTRICT upperBasic,
     913  double multiplier, double multiplier2,
     914  double norm, double theta, double tolerance)
     915{
     916  if (last - first > 256) {
     917    int mid = (last + first) >> 1;
     918    cilk_spawn update(first, mid, which, work, work2, weights, lowerBasic, solutionBasic,
     919      upperBasic, multiplier, multiplier2, norm, theta, tolerance);
     920    update(mid, last, which, work, work2, weights, lowerBasic, solutionBasic,
     921      upperBasic, multiplier, multiplier2, norm, theta, tolerance);
    930922    cilk_sync;
    931923  } else {
     
    933925      int iRow = which[i];
    934926      double updateValue = work[iRow];
    935       double thetaDevex = multiplier2*updateValue;
     927      double thetaDevex = multiplier2 * updateValue;
    936928      double devex = weights[iRow];
    937929      double valueDevex = work2[iRow];
    938       devex +=  thetaDevex * (thetaDevex * norm + valueDevex * multiplier);
     930      devex += thetaDevex * (thetaDevex * norm + valueDevex * multiplier);
    939931      if (devex < DEVEX_TRY_NORM)
    940         devex = DEVEX_TRY_NORM;
     932        devex = DEVEX_TRY_NORM;
    941933      weights[iRow] = devex;
    942934      double value = solutionBasic[iRow];
     
    947939      solutionBasic[iRow] = value;
    948940      if (value < lower - tolerance) {
    949         value -= lower;
    950         value *= value;
     941        value -= lower;
     942        value *= value;
    951943#ifdef CLP_DUAL_FIXED_COLUMN_MULTIPLIER
    952         if (lower == upper)
    953           value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
     944        if (lower == upper)
     945          value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
    954946#endif
    955947      } else if (value > upper + tolerance) {
    956         value -= upper;
    957         value *= value;
     948        value -= upper;
     949        value *= value;
    958950#ifdef CLP_DUAL_FIXED_COLUMN_MULTIPLIER
    959         if (lower == upper)
    960           value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
     951        if (lower == upper)
     952          value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
    961953#endif
    962954      } else {
    963         // feasible
    964         value=0.0;
     955        // feasible
     956        value = 0.0;
    965957      }
    966958      // store square
    967       work[iRow]=value;
    968     }
    969   }
    970 }
    971 #endif
    972 void
    973 AbcDualRowSteepest::updatePrimalSolutionAndWeights(CoinIndexedVector & weightsVector,
    974                                     CoinIndexedVector & primalUpdate,
    975                                                    double theta)
     959      work[iRow] = value;
     960    }
     961  }
     962}
     963#endif
     964void AbcDualRowSteepest::updatePrimalSolutionAndWeights(CoinIndexedVector &weightsVector,
     965  CoinIndexedVector &primalUpdate,
     966  double theta)
    976967{
    977968  //printf("updatePrimal iteration %d - weightsVector has %d, primalUpdate has %d\n",
    978969  //     model_->numberIterations(),weightsVector.getNumElements(),primalUpdate.getNumElements());
    979   double *  COIN_RESTRICT weights = weights_->denseVector();
    980   double *  COIN_RESTRICT work2 = weightsVector.denseVector();
     970  double *COIN_RESTRICT weights = weights_->denseVector();
     971  double *COIN_RESTRICT work2 = weightsVector.denseVector();
    981972  int pivotRow = model_->lastPivotRow();
    982   assert (model_->pivotRow()==model_->lastPivotRow());
    983   double * COIN_RESTRICT work = primalUpdate.denseVector();
     973  assert(model_->pivotRow() == model_->lastPivotRow());
     974  double *COIN_RESTRICT work = primalUpdate.denseVector();
    984975  int numberNonZero = primalUpdate.getNumElements();
    985   int * COIN_RESTRICT which = primalUpdate.getIndices();
     976  int *COIN_RESTRICT which = primalUpdate.getIndices();
    986977  double tolerance = model_->currentPrimalTolerance();
    987   double * COIN_RESTRICT infeas = infeasible_->denseVector();
    988   double * COIN_RESTRICT solutionBasic = model_->solutionBasic();
    989   const double * COIN_RESTRICT lowerBasic = model_->lowerBasic();
    990   const double * COIN_RESTRICT upperBasic = model_->upperBasic();
    991   assert (!primalUpdate.packedMode());
     978  double *COIN_RESTRICT infeas = infeasible_->denseVector();
     979  double *COIN_RESTRICT solutionBasic = model_->solutionBasic();
     980  const double *COIN_RESTRICT lowerBasic = model_->lowerBasic();
     981  const double *COIN_RESTRICT upperBasic = model_->upperBasic();
     982  assert(!primalUpdate.packedMode());
    992983#ifdef CLP_DEBUG
    993   if ( model_->logLevel (  ) > 4  &&
    994        fabs(norm_ - weights[pivotRow]) > 1.0e-2 * (1.0 + norm_))
     984  if (model_->logLevel() > 4 && fabs(norm_ - weights[pivotRow]) > 1.0e-2 * (1.0 + norm_))
    995985    printf("on row %d, true weight %g, old %g\n",
    996            pivotRow, sqrt(norm_), sqrt(weights[pivotRow]));
     986      pivotRow, sqrt(norm_), sqrt(weights[pivotRow]));
    997987#endif
    998988  // pivot element
    999   double alpha=model_->alpha();
     989  double alpha = model_->alpha();
    1000990  // could re-initialize here (could be expensive)
    1001991  norm_ /= alpha * alpha;
     
    1006996  // only weights3 is used? - slightly faster to just update weights if going to invert
    1007997  xweights3++;
    1008   if ((xweights1+xweights2+xweights3)%1000==0) {
     998  if ((xweights1 + xweights2 + xweights3) % 1000 == 0) {
    1009999    printf("ZZ iteration %d sum weights %d - %d %d %d\n",
    1010            model_->numberIterations(),xweights1+xweights2+xweights3,xweights1,xweights2,xweights3);
    1011     assert(abs(model_->numberIterations()-(xweights1+xweights2+xweights3))<=1);
     1000      model_->numberIterations(), xweights1 + xweights2 + xweights3, xweights1, xweights2, xweights3);
     1001    assert(abs(model_->numberIterations() - (xweights1 + xweights2 + xweights3)) <= 1);
    10121002  }
    10131003#endif
    10141004  // look at updated column
    1015   double multiplier2=1.0;
    1016   if (model_->directionOut()<0) {
     1005  double multiplier2 = 1.0;
     1006  if (model_->directionOut() < 0) {
    10171007#ifdef ABC_DEBUG
    1018     printf("Minus out in %d %d, out %d %d\n",model_->sequenceIn(),model_->directionIn(),
    1019            model_->sequenceOut(),model_->directionOut());
    1020 #endif
    1021     multiplier2=-1.0;
    1022   }
    1023 #if ABC_PARALLEL==2
    1024   update(0,numberNonZero,which,work,work2,weights,
    1025          lowerBasic,solutionBasic,upperBasic,
    1026          multiplier,multiplier2,norm_,theta,tolerance);
     1008    printf("Minus out in %d %d, out %d %d\n", model_->sequenceIn(), model_->directionIn(),
     1009      model_->sequenceOut(), model_->directionOut());
     1010#endif
     1011    multiplier2 = -1.0;
     1012  }
     1013#if ABC_PARALLEL == 2
     1014  update(0, numberNonZero, which, work, work2, weights,
     1015    lowerBasic, solutionBasic, upperBasic,
     1016    multiplier, multiplier2, norm_, theta, tolerance);
    10271017  for (int i = 0; i < numberNonZero; i++) {
    10281018    int iRow = which[i];
    1029     double infeasibility=work[iRow];
    1030     work[iRow]=0.0;
     1019    double infeasibility = work[iRow];
     1020    work[iRow] = 0.0;
    10311021    if (infeasibility) {
    10321022      if (infeas[iRow])
    1033         infeas[iRow] = infeasibility; // already there
     1023        infeas[iRow] = infeasibility; // already there
    10341024      else
    1035         infeasible_->quickAdd(iRow, infeasibility);
     1025        infeasible_->quickAdd(iRow, infeasibility);
    10361026    } else {
    10371027      // feasible - was it infeasible - if so set tiny
    10381028      if (infeas[iRow])
    1039         infeas[iRow] = COIN_INDEXED_REALLY_TINY_ELEMENT;
     1029        infeas[iRow] = COIN_INDEXED_REALLY_TINY_ELEMENT;
    10401030    }
    10411031  }
     
    10441034    int iRow = which[i];
    10451035    double updateValue = work[iRow];
    1046     work[iRow]=0.0;
    1047     double thetaDevex = multiplier2*updateValue;
     1036    work[iRow] = 0.0;
     1037    double thetaDevex = multiplier2 * updateValue;
    10481038    double devex = weights[iRow];
    10491039    double valueDevex = work2[iRow];
    1050     devex +=  thetaDevex * (thetaDevex * norm_ + valueDevex * multiplier);
     1040    devex += thetaDevex * (thetaDevex * norm_ + valueDevex * multiplier);
    10511041    if (devex < DEVEX_TRY_NORM)
    10521042      devex = DEVEX_TRY_NORM;
     
    10631053#ifdef CLP_DUAL_FIXED_COLUMN_MULTIPLIER
    10641054      if (lower == upper)
    1065         value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
     1055        value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
    10661056#endif
    10671057      // store square in list
    10681058      if (infeas[iRow])
    1069         infeas[iRow] = value; // already there
     1059        infeas[iRow] = value; // already there
    10701060      else
    1071         infeasible_->quickAdd(iRow, value);
     1061        infeasible_->quickAdd(iRow, value);
    10721062    } else if (value > upper + tolerance) {
    10731063      value -= upper;
     
    10751065#ifdef CLP_DUAL_FIXED_COLUMN_MULTIPLIER
    10761066      if (lower == upper)
    1077         value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
     1067        value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
    10781068#endif
    10791069      // store square in list
    10801070      if (infeas[iRow])
    1081         infeas[iRow] = value; // already there
     1071        infeas[iRow] = value; // already there
    10821072      else
    1083         infeasible_->quickAdd(iRow, value);
     1073        infeasible_->quickAdd(iRow, value);
    10841074    } else {
    10851075      // feasible - was it infeasible - if so set tiny
    10861076      if (infeas[iRow])
    1087         infeas[iRow] = COIN_INDEXED_REALLY_TINY_ELEMENT;
     1077        infeas[iRow] = COIN_INDEXED_REALLY_TINY_ELEMENT;
    10881078    }
    10891079  }
     
    11061096  // see 1/2 above primalUpdate.setNumElements(0);
    11071097}
    1108 extern void parallelDual5(AbcSimplexFactorization * factorization,
    1109                          CoinIndexedVector ** whichVector,
    1110                         int numberCpu,
    1111                         int whichCpu,
    1112                          double * weights);
     1098extern void parallelDual5(AbcSimplexFactorization *factorization,
     1099  CoinIndexedVector **whichVector,
     1100  int numberCpu,
     1101  int whichCpu,
     1102  double *weights);
    11131103/* Saves any weights round factorization as pivot rows may change
    11141104   1) before factorization
     
    11171107   4) restore weights
    11181108*/
    1119 void
    1120 AbcDualRowSteepest::saveWeights(AbcSimplex * model, int mode)
     1109void AbcDualRowSteepest::saveWeights(AbcSimplex *model, int mode)
    11211110{
    11221111  model_ = model;
    11231112  int numberRows = model_->numberRows();
    11241113  // faster to save indices in array numberTotal in length
    1125   const int * pivotVariable = model_->pivotVariable();
    1126   double * weights = weights_ ? weights_->denseVector() : NULL;
     1114  const int *pivotVariable = model_->pivotVariable();
     1115  double *weights = weights_ ? weights_->denseVector() : NULL;
    11271116  // see if we need to switch
    11281117  //if (mode_==2&&mode==2) {
    1129     // switch
    1130     //mode=5;
     1118  // switch
     1119  //mode=5;
    11311120  //}
    11321121  if (mode == 1) {
    1133     if(weights_) {
     1122    if (weights_) {
    11341123      // Check if size has changed
    11351124      if (infeasible_->capacity() == numberRows) {
    1136         // change from row numbers to sequence numbers
    1137         CoinAbcMemcpy(weights_->getIndices(),pivotVariable,numberRows);
    1138         state_ = 1;
     1125        // change from row numbers to sequence numbers
     1126        CoinAbcMemcpy(weights_->getIndices(), pivotVariable, numberRows);
     1127        state_ = 1;
    11391128      } else {
    1140         // size has changed - clear everything
    1141         delete weights_;
    1142         weights_ = NULL;
    1143         delete infeasible_;
    1144         infeasible_ = NULL;
    1145         delete savedWeights_;
    1146         savedWeights_ = NULL;
    1147         state_ = -1;
    1148       }
    1149     }
    1150   } else if (mode !=3) {
     1129        // size has changed - clear everything
     1130        delete weights_;
     1131        weights_ = NULL;
     1132        delete infeasible_;
     1133        infeasible_ = NULL;
     1134        delete savedWeights_;
     1135        savedWeights_ = NULL;
     1136        state_ = -1;
     1137      }
     1138    }
     1139  } else if (mode != 3) {
    11511140    // restore
    11521141    if (!weights_ || state_ == -1 || mode == 5) {
    11531142      // see if crash basis???
    1154       int numberBasicSlacks=0;
    1155       bool initializeNorms=false;
    1156       for (int i=0;i<numberRows;i++) {
    1157         if (model_->getInternalStatus(i)==AbcSimplex::basic)
    1158           numberBasicSlacks++;
    1159       }
    1160       if (numberBasicSlacks<numberRows&&!model_->numberIterations()) {
    1161         char line[100];
    1162         if (numberBasicSlacks>numberRows-(numberRows>>1)&&mode_==3&&
    1163             (model_->moreSpecialOptions()&256)==0) {
    1164           sprintf(line,"Steep initial basis has %d structurals out of %d - initializing norms\n",numberRows-numberBasicSlacks,numberRows);
    1165           initializeNorms=true;
    1166         } else {
    1167           sprintf(line,"Steep initial basis has %d structurals out of %d - too many\n",numberRows-numberBasicSlacks,numberRows);
    1168         }
    1169         model_->messageHandler()->message(CLP_GENERAL2,*model_->messagesPointer())
    1170           << line << CoinMessageEol;
     1143      int numberBasicSlacks = 0;
     1144      bool initializeNorms = false;
     1145      for (int i = 0; i < numberRows; i++) {
     1146        if (model_->getInternalStatus(i) == AbcSimplex::basic)
     1147          numberBasicSlacks++;
     1148      }
     1149      if (numberBasicSlacks < numberRows && !model_->numberIterations()) {
     1150        char line[100];
     1151        if (numberBasicSlacks > numberRows - (numberRows >> 1) && mode_ == 3 && (model_->moreSpecialOptions() & 256) == 0) {
     1152          sprintf(line, "Steep initial basis has %d structurals out of %d - initializing norms\n", numberRows - numberBasicSlacks, numberRows);
     1153          initializeNorms = true;
     1154        } else {
     1155          sprintf(line, "Steep initial basis has %d structurals out of %d - too many\n", numberRows - numberBasicSlacks, numberRows);
     1156        }
     1157        model_->messageHandler()->message(CLP_GENERAL2, *model_->messagesPointer())
     1158          << line << CoinMessageEol;
    11711159      }
    11721160      // initialize weights
     
    11781166      savedWeights_ = new CoinIndexedVector();
    11791167      // allow for dense multiple of 8!
    1180       savedWeights_->reserve(numberRows+((initializeNorms) ? 8 : 0));
     1168      savedWeights_->reserve(numberRows + ((initializeNorms) ? 8 : 0));
    11811169      infeasible_ = new CoinIndexedVector();
    11821170      infeasible_->reserve(numberRows);
    11831171      weights = weights_->denseVector();
    1184       if (mode == 5||(mode_!=1&&!initializeNorms)) {
    1185         // initialize to 1.0 (can we do better?)
    1186         for (int i = 0; i < numberRows; i++) {
    1187           weights[i] = 1.0;
    1188         }
     1172      if (mode == 5 || (mode_ != 1 && !initializeNorms)) {
     1173        // initialize to 1.0 (can we do better?)
     1174        for (int i = 0; i < numberRows; i++) {
     1175          weights[i] = 1.0;
     1176        }
    11891177      } else {
    1190         double *  COIN_RESTRICT array = savedWeights_->denseVector();
    1191         int *  COIN_RESTRICT which = savedWeights_->getIndices();
    1192         // Later look at factorization to see which can be skipped
    1193         // also use threads to parallelize
     1178        double *COIN_RESTRICT array = savedWeights_->denseVector();
     1179        int *COIN_RESTRICT which = savedWeights_->getIndices();
     1180        // Later look at factorization to see which can be skipped
     1181        // also use threads to parallelize
    11941182#if 0
    11951183        // use infeasible to collect row counts
     
    12131201        int nSlack=0;
    12141202#endif
    1215         //#undef ABC_PARALLEL
    1216         // for now just with cilk
    1217 #if ABC_PARALLEL==2
    1218         if (model_->parallelMode()==0) {
    1219 #endif 
    1220         for (int i = 0; i < numberRows; i++) {
    1221           double value = 0.0;
    1222           array[i] = 1.0;
    1223           which[0] = i;
    1224           savedWeights_->setNumElements(1);
    1225           model_->factorization()->updateColumnTranspose(*savedWeights_);
    1226           int number = savedWeights_->getNumElements();
    1227           for (int j = 0; j < number; j++) {
    1228             int k= which[j];
    1229             value += array[k] * array[k];
    1230             array[k] = 0.0;
    1231           }
     1203        //#undef ABC_PARALLEL
     1204        // for now just with cilk
     1205#if ABC_PARALLEL == 2
     1206        if (model_->parallelMode() == 0) {
     1207#endif
     1208          for (int i = 0; i < numberRows; i++) {
     1209            double value = 0.0;
     1210            array[i] = 1.0;
     1211            which[0] = i;
     1212            savedWeights_->setNumElements(1);
     1213            model_->factorization()->updateColumnTranspose(*savedWeights_);
     1214            int number = savedWeights_->getNumElements();
     1215            for (int j = 0; j < number; j++) {
     1216              int k = which[j];
     1217              value += array[k] * array[k];
     1218              array[k] = 0.0;
     1219            }
    12321220#if 0
    12331221          if (!counts[i]) {
     
    12361224          }
    12371225#endif
    1238           savedWeights_->setNumElements(0);
    1239           weights[i] = value;
    1240         }
    1241 #if ABC_PARALLEL==2
    1242         } else {
    1243           // parallel
    1244           // get arrays
    1245           int numberCpuMinusOne=CoinMin(model_->parallelMode(),3);
    1246           int which[3];
    1247           CoinIndexedVector * whichVector[4];
    1248           for (int i=0;i<numberCpuMinusOne;i++) {
    1249             which[i]=model_->getAvailableArray();
    1250             whichVector[i]=model_->usefulArray(which[i]);
    1251             assert(!whichVector[i]->packedMode());
    1252           }
    1253           whichVector[numberCpuMinusOne]=savedWeights_;
    1254           parallelDual5(model_->factorization(),whichVector,numberCpuMinusOne+1,numberCpuMinusOne,weights);
    1255           for (int i=0;i<numberCpuMinusOne;i++)
    1256             model_->clearArrays(which[i]);
    1257         }
    1258 #endif 
     1226            savedWeights_->setNumElements(0);
     1227            weights[i] = value;
     1228          }
     1229#if ABC_PARALLEL == 2
     1230        } else {
     1231          // parallel
     1232          // get arrays
     1233          int numberCpuMinusOne = CoinMin(model_->parallelMode(), 3);
     1234          int which[3];
     1235          CoinIndexedVector *whichVector[4];
     1236          for (int i = 0; i < numberCpuMinusOne; i++) {
     1237            which[i] = model_->getAvailableArray();
     1238            whichVector[i] = model_->usefulArray(which[i]);
     1239            assert(!whichVector[i]->packedMode());
     1240          }
     1241          whichVector[numberCpuMinusOne] = savedWeights_;
     1242          parallelDual5(model_->factorization(), whichVector, numberCpuMinusOne + 1, numberCpuMinusOne, weights);
     1243          for (int i = 0; i < numberCpuMinusOne; i++)
     1244            model_->clearArrays(which[i]);
     1245        }
     1246#endif
    12591247#if 0
    12601248        printf("Steep %d can be skipped\n",nSlack);
     
    12621250      }
    12631251    } else {
    1264       int useArray=model_->getAvailableArrayPublic();
    1265       CoinIndexedVector * usefulArray = model_->usefulArray(useArray);
    1266       int *  COIN_RESTRICT which = usefulArray->getIndices();
    1267       double *  COIN_RESTRICT element = usefulArray->denseVector();
    1268       if (mode!=4) {
    1269         CoinAbcMemcpy(which,weights_->getIndices(),numberRows);
    1270         CoinAbcScatterTo(weights_->denseVector(),element,which,numberRows);
     1252      int useArray = model_->getAvailableArrayPublic();
     1253      CoinIndexedVector *usefulArray = model_->usefulArray(useArray);
     1254      int *COIN_RESTRICT which = usefulArray->getIndices();
     1255      double *COIN_RESTRICT element = usefulArray->denseVector();
     1256      if (mode != 4) {
     1257        CoinAbcMemcpy(which, weights_->getIndices(), numberRows);
     1258        CoinAbcScatterTo(weights_->denseVector(), element, which, numberRows);
    12711259      } else {
    1272         // restore weights
    1273         CoinAbcMemcpy(which,savedWeights_->getIndices(),numberRows);
    1274         CoinAbcScatterTo(savedWeights_->denseVector(),element,which,numberRows);
     1260        // restore weights
     1261        CoinAbcMemcpy(which, savedWeights_->getIndices(), numberRows);
     1262        CoinAbcScatterTo(savedWeights_->denseVector(), element, which, numberRows);
    12751263      }
    12761264      for (int i = 0; i < numberRows; i++) {
    1277         int iPivot = pivotVariable[i];
    1278         double thisWeight=element[iPivot];
    1279         if (thisWeight) {
    1280           if (thisWeight < DEVEX_TRY_NORM)
    1281             thisWeight = DEVEX_TRY_NORM; // may need to check more
    1282           weights[i] = thisWeight;
    1283         } else {
    1284           // odd
    1285           weights[i] = 1.0;
    1286         }
     1265        int iPivot = pivotVariable[i];
     1266        double thisWeight = element[iPivot];
     1267        if (thisWeight) {
     1268          if (thisWeight < DEVEX_TRY_NORM)
     1269            thisWeight = DEVEX_TRY_NORM; // may need to check more
     1270          weights[i] = thisWeight;
     1271        } else {
     1272          // odd
     1273          weights[i] = 1.0;
     1274        }
    12871275      }
    12881276      if (0) {
    1289         double w[1000];
    1290         int s[1000];
    1291         assert (numberRows<=1000);
    1292         memcpy(w,weights,numberRows*sizeof(double));
    1293         memcpy(s,pivotVariable,numberRows*sizeof(int));
    1294         CoinSort_2(s,s+numberRows,w);
    1295         printf("Weights===========\n");
    1296         for (int i=0;i<numberRows;i++) {
    1297           printf("%d seq %d weight %g\n",i,s[i],w[i]);
    1298         }
    1299         printf("End weights===========\n");
     1277        double w[1000];
     1278        int s[1000];
     1279        assert(numberRows <= 1000);
     1280        memcpy(w, weights, numberRows * sizeof(double));
     1281        memcpy(s, pivotVariable, numberRows * sizeof(int));
     1282        CoinSort_2(s, s + numberRows, w);
     1283        printf("Weights===========\n");
     1284        for (int i = 0; i < numberRows; i++) {
     1285          printf("%d seq %d weight %g\n", i, s[i], w[i]);
     1286        }
     1287        printf("End weights===========\n");
    13001288      }
    13011289      usefulArray->setNumElements(numberRows);
     
    13051293    }
    13061294    state_ = 0;
    1307     CoinAbcMemcpy(savedWeights_->denseVector(),weights_->denseVector(),numberRows);
    1308     CoinAbcMemcpy(savedWeights_->getIndices(),pivotVariable,numberRows);
     1295    CoinAbcMemcpy(savedWeights_->denseVector(), weights_->denseVector(), numberRows);
     1296    CoinAbcMemcpy(savedWeights_->getIndices(), pivotVariable, numberRows);
    13091297  }
    13101298  if (mode >= 2) {
    13111299    infeasible_->clear();
    13121300    double tolerance = model_->currentPrimalTolerance();
    1313     const double *  COIN_RESTRICT solutionBasic = model_->solutionBasic();
    1314     const double *  COIN_RESTRICT lowerBasic = model_->lowerBasic();
    1315     const double *  COIN_RESTRICT upperBasic = model_->upperBasic();
    1316     if ((model_->stateOfProblem()&VALUES_PASS2)==0) {
     1301    const double *COIN_RESTRICT solutionBasic = model_->solutionBasic();
     1302    const double *COIN_RESTRICT lowerBasic = model_->lowerBasic();
     1303    const double *COIN_RESTRICT upperBasic = model_->upperBasic();
     1304    if ((model_->stateOfProblem() & VALUES_PASS2) == 0) {
    13171305      for (int iRow = 0; iRow < numberRows; iRow++) {
    1318         double value = solutionBasic[iRow];
    1319         double lower = lowerBasic[iRow];
    1320         double upper = upperBasic[iRow];
    1321         if (value < lower - tolerance) {
    1322           value -= lower;
    1323           value *= value;
     1306        double value = solutionBasic[iRow];
     1307        double lower = lowerBasic[iRow];
     1308        double upper = upperBasic[iRow];
     1309        if (value < lower - tolerance) {
     1310          value -= lower;
     1311          value *= value;
    13241312#ifdef CLP_DUAL_FIXED_COLUMN_MULTIPLIER
    1325           if (lower == upper)
    1326             value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
    1327 #endif
    1328           // store square in list
    1329           infeasible_->quickAdd(iRow, value);
    1330         } else if (value > upper + tolerance) {
    1331           value -= upper;
    1332           value *= value;
     1313          if (lower == upper)
     1314            value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
     1315#endif
     1316          // store square in list
     1317          infeasible_->quickAdd(iRow, value);
     1318        } else if (value > upper + tolerance) {
     1319          value -= upper;
     1320          value *= value;
    13331321#ifdef CLP_DUAL_FIXED_COLUMN_MULTIPLIER
    1334           if (lower == upper)
    1335             value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
    1336 #endif
    1337           // store square in list
    1338         infeasible_->quickAdd(iRow, value);
    1339         }
     1322          if (lower == upper)
     1323            value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
     1324#endif
     1325          // store square in list
     1326          infeasible_->quickAdd(iRow, value);
     1327        }
    13401328      }
    13411329    } else {
    13421330      // check values pass
    1343       const double * fakeDjs = model_->fakeDjs();
    1344       int numberFake=0;
     1331      const double *fakeDjs = model_->fakeDjs();
     1332      int numberFake = 0;
    13451333      for (int iRow = 0; iRow < numberRows; iRow++) {
    1346         double value = solutionBasic[iRow];
    1347         double lower = lowerBasic[iRow];
    1348         double upper = upperBasic[iRow];
    1349         if (value < lower - tolerance) {
    1350           value -= lower;
    1351         } else if (value > upper + tolerance) {
    1352           value -= upper;
    1353         } else {
    1354           value=0.0;
    1355         }
    1356         if (value) {
    1357           value *= value;
     1334        double value = solutionBasic[iRow];
     1335        double lower = lowerBasic[iRow];
     1336        double upper = upperBasic[iRow];
     1337        if (value < lower - tolerance) {
     1338          value -= lower;
     1339        } else if (value > upper + tolerance) {
     1340          value -= upper;
     1341        } else {
     1342          value = 0.0;
     1343        }
     1344        if (value) {
     1345          value *= value;
    13581346#ifdef CLP_DUAL_FIXED_COLUMN_MULTIPLIER
    1359           if (lower == upper)
    1360             value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
    1361 #endif
    1362           // store square in list
    1363           infeasible_->quickAdd(iRow, value);
    1364           int iSequence=pivotVariable[iRow];
    1365           double fakeDj=fakeDjs[iSequence];
    1366           if (fabs(fakeDj)>10.0*tolerance)
    1367             numberFake++;
    1368         }
     1347          if (lower == upper)
     1348            value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
     1349#endif
     1350          // store square in list
     1351          infeasible_->quickAdd(iRow, value);
     1352          int iSequence = pivotVariable[iRow];
     1353          double fakeDj = fakeDjs[iSequence];
     1354          if (fabs(fakeDj) > 10.0 * tolerance)
     1355            numberFake++;
     1356        }
    13691357      }
    13701358      if (numberFake)
    1371         printf("%d fake basic djs\n",numberFake);
     1359        printf("%d fake basic djs\n", numberFake);
    13721360      else
    1373         model_->setStateOfProblem(model_->stateOfProblem()&~VALUES_PASS2);
     1361        model_->setStateOfProblem(model_->stateOfProblem() & ~VALUES_PASS2);
    13741362    }
    13751363  }
    13761364}
    13771365// Recompute infeasibilities
    1378 void
    1379 AbcDualRowSteepest::recomputeInfeasibilities()
     1366void AbcDualRowSteepest::recomputeInfeasibilities()
    13801367{
    13811368  int numberRows = model_->numberRows();
    13821369  infeasible_->clear();
    13831370  double tolerance = model_->currentPrimalTolerance();
    1384   const double *  COIN_RESTRICT solutionBasic = model_->solutionBasic();
    1385   const double *  COIN_RESTRICT lowerBasic = model_->lowerBasic();
    1386   const double *  COIN_RESTRICT upperBasic = model_->upperBasic();
     1371  const double *COIN_RESTRICT solutionBasic = model_->solutionBasic();
     1372  const double *COIN_RESTRICT lowerBasic = model_->lowerBasic();
     1373  const double *COIN_RESTRICT upperBasic = model_->upperBasic();
    13871374  for (int iRow = 0; iRow < numberRows; iRow++) {
    13881375    double value = solutionBasic[iRow];
     
    13941381#ifdef CLP_DUAL_FIXED_COLUMN_MULTIPLIER
    13951382      if (lower == upper)
    1396         value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
     1383        value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
    13971384#endif
    13981385      // store square in list
     
    14031390#ifdef CLP_DUAL_FIXED_COLUMN_MULTIPLIER
    14041391      if (lower == upper)
    1405         value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
     1392        value *= CLP_DUAL_FIXED_COLUMN_MULTIPLIER; // bias towards taking out fixed variables
    14061393#endif
    14071394      // store square in list
     
    14131400// Clone
    14141401//-------------------------------------------------------------------
    1415 AbcDualRowPivot * AbcDualRowSteepest::clone(bool CopyData) const
     1402AbcDualRowPivot *AbcDualRowSteepest::clone(bool CopyData) const
    14161403{
    14171404  if (CopyData) {
     
    14221409}
    14231410// Gets rid of all arrays
    1424 void
    1425 AbcDualRowSteepest::clearArrays()
     1411void AbcDualRowSteepest::clearArrays()
    14261412{
    14271413  if (persistence_ == normal) {
     
    14361422}
    14371423// Returns true if would not find any row
    1438 bool
    1439 AbcDualRowSteepest::looksOptimal() const
     1424bool AbcDualRowSteepest::looksOptimal() const
    14401425{
    14411426  int iRow;
     
    14451430  double error = CoinMin(1.0e-2, model_->largestPrimalError());
    14461431  // allow tolerance at least slightly bigger than standard
    1447   tolerance = tolerance +  error;
     1432  tolerance = tolerance + error;
    14481433  // But cap
    14491434  tolerance = CoinMin(1000.0, tolerance);
    14501435  int numberRows = model_->numberRows();
    14511436  int numberInfeasible = 0;
    1452   const double *  COIN_RESTRICT solutionBasic = model_->solutionBasic();
    1453   const double *  COIN_RESTRICT lowerBasic = model_->lowerBasic();
    1454   const double *  COIN_RESTRICT upperBasic = model_->upperBasic();
     1437  const double *COIN_RESTRICT solutionBasic = model_->solutionBasic();
     1438  const double *COIN_RESTRICT lowerBasic = model_->lowerBasic();
     1439  const double *COIN_RESTRICT upperBasic = model_->upperBasic();
    14551440  for (iRow = 0; iRow < numberRows; iRow++) {
    14561441    double value = solutionBasic[iRow];
     
    14651450  return (numberInfeasible == 0);
    14661451}
     1452
     1453/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
     1454*/
Note: See TracChangeset for help on using the changeset viewer.