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

- File List
- File Members

# /home/coin/svn-release/Alps-1.4.8/CoinUtils/src/CoinWarmStartBasis.hpp

Go to the documentation of this file.

    00001 /* $Id: CoinWarmStartBasis.hpp 1515 2011-12-10 23:38:04Z 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
    00369 const char *statusName(CoinWarmStartBasis::Status status) ;
    00370
    00371
    00395 class CoinWarmStartBasisDiff : public virtual CoinWarmStartDiff
    00396 { public:
    00397
    00399   virtual CoinWarmStartDiff *clone() const
    00400   { CoinWarmStartBasisDiff *cwsbd =  new CoinWarmStartBasisDiff(*this) ;
    00401     return (dynamic_cast<CoinWarmStartDiff *>(cwsbd)) ; }
    00402
    00404   virtual
    00405     CoinWarmStartBasisDiff &operator= (const CoinWarmStartBasisDiff &rhs) ;
    00406
    00408   virtual ~CoinWarmStartBasisDiff();
    00409
    00410   protected:
    00411
    00418   CoinWarmStartBasisDiff () : sze_(0), difference_(0) { }
    00419
    00430   CoinWarmStartBasisDiff (const CoinWarmStartBasisDiff &cwsbd) ;
    00431
    00433   CoinWarmStartBasisDiff (int sze, const unsigned int *const diffNdxs,
    00434                           const unsigned int *const diffVals) ;
    00435
    00437   CoinWarmStartBasisDiff (const CoinWarmStartBasis * rhs);
    00438
    00439   private:
    00440
    00441   friend CoinWarmStartDiff*
    00442     CoinWarmStartBasis::generateDiff(const CoinWarmStart *const oldCWS) const ;
    00443   friend void
    00444     CoinWarmStartBasis::applyDiff(const CoinWarmStartDiff *const diff) ;
    00445
    00447   int sze_ ;
    00448
    00451   unsigned int *difference_ ;
    00452
    00453 } ;
    00454
    00455
    00456 #endif