Changeset 1109


Ignore:
Timestamp:
Sep 17, 2007 9:46:00 AM (12 years ago)
Author:
forrest
Message:

move some minor stuff from trunk

Location:
stable/1.5/Clp/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • stable/1.5/Clp/src/ClpGubDynamicMatrix.hpp

    r1099 r1109  
    4848                                bool check=false);
    4949
     50  using ClpPackedMatrix::times ;
    5051    /** Return <code>y + A * scalar *x</code> in <code>y</code>.
    5152        @pre <code>x</code> must be of size <code>numColumns()</code>
  • stable/1.5/Clp/src/ClpPlusMinusOneMatrix.cpp

    r901 r1109  
    2727{
    2828  setType(12);
    29   elements_ = NULL;
     29  matrix_ = NULL;
    3030  startPositive_ = NULL;
    3131  startNegative_ = NULL;
     
    4343: ClpMatrixBase(rhs)
    4444
    45   elements_ = NULL;
     45  matrix_ = NULL;
    4646  startPositive_ = NULL;
    4747  startNegative_ = NULL;
     
    7575{
    7676  setType(12);
    77   elements_ = NULL;
     77  matrix_ = NULL;
    7878  lengths_=NULL;
    7979  numberRows_=numberRows;
     
    9393
    9494  setType(12);
    95   elements_ = NULL;
     95  matrix_ = NULL;
    9696  startPositive_ = NULL;
    9797  startNegative_ = NULL;
     
    174174ClpPlusMinusOneMatrix::~ClpPlusMinusOneMatrix ()
    175175{
    176   delete [] elements_;
     176  delete matrix_;
    177177  delete [] startPositive_;
    178178  delete [] startNegative_;
     
    189189  if (this != &rhs) {
    190190    ClpMatrixBase::operator=(rhs);
    191     delete [] elements_;
     191    delete matrix_;
    192192    delete [] startPositive_;
    193193    delete [] startNegative_;
    194194    delete [] lengths_;
    195195    delete [] indices_;
    196     elements_ = NULL;
     196    matrix_ = NULL;
    197197    startPositive_ = NULL;
    198198    lengths_=NULL;
     
    238238: ClpMatrixBase(rhs)
    239239
    240   elements_ = NULL;
     240  matrix_ = NULL;
    241241  startPositive_ = NULL;
    242242  startNegative_ = NULL;
     
    10421042ClpPlusMinusOneMatrix::getPackedMatrix() const
    10431043{
    1044   int numberMinor = (!columnOrdered_) ? numberColumns_ : numberRows_;
    1045   int numberMajor = (columnOrdered_) ? numberColumns_ : numberRows_;
    1046   return new CoinPackedMatrix(columnOrdered_,numberMinor,numberMajor,
     1044  if (!matrix_) {
     1045    int numberMinor = (!columnOrdered_) ? numberColumns_ : numberRows_;
     1046    int numberMajor = (columnOrdered_) ? numberColumns_ : numberRows_;
     1047    int numberElements = startPositive_[numberMajor];
     1048    double * elements = new double [numberElements];
     1049    CoinBigIndex j=0;
     1050    int i;
     1051    for (i=0;i<numberMajor;i++) {
     1052      for (;j<startNegative_[i];j++) {
     1053        elements[j]=1.0;
     1054      }
     1055      for (;j<startPositive_[i+1];j++) {
     1056        elements[j]=-1.0;
     1057      }
     1058    }
     1059    matrix_ =  new CoinPackedMatrix(columnOrdered_,numberMinor,numberMajor,
    10471060                              getNumElements(),
    1048                               getElements(),indices_,
     1061                              elements,indices_,
    10491062                              startPositive_,getVectorLengths());
    1050 
     1063    delete [] elements;
     1064  }
     1065  return matrix_;
    10511066}
    10521067/* A vector containing the elements in the packed matrix. Note that there
     
    10571072ClpPlusMinusOneMatrix::getElements() const
    10581073{
    1059   if (!elements_) {
    1060     int numberMajor = (columnOrdered_) ? numberColumns_ : numberRows_;
    1061     int numberElements = startPositive_[numberMajor];
    1062     elements_ = new double [numberElements];
    1063     CoinBigIndex j=0;
    1064     int i;
    1065     for (i=0;i<numberMajor;i++) {
    1066       for (;j<startNegative_[i];j++) {
    1067         elements_[j]=1.0;
    1068       }
    1069       for (;j<startPositive_[i+1];j++) {
    1070         elements_[j]=-1.0;
    1071       }
    1072     }
    1073   }
    1074   return elements_;
     1074  if (!matrix_)
     1075    getPackedMatrix();
     1076  return matrix_->getElements();
    10751077}
    10761078
     
    11231125  delete [] lengths_;
    11241126  lengths_=NULL;
    1125   delete [] elements_;
    1126   elements_= NULL;
     1127  delete matrix_;
     1128  matrix_= NULL;
    11271129  CoinBigIndex * newPositive = new CoinBigIndex [newNumber+1];
    11281130  CoinBigIndex * newNegative = new CoinBigIndex [newNumber];
     
    11911193  delete [] lengths_;
    11921194  lengths_=NULL;
    1193   delete [] elements_;
    1194   elements_= NULL;
     1195  delete matrix_;
     1196  matrix_= NULL;
    11951197  int * newIndices = new int [newSize];
    11961198  newSize=0;
     
    13341336  delete [] lengths_;
    13351337  lengths_=NULL;
    1336   delete [] elements_;
    1337   elements_= NULL;
     1338  delete matrix_;
     1339  matrix_= NULL;
    13381340  int numberNow = startPositive_[numberColumns_];
    13391341  CoinBigIndex * temp;
     
    14041406  delete [] lengths_;
    14051407  lengths_=NULL;
    1406   delete [] elements_;
    1407   elements_= NULL;
     1408  delete matrix_;
     1409  matrix_= NULL;
    14081410  int numberNow = startPositive_[numberColumns_];
    14091411  int * newIndices = new int [numberNow+size];
     
    16321634ClpPlusMinusOneMatrix::releasePackedMatrix() const
    16331635{
    1634   delete [] elements_;
     1636  delete matrix_;
    16351637  delete [] lengths_;
    1636   elements_=NULL;
     1638  matrix_=NULL;
    16371639  lengths_=NULL;
    16381640}
  • stable/1.5/Clp/src/ClpPlusMinusOneMatrix.hpp

    r1055 r1109  
    254254   //@{
    255255  /// For fake CoinPackedMatrix
    256   mutable double * elements_;
     256  mutable CoinPackedMatrix * matrix_;
    257257  mutable int * lengths_;
    258258  /// Start of +1's for each
  • stable/1.5/Clp/src/ClpSimplex.cpp

    r1093 r1109  
    83988398  // But swap if pivot variable was slack as clp stores slack as -1.0
    83998399  double value = (pivotVariable_[row]<numberColumns_) ? 1.0 : -1.0;
    8400   // What about scaling ?
     8400  // but scale
     8401  if (rowScale_) {
     8402    int pivot = pivotVariable_[row];
     8403    if (pivot<numberColumns_)
     8404      value *= columnScale_[pivot];
     8405    else
     8406      value /= rowScale_[pivot-numberColumns_];
     8407  }
    84018408  rowArray1->insert(row,value);
    84028409  factorization->updateColumnTranspose(rowArray0,rowArray1);
    8403   memcpy(z,rowArray1->denseVector(),numberRows()*sizeof(double));
     8410  if (!rowScale_) {
     8411    memcpy(z,rowArray1->denseVector(),numberRows_*sizeof(double));
     8412  } else {
     8413    double * array = rowArray1->denseVector();
     8414    for (int i=0;i<numberRows_;i++) {
     8415      z[i] = array[i] * rowScale_[i];
     8416    }
     8417  }
    84048418  rowArray1->clear();
    84058419}
     
    84758489    abort();
    84768490  }
    8477   ClpFactorization * factorization = factorization_;
    84788491  CoinIndexedVector * rowArray0 = rowArray(0);
    84798492  CoinIndexedVector * rowArray1 = rowArray(1);
     
    84878500#endif
    84888501  // put +1 in row
     8502  // but scale
     8503  double value;
     8504  if (!rowScale_) {
     8505    value=1.0;
     8506  } else {
     8507    value = rowScale_[col];
     8508  }
     8509  rowArray1->insert(col,value);
     8510  factorization_->updateColumn(rowArray0,rowArray1,false);
    84898511  // But swap if pivot variable was slack as clp stores slack as -1.0
    8490   double value = (pivotVariable_[col]<numberColumns_) ? 1.0 : -1.0;
    8491   // What about scaling ?
    8492   rowArray1->insert(col,value);
    8493   factorization->updateColumn(rowArray0,rowArray1,false);
    8494   memcpy(vec,rowArray1->denseVector(),numberRows()*sizeof(double));
     8512  double * array = rowArray1->denseVector();
     8513  if (!rowScale_) {
     8514    for (int i=0;i<numberRows_;i++) {
     8515      double multiplier = (pivotVariable_[i]<numberColumns_) ? 1.0 : -1.0;
     8516      vec[i] = multiplier * array[i];
     8517    }
     8518  } else {
     8519    for (int i=0;i<numberRows_;i++) {
     8520      int pivot = pivotVariable_[i];
     8521      double value = array[i];
     8522      if (pivot<numberColumns_)
     8523        vec[i] = value * columnScale_[pivot];
     8524      else
     8525        vec[i] = - value / rowScale_[pivot-numberColumns_];
     8526    }
     8527  }
    84958528  rowArray1->clear();
    84968529}
     
    92859318    factorization_->setPersistenceFlag(value);
    92869319}
     9320// Move status and solution across
     9321void
     9322ClpSimplex::moveInfo(const ClpSimplex & rhs, bool justStatus)
     9323{
     9324  objectiveValue_ = rhs.objectiveValue_;
     9325  numberIterations_ = rhs. numberIterations_;
     9326  problemStatus_ = rhs. problemStatus_;
     9327  secondaryStatus_ = rhs. secondaryStatus_;
     9328  assert (numberRows_ == rhs.numberRows_);
     9329  assert (numberColumns_ == rhs.numberColumns_);
     9330  if (!justStatus) {
     9331    delete [] status_;
     9332    if (rhs.status_) {
     9333      status_ = CoinCopyOfArray(rhs.status_,numberRows_+numberColumns_);
     9334    } else {
     9335      status_ = NULL;
     9336    }
     9337    memcpy(columnActivity_,rhs.columnActivity_,numberColumns_*sizeof(double));
     9338    memcpy(reducedCost_,rhs.reducedCost_,numberColumns_*sizeof(double));
     9339    memcpy(rowActivity_,rhs.rowActivity_,numberRows_*sizeof(double));
     9340    memcpy(dual_,rhs.dual_,numberRows_*sizeof(double));
     9341  }
     9342}
    92879343// Create C++ lines to get to current state
    92889344void
  • stable/1.5/Clp/src/ClpSimplex.hpp

    r1090 r1109  
    964964  /// May delete or may make clean and emptyish factorization
    965965  void setEmptyFactorization();
     966  /// Move status and solution across
     967  void moveInfo(const ClpSimplex & rhs, bool justStatus=false);
    966968  //@}
    967969
  • stable/1.5/Clp/src/ClpSolve.cpp

    r1088 r1109  
    672672      plusMinus=true;
    673673  }
     674  //plusMinus=true;
    674675#ifndef SLIM_CLP
    675676  // Statistics (+1,-1, other) - used to decide on strategy if not +-1
     
    22182219    time2=0.0;
    22192220  }
    2220   if (saveMatrix&&model2==this) {
    2221     // delete and replace
    2222     delete model2->clpMatrix();
    2223     model2->replaceMatrix(saveMatrix);
     2221  if (saveMatrix) {
     2222    if (model2==this) {
     2223      // delete and replace
     2224      delete model2->clpMatrix();
     2225      model2->replaceMatrix(saveMatrix);
     2226    } else {
     2227      delete saveMatrix;
     2228    }
    22242229  }
    22252230  numberIterations = model2->numberIterations();
Note: See TracChangeset for help on using the changeset viewer.