Ignore:
Timestamp:
Nov 5, 2002 1:04:44 AM (19 years ago)
Author:
ladanyi
Message:

devel-1 merged into HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ClpDualRowSteepest.cpp

    r2 r50  
    99#include "ClpSimplex.hpp"
    1010#include "ClpDualRowSteepest.hpp"
    11 #include "OsiIndexedVector.hpp"
     11#include "CoinIndexedVector.hpp"
    1212#include "ClpFactorization.hpp"
    1313#include "CoinHelperFunctions.hpp"
    14 #include <stdio.h>
     14#include <cstdio>
    1515
    1616//#############################################################################
     
    3030    savedWeights_(NULL)
    3131{
    32   type_=2;
     32  type_=2+64*mode;
    3333}
    3434
     
    4343  model_ = rhs.model_;
    4444  if (rhs.infeasible_) {
    45     infeasible_= new OsiIndexedVector(rhs.infeasible_);
     45    infeasible_= new CoinIndexedVector(rhs.infeasible_);
    4646  } else {
    4747    infeasible_=NULL;
     
    5151    int number = model_->numberRows();
    5252    weights_= new double[number];
    53     CoinDisjointCopyN(rhs.weights_,number,weights_);
     53    ClpDisjointCopyN(rhs.weights_,number,weights_);
    5454  } else {
    5555    weights_=NULL;
    5656  }
    5757  if (rhs.alternateWeights_) {
    58     alternateWeights_= new OsiIndexedVector(rhs.alternateWeights_);
     58    alternateWeights_= new CoinIndexedVector(rhs.alternateWeights_);
    5959  } else {
    6060    alternateWeights_=NULL;
    6161  }
    6262  if (rhs.savedWeights_) {
    63     savedWeights_= new OsiIndexedVector(rhs.savedWeights_);
     63    savedWeights_= new CoinIndexedVector(rhs.savedWeights_);
    6464  } else {
    6565    savedWeights_=NULL;
     
    9494    delete savedWeights_;
    9595    if (rhs.infeasible_!=NULL) {
    96       infeasible_= new OsiIndexedVector(rhs.infeasible_);
     96      infeasible_= new CoinIndexedVector(rhs.infeasible_);
    9797    } else {
    9898      infeasible_=NULL;
     
    102102      int number = model_->numberRows();
    103103      weights_= new double[number];
    104       CoinDisjointCopyN(rhs.weights_,number,weights_);
     104      ClpDisjointCopyN(rhs.weights_,number,weights_);
    105105    } else {
    106106      weights_=NULL;
    107107    }
    108108    if (rhs.alternateWeights_!=NULL) {
    109       alternateWeights_= new OsiIndexedVector(rhs.alternateWeights_);
     109      alternateWeights_= new CoinIndexedVector(rhs.alternateWeights_);
    110110    } else {
    111111      alternateWeights_=NULL;
    112112    }
    113113    if (rhs.savedWeights_!=NULL) {
    114       savedWeights_= new OsiIndexedVector(rhs.savedWeights_);
     114      savedWeights_= new CoinIndexedVector(rhs.savedWeights_);
    115115    } else {
    116116      savedWeights_=NULL;
     
    153153// Updates weights
    154154void
    155 ClpDualRowSteepest::updateWeights(OsiIndexedVector * input,
    156                                   OsiIndexedVector * spare,
    157                                   OsiIndexedVector * updatedColumn)
     155ClpDualRowSteepest::updateWeights(CoinIndexedVector * input,
     156                                  CoinIndexedVector * spare,
     157                                  CoinIndexedVector * updatedColumn)
    158158{
    159159  // clear other region
     
    172172  {
    173173    int numberRows = model_->numberRows();
    174     OsiIndexedVector * temp = new OsiIndexedVector();
     174    CoinIndexedVector * temp = new CoinIndexedVector();
    175175    temp->reserve(numberRows+
    176176                  model_->factorization()->maximumPivots());
     
    245245      }
    246246    }
     247#ifdef CLP_DEBUG
    247248    assert(work3[pivotRow]&&work[pivotRow]);
     249#endif
    248250    alternateWeights_->setNumElements(nSave);
    249251    if (norm < TRY_NORM)
     
    263265void
    264266ClpDualRowSteepest::updatePrimalSolution(
    265                                         OsiIndexedVector * primalUpdate,
     267                                        CoinIndexedVector * primalUpdate,
    266268                                        double primalRatio,
    267269                                        double & objectiveChange)
     
    275277  const int * pivotVariable = model_->pivotVariable();
    276278  double * infeas = infeasible_->denseVector();
     279  int pivotRow = model_->pivotRow();
     280  double * solution = model_->solutionRegion();
    277281  for (i=0;i<number;i++) {
    278282    int iRow=which[i];
    279283    int iPivot=pivotVariable[iRow];
    280     double & value = model_->solutionAddress(iPivot);
     284    double value = solution[iPivot];
    281285    double cost = model_->cost(iPivot);
    282286    double change = primalRatio*work[iRow];
    283287    value -= change;
     288    changeObj -= change*cost;
     289    solution[iPivot] = value;
    284290    double lower = model_->lower(iPivot);
    285291    double upper = model_->upper(iPivot);
     292    // But if pivot row then use value of incoming
     293    if (iRow==pivotRow) {
     294      iPivot = model_->sequenceIn();
     295      // make last resort choice
     296      lower = 1.0e-6*model_->lower(iPivot);
     297      upper = 1.0e-6*model_->upper(iPivot);
     298      value = 1.0e-6*model_->valueIncomingDual();
     299    }
    286300    if (value>upper+tolerance) {
    287301      // store square in list
     
    301315        infeas[iRow] = 1.0e-100;
    302316    }
    303     changeObj -= change*cost;
    304317    work[iRow]=0.0;
    305318  }
     
    332345    }
    333346    state_=1;
    334   } else if (mode==2||mode==4) {
     347  } else if (mode==2||mode==4||mode==5) {
    335348    // restore
    336     if (!weights_||state_==-1) {
     349    if (!weights_||state_==-1||mode==5) {
    337350      // initialize weights
    338351      delete [] weights_;
    339352      delete alternateWeights_;
    340353      weights_ = new double[numberRows];
    341       alternateWeights_ = new OsiIndexedVector();
     354      alternateWeights_ = new CoinIndexedVector();
    342355      // enough space so can use it for factorization
    343356      alternateWeights_->reserve(numberRows+
    344357                                 model_->factorization()->maximumPivots());
    345       if (!mode_) {
     358      if (!mode_||mode==5) {
    346359        // initialize to 1.0 (can we do better?)
    347360        for (i=0;i<numberRows;i++) {
     
    349362        }
    350363      } else {
    351         OsiIndexedVector * temp = new OsiIndexedVector();
     364        CoinIndexedVector * temp = new CoinIndexedVector();
    352365        temp->reserve(numberRows+
    353366                      model_->factorization()->maximumPivots());
     
    374387      }
    375388      // create saved weights (not really indexedvector)
    376       savedWeights_ = new OsiIndexedVector();
     389      savedWeights_ = new CoinIndexedVector();
    377390      savedWeights_->reserve(numberRows);
    378391     
     
    415428    // set up infeasibilities
    416429    if (!infeasible_) {
    417       infeasible_ = new OsiIndexedVector();
     430      infeasible_ = new CoinIndexedVector();
    418431      infeasible_->reserve(numberRows);
    419432    }
     
    468481  }
    469482}
    470 
     483// Gets rid of all arrays
     484void
     485ClpDualRowSteepest::clearArrays()
     486{
     487  delete [] weights_;
     488  weights_=NULL;
     489  delete infeasible_;
     490  infeasible_ = NULL;
     491  delete alternateWeights_;
     492  alternateWeights_ = NULL;
     493  delete savedWeights_;
     494  savedWeights_ = NULL;
     495  state_ =-1;
     496}
     497
Note: See TracChangeset for help on using the changeset viewer.