- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/svn-release/Alps-1.5.0/Clp/src/ClpMatrixBase.hpp

Go to the documentation of this file.

    00001 /* $Id: ClpMatrixBase.hpp 2078 2015-01-05 12:39:49Z forrest $ */
    00002 // Copyright (C) 2002, International Business Machines
    00003 // Corporation and others.  All Rights Reserved.
    00004 // This code is licensed under the terms of the Eclipse Public License (EPL).
    00005
    00006 #ifndef ClpMatrixBase_H
    00007 #define ClpMatrixBase_H
    00008
    00009 #include "CoinPragma.hpp"
    00010 #include "CoinTypes.hpp"
    00011
    00012 #include "CoinPackedMatrix.hpp"
    00013 class CoinIndexedVector;
    00014 class ClpSimplex;
    00015 class ClpModel;
    00016 // Compilers can produce better code if they know about __restrict
    00017 #ifndef COIN_RESTRICT
    00018 #ifdef COIN_USE_RESTRICT
    00019 #define COIN_RESTRICT __restrict
    00020 #else
    00021 #define COIN_RESTRICT
    00022 #endif
    00023 #endif
    00024
    00038 class ClpMatrixBase  {
    00039
    00040 public:
    00043
    00044      virtual CoinPackedMatrix * getPackedMatrix() const = 0;
    00046      virtual bool isColOrdered() const = 0;
    00048      virtual CoinBigIndex getNumElements() const = 0;
    00050      virtual int getNumCols() const = 0;
    00052      virtual int getNumRows() const = 0;
    00053
    00058      virtual const double * getElements() const = 0;
    00064      virtual const int * getIndices() const = 0;
    00065
    00066      virtual const CoinBigIndex * getVectorStarts() const = 0;
    00068      virtual const int * getVectorLengths() const = 0 ;
    00070      virtual int getVectorLength(int index) const ;
    00072      virtual void deleteCols(const int numDel, const int * indDel) = 0;
    00074      virtual void deleteRows(const int numDel, const int * indDel) = 0;
    00075 #ifndef CLP_NO_VECTOR
    00077      virtual void appendCols(int number, const CoinPackedVectorBase * const * columns);
    00079      virtual void appendRows(int number, const CoinPackedVectorBase * const * rows);
    00080 #endif
    00081
    00084      virtual void modifyCoefficient(int row, int column, double newElement,
    00085                                     bool keepZero = false);
    00090      virtual int appendMatrix(int number, int type,
    00091                               const CoinBigIndex * starts, const int * index,
    00092                               const double * element, int numberOther = -1);
    00093
    00096      virtual ClpMatrixBase * reverseOrderedCopy() const {
    00097           return NULL;
    00098      }
    00099
    00101      virtual CoinBigIndex countBasis(const int * whichColumn,
    00102                                      int & numberColumnBasic) = 0;
    00104      virtual void fillBasis(ClpSimplex * model,
    00105                             const int * whichColumn,
    00106                             int & numberColumnBasic,
    00107                             int * row, int * start,
    00108                             int * rowCount, int * columnCount,
    00109                             CoinFactorizationDouble * element) = 0;
    00113      virtual int scale(ClpModel * , const ClpSimplex * = NULL) const {
    00114           return 1;
    00115      }
    00118      virtual void scaleRowCopy(ClpModel * ) const { }
    00120      virtual bool canGetRowCopy() const {
    00121           return true;
    00122      }
    00126      inline virtual ClpMatrixBase * scaledColumnCopy(ClpModel * ) const {
    00127           return this->clone();
    00128      }
    00129
    00140      virtual bool allElementsInRange(ClpModel * ,
    00141                                      double , double ,
    00142                                      int = 15) {
    00143           return true;
    00144      }
    00150      virtual void setDimensions(int numrows, int numcols);
    00154      virtual void rangeOfElements(double & smallestNegative, double & largestNegative,
    00155                                   double & smallestPositive, double & largestPositive);
    00156
    00159      virtual void unpack(const ClpSimplex * model, CoinIndexedVector * rowArray,
    00160                          int column) const = 0;
    00165      virtual void unpackPacked(ClpSimplex * model,
    00166                                CoinIndexedVector * rowArray,
    00167                                int column) const = 0;
    00172      virtual int refresh(ClpSimplex * ) {
    00173           return 0;
    00174      }
    00175
    00176      // Really scale matrix
    00177      virtual void reallyScale(const double * rowScale, const double * columnScale);
    00183      virtual CoinBigIndex * dubiousWeights(const ClpSimplex * model, int * inputWeights) const;
    00186      virtual void add(const ClpSimplex * model, CoinIndexedVector * rowArray,
    00187                       int column, double multiplier) const = 0;
    00189      virtual void add(const ClpSimplex * model, double * array,
    00190                       int column, double multiplier) const = 0;
    00192      virtual void releasePackedMatrix() const = 0;
    00194      virtual bool canDoPartialPricing() const;
    00196      virtual int hiddenRows() const;
    00198      virtual void partialPricing(ClpSimplex * model, double start, double end,
    00199                                  int & bestSequence, int & numberWanted);
    00209      virtual int extendUpdated(ClpSimplex * model, CoinIndexedVector * update, int mode);
    00216      virtual void primalExpanded(ClpSimplex * model, int mode);
    00226      virtual void dualExpanded(ClpSimplex * model, CoinIndexedVector * array,
    00227                                double * other, int mode);
    00247      virtual int generalExpanded(ClpSimplex * model, int mode, int & number);
    00251      virtual int updatePivot(ClpSimplex * model, double oldInValue, double oldOutValue);
    00255      virtual void createVariable(ClpSimplex * model, int & bestSequence);
    00258      virtual int checkFeasible(ClpSimplex * model, double & sum) const ;
    00260      double reducedCost(ClpSimplex * model, int sequence) const;
    00262      virtual void correctSequence(const ClpSimplex * model, int & sequenceIn, int & sequenceOut) ;
    00264
    00265      //---------------------------------------------------------------------------
    00273      virtual void times(double scalar,
    00274                         const double * COIN_RESTRICT x, double * COIN_RESTRICT y) const = 0;
    00278      virtual void times(double scalar,
    00279                         const double * COIN_RESTRICT x, double * COIN_RESTRICT y,
    00280                         const double * COIN_RESTRICT rowScale,
    00281                         const double * COIN_RESTRICT columnScale) const;
    00285      virtual void transposeTimes(double scalar,
    00286                                  const double * COIN_RESTRICT x, double * COIN_RESTRICT y) const = 0;
    00290      virtual void transposeTimes(double scalar,
    00291                                  const double * COIN_RESTRICT x, double * COIN_RESTRICT y,
    00292                                  const double * COIN_RESTRICT rowScale,
    00293                                  const double * COIN_RESTRICT columnScale,
    00294                                  double * COIN_RESTRICT spare = NULL) const;
    00295 #if COIN_LONG_WORK
    00296      // For long double versions (aborts if not supported)
    00297      virtual void times(CoinWorkDouble scalar,
    00298                         const CoinWorkDouble * COIN_RESTRICT x, CoinWorkDouble * COIN_RESTRICT y) const ;
    00299      virtual void transposeTimes(CoinWorkDouble scalar,
    00300                                  const CoinWorkDouble * COIN_RESTRICT x, CoinWorkDouble * COIN_RESTRICT y) const ;
    00301 #endif
    00302
    00306      virtual void transposeTimes(const ClpSimplex * model, double scalar,
    00307                                  const CoinIndexedVector * x,
    00308                                  CoinIndexedVector * y,
    00309                                  CoinIndexedVector * z) const = 0;
    00314      virtual void subsetTransposeTimes(const ClpSimplex * model,
    00315                                        const CoinIndexedVector * x,
    00316                                        const CoinIndexedVector * y,
    00317                                        CoinIndexedVector * z) const = 0;
    00320      virtual bool canCombine(const ClpSimplex * ,
    00321                              const CoinIndexedVector * ) const {
    00322           return false;
    00323      }
    00325      virtual void transposeTimes2(const ClpSimplex * model,
    00326                                   const CoinIndexedVector * pi1, CoinIndexedVector * dj1,
    00327                                   const CoinIndexedVector * pi2,
    00328                                   CoinIndexedVector * spare,
    00329                                   double referenceIn, double devex,
    00330                                   // Array for exact devex to say what is in reference framework
    00331                                   unsigned int * reference,
    00332                                   double * weights, double scaleFactor);
    00334      virtual void subsetTimes2(const ClpSimplex * model,
    00335                                CoinIndexedVector * dj1,
    00336                                const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
    00337                                double referenceIn, double devex,
    00338                                // Array for exact devex to say what is in reference framework
    00339                                unsigned int * reference,
    00340                                double * weights, double scaleFactor);
    00345      virtual void listTransposeTimes(const ClpSimplex * model,
    00346                                      double * x,
    00347                                      int * y,
    00348                                      int number,
    00349                                      double * z) const;
    00351
    00352
    00353
    00354      virtual ClpMatrixBase * clone() const = 0;
    00359      virtual ClpMatrixBase * subsetClone (
    00360           int numberRows, const int * whichRows,
    00361           int numberColumns, const int * whichColumns) const;
    00363      virtual void backToBasics() {}
    00370      inline int type() const {
    00371           return type_;
    00372      }
    00374      void setType(int newtype) {
    00375           type_ = newtype;
    00376      }
    00378      void useEffectiveRhs(ClpSimplex * model);
    00382      virtual double * rhsOffset(ClpSimplex * model, bool forceRefresh = false,
    00383                                 bool check = false);
    00385      inline int lastRefresh() const {
    00386           return lastRefresh_;
    00387      }
    00389      inline int refreshFrequency() const {
    00390           return refreshFrequency_;
    00391      }
    00392      inline void setRefreshFrequency(int value) {
    00393           refreshFrequency_ = value;
    00394      }
    00396      inline bool skipDualCheck() const {
    00397           return skipDualCheck_;
    00398      }
    00399      inline void setSkipDualCheck(bool yes) {
    00400           skipDualCheck_ = yes;
    00401      }
    00404      inline int minimumObjectsScan() const {
    00405           return minimumObjectsScan_;
    00406      }
    00407      inline void setMinimumObjectsScan(int value) {
    00408           minimumObjectsScan_ = value;
    00409      }
    00411      inline int minimumGoodReducedCosts() const {
    00412           return minimumGoodReducedCosts_;
    00413      }
    00414      inline void setMinimumGoodReducedCosts(int value) {
    00415           minimumGoodReducedCosts_ = value;
    00416      }
    00418      inline double startFraction() const {
    00419           return startFraction_;
    00420      }
    00421      inline void setStartFraction(double value) {
    00422           startFraction_ = value;
    00423      }
    00425      inline double endFraction() const {
    00426           return endFraction_;
    00427      }
    00428      inline void setEndFraction(double value) {
    00429           endFraction_ = value;
    00430      }
    00432      inline double savedBestDj() const {
    00433           return savedBestDj_;
    00434      }
    00435      inline void setSavedBestDj(double value) {
    00436           savedBestDj_ = value;
    00437      }
    00439      inline int originalWanted() const {
    00440           return originalWanted_;
    00441      }
    00442      inline void setOriginalWanted(int value) {
    00443           originalWanted_ = value;
    00444      }
    00446      inline int currentWanted() const {
    00447           return currentWanted_;
    00448      }
    00449      inline void setCurrentWanted(int value) {
    00450           currentWanted_ = value;
    00451      }
    00453      inline int savedBestSequence() const {
    00454           return savedBestSequence_;
    00455      }
    00456      inline void setSavedBestSequence(int value) {
    00457           savedBestSequence_ = value;
    00458      }
    00460
    00461
    00462 protected:
    00463
    00469      ClpMatrixBase();
    00471 public:
    00472      virtual ~ClpMatrixBase();
    00473 protected:
    00474      // Copy
    00475      ClpMatrixBase(const ClpMatrixBase&);
    00476      // Assignment
    00477      ClpMatrixBase& operator=(const ClpMatrixBase&);
    00479
    00480
    00481 protected:
    00488      double * rhsOffset_;
    00490      double startFraction_;
    00492      double endFraction_;
    00494      double savedBestDj_;
    00496      int originalWanted_;
    00498      int currentWanted_;
    00500      int savedBestSequence_;
    00502      int type_;
    00504      int lastRefresh_;
    00506      int refreshFrequency_;
    00508      int minimumObjectsScan_;
    00510      int minimumGoodReducedCosts_;
    00512      int trueSequenceIn_;
    00514      int trueSequenceOut_;
    00516      bool skipDualCheck_;
    00518 };
    00519 // bias for free variables
    00520 #define FREE_BIAS 1.0e1
    00521 // Acceptance criteria for free variables
    00522 #define FREE_ACCEPT 1.0e2
    00523
    00524 #endif