| 1 |
// (C) Copyright International Business Machines Corporation, 2006 |
| 2 |
// All Rights Reserved. |
| 3 |
// This code is published under the Eclipse Public License. |
| 4 |
// |
| 5 |
// Authors : |
| 6 |
// Pierre Bonami, International Business Machines Corporation |
| 7 |
// |
| 8 |
// Date : 11/21/2006 |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
#ifndef BonFilterWarmStart_H |
| 14 |
#define BonFilterWarmStart_H |
| 15 |
|
| 16 |
#include "CoinWarmStartBasis.hpp" |
| 17 |
#include "CoinWarmStartPrimalDual.hpp" |
| 18 |
#include "BonFilterTypes.hpp" /* for types */ |
| 19 |
#include "CoinSmartPtr.hpp" |
| 20 |
|
| 21 |
#include <vector> |
| 22 |
|
| 23 |
namespace Bonmin |
| 24 |
{ |
| 25 |
|
| 26 |
/** Warm start for filter interface. |
| 27 |
* Warm start for filter constists of a (possibly huge) array of integers. |
| 28 |
* This class inherits from CoinWarmStartPrimalDual, because that's what |
| 29 |
* this warmstart really is. <br> |
| 30 |
* For practical reason (integration in Cbc) this class also inherits from |
| 31 |
* CoinWarmStartBasis. <br> |
| 32 |
*/ |
| 33 |
class FilterWarmStart : |
| 34 |
public virtual CoinWarmStartPrimalDual, public virtual CoinWarmStartBasis, |
| 35 |
public Coin::ReferencedObject |
| 36 |
{ |
| 37 |
typedef FilterTypes::fint fint; |
| 38 |
typedef FilterTypes::real real; |
| 39 |
|
| 40 |
public: |
| 41 |
/** Default values for istat */ |
| 42 |
static fint def_istat[14]; |
| 43 |
/** Constructor */ |
| 44 |
FilterWarmStart(const fint xSize = 0, |
| 45 |
const real* xArray = NULL, |
| 46 |
const fint lamSize = 0, |
| 47 |
const real* lamArray = NULL, |
| 48 |
const fint lwsSize = 0, |
| 49 |
const fint *lwsArray = NULL, |
| 50 |
const fint istat[14] = def_istat); |
| 51 |
|
| 52 |
/** Copy constructor */ |
| 53 |
FilterWarmStart(const FilterWarmStart & other); |
| 54 |
|
| 55 |
/** virtual copy */ |
| 56 |
virtual CoinWarmStart * clone() const |
| 57 |
{ |
| 58 |
return new FilterWarmStart(*this); |
| 59 |
} |
| 60 |
|
| 61 |
/** Destructor. */ |
| 62 |
virtual ~FilterWarmStart(); |
| 63 |
|
| 64 |
/** Generate differences.*/ |
| 65 |
virtual CoinWarmStartDiff* generateDiff(const CoinWarmStart * const other) const; |
| 66 |
|
| 67 |
/** Apply differences. */ |
| 68 |
virtual void applyDiff(const CoinWarmStartDiff * const cswDiff); |
| 69 |
|
| 70 |
/** Access to lws array */ |
| 71 |
const fint *lwsArray() const |
| 72 |
{ |
| 73 |
return lwsArray_; |
| 74 |
} |
| 75 |
|
| 76 |
/** Access to lws size. */ |
| 77 |
fint lwsSize() const |
| 78 |
{ |
| 79 |
return lwsSize_; |
| 80 |
} |
| 81 |
|
| 82 |
const fint* istat()const |
| 83 |
{ |
| 84 |
return istat_; |
| 85 |
} |
| 86 |
|
| 87 |
/// flush the starting point |
| 88 |
void flushPoint(); |
| 89 |
|
| 90 |
///Is this an empty warm start? |
| 91 |
bool empty() const |
| 92 |
{ |
| 93 |
return empty_; |
| 94 |
} |
| 95 |
private: |
| 96 |
/** Size of fint lws array store. */ |
| 97 |
fint lwsSize_; |
| 98 |
|
| 99 |
/** fint lws array to store */ |
| 100 |
fint* lwsArray_; |
| 101 |
|
| 102 |
/** Filter's istat (AW: I think we only need first entry) */ |
| 103 |
fint istat_[14]; |
| 104 |
|
| 105 |
///Say if warm start is empty |
| 106 |
bool empty_; |
| 107 |
}; |
| 108 |
|
| 109 |
class FilterWarmStartDiff : public CoinWarmStartPrimalDualDiff |
| 110 |
{ |
| 111 |
typedef FilterTypes::fint fint; |
| 112 |
typedef FilterTypes::real real; |
| 113 |
|
| 114 |
friend class FilterWarmStart; |
| 115 |
|
| 116 |
public: |
| 117 |
FilterWarmStartDiff(CoinWarmStartPrimalDualDiff * diff, |
| 118 |
fint capacity); |
| 119 |
|
| 120 |
virtual ~FilterWarmStartDiff() {} |
| 121 |
|
| 122 |
virtual CoinWarmStartDiff * clone() const |
| 123 |
{ |
| 124 |
return new FilterWarmStartDiff(*this); |
| 125 |
} |
| 126 |
|
| 127 |
void flushPoint(); |
| 128 |
private: |
| 129 |
/** One difference is two integers (indice and difference). */ |
| 130 |
typedef std::pair<fint, fint> OneDiff; |
| 131 |
/** Vector of all the differences.*/ |
| 132 |
std::vector<OneDiff> differences; |
| 133 |
/** istat */ |
| 134 |
fint istat_[14]; |
| 135 |
}; |
| 136 |
|
| 137 |
} /* end namespace Bonmin */ |
| 138 |
#endif |
| 139 |
|