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

- File List
- File Members

# /home/coin/SVN-release/Blis-0.91.0/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;
    00320   bool fixFullBasis();
    00321
    00323
    00324 protected:
    00331
    00332     int numStructural_;
    00334     int numArtificial_;
    00336     int maxSize_;
    00338     char * structuralStatus_;
    00340     char * artificialStatus_;
    00342 };
    00343
    00344
    00349 inline CoinWarmStartBasis::Status getStatus(const char *array, int i)  {
    00350   const int st = (array[i>>2] >> ((i&3)<<1)) & 3;
    00351   return static_cast<CoinWarmStartBasis::Status>(st);
    00352 }
    00353
    00358 inline void setStatus(char * array, int i, CoinWarmStartBasis::Status st) {
    00359   char& st_byte = array[i>>2];
    00360   st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
    00361   st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
    00362 }
    00363
    00364
    00365
    00389 class CoinWarmStartBasisDiff : public virtual CoinWarmStartDiff
    00390 { public:
    00391
    00393   virtual CoinWarmStartDiff *clone() const
    00394   { CoinWarmStartBasisDiff *cwsbd =  new CoinWarmStartBasisDiff(*this) ;
    00395     return (dynamic_cast<CoinWarmStartDiff *>(cwsbd)) ; }
    00396
    00398   virtual
    00399     CoinWarmStartBasisDiff &operator= (const CoinWarmStartBasisDiff &rhs) ;
    00400
    00402   virtual ~CoinWarmStartBasisDiff();
    00403
    00404   protected:
    00405
    00412   CoinWarmStartBasisDiff () : sze_(0), difference_(0) { }
    00413
    00424   CoinWarmStartBasisDiff (const CoinWarmStartBasisDiff &cwsbd) ;
    00425
    00427   CoinWarmStartBasisDiff (int sze, const unsigned int *const diffNdxs,
    00428                           const unsigned int *const diffVals) ;
    00429
    00431   CoinWarmStartBasisDiff (const CoinWarmStartBasis * rhs);
    00432
    00433   private:
    00434
    00435   friend CoinWarmStartDiff*
    00436     CoinWarmStartBasis::generateDiff(const CoinWarmStart *const oldCWS) const ;
    00437   friend void
    00438     CoinWarmStartBasis::applyDiff(const CoinWarmStartDiff *const diff) ;
    00439
    00441   int sze_ ;
    00442
    00445   unsigned int *difference_ ;
    00446
    00447 } ;
    00448
    00449
    00450 #endif