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

- File List
- File Members

# /home/coin/svn-release/Alps-1.4.8/Alps/examples/Abc/AbcTreeNode.h

Go to the documentation of this file.

    00001 /*===========================================================================*
    00002  * This file is part of the Abstract Library for Parallel Search (ALPS).     *
    00003  *                                                                           *
    00004  * ALPS 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  *===========================================================================*/
    00022
    00023 #ifndef AbcTreeNode_h_
    00024 #define AbcTreeNode_h_
    00025
    00026 //#include <utility>
    00027 #include "AlpsKnowledgeBroker.h"
    00028 #include "AlpsTreeNode.h"
    00029
    00030 #include "AbcModel.h"
    00031 #include "AbcNodeDesc.h"
    00032
    00033 //#############################################################################
    00034
    00035 enum AbcVarStatus {
    00036     AbcVarFree,
    00037     AbcVarFixedToUB,
    00038     AbcVarFixedToLB
    00039 };
    00040
    00041 //#############################################################################
    00042
    00043 class AbcTreeNode : public AlpsTreeNode {
    00044  private:
    00045     // NO: default constructor, copy constructor, assignment operator
    00046     AbcTreeNode(const AbcTreeNode&);
    00047     AbcTreeNode& operator=(const AbcTreeNode&);
    00048
    00049  private:
    00051     int branchedOn_;
    00052
    00054     double branchedOnVal_;
    00055
    00057     int branchedDir_;
    00058
    00060     double guessedObjectiveValue_;
    00061
    00063     int numberUnsatisfied_;
    00064
    00065  public:
    00066     AbcTreeNode()
    00067         :
    00068         branchedOn_(-1),
    00069         branchedOnVal_(ALPS_BND_MAX),
    00070         branchedDir_(0),
    00071         guessedObjectiveValue_(ALPS_OBJ_MAX),
    00072         numberUnsatisfied_(0)
    00073         {
    00074             desc_ = new AbcNodeDesc(dynamic_cast<AbcModel*>
    00075                        (getKnowledgeBroker()->getModel()));
    00076         }
    00077
    00078     AbcTreeNode(AbcModel* m)
    00079         :
    00080         branchedOn_(-1),
    00081         branchedOnVal_(ALPS_BND_MAX),
    00082         branchedDir_(0),
    00083         guessedObjectiveValue_(ALPS_OBJ_MAX),
    00084         numberUnsatisfied_(0)
    00085         {
    00086             desc_ = new AbcNodeDesc(m);
    00087         }
    00088
    00089     AbcTreeNode(AbcNodeDesc*& desc)
    00090         :
    00091         branchedOn_(-1),
    00092         branchedOnVal_(ALPS_BND_MAX),
    00093         branchedDir_(0),
    00094         guessedObjectiveValue_(ALPS_OBJ_MAX),
    00095         numberUnsatisfied_(0)
    00096         {
    00097             desc_ = desc;
    00098             desc = 0;
    00099             //At the time of registering node, that node hasn't set broker
    00100             //desc_->setModel(getKnowledgeBroker()->getDataPool()->getModel());
    00101         }
    00102
    00103     ~AbcTreeNode()
    00104         {
    00105         }
    00106
    00107     virtual AlpsTreeNode* createNewTreeNode(AlpsNodeDesc*& desc) const;
    00108
    00110     virtual int process(bool isRoot = false, bool rampUp = false);
    00111
    00120     int chooseBranch (AbcModel * model, bool& strongFound);
    00121
    00124
    00125     inline double getObjValue() const { return quality_; }
    00126     inline void setObjValue(const double objValue) { quality_ = objValue; }
    00128
    00129     virtual std::vector< CoinTriple<AlpsNodeDesc*, AlpsNodeStatus, double> >
    00130         branch();
    00131
    00133     inline int numberUnsatisfied() const
    00134         { return numberUnsatisfied_; }
    00135
    00137     inline double guessedObjectiveValue() const
    00138         { return guessedObjectiveValue_; }
    00140     inline void setGuessedObjectiveValue(double value)
    00141         { guessedObjectiveValue_ = value; }
    00143     void setBranchedOn(int b) { branchedOn_ = b; }
    00145     void setBranchedDir(int d) { branchedDir_ = d; }
    00147     void setBranchedOnValue(double b) { branchedOnVal_ = b; }
    00149     int getBranchedOn() const { return branchedOn_; }
    00151     int getBranchedDir() const { return branchedDir_; }
    00153     double getBranchedOnValue() const { return branchedOnVal_; }
    00155     virtual AlpsEncoded* encode() const;
    00157     virtual AlpsKnowledge* decode(AlpsEncoded&) const;
    00158
    00159 };
    00160
    00161 #endif