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

- File List
- File Members

# /home/coin/SVN-release/Cgl-0.55.0/CoinUtils/src/CoinWarmStartBasis.hpp

Go to the documentation of this file.

    00001 /* $Id: CoinWarmStartBasis.hpp 1215 2009-11-05 11:03:04Z forrest $ */
    00012 #ifndef CoinWarmStartBasis_H
    00013 #define CoinWarmStartBasis_H
    00014
    00015 #include <vector>
    00016
    00017 #include "CoinSort.hpp"
    00018 #include "CoinHelperFunctions.hpp"
    00019 #include "CoinWarmStart.hpp"
    00020
    00021 //#############################################################################
    00022
    00039 class CoinWarmStartBasis : public virtual CoinWarmStart {
    00040 public:
    00041
    00056   enum Status {
    00057     isFree = 0x00,
    00058     basic = 0x01,
    00059     atUpperBound = 0x02,
    00060     atLowerBound = 0x03
    00061   };
    00062
    00066   typedef CoinTriple<int,int,int> XferEntry ;
    00067
    00071   typedef std::vector<XferEntry> XferVec ;
    00072
    00073 public:
    00074
    00085
    00086   inline int getNumStructural() const { return numStructural_; }
    00087
    00089   inline int getNumArtificial() const { return numArtificial_; }
    00090
    00095   int numberBasicStructurals() const ;
    00096
    00098   inline Status getStructStatus(int i) const {
    00099     const int st = (structuralStatus_[i>>2] >> ((i&3)<<1)) & 3;
    00100     return static_cast<CoinWarmStartBasis::Status>(st);
    00101   }
    00102
    00104   inline void setStructStatus(int i, Status st) {
    00105     char& st_byte = structuralStatus_[i>>2];
    00106     st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
    00107     st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
    00108   }
    00109
    00115   inline char * getStructuralStatus() { return structuralStatus_; }
    00116
    00122   inline const char * getStructuralStatus() const { return structuralStatus_; }
    00123
    00127   inline char * getArtificialStatus() { return artificialStatus_; }
    00128
    00130   inline Status getArtifStatus(int i) const {
    00131     const int st = (artificialStatus_[i>>2] >> ((i&3)<<1)) & 3;
    00132     return static_cast<CoinWarmStartBasis::Status>(st);
    00133   }
    00134
    00136   inline void setArtifStatus(int i, Status st) {
    00137     char& st_byte = artificialStatus_[i>>2];
    00138     st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
    00139     st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
    00140   }
    00141
    00147   inline const char * getArtificialStatus() const { return artificialStatus_; }
    00148
    00150
    00153
    00161   virtual CoinWarmStartDiff*
    00162   generateDiff (const CoinWarmStart *const oldCWS) const ;
    00163
    00170   virtual void
    00171   applyDiff (const CoinWarmStartDiff *const cwsdDiff) ;
    00172
    00174
    00175
    00178
    00184   virtual void setSize(int ns, int na) ;
    00185
    00194   virtual void resize (int newNumberRows, int newNumberColumns);
    00195
    00212   virtual void compressRows (int tgtCnt, const int *tgts) ;
    00213
    00225   virtual void deleteRows(int rawTgtCnt, const int *rawTgts) ;
    00226
    00237   virtual void deleteColumns(int number, const int * which);
    00238
    00251   virtual void mergeBasis(const CoinWarmStartBasis *src,
    00252                           const XferVec *xferRows,
    00253                           const XferVec *xferCols) ;
    00254
    00256
    00260
    00266   CoinWarmStartBasis();
    00267
    00277   CoinWarmStartBasis(int ns, int na, const char* sStat, const char* aStat) ;
    00278
    00280   CoinWarmStartBasis(const CoinWarmStartBasis& ws) ;
    00281
    00283   virtual CoinWarmStart *clone() const
    00284   {
    00285      return new CoinWarmStartBasis(*this);
    00286   }
    00287
    00289   virtual ~CoinWarmStartBasis();
    00290
    00293   virtual CoinWarmStartBasis& operator=(const CoinWarmStartBasis& rhs) ;
    00294
    00310   virtual void assignBasisStatus(int ns, int na, char*& sStat, char*& aStat) ;
    00312
    00315
    00317   virtual void print() const;
    00319   bool fullBasis() const;
    00321   bool fixFullBasis();
    00322
    00324
    00325 protected:
    00332
    00333     int numStructural_;
    00335     int numArtificial_;
    00337     int maxSize_;
    00339     char * structuralStatus_;
    00341     char * artificialStatus_;
    00343 };
    00344
    00345
    00350 inline CoinWarmStartBasis::Status getStatus(const char *array, int i)  {
    00351   const int st = (array[i>>2] >> ((i&3)<<1)) & 3;
    00352   return static_cast<CoinWarmStartBasis::Status>(st);
    00353 }
    00354
    00359 inline void setStatus(char * array, int i, CoinWarmStartBasis::Status st) {
    00360   char& st_byte = array[i>>2];
    00361   st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
    00362   st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
    00363 }
    00364
    00365
    00366
    00390 class CoinWarmStartBasisDiff : public virtual CoinWarmStartDiff
    00391 { public:
    00392
    00394   virtual CoinWarmStartDiff *clone() const
    00395   { CoinWarmStartBasisDiff *cwsbd =  new CoinWarmStartBasisDiff(*this) ;
    00396     return (dynamic_cast<CoinWarmStartDiff *>(cwsbd)) ; }
    00397
    00399   virtual
    00400     CoinWarmStartBasisDiff &operator= (const CoinWarmStartBasisDiff &rhs) ;
    00401
    00403   virtual ~CoinWarmStartBasisDiff();
    00404
    00405   protected:
    00406
    00413   CoinWarmStartBasisDiff () : sze_(0), difference_(0) { }
    00414
    00425   CoinWarmStartBasisDiff (const CoinWarmStartBasisDiff &cwsbd) ;
    00426
    00428   CoinWarmStartBasisDiff (int sze, const unsigned int *const diffNdxs,
    00429                           const unsigned int *const diffVals) ;
    00430
    00432   CoinWarmStartBasisDiff (const CoinWarmStartBasis * rhs);
    00433
    00434   private:
    00435
    00436   friend CoinWarmStartDiff*
    00437     CoinWarmStartBasis::generateDiff(const CoinWarmStart *const oldCWS) const ;
    00438   friend void
    00439     CoinWarmStartBasis::applyDiff(const CoinWarmStartDiff *const diff) ;
    00440
    00442   int sze_ ;
    00443
    00446   unsigned int *difference_ ;
    00447
    00448 } ;
    00449
    00450
    00451 #endif