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

- File List
- File Members

# /home/coin/SVN-release/Clp-1.5.0/CoinUtils/src/CoinWarmStartDual.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2000, International Business Machines
    00002 // Corporation and others.  All Rights Reserved.
    00003
    00004 #ifndef CoinWarmStartDual_H
    00005 #define CoinWarmStartDual_H
    00006
    00007 #include "CoinHelperFunctions.hpp"
    00008 #include "CoinWarmStart.hpp"
    00009
    00010
    00011 //#############################################################################
    00012
    00015 class CoinWarmStartDual : public CoinWarmStart {
    00016 protected:
    00017    inline void gutsOfDestructor() {
    00018       delete[] dualVector_;
    00019    }
    00020    inline void gutsOfCopy(const CoinWarmStartDual& rhs) {
    00021       dualSize_  = rhs.dualSize_;
    00022       dualVector_ = new double[dualSize_];
    00023       CoinDisjointCopyN(rhs.dualVector_, dualSize_, dualVector_);
    00024    }
    00025
    00026 public:
    00028    int size() const { return dualSize_; }
    00030    const double * dual() const { return dualVector_; }
    00031
    00035    void assignDual(int size, double *& dual) {
    00036       dualSize_ = size;
    00037       delete[] dualVector_;
    00038       dualVector_ = dual;
    00039       dual = NULL;
    00040    }
    00041
    00042    CoinWarmStartDual() : dualSize_(0), dualVector_(NULL) {}
    00043
    00044    CoinWarmStartDual(int size, const double * dual) :
    00045       dualSize_(size), dualVector_(new double[size]) {
    00046       CoinDisjointCopyN(dual, size, dualVector_);
    00047    }
    00048
    00049    CoinWarmStartDual(const CoinWarmStartDual& rhs) {
    00050       gutsOfCopy(rhs);
    00051    }
    00052
    00053    CoinWarmStartDual& operator=(const CoinWarmStartDual& rhs) {
    00054       if (this != &rhs) {
    00055          gutsOfDestructor();
    00056          gutsOfCopy(rhs);
    00057       }
    00058       return *this;
    00059    }
    00060
    00062    virtual CoinWarmStart *clone() const {
    00063       return new CoinWarmStartDual(*this);
    00064    }
    00065
    00066    virtual ~CoinWarmStartDual() {
    00067       gutsOfDestructor();
    00068    }
    00069
    00072
    00080   virtual CoinWarmStartDiff*
    00081   generateDiff (const CoinWarmStart *const oldCWS) const ;
    00082
    00089   virtual void applyDiff (const CoinWarmStartDiff *const cwsdDiff) ;
    00090
    00092
    00093 private:
    00095
    00096
    00097    int dualSize_;
    00099    double * dualVector_;
    00101 };
    00102
    00103 //#############################################################################
    00104
    00120 class CoinWarmStartDualDiff : public CoinWarmStartDiff
    00121 { public:
    00122
    00124   virtual CoinWarmStartDiff *clone() const
    00125   { CoinWarmStartDualDiff *cwsdd =  new CoinWarmStartDualDiff(*this) ;
    00126     return (dynamic_cast<CoinWarmStartDiff *>(cwsdd)) ; }
    00127
    00129   virtual CoinWarmStartDualDiff &operator= (const CoinWarmStartDualDiff &rhs) ;
    00130
    00132   virtual ~CoinWarmStartDualDiff()
    00133   { delete[] diffNdxs_ ;
    00134     delete[] diffVals_ ; }
    00135
    00136   protected:
    00137
    00144   CoinWarmStartDualDiff () : sze_(0), diffNdxs_(0), diffVals_(NULL) {}
    00145
    00156   CoinWarmStartDualDiff (const CoinWarmStartDualDiff &rhs) ;
    00157
    00158   private:
    00159
    00160   friend CoinWarmStartDiff*
    00161     CoinWarmStartDual::generateDiff(const CoinWarmStart *const oldCWS) const ;
    00162   friend void
    00163     CoinWarmStartDual::applyDiff(const CoinWarmStartDiff *const diff) ;
    00164
    00166   CoinWarmStartDualDiff (int sze, const unsigned int *const diffNdxs,
    00167                          const double *const diffVals) ;
    00168
    00173   int sze_ ;
    00174
    00177   unsigned int *diffNdxs_ ;
    00178
    00181   double *diffVals_ ;
    00182 } ;
    00183
    00184
    00185 #endif
    00186