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

- File List
- File Members

# /home/coin/SVN-release/Bcps-0.91.0/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 Common 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-2005, International Business Machines                  *
    00021  * Corporation, Lehigh University, Yan Xu, Ted Ralphs, Matthew Salzman and   *
    00022  * others. All Rights Reserved.                                              *
    00023  *===========================================================================*/
    00024
    00025 #ifndef BlisNodeDesc_h_
    00026 #define BlisNodeDesc_h_
    00027
    00028 //#############################################################################
    00029
    00030 #include "CoinWarmStartBasis.hpp"
    00031
    00032 #include "AlpsNodeDesc.h"
    00033 #include "BcpsNodeDesc.h"
    00034
    00035 #include "BlisHelp.h"
    00036 #include "BlisModel.h"
    00037
    00038 //#############################################################################
    00039
    00040
    00041 class BlisNodeDesc : public BcpsNodeDesc {
    00042
    00043  private:
    00044
    00046     int branchedDir_;
    00047
    00049     int branchedInd_;
    00050
    00052     double branchedVal_;
    00053
    00055     CoinWarmStartBasis *basis_;
    00056
    00057  public:
    00058
    00060     BlisNodeDesc() :
    00061         BcpsNodeDesc(),
    00062         branchedDir_(0),
    00063         branchedInd_(-1),
    00064         branchedVal_(0.0),
    00065         basis_(NULL)
    00066         {}
    00067
    00069     BlisNodeDesc(BlisModel* m)
    00070         :
    00071         BcpsNodeDesc(m),
    00072         branchedDir_(0),
    00073         branchedInd_(-1),
    00074         branchedVal_(0.0),
    00075         basis_(NULL)
    00076         {}
    00077
    00079     virtual ~BlisNodeDesc() { delete basis_; }
    00080
    00082     void setBasis(CoinWarmStartBasis *&ws) {
    00083         if (basis_) { delete basis_; }
    00084         basis_= ws;
    00085         ws = NULL;
    00086     }
    00087
    00089     CoinWarmStartBasis * getBasis() const { return basis_; }
    00090
    00092     void setBranchedDir(int d) { branchedDir_ = d; }
    00093
    00095     int getBranchedDir() const { return branchedDir_; }
    00096
    00098     void setBranchedInd(int d) { branchedInd_ = d; }
    00099
    00101     int getBranchedInd() const { return branchedInd_; }
    00102
    00104     void setBranchedVal(double d) { branchedVal_ = d; }
    00105
    00107     double getBranchedVal() const { return branchedVal_; }
    00108
    00109  protected:
    00110
    00112     AlpsReturnStatus encodeBlis(AlpsEncoded *encoded) const {
    00113         AlpsReturnStatus status = AlpsReturnStatusOk;
    00114
    00115         encoded->writeRep(branchedDir_);
    00116         encoded->writeRep(branchedInd_);
    00117         encoded->writeRep(branchedVal_);
    00118
    00119         // Basis
    00120         int ava = 0;
    00121         if (basis_) {
    00122             ava = 1;
    00123             encoded->writeRep(ava);
    00124             BlisEncodeWarmStart(encoded, basis_);
    00125         }
    00126         else {
    00127             encoded->writeRep(ava);
    00128         }
    00129
    00130         return status;
    00131     }
    00132
    00134     AlpsReturnStatus decodeBlis(AlpsEncoded &encoded) {
    00135         AlpsReturnStatus status = AlpsReturnStatusOk;
    00136
    00137         encoded.readRep(branchedDir_);
    00138         encoded.readRep(branchedInd_);
    00139         encoded.readRep(branchedVal_);
    00140
    00141         // Basis
    00142         int ava;
    00143         encoded.readRep(ava);
    00144         if (ava == 1) {
    00145             basis_ = BlisDecodeWarmStart(encoded, &status);
    00146         }
    00147         else {
    00148             basis_ = NULL;
    00149         }
    00150
    00151         return status;
    00152     }
    00153
    00154  public:
    00155
    00157     virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const {
    00158         AlpsReturnStatus status = AlpsReturnStatusOk;
    00159
    00160         status = encodeBcps(encoded);
    00161         status = encodeBlis(encoded);
    00162
    00163         return status;
    00164     }
    00165
    00167     virtual AlpsReturnStatus decode(AlpsEncoded &encoded) {
    00168
    00169         AlpsReturnStatus status = AlpsReturnStatusOk;
    00170
    00171         status = decodeBcps(encoded);
    00172         status = decodeBlis(encoded);
    00173
    00174         return status;
    00175     }
    00176
    00177 };
    00178 #endif