AlpsDecompNodeDesc.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef AlpsDecompNodeDesc_h_
00018 #define AlpsDecompNodeDesc_h_
00019
00020
00021 #include "AlpsEncoded.h"
00022 #include "AlpsNodeDesc.h"
00023 #include "AlpsDecompModel.h"
00024 #include "UtilMacrosAlps.h"
00025
00026
00027 class CoinWarmStartBasis;
00028
00029
00053
00054
00055
00056 class AlpsDecompNodeDesc : public AlpsNodeDesc {
00057
00058 private:
00059
00060
00065
00066
00070 std::string m_classTag;
00071
00072 public:
00074 double* lowerBounds_;
00076 double* upperBounds_;
00078 int numberCols_;
00080 int branchedDir_;
00082 std::vector< std::pair<int, double> > branched_;
00083
00084
00086 CoinWarmStartBasis* basis_;
00087
00088 public:
00089
00091 AlpsDecompNodeDesc() :
00092 AlpsNodeDesc(),
00093 branchedDir_(0),
00094 basis_(NULL) {
00095 }
00096
00098 AlpsDecompNodeDesc(AlpsModel* m)
00099 :
00100 AlpsNodeDesc(m),
00101 branchedDir_(0),
00102 basis_(NULL) {
00103 }
00104
00105 AlpsDecompNodeDesc(AlpsDecompModel* m,
00106 const double* lb,
00107 const double* ub)
00108 :
00109 AlpsNodeDesc(m),
00110 branchedDir_(0),
00111 basis_(NULL) {
00112 numberCols_ = m->getNumCoreCols();
00113 assert(numberCols_);
00114 lowerBounds_ = new double [numberCols_];
00115 upperBounds_ = new double [numberCols_];
00116 memcpy(lowerBounds_, lb, sizeof(double)*numberCols_);
00117 memcpy(upperBounds_, ub, sizeof(double)*numberCols_);
00118 }
00119
00121 virtual ~AlpsDecompNodeDesc() {
00122 if (lowerBounds_ != 0) {
00123 delete [] lowerBounds_;
00124 lowerBounds_ = 0;
00125 }
00126
00127 if (upperBounds_ != 0) {
00128 delete [] upperBounds_;
00129 upperBounds_ = 0;
00130 }
00131
00132 delete basis_;
00133 }
00134
00136 void setBasis(CoinWarmStartBasis*& ws) {
00137 if (basis_) {
00138 delete basis_;
00139 }
00140
00141 basis_ = ws;
00142 ws = NULL;
00143 }
00144
00146 CoinWarmStartBasis* getBasis() const {
00147 return basis_;
00148 }
00149
00151 void setBranchedDir(int d) {
00152 branchedDir_ = d;
00153 }
00154
00156 int getBranchedDir() const {
00157 return branchedDir_;
00158 }
00159
00161 void setBranched(std::vector< std::pair<int, double> > b) {
00162 branched_ = b;
00163 }
00164
00166 std::vector< std::pair<int, double> > getBranched() const {
00167 return branched_;
00168 }
00169
00170 protected:
00171
00172
00173
00174
00175
00177 AlpsReturnStatus encodeAlpsDecomp(AlpsEncoded* encoded) const {
00178 AlpsReturnStatus status = AlpsReturnStatusOk;
00179 encoded->writeRep(branchedDir_);
00180
00181 int ava = 0;
00182
00183 if (basis_) {
00184 ava = 1;
00185 encoded->writeRep(ava);
00186
00187
00188 UtilAlpsEncodeWarmStart(encoded, basis_);
00189 } else {
00190 encoded->writeRep(ava);
00191 }
00192
00193 return status;
00194 }
00195
00197 AlpsReturnStatus decodeAlpsDecomp(AlpsEncoded& encoded) {
00198 AlpsReturnStatus status = AlpsReturnStatusOk;
00199 encoded.readRep(branchedDir_);
00200
00201 int ava;
00202 encoded.readRep(ava);
00203
00204 if (ava == 1) {
00205 basis_ = UtilAlpsDecodeWarmStart(encoded, &status);
00206 } else {
00207 basis_ = NULL;
00208 }
00209
00210 return status;
00211 }
00212
00213 public:
00214
00215
00216
00217
00218
00220 virtual AlpsReturnStatus encode(AlpsEncoded* encoded) const {
00221 AlpsReturnStatus status = AlpsReturnStatusOk;
00222 status = encodeAlpsDecomp(encoded);
00223 return status;
00224 }
00225
00227 virtual AlpsReturnStatus decode(AlpsEncoded& encoded) {
00228 AlpsReturnStatus status = AlpsReturnStatusOk;
00229 status = decodeAlpsDecomp(encoded);
00230 return status;
00231 }
00232
00233 };
00234 #endif