00001
00002
00003 #ifndef ClpMatrixBase_H
00004 #define ClpMatrixBase_H
00005
00006 #include "CoinPragma.hpp"
00007
00008 #include "CoinPackedMatrix.hpp"
00009 class CoinIndexedVector;
00010 class ClpSimplex;
00011 class ClpModel;
00012
00026 class ClpMatrixBase {
00027
00028 public:
00031
00032 virtual CoinPackedMatrix * getPackedMatrix() const = 0;
00034 virtual bool isColOrdered() const = 0;
00036 virtual CoinBigIndex getNumElements() const = 0;
00038 virtual int getNumCols() const = 0;
00040 virtual int getNumRows() const = 0;
00041
00046 virtual const double * getElements() const = 0;
00052 virtual const int * getIndices() const = 0;
00053
00054 virtual const CoinBigIndex * getVectorStarts() const = 0;
00056 virtual const int * getVectorLengths() const = 0 ;
00058 virtual int getVectorLength(int index) const ;
00060 virtual void deleteCols(const int numDel, const int * indDel) = 0;
00062 virtual void deleteRows(const int numDel, const int * indDel) = 0;
00063 #ifndef CLP_NO_VECTOR
00065 virtual void appendCols(int number, const CoinPackedVectorBase * const * columns);
00067 virtual void appendRows(int number, const CoinPackedVectorBase * const * rows);
00068 #endif
00069
00072 virtual void modifyCoefficient(int row, int column, double newElement,
00073 bool keepZero=false);
00078 virtual int appendMatrix(int number, int type,
00079 const CoinBigIndex * starts, const int * index,
00080 const double * element, int numberOther=-1);
00081
00084 virtual ClpMatrixBase * reverseOrderedCopy() const {return NULL;}
00085
00087 virtual CoinBigIndex countBasis(ClpSimplex * model,
00088 const int * whichColumn,
00089 int numberRowBasic,
00090 int & numberColumnBasic)=0;
00092 virtual void fillBasis(ClpSimplex * model,
00093 const int * whichColumn,
00094 int & numberColumnBasic,
00095 int * row, int * start,
00096 int * rowCount, int * columnCount,
00097 double * element)=0;
00101 virtual int scale(ClpModel * model, const ClpSimplex * baseModel=NULL) const
00102 { return 1;}
00105 virtual void scaleRowCopy(ClpModel * model) const
00106 { }
00108 virtual bool canGetRowCopy() const
00109 { return true;}
00113 inline virtual ClpMatrixBase * scaledColumnCopy(ClpModel * model) const
00114 { return this->clone();}
00115
00126 virtual bool allElementsInRange(ClpModel * model,
00127 double smallest, double largest,
00128 int check=15)
00129 { return true;}
00135 virtual void setDimensions(int numrows, int numcols);
00139 virtual void rangeOfElements(double & smallestNegative, double & largestNegative,
00140 double & smallestPositive, double & largestPositive);
00141
00144 virtual void unpack(const ClpSimplex * model,CoinIndexedVector * rowArray,
00145 int column) const =0;
00150 virtual void unpackPacked(ClpSimplex * model,
00151 CoinIndexedVector * rowArray,
00152 int column) const =0;
00157 virtual int refresh(ClpSimplex * model)
00158 { return 0;}
00159
00160
00161 virtual void reallyScale(const double * rowScale, const double * columnScale);
00167 virtual CoinBigIndex * dubiousWeights(const ClpSimplex * model,int * inputWeights) const;
00170 virtual void add(const ClpSimplex * model,CoinIndexedVector * rowArray,
00171 int column, double multiplier) const =0;
00173 virtual void add(const ClpSimplex * model,double * array,
00174 int column, double multiplier) const =0;
00176 virtual void releasePackedMatrix() const =0;
00178 virtual bool canDoPartialPricing() const;
00180 virtual int hiddenRows() const;
00182 virtual void partialPricing(ClpSimplex * model, double start, double end,
00183 int & bestSequence, int & numberWanted);
00193 virtual int extendUpdated(ClpSimplex * model,CoinIndexedVector * update,int mode);
00200 virtual void primalExpanded(ClpSimplex * model,int mode);
00210 virtual void dualExpanded(ClpSimplex * model,CoinIndexedVector * array,
00211 double * other,int mode);
00231 virtual int generalExpanded(ClpSimplex * model,int mode,int & number);
00235 virtual int updatePivot(ClpSimplex * model,double oldInValue, double oldOutValue);
00239 virtual void createVariable(ClpSimplex * model, int & bestSequence);
00242 virtual int checkFeasible(ClpSimplex * model,double & sum) const ;
00244 double reducedCost(ClpSimplex * model,int sequence) const;
00246 virtual void correctSequence(const ClpSimplex * model,int & sequenceIn, int & sequenceOut) ;
00248
00249
00257 virtual void times(double scalar,
00258 const double * x, double * y) const=0;
00262 virtual void times(double scalar,
00263 const double * x, double * y,
00264 const double * rowScale,
00265 const double * columnScale) const;
00269 virtual void transposeTimes(double scalar,
00270 const double * x, double * y) const = 0;
00274 virtual void transposeTimes(double scalar,
00275 const double * x, double * y,
00276 const double * rowScale,
00277 const double * columnScale,
00278 double * spare=NULL) const;
00283 virtual void transposeTimes(const ClpSimplex * model, double scalar,
00284 const CoinIndexedVector * x,
00285 CoinIndexedVector * y,
00286 CoinIndexedVector * z) const = 0;
00291 virtual void subsetTransposeTimes(const ClpSimplex * model,
00292 const CoinIndexedVector * x,
00293 const CoinIndexedVector * y,
00294 CoinIndexedVector * z) const = 0;
00297 virtual bool canCombine(const ClpSimplex * model,
00298 const CoinIndexedVector * pi) const {return false;}
00300 virtual void transposeTimes2(const ClpSimplex * model,
00301 const CoinIndexedVector * pi1, CoinIndexedVector * dj1,
00302 const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
00303 CoinIndexedVector * spare,
00304 double referenceIn, double devex,
00305
00306 unsigned int * reference,
00307 double * weights, double scaleFactor);
00309 virtual void subsetTimes2(const ClpSimplex * model,
00310 CoinIndexedVector * dj1,
00311 const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
00312 double referenceIn, double devex,
00313
00314 unsigned int * reference,
00315 double * weights, double scaleFactor);
00320 virtual void listTransposeTimes(const ClpSimplex * model,
00321 double * x,
00322 int * y,
00323 int number,
00324 double * z) const;
00326
00327
00328
00329 virtual ClpMatrixBase * clone() const = 0;
00334 virtual ClpMatrixBase * subsetClone (
00335 int numberRows, const int * whichRows,
00336 int numberColumns, const int * whichColumns) const;
00338 virtual void backToBasics() {}
00345 inline int type() const
00346 { return type_;}
00348 void setType(int type) {type_=type;}
00350 void useEffectiveRhs(ClpSimplex * model);
00354 virtual double * rhsOffset(ClpSimplex * model,bool forceRefresh=false,
00355 bool check=false);
00357 inline int lastRefresh() const
00358 { return lastRefresh_;}
00360 inline int refreshFrequency() const
00361 { return refreshFrequency_;}
00362 inline void setRefreshFrequency(int value)
00363 { refreshFrequency_=value;}
00365 inline bool skipDualCheck() const
00366 { return skipDualCheck_;}
00367 inline void setSkipDualCheck(bool yes)
00368 { skipDualCheck_=yes;}
00371 inline int minimumObjectsScan() const
00372 { return minimumObjectsScan_;}
00373 inline void setMinimumObjectsScan(int value)
00374 { minimumObjectsScan_=value;}
00376 inline int minimumGoodReducedCosts() const
00377 { return minimumGoodReducedCosts_;}
00378 inline void setMinimumGoodReducedCosts(int value)
00379 { minimumGoodReducedCosts_=value;}
00381 inline double startFraction() const
00382 { return startFraction_;}
00383 inline void setStartFraction(double value)
00384 { startFraction_ = value;}
00386 inline double endFraction() const
00387 { return endFraction_;}
00388 inline void setEndFraction(double value)
00389 { endFraction_ = value;}
00391 inline double savedBestDj() const
00392 { return savedBestDj_;}
00393 inline void setSavedBestDj(double value)
00394 { savedBestDj_ = value;}
00396 inline int originalWanted() const
00397 { return originalWanted_;}
00398 inline void setOriginalWanted(int value)
00399 { originalWanted_ = value;}
00401 inline int currentWanted() const
00402 { return currentWanted_;}
00403 inline void setCurrentWanted(int value)
00404 { currentWanted_ = value;}
00406 inline int savedBestSequence() const
00407 { return savedBestSequence_;}
00408 inline void setSavedBestSequence(int value)
00409 { savedBestSequence_ = value;}
00411
00412
00413 protected:
00414
00420 ClpMatrixBase();
00422 public:
00423 virtual ~ClpMatrixBase();
00424 protected:
00425
00426 ClpMatrixBase(const ClpMatrixBase&);
00427
00428 ClpMatrixBase& operator=(const ClpMatrixBase&);
00430
00431
00432 protected:
00439 double * rhsOffset_;
00441 double startFraction_;
00443 double endFraction_;
00445 double savedBestDj_;
00447 int originalWanted_;
00449 int currentWanted_;
00451 int savedBestSequence_;
00453 int type_;
00455 int lastRefresh_;
00457 int refreshFrequency_;
00459 int minimumObjectsScan_;
00461 int minimumGoodReducedCosts_;
00463 int trueSequenceIn_;
00465 int trueSequenceOut_;
00467 bool skipDualCheck_;
00469 };
00470
00471 #define FREE_BIAS 1.0e1
00472
00473 #define FREE_ACCEPT 1.0e2
00474
00475 #endif