/home/coin/SVN-release/Cbc-1.1.1/Clp/src/ClpPackedMatrix.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2002, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef ClpPackedMatrix_H
00004 #define ClpPackedMatrix_H
00005 
00006 
00007 #include "CoinPragma.hpp"
00008 
00009 #include "ClpMatrixBase.hpp"
00010 
00017 class ClpPackedMatrix2;
00018 class ClpPackedMatrix : public ClpMatrixBase {
00019   
00020 public:
00023 
00024   virtual CoinPackedMatrix * getPackedMatrix() const { return matrix_;};
00026     virtual bool isColOrdered() const { return matrix_->isColOrdered(); }
00028   virtual  CoinBigIndex getNumElements() const 
00029   { return matrix_->getNumElements(); }
00031    virtual int getNumCols() const { return matrix_->getNumCols(); }
00033   virtual int getNumRows() const { return matrix_->getNumRows(); };
00034 
00039    virtual const double * getElements() const 
00040   { return matrix_->getElements();};
00046    virtual const int * getIndices() const 
00047   { return matrix_->getIndices();};
00048 
00049    virtual const CoinBigIndex * getVectorStarts() const 
00050   { return matrix_->getVectorStarts();};
00052    virtual const int * getVectorLengths() const 
00053   { return matrix_->getVectorLengths();} ;
00055   virtual int getVectorLength(int index) const 
00056   { return matrix_->getVectorSize(index);};
00057 
00059   virtual void deleteCols(const int numDel, const int * indDel);
00061   virtual void deleteRows(const int numDel, const int * indDel);
00062 #ifndef CLP_NO_VECTOR
00064   virtual void appendCols(int number, const CoinPackedVectorBase * const * columns);
00066   virtual void appendRows(int number, const CoinPackedVectorBase * const * rows);
00067 #endif
00068 
00072   virtual int appendMatrix(int number, int type,
00073                            const CoinBigIndex * starts, const int * index,
00074                            const double * element, int numberOther=-1);
00079   virtual void replaceVector(const int index,
00080                        const int numReplace, const double * newElements)
00081       {matrix_->replaceVector(index,numReplace,newElements);};
00085   virtual void modifyCoefficient(int row, int column, double newElement,
00086                            bool keepZero=false)
00087        {matrix_->modifyCoefficient(row, column, newElement, keepZero);}
00089   virtual ClpMatrixBase * reverseOrderedCopy() const;
00091   virtual CoinBigIndex countBasis(ClpSimplex * model,
00092                                  const int * whichColumn, 
00093                                  int numberRowBasic,
00094                                   int & numberColumnBasic);
00096   virtual void fillBasis(ClpSimplex * model,
00097                                  const int * whichColumn, 
00098                                  int & numberColumnBasic,
00099                                  int * row, int * start,
00100                                  int * rowCount, int * columnCount,
00101                                  double * element);
00104   virtual int scale(ClpModel * model) const ;
00107   virtual void scaleRowCopy(ClpModel * model) const ;
00111   virtual ClpMatrixBase * scaledColumnCopy(ClpModel * model) const ;
00122   virtual bool allElementsInRange(ClpModel * model,
00123                                   double smallest, double largest,
00124                                   int check=15);
00128   virtual void rangeOfElements(double & smallestNegative, double & largestNegative,
00129                        double & smallestPositive, double & largestPositive);
00130 
00133   virtual void unpack(const ClpSimplex * model,CoinIndexedVector * rowArray,
00134                    int column) const ;
00139   virtual void unpackPacked(ClpSimplex * model,
00140                             CoinIndexedVector * rowArray,
00141                             int column) const;
00144   virtual void add(const ClpSimplex * model,CoinIndexedVector * rowArray,
00145                    int column, double multiplier) const ;
00147   virtual void add(const ClpSimplex * model,double * array,
00148                    int column, double multiplier) const;
00150    virtual void releasePackedMatrix() const { };
00155   virtual CoinBigIndex * dubiousWeights(const ClpSimplex * model,int * inputWeights) const;
00157   virtual bool canDoPartialPricing() const;
00159   virtual void partialPricing(ClpSimplex * model, double start, double end,
00160                       int & bestSequence, int & numberWanted);
00162   virtual int refresh(ClpSimplex * model);
00163   // Really scale matrix
00164   virtual void reallyScale(const double * rowScale, const double * columnScale);
00170   virtual void setDimensions(int numrows, int numcols);
00172 
00178   virtual void times(double scalar,
00179                        const double * x, double * y) const;
00181   virtual void times(double scalar,
00182                      const double * x, double * y,
00183                      const double * rowScale, 
00184                      const double * columnScale) const;
00188     virtual void transposeTimes(double scalar,
00189                                 const double * x, double * y) const;
00191     virtual void transposeTimes(double scalar,
00192                                 const double * x, double * y,
00193                                 const double * rowScale, 
00194                                 const double * columnScale,
00195                                 double * spare=NULL) const;
00200   virtual void transposeTimes(const ClpSimplex * model, double scalar,
00201                               const CoinIndexedVector * x,
00202                               CoinIndexedVector * y,
00203                               CoinIndexedVector * z) const;
00208   void transposeTimesByColumn(const ClpSimplex * model, double scalar,
00209                               const CoinIndexedVector * x,
00210                               CoinIndexedVector * y,
00211                               CoinIndexedVector * z) const;
00217   virtual void transposeTimesByRow(const ClpSimplex * model, double scalar,
00218                               const CoinIndexedVector * x,
00219                               CoinIndexedVector * y,
00220                               CoinIndexedVector * z) const;
00224   virtual void subsetTransposeTimes(const ClpSimplex * model,
00225                                     const CoinIndexedVector * x,
00226                                     const CoinIndexedVector * y,
00227                                     CoinIndexedVector * z) const;
00230   virtual bool canCombine(const ClpSimplex * model,
00231                           const CoinIndexedVector * pi) const;
00233   virtual void transposeTimes2(const ClpSimplex * model,
00234                                const CoinIndexedVector * pi1, CoinIndexedVector * dj1,
00235                                const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
00236                                CoinIndexedVector * spare,
00237                                double referenceIn, double devex,
00238                                // Array for exact devex to say what is in reference framework
00239                                unsigned int * reference,
00240                                double * weights, double scaleFactor);
00242   virtual void subsetTimes2(const ClpSimplex * model,
00243                                 CoinIndexedVector * dj1,
00244                                const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
00245                                double referenceIn, double devex,
00246                                // Array for exact devex to say what is in reference framework
00247                                unsigned int * reference,
00248                                double * weights, double scaleFactor);
00250   void useEffectiveRhs(ClpSimplex * model);
00252 
00255 
00256   inline CoinPackedMatrix * matrix() const { return matrix_;};
00260   inline void setMatrixNull()
00261   { matrix_=NULL;};
00263 
00264 
00268    ClpPackedMatrix();
00270    virtual ~ClpPackedMatrix();
00272 
00276    ClpPackedMatrix(const ClpPackedMatrix&);
00278    ClpPackedMatrix(const CoinPackedMatrix&);
00281   ClpPackedMatrix (const ClpPackedMatrix & wholeModel,
00282                     int numberRows, const int * whichRows,
00283                     int numberColumns, const int * whichColumns);
00284   ClpPackedMatrix (const CoinPackedMatrix & wholeModel,
00285                     int numberRows, const int * whichRows,
00286                     int numberColumns, const int * whichColumns);
00287 
00289    ClpPackedMatrix(CoinPackedMatrix * matrix);
00290 
00291    ClpPackedMatrix& operator=(const ClpPackedMatrix&);
00293   virtual ClpMatrixBase * clone() const ;
00296   virtual ClpMatrixBase * subsetClone (
00297                     int numberRows, const int * whichRows,
00298                     int numberColumns, const int * whichColumns) const ;
00300   void specialRowCopy(ClpSimplex * model,const ClpMatrixBase * rowCopy); 
00302    
00303     
00304 protected:
00308 
00309   CoinPackedMatrix * matrix_;
00311   int numberActiveColumns_;
00313   bool zeroElements_;
00315   bool hasGaps_;
00317   ClpPackedMatrix2 * rowCopy_;
00319 };
00320 #ifdef THREAD
00321 #include <pthread.h>
00322 typedef struct {
00323   double acceptablePivot;
00324   const ClpSimplex * model;
00325   double * spare;
00326   int * spareIndex;
00327   double * arrayTemp;
00328   int * indexTemp;
00329   int * numberInPtr;
00330   double * bestPossiblePtr;
00331   double * upperThetaPtr;
00332   int * posFreePtr;
00333   double * freePivotPtr;
00334   int * numberOutPtr;
00335   const unsigned short * count;
00336   const double * pi;
00337   const CoinBigIndex * rowStart;
00338   const double * element;
00339   const unsigned short * column;
00340   int offset;
00341   int numberInRowArray;
00342   int numberLook;
00343 } dualColumn0Struct;
00344 #endif
00345 class ClpPackedMatrix2 {
00346   
00347 public:
00353   void transposeTimes(const ClpSimplex * model,
00354                       const CoinPackedMatrix * rowCopy,
00355                       const CoinIndexedVector * x,
00356                       CoinIndexedVector * spareArray,
00357                       CoinIndexedVector * z) const;
00359   inline bool usefulInfo() const
00360   { return rowStart_!=NULL;};
00362 
00363 
00367    ClpPackedMatrix2();
00369    ClpPackedMatrix2(ClpSimplex * model,const CoinPackedMatrix * rowCopy);
00371    virtual ~ClpPackedMatrix2();
00373 
00377    ClpPackedMatrix2(const ClpPackedMatrix2&);
00378    ClpPackedMatrix2& operator=(const ClpPackedMatrix2&);
00380    
00381     
00382 protected:
00386 
00387   int numberBlocks_;
00389   int numberRows_;
00391   int * offset_;
00393   mutable unsigned short * count_;
00395   mutable CoinBigIndex * rowStart_;
00397   unsigned short * column_;
00399   double * work_;
00400 #ifdef THREAD
00401   pthread_t * threadId_;
00402   dualColumn0Struct * info_;
00403 #endif
00404 
00405 };
00406 
00407 #endif

Generated on Thu May 15 21:59:05 2008 by  doxygen 1.4.7