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);
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;
00337
00344 inline int type() const
00345 { return type_;}
00347 void setType(int type) {type_=type;}
00349 void useEffectiveRhs(ClpSimplex * model);
00353 virtual double * rhsOffset(ClpSimplex * model,bool forceRefresh=false,
00354 bool check=false);
00356 inline int lastRefresh() const
00357 { return lastRefresh_;}
00359 inline int refreshFrequency() const
00360 { return refreshFrequency_;}
00361 inline void setRefreshFrequency(int value)
00362 { refreshFrequency_=value;}
00364 inline bool skipDualCheck() const
00365 { return skipDualCheck_;}
00366 inline void setSkipDualCheck(bool yes)
00367 { skipDualCheck_=yes;}
00370 inline int minimumObjectsScan() const
00371 { return minimumObjectsScan_;}
00372 inline void setMinimumObjectsScan(int value)
00373 { minimumObjectsScan_=value;}
00375 inline int minimumGoodReducedCosts() const
00376 { return minimumGoodReducedCosts_;}
00377 inline void setMinimumGoodReducedCosts(int value)
00378 { minimumGoodReducedCosts_=value;}
00380 inline double startFraction() const
00381 { return startFraction_;}
00382 inline void setStartFraction(double value)
00383 { startFraction_ = value;}
00385 inline double endFraction() const
00386 { return endFraction_;}
00387 inline void setEndFraction(double value)
00388 { endFraction_ = value;}
00390 inline double savedBestDj() const
00391 { return savedBestDj_;}
00392 inline void setSavedBestDj(double value)
00393 { savedBestDj_ = value;}
00395 inline int originalWanted() const
00396 { return originalWanted_;}
00397 inline void setOriginalWanted(int value)
00398 { originalWanted_ = value;}
00400 inline int currentWanted() const
00401 { return currentWanted_;}
00402 inline void setCurrentWanted(int value)
00403 { currentWanted_ = value;}
00405 inline int savedBestSequence() const
00406 { return savedBestSequence_;}
00407 inline void setSavedBestSequence(int value)
00408 { savedBestSequence_ = value;}
00410
00411
00412 protected:
00413
00419 ClpMatrixBase();
00421 public:
00422 virtual ~ClpMatrixBase();
00423 protected:
00424
00425 ClpMatrixBase(const ClpMatrixBase&);
00426
00427 ClpMatrixBase& operator=(const ClpMatrixBase&);
00429
00430
00431 protected:
00438 double * rhsOffset_;
00440 double startFraction_;
00442 double endFraction_;
00444 double savedBestDj_;
00446 int originalWanted_;
00448 int currentWanted_;
00450 int savedBestSequence_;
00452 int type_;
00454 int lastRefresh_;
00456 int refreshFrequency_;
00458 int minimumObjectsScan_;
00460 int minimumGoodReducedCosts_;
00462 int trueSequenceIn_;
00464 int trueSequenceOut_;
00466 bool skipDualCheck_;
00468 };
00469
00470 #define FREE_BIAS 1.0e1
00471
00472 #define FREE_ACCEPT 1.0e2
00473
00474 #endif