Changeset 27 for branches


Ignore:
Timestamp:
Sep 24, 2002 12:45:42 PM (17 years ago)
Author:
forrest
Message:

Changes to make more reliable if problem size changes

Location:
branches/devel-1
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-1/ClpDualRowPivot.cpp

    r19 r27  
    7575{
    7676}
     77// Gets rid of all arrays
     78void
     79ClpDualRowPivot::clearArrays()
     80{
     81}
  • branches/devel-1/ClpDualRowSteepest.cpp

    r19 r27  
    481481  }
    482482}
    483 
     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}
     496
  • branches/devel-1/ClpModel.cpp

    r19 r27  
    267267}
    268268void
     269ClpModel::loadProblem (
     270                              const int numcols, const int numrows,
     271                              const int* start, const int* index,
     272                              const double* value,const int* length,
     273                              const double* collb, const double* colub,   
     274                              const double* obj,
     275                              const double* rowlb, const double* rowub,
     276                              const double * rowObjective)
     277{
     278  gutsOfLoadModel(numrows, numcols,
     279                  collb, colub, obj, rowlb, rowub, rowObjective);
     280  // Compute number of elements
     281  int numberElements = 0;
     282  int i;
     283  for (i=0;i<numcols;i++)
     284    numberElements += length[i];
     285  CoinPackedMatrix matrix(true,numrows,numcols,numberElements,
     286                              value,index,start,length);
     287  matrix_ = new ClpPackedMatrix(matrix);
     288}
     289void
    269290ClpModel::getRowBound(int iRow, double& lower, double& upper) const
    270291{
  • branches/devel-1/ClpPrimalColumnPivot.cpp

    r19 r27  
    6666}
    6767
     68// Gets rid of all arrays
     69void
     70ClpPrimalColumnPivot::clearArrays()
     71{
     72}
  • branches/devel-1/ClpPrimalColumnSteepest.cpp

    r19 r27  
    940940  }
    941941}
     942// Gets rid of all arrays
     943void
     944ClpPrimalColumnSteepest::clearArrays()
     945{
     946  delete [] weights_;
     947  weights_=NULL;
     948  delete infeasible_;
     949  infeasible_ = NULL;
     950  delete alternateWeights_;
     951  alternateWeights_ = NULL;
     952  delete [] savedWeights_;
     953  savedWeights_ = NULL;
     954  delete [] reference_;
     955  reference_ = NULL;
     956}
  • branches/devel-1/ClpSimplex.cpp

    r26 r27  
    470470    gutsOfSolution ( rowActivities, columnActivities);
    471471    // release extra memory
    472     deleteRim();
     472    deleteRim(false);
    473473  }
    474474  return factorization_->status();
     
    497497  int status = internalFactorize(-1);
    498498  // release extra memory
    499   deleteRim();
     499  deleteRim(false);
    500500
    501501  return status;
     
    13141314    nonLinearCost_ = new ClpNonLinearCost(*rhs.nonLinearCost_);
    13151315}
    1316 // type == 0 do everything
     1316// type == 0 do everything, most + pivot data, 2 factorization data as well
    13171317void
    13181318ClpSimplex::gutsOfDelete(int type)
     
    13551355  delete rowCopy_;
    13561356  rowCopy_=NULL;
     1357  delete [] saveStatus_;
     1358  saveStatus_=NULL;
    13571359  if (!type) {
    13581360    // delete everything
     1361    delete factorization_;
     1362    factorization_ = NULL;
    13591363    delete [] pivotVariable_;
    13601364    pivotVariable_=NULL;
    1361     delete factorization_;
    1362     factorization_ = NULL;
    13631365    delete dualRowPivot_;
    13641366    dualRowPivot_ = NULL;
    13651367    delete primalColumnPivot_;
    13661368    primalColumnPivot_ = NULL;
    1367     delete [] saveStatus_;
    1368     saveStatus_=NULL;
    13691369    delete status_;
    13701370    status_=NULL;
     1371  } else {
     1372    // delete any size information in methods
     1373    if (type>1) {
     1374      factorization_->clearArrays();
     1375      delete [] pivotVariable_;
     1376      pivotVariable_=NULL;
     1377    }
     1378    dualRowPivot_->clearArrays();
     1379    primalColumnPivot_->clearArrays();
    13711380  }
    13721381}
     
    17801789}
    17811790void
    1782 ClpSimplex::deleteRim()
     1791ClpSimplex::deleteRim(bool getRidOfFactorizationData)
    17831792{
    17841793  int i;
     
    18211830  // scaling may have been turned off
    18221831  scalingFlag_ = abs(scalingFlag_);
    1823   gutsOfDelete(1);
     1832  if(getRidOfFactorizationData)
     1833    gutsOfDelete(2);
     1834  else
     1835    gutsOfDelete(1);
    18241836}
    18251837void
     
    29893001  createStatus();
    29903002}
     3003void
     3004ClpSimplex::loadProblem (  const int numcols, const int numrows,
     3005                           const int* start, const int* index,
     3006                           const double* value,const int * length,
     3007                           const double* collb, const double* colub,   
     3008                           const double* obj,
     3009                           const double* rowlb, const double* rowub,
     3010                           const double * rowObjective)
     3011{
     3012  ClpModel::loadProblem(numcols, numrows, start, index, value, length,
     3013                          collb, colub, obj, rowlb, rowub,
     3014                          rowObjective);
     3015  createStatus();
     3016}
    29913017// Read an mps file from the given filename
    29923018int
  • branches/devel-1/ClpSimplexDual.cpp

    r26 r27  
    345345
    346346  //assert(!numberFake_||problemStatus_); // all bounds should be okay
    347   // at present we are leaving factorization around
    348   // maybe we should empty it
     347  factorization_->sparseThreshold(saveSparse);
     348  // Get rid of some arrays and empty factorization
    349349  deleteRim();
    350350  handler_->message(CLP_SIMPLEX_FINISHED+problemStatus_,messages_)
     
    353353  // Restore any saved stuff
    354354  perturbation_ = savePerturbation;
    355   factorization_->sparseThreshold(saveSparse);
    356355  dualBound_ = saveDualBound_;
    357356  return problemStatus_;
     
    24132412  delete [] savePivot;
    24142413
    2415   // at present we are leaving factorization around
    2416   // maybe we should empty it
     2414  factorization_->sparseThreshold(saveSparse);
     2415  // Get rid of some arrays and empty factorization
    24172416  deleteRim();
    2418   factorization_->sparseThreshold(saveSparse);
    24192417#else
    24202418  // save basis and solution
  • branches/devel-1/ClpSimplexPrimal.cpp

    r26 r27  
    369369    computeDuals();
    370370  }
    371   // at present we are leaving factorization around
    372   // maybe we should empty it
     371  factorization_->sparseThreshold(saveSparse);
     372  // Get rid of some arrays and empty factorization
    373373  deleteRim();
    374374  handler_->message(CLP_SIMPLEX_FINISHED+problemStatus_,messages_)
     
    377377  // Restore any saved stuff
    378378  perturbation_ = savePerturbation;
    379   factorization_->sparseThreshold(saveSparse);
    380379  infeasibilityCost_ = saveInfeasibilityCost;
    381380  return problemStatus_;
  • branches/devel-1/include/ClpDualRowPivot.hpp

    r19 r27  
    5757  /// Gets rid of last update (may be empty)
    5858  virtual void unrollWeights();
     59  /// Gets rid of all arrays (may be empty)
     60  virtual void clearArrays();
    5961  //@}
    6062 
  • branches/devel-1/include/ClpDualRowSteepest.hpp

    r19 r27  
    5252  /// Gets rid of last update
    5353  virtual void unrollWeights();
     54  /// Gets rid of all arrays
     55  virtual void clearArrays();
    5456  //@}
    5557 
  • branches/devel-1/include/ClpModel.hpp

    r19 r27  
    7575                     const int* start, const int* index,
    7676                     const double* value,
     77                     const double* collb, const double* colub,   
     78                     const double* obj,
     79                      const double* rowlb, const double* rowub,
     80                      const double * rowObjective=NULL);
     81  /// This one is for after presolve to save memory
     82  void loadProblem (  const int numcols, const int numrows,
     83                     const int* start, const int* index,
     84                      const double* value,const int * length,
    7785                     const double* collb, const double* colub,   
    7886                     const double* obj,
     
    163171   inline double * primalColumnSolution() const { return columnActivity_; }
    164172   inline const double * getColSolution() const { return columnActivity_; }
     173   inline void setColSolution(const double * input)
     174   { memcpy(columnActivity_,input,numberColumns_*sizeof(double));};
    165175   /// Dual row solution
    166176   inline double * dualRowSolution() const      { return dual_; }
     
    193203      return matrix_->getPackedMatrix();
    194204   }
     205   /// Number of elements in matrix
     206   inline int getNumElements() const
     207     { return matrix_->getNumElements();};
    195208   /// Row Matrix
    196209   inline ClpMatrixBase * rowCopy() const       { return rowCopy_; }
  • branches/devel-1/include/ClpPrimalColumnPivot.hpp

    r19 r27  
    5656  virtual int pivotRow(double & way)
    5757  {way=0;return -2;};
     58  /// Gets rid of all arrays (may be empty)
     59  virtual void clearArrays();
    5860  //@}
    5961 
  • branches/devel-1/include/ClpPrimalColumnSteepest.hpp

    r19 r27  
    4848  /// Gets rid of last update
    4949  virtual void unrollWeights();
     50  /// Gets rid of all arrays
     51  virtual void clearArrays();
    5052  //@}
    5153 
  • branches/devel-1/include/ClpSimplex.hpp

    r26 r27  
    105105                     const int* start, const int* index,
    106106                     const double* value,
     107                     const double* collb, const double* colub,   
     108                     const double* obj,
     109                      const double* rowlb, const double* rowub,
     110                      const double * rowObjective=NULL);
     111  /// This one is for after presolve to save memory
     112  void loadProblem (  const int numcols, const int numrows,
     113                     const int* start, const int* index,
     114                      const double* value,const int * length,
    107115                     const double* collb, const double* colub,   
    108116                     const double* obj,
     
    371379                       const double * columnActivities,
    372380                       bool valuesPass=false);
    373   /// Does most of deletion (0 = all, 1 = most)
     381  /// Does most of deletion (0 = all, 1 = most, 2 most + factorization)
    374382  void gutsOfDelete(int type);
    375383  /// Does most of copying
     
    385393  */
    386394  bool createRim(int what,bool makeRowCopy=false);
    387   /// releases above arrays and does solution scaling out
    388   void deleteRim();
     395  /** releases above arrays and does solution scaling out.  May also
     396      get rid of factorization data */
     397  void deleteRim(bool getRidOfFactorizationData=true);
    389398  /// Sanity check on input rim data (after scaling) - returns true if okay
    390399  bool sanityCheck();
     
    516525  inline bool statusExists() const
    517526  { return (status_!=NULL);};
     527  /// Return address of status array (char[numberRows+numberColumns])
     528  inline unsigned char *  statusArray()
     529  { return status_;};
    518530  /** Set up status array (can be used by OsiClp).
    519531      Also can be used to set up all slack basis */
Note: See TracChangeset for help on using the changeset viewer.