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

- File List
- File Members

# /home/coin/SVN-release/Cgl-0.52.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 &= ~(3 << ((i&3)<<1));
    00106     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 &= ~(3 << ((i&3)<<1));
    00138     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;
    00317
    00319
    00320 protected:
    00327
    00328     int numStructural_;
    00330     int numArtificial_;
    00332     int maxSize_;
    00334     char * structuralStatus_;
    00336     char * artificialStatus_;
    00338 };
    00339
    00340
    00345 inline CoinWarmStartBasis::Status getStatus(const char *array, int i)  {
    00346   const int st = (array[i>>2] >> ((i&3)<<1)) & 3;
    00347   return static_cast<CoinWarmStartBasis::Status>(st);
    00348 }
    00349
    00354 inline void setStatus(char * array, int i, CoinWarmStartBasis::Status st) {
    00355   char& st_byte = array[i>>2];
    00356   st_byte &= ~(3 << ((i&3)<<1));
    00357   st_byte |= (st << ((i&3)<<1));
    00358 }
    00359
    00360
    00361
    00385 class CoinWarmStartBasisDiff : public virtual CoinWarmStartDiff
    00386 { public:
    00387
    00389   virtual CoinWarmStartDiff *clone() const
    00390   { CoinWarmStartBasisDiff *cwsbd =  new CoinWarmStartBasisDiff(*this) ;
    00391     return (dynamic_cast<CoinWarmStartDiff *>(cwsbd)) ; }
    00392
    00394   virtual
    00395     CoinWarmStartBasisDiff &operator= (const CoinWarmStartBasisDiff &rhs) ;
    00396
    00398   virtual ~CoinWarmStartBasisDiff();
    00399
    00400   protected:
    00401
    00408   CoinWarmStartBasisDiff () : sze_(0), difference_(0) { }
    00409
    00420   CoinWarmStartBasisDiff (const CoinWarmStartBasisDiff &cwsbd) ;
    00421
    00423   CoinWarmStartBasisDiff (int sze, const unsigned int *const diffNdxs,
    00424                           const unsigned int *const diffVals) ;
    00425
    00427   CoinWarmStartBasisDiff (const CoinWarmStartBasis * rhs);
    00428
    00429   private:
    00430
    00431   friend CoinWarmStartDiff*
    00432     CoinWarmStartBasis::generateDiff(const CoinWarmStart *const oldCWS) const ;
    00433   friend void
    00434     CoinWarmStartBasis::applyDiff(const CoinWarmStartDiff *const diff) ;
    00435
    00437   int sze_ ;
    00438
    00441   unsigned int *difference_ ;
    00442
    00443 } ;
    00444
    00445
    00446 #endif