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

- File List
- File Members

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

Go to the documentation of this file.

    00001
    00011 #ifndef CoinWarmStartBasis_H
    00012 #define CoinWarmStartBasis_H
    00013
    00014 #include <vector>
    00015
    00016 #include "CoinSort.hpp"
    00017 #include "CoinHelperFunctions.hpp"
    00018 #include "CoinWarmStart.hpp"
    00019
    00020 //#############################################################################
    00021
    00038 class CoinWarmStartBasis : public virtual CoinWarmStart {
    00039 public:
    00040
    00055   enum Status {
    00056     isFree = 0x00,
    00057     basic = 0x01,
    00058     atUpperBound = 0x02,
    00059     atLowerBound = 0x03
    00060   };
    00061
    00065   typedef CoinTriple<int,int,int> XferEntry ;
    00066
    00070   typedef std::vector<XferEntry> XferVec ;
    00071
    00072 public:
    00073
    00084
    00085   inline int getNumStructural() const { return numStructural_; }
    00086
    00088   inline int getNumArtificial() const { return numArtificial_; }
    00089
    00094   int numberBasicStructurals() const ;
    00095
    00097   inline Status getStructStatus(int i) const {
    00098     const int st = (structuralStatus_[i>>2] >> ((i&3)<<1)) & 3;
    00099     return static_cast<CoinWarmStartBasis::Status>(st);
    00100   }
    00101
    00103   inline void setStructStatus(int i, Status st) {
    00104     char& st_byte = structuralStatus_[i>>2];
    00105     st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
    00106     st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
    00107   }
    00108
    00114   inline char * getStructuralStatus() { return structuralStatus_; }
    00115
    00121   inline const char * getStructuralStatus() const { return structuralStatus_; }
    00122
    00126   inline char * getArtificialStatus() { return artificialStatus_; }
    00127
    00129   inline Status getArtifStatus(int i) const {
    00130     const int st = (artificialStatus_[i>>2] >> ((i&3)<<1)) & 3;
    00131     return static_cast<CoinWarmStartBasis::Status>(st);
    00132   }
    00133
    00135   inline void setArtifStatus(int i, Status st) {
    00136     char& st_byte = artificialStatus_[i>>2];
    00137     st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
    00138     st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
    00139   }
    00140
    00146   inline const char * getArtificialStatus() const { return artificialStatus_; }
    00147
    00149
    00152
    00160   virtual CoinWarmStartDiff*
    00161   generateDiff (const CoinWarmStart *const oldCWS) const ;
    00162
    00169   virtual void
    00170   applyDiff (const CoinWarmStartDiff *const cwsdDiff) ;
    00171
    00173
    00174
    00177
    00183   virtual void setSize(int ns, int na) ;
    00184
    00193   virtual void resize (int newNumberRows, int newNumberColumns);
    00194
    00211   virtual void compressRows (int tgtCnt, const int *tgts) ;
    00212
    00224   virtual void deleteRows(int rawTgtCnt, const int *rawTgts) ;
    00225
    00236   virtual void deleteColumns(int number, const int * which);
    00237
    00250   virtual void mergeBasis(const CoinWarmStartBasis *src,
    00251                           const XferVec *xferRows,
    00252                           const XferVec *xferCols) ;
    00253
    00255
    00259
    00265   CoinWarmStartBasis();
    00266
    00276   CoinWarmStartBasis(int ns, int na, const char* sStat, const char* aStat) ;
    00277
    00279   CoinWarmStartBasis(const CoinWarmStartBasis& ws) ;
    00280
    00282   virtual CoinWarmStart *clone() const
    00283   {
    00284      return new CoinWarmStartBasis(*this);
    00285   }
    00286
    00288   virtual ~CoinWarmStartBasis();
    00289
    00292   virtual CoinWarmStartBasis& operator=(const CoinWarmStartBasis& rhs) ;
    00293
    00309   virtual void assignBasisStatus(int ns, int na, char*& sStat, char*& aStat) ;
    00311
    00314
    00316   virtual void print() const;
    00318   bool fullBasis() const;
    00319
    00321
    00322 protected:
    00329
    00330     int numStructural_;
    00332     int numArtificial_;
    00334     int maxSize_;
    00336     char * structuralStatus_;
    00338     char * artificialStatus_;
    00340 };
    00341
    00342
    00347 inline CoinWarmStartBasis::Status getStatus(const char *array, int i)  {
    00348   const int st = (array[i>>2] >> ((i&3)<<1)) & 3;
    00349   return static_cast<CoinWarmStartBasis::Status>(st);
    00350 }
    00351
    00356 inline void setStatus(char * array, int i, CoinWarmStartBasis::Status st) {
    00357   char& st_byte = array[i>>2];
    00358   st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
    00359   st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
    00360 }
    00361
    00362
    00363
    00387 class CoinWarmStartBasisDiff : public virtual CoinWarmStartDiff
    00388 { public:
    00389
    00391   virtual CoinWarmStartDiff *clone() const
    00392   { CoinWarmStartBasisDiff *cwsbd =  new CoinWarmStartBasisDiff(*this) ;
    00393     return (dynamic_cast<CoinWarmStartDiff *>(cwsbd)) ; }
    00394
    00396   virtual
    00397     CoinWarmStartBasisDiff &operator= (const CoinWarmStartBasisDiff &rhs) ;
    00398
    00400   virtual ~CoinWarmStartBasisDiff();
    00401
    00402   protected:
    00403
    00410   CoinWarmStartBasisDiff () : sze_(0), difference_(0) { }
    00411
    00422   CoinWarmStartBasisDiff (const CoinWarmStartBasisDiff &cwsbd) ;
    00423
    00425   CoinWarmStartBasisDiff (int sze, const unsigned int *const diffNdxs,
    00426                           const unsigned int *const diffVals) ;
    00427
    00429   CoinWarmStartBasisDiff (const CoinWarmStartBasis * rhs);
    00430
    00431   private:
    00432
    00433   friend CoinWarmStartDiff*
    00434     CoinWarmStartBasis::generateDiff(const CoinWarmStart *const oldCWS) const ;
    00435   friend void
    00436     CoinWarmStartBasis::applyDiff(const CoinWarmStartDiff *const diff) ;
    00437
    00439   int sze_ ;
    00440
    00443   unsigned int *difference_ ;
    00444
    00445 } ;
    00446
    00447
    00448 #endif