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

- File List
- File Members

# /home/coin/svn-release/Smi-0.93.1/CoinUtils/src/CoinWarmStartBasis.hpp

Go to the documentation of this file.

    00001 /* $Id: CoinWarmStartBasis.hpp 1372 2011-01-03 23:31:00Z lou $ */
    00013 #ifndef CoinWarmStartBasis_H
    00014 #define CoinWarmStartBasis_H
    00015
    00016 #include <vector>
    00017
    00018 #include "CoinSort.hpp"
    00019 #include "CoinHelperFunctions.hpp"
    00020 #include "CoinWarmStart.hpp"
    00021
    00022 //#############################################################################
    00023
    00040 class CoinWarmStartBasis : public virtual CoinWarmStart {
    00041 public:
    00042
    00057   enum Status {
    00058     isFree = 0x00,
    00059     basic = 0x01,
    00060     atUpperBound = 0x02,
    00061     atLowerBound = 0x03
    00062   };
    00063
    00067   typedef CoinTriple<int,int,int> XferEntry ;
    00068
    00072   typedef std::vector<XferEntry> XferVec ;
    00073
    00074 public:
    00075
    00086
    00087   inline int getNumStructural() const { return numStructural_; }
    00088
    00090   inline int getNumArtificial() const { return numArtificial_; }
    00091
    00096   int numberBasicStructurals() const ;
    00097
    00099   inline Status getStructStatus(int i) const {
    00100     const int st = (structuralStatus_[i>>2] >> ((i&3)<<1)) & 3;
    00101     return static_cast<CoinWarmStartBasis::Status>(st);
    00102   }
    00103
    00105   inline void setStructStatus(int i, Status st) {
    00106     char& st_byte = structuralStatus_[i>>2];
    00107     st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
    00108     st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
    00109   }
    00110
    00116   inline char * getStructuralStatus() { return structuralStatus_; }
    00117
    00123   inline const char * getStructuralStatus() const { return structuralStatus_; }
    00124
    00128   inline char * getArtificialStatus() { return artificialStatus_; }
    00129
    00131   inline Status getArtifStatus(int i) const {
    00132     const int st = (artificialStatus_[i>>2] >> ((i&3)<<1)) & 3;
    00133     return static_cast<CoinWarmStartBasis::Status>(st);
    00134   }
    00135
    00137   inline void setArtifStatus(int i, Status st) {
    00138     char& st_byte = artificialStatus_[i>>2];
    00139     st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
    00140     st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
    00141   }
    00142
    00148   inline const char * getArtificialStatus() const { return artificialStatus_; }
    00149
    00151
    00154
    00162   virtual CoinWarmStartDiff*
    00163   generateDiff (const CoinWarmStart *const oldCWS) const ;
    00164
    00171   virtual void
    00172   applyDiff (const CoinWarmStartDiff *const cwsdDiff) ;
    00173
    00175
    00176
    00179
    00185   virtual void setSize(int ns, int na) ;
    00186
    00195   virtual void resize (int newNumberRows, int newNumberColumns);
    00196
    00213   virtual void compressRows (int tgtCnt, const int *tgts) ;
    00214
    00226   virtual void deleteRows(int rawTgtCnt, const int *rawTgts) ;
    00227
    00238   virtual void deleteColumns(int number, const int * which);
    00239
    00252   virtual void mergeBasis(const CoinWarmStartBasis *src,
    00253                           const XferVec *xferRows,
    00254                           const XferVec *xferCols) ;
    00255
    00257
    00261
    00267   CoinWarmStartBasis();
    00268
    00278   CoinWarmStartBasis(int ns, int na, const char* sStat, const char* aStat) ;
    00279
    00281   CoinWarmStartBasis(const CoinWarmStartBasis& ws) ;
    00282
    00284   virtual CoinWarmStart *clone() const
    00285   {
    00286      return new CoinWarmStartBasis(*this);
    00287   }
    00288
    00290   virtual ~CoinWarmStartBasis();
    00291
    00294   virtual CoinWarmStartBasis& operator=(const CoinWarmStartBasis& rhs) ;
    00295
    00311   virtual void assignBasisStatus(int ns, int na, char*& sStat, char*& aStat) ;
    00313
    00316
    00318   virtual void print() const;
    00320   bool fullBasis() const;
    00322   bool fixFullBasis();
    00323
    00325
    00326 protected:
    00333
    00334     int numStructural_;
    00336     int numArtificial_;
    00338     int maxSize_;
    00340     char * structuralStatus_;
    00342     char * artificialStatus_;
    00344 };
    00345
    00346
    00351 inline CoinWarmStartBasis::Status getStatus(const char *array, int i)  {
    00352   const int st = (array[i>>2] >> ((i&3)<<1)) & 3;
    00353   return static_cast<CoinWarmStartBasis::Status>(st);
    00354 }
    00355
    00360 inline void setStatus(char * array, int i, CoinWarmStartBasis::Status st) {
    00361   char& st_byte = array[i>>2];
    00362   st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
    00363   st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
    00364 }
    00365
    00366
    00367
    00391 class CoinWarmStartBasisDiff : public virtual CoinWarmStartDiff
    00392 { public:
    00393
    00395   virtual CoinWarmStartDiff *clone() const
    00396   { CoinWarmStartBasisDiff *cwsbd =  new CoinWarmStartBasisDiff(*this) ;
    00397     return (dynamic_cast<CoinWarmStartDiff *>(cwsbd)) ; }
    00398
    00400   virtual
    00401     CoinWarmStartBasisDiff &operator= (const CoinWarmStartBasisDiff &rhs) ;
    00402
    00404   virtual ~CoinWarmStartBasisDiff();
    00405
    00406   protected:
    00407
    00414   CoinWarmStartBasisDiff () : sze_(0), difference_(0) { }
    00415
    00426   CoinWarmStartBasisDiff (const CoinWarmStartBasisDiff &cwsbd) ;
    00427
    00429   CoinWarmStartBasisDiff (int sze, const unsigned int *const diffNdxs,
    00430                           const unsigned int *const diffVals) ;
    00431
    00433   CoinWarmStartBasisDiff (const CoinWarmStartBasis * rhs);
    00434
    00435   private:
    00436
    00437   friend CoinWarmStartDiff*
    00438     CoinWarmStartBasis::generateDiff(const CoinWarmStart *const oldCWS) const ;
    00439   friend void
    00440     CoinWarmStartBasis::applyDiff(const CoinWarmStartDiff *const diff) ;
    00441
    00443   int sze_ ;
    00444
    00447   unsigned int *difference_ ;
    00448
    00449 } ;
    00450
    00451
    00452 #endif