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

- File List
- File Members

# /home/coin/svn-release/Blis-0.94.1/Bcps/examples/Blis/BlisNodeDesc.h

Go to the documentation of this file.

    00001 /*===========================================================================*
    00002  * This file is part of the Bcps Linear Solver (BLIS).                       *
    00003  *                                                                           *
    00004  * BLIS is distributed under the Eclipse Public License as part of the       *
    00005  * COIN-OR repository (http://www.coin-or.org).                              *
    00006  *                                                                           *
    00007  * Authors:                                                                  *
    00008  *                                                                           *
    00009  *          Yan Xu, Lehigh University                                        *
    00010  *          Ted Ralphs, Lehigh University                                    *
    00011  *                                                                           *
    00012  * Conceptual Design:                                                        *
    00013  *                                                                           *
    00014  *          Yan Xu, Lehigh University                                        *
    00015  *          Ted Ralphs, Lehigh University                                    *
    00016  *          Laszlo Ladanyi, IBM T.J. Watson Research Center                  *
    00017  *          Matthew Saltzman, Clemson University                             *
    00018  *                                                                           *
    00019  *                                                                           *
    00020  * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs.       *
    00021  * All Rights Reserved.                                                      *
    00022  *===========================================================================*/
    00023
    00024 #ifndef BlisNodeDesc_h_
    00025 #define BlisNodeDesc_h_
    00026
    00027 //#############################################################################
    00028
    00029 #include "CoinWarmStartBasis.hpp"
    00030
    00031 #include "AlpsNodeDesc.h"
    00032 #include "BcpsNodeDesc.h"
    00033
    00034 #include "BlisHelp.h"
    00035 #include "BlisModel.h"
    00036
    00037 //#############################################################################
    00038
    00039
    00040 class BlisNodeDesc : public BcpsNodeDesc {
    00041
    00042  private:
    00043
    00045     int branchedDir_;
    00046
    00048     int branchedInd_;
    00049
    00051     double branchedVal_;
    00052
    00054     CoinWarmStartBasis *basis_;
    00055
    00056  public:
    00057
    00059     BlisNodeDesc() :
    00060         BcpsNodeDesc(),
    00061         branchedDir_(0),
    00062         branchedInd_(-1),
    00063         branchedVal_(0.0),
    00064         basis_(NULL)
    00065         {}
    00066
    00068     BlisNodeDesc(BlisModel* m)
    00069         :
    00070         BcpsNodeDesc(m),
    00071         branchedDir_(0),
    00072         branchedInd_(-1),
    00073         branchedVal_(0.0),
    00074         basis_(NULL)
    00075         {}
    00076
    00078     virtual ~BlisNodeDesc() { delete basis_; }
    00079
    00081     void setBasis(CoinWarmStartBasis *&ws) {
    00082         if (basis_) { delete basis_; }
    00083         basis_= ws;
    00084         ws = NULL;
    00085     }
    00086
    00088     CoinWarmStartBasis * getBasis() const { return basis_; }
    00089
    00091     void setBranchedDir(int d) { branchedDir_ = d; }
    00092
    00094     int getBranchedDir() const { return branchedDir_; }
    00095
    00097     void setBranchedInd(int d) { branchedInd_ = d; }
    00098
    00100     int getBranchedInd() const { return branchedInd_; }
    00101
    00103     void setBranchedVal(double d) { branchedVal_ = d; }
    00104
    00106     double getBranchedVal() const { return branchedVal_; }
    00107
    00108  protected:
    00109
    00111     AlpsReturnStatus encodeBlis(AlpsEncoded *encoded) const {
    00112         AlpsReturnStatus status = AlpsReturnStatusOk;
    00113
    00114         encoded->writeRep(branchedDir_);
    00115         encoded->writeRep(branchedInd_);
    00116         encoded->writeRep(branchedVal_);
    00117
    00118         // Basis
    00119         int ava = 0;
    00120         if (basis_) {
    00121             ava = 1;
    00122             encoded->writeRep(ava);
    00123             BlisEncodeWarmStart(encoded, basis_);
    00124         }
    00125         else {
    00126             encoded->writeRep(ava);
    00127         }
    00128
    00129         return status;
    00130     }
    00131
    00133     AlpsReturnStatus decodeBlis(AlpsEncoded &encoded) {
    00134         AlpsReturnStatus status = AlpsReturnStatusOk;
    00135
    00136         encoded.readRep(branchedDir_);
    00137         encoded.readRep(branchedInd_);
    00138         encoded.readRep(branchedVal_);
    00139
    00140         // Basis
    00141         int ava;
    00142         encoded.readRep(ava);
    00143         if (ava == 1) {
    00144             basis_ = BlisDecodeWarmStart(encoded, &status);
    00145         }
    00146         else {
    00147             basis_ = NULL;
    00148         }
    00149
    00150         return status;
    00151     }
    00152
    00153  public:
    00154
    00156     virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const {
    00157         AlpsReturnStatus status = AlpsReturnStatusOk;
    00158
    00159         status = encodeBcps(encoded);
    00160         status = encodeBlis(encoded);
    00161
    00162         return status;
    00163     }
    00164
    00166     virtual AlpsReturnStatus decode(AlpsEncoded &encoded) {
    00167
    00168         AlpsReturnStatus status = AlpsReturnStatusOk;
    00169
    00170         status = decodeBcps(encoded);
    00171         status = decodeBlis(encoded);
    00172
    00173         return status;
    00174     }
    00175
    00176 };
    00177 #endif