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
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);
00230 virtual int generalExpanded(ClpSimplex * model,int mode,int & number);
00234 virtual int updatePivot(ClpSimplex * model,double oldInValue, double oldOutValue);
00238 virtual void createVariable(ClpSimplex * model, int & bestSequence);
00241 virtual int checkFeasible(ClpSimplex * model,double & sum) const ;
00243 double reducedCost(ClpSimplex * model,int sequence) const;
00245 virtual void correctSequence(int & sequenceIn, int & sequenceOut) const;
00247
00248
00256 virtual void times(double scalar,
00257 const double * x, double * y) const=0;
00261 virtual void times(double scalar,
00262 const double * x, double * y,
00263 const double * rowScale,
00264 const double * columnScale) const;
00268 virtual void transposeTimes(double scalar,
00269 const double * x, double * y) const = 0;
00273 virtual void transposeTimes(double scalar,
00274 const double * x, double * y,
00275 const double * rowScale,
00276 const double * columnScale,
00277 double * spare=NULL) const;
00282 virtual void transposeTimes(const ClpSimplex * model, double scalar,
00283 const CoinIndexedVector * x,
00284 CoinIndexedVector * y,
00285 CoinIndexedVector * z) const = 0;
00290 virtual void subsetTransposeTimes(const ClpSimplex * model,
00291 const CoinIndexedVector * x,
00292 const CoinIndexedVector * y,
00293 CoinIndexedVector * z) const = 0;
00296 virtual bool canCombine(const ClpSimplex * model,
00297 const CoinIndexedVector * pi) const {return false;};
00299 virtual void transposeTimes2(const ClpSimplex * model,
00300 const CoinIndexedVector * pi1, CoinIndexedVector * dj1,
00301 const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
00302 CoinIndexedVector * spare,
00303 double referenceIn, double devex,
00304
00305 unsigned int * reference,
00306 double * weights, double scaleFactor);
00308 virtual void subsetTimes2(const ClpSimplex * model,
00309 CoinIndexedVector * dj1,
00310 const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
00311 double referenceIn, double devex,
00312
00313 unsigned int * reference,
00314 double * weights, double scaleFactor);
00319 virtual void listTransposeTimes(const ClpSimplex * model,
00320 double * x,
00321 int * y,
00322 int number,
00323 double * z) const;
00325
00326
00327
00328 virtual ClpMatrixBase * clone() const = 0;
00333 virtual ClpMatrixBase * subsetClone (
00334 int numberRows, const int * whichRows,
00335 int numberColumns, const int * whichColumns) const;
00336
00343 inline int type() const
00344 { return type_;};
00346 void setType(int type) {type_=type;};
00348 void useEffectiveRhs(ClpSimplex * model);
00352 virtual double * rhsOffset(ClpSimplex * model,bool forceRefresh=false,
00353 bool check=false);
00355 inline int lastRefresh() const
00356 { return lastRefresh_;};
00358 inline int refreshFrequency() const
00359 { return refreshFrequency_;};
00360 inline void setRefreshFrequency(int value)
00361 { refreshFrequency_=value;};
00363 inline bool skipDualCheck() const
00364 { return skipDualCheck_;};
00365 inline void setSkipDualCheck(bool yes)
00366 { skipDualCheck_=yes;};
00369 inline int minimumObjectsScan() const
00370 { return minimumObjectsScan_;};
00371 inline void setMinimumObjectsScan(int value)
00372 { minimumObjectsScan_=value;};
00374 inline int minimumGoodReducedCosts() const
00375 { return minimumGoodReducedCosts_;};
00376 inline void setMinimumGoodReducedCosts(int value)
00377 { minimumGoodReducedCosts_=value;};
00379 inline double startFraction() const
00380 { return startFraction_;};
00381 inline void setStartFraction(double value)
00382 { startFraction_ = value;};
00384 inline double endFraction() const
00385 { return endFraction_;};
00386 inline void setEndFraction(double value)
00387 { endFraction_ = value;};
00389 inline double savedBestDj() const
00390 { return savedBestDj_;};
00391 inline void setSavedBestDj(double value)
00392 { savedBestDj_ = value;};
00394 inline int originalWanted() const
00395 { return originalWanted_;};
00396 inline void setOriginalWanted(int value)
00397 { originalWanted_ = value;};
00399 inline int currentWanted() const
00400 { return currentWanted_;};
00401 inline void setCurrentWanted(int value)
00402 { currentWanted_ = value;};
00404 inline int savedBestSequence() const
00405 { return savedBestSequence_;};
00406 inline void setSavedBestSequence(int value)
00407 { savedBestSequence_ = value;};
00409
00410
00411 protected:
00412
00418 ClpMatrixBase();
00420 public:
00421 virtual ~ClpMatrixBase();
00422 protected:
00423
00424 ClpMatrixBase(const ClpMatrixBase&);
00425
00426 ClpMatrixBase& operator=(const ClpMatrixBase&);
00428
00429
00430 protected:
00437 double * rhsOffset_;
00439 double startFraction_;
00441 double endFraction_;
00443 double savedBestDj_;
00445 int originalWanted_;
00447 int currentWanted_;
00449 int savedBestSequence_;
00451 int type_;
00453 int lastRefresh_;
00455 int refreshFrequency_;
00457 int minimumObjectsScan_;
00459 int minimumGoodReducedCosts_;
00461 int trueSequenceIn_;
00463 int trueSequenceOut_;
00465 bool skipDualCheck_;
00467 };
00468
00469 #define FREE_BIAS 1.0e1
00470
00471 #define FREE_ACCEPT 1.0e2
00472
00473 #endif