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

- File List
- File Members

# /home/coin/svn-release/Bcps-0.93.11/Alps/src/AlpsSearchStrategyBase.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 AlpsSearchStrategyBase_h_
    00024 #define AlpsSearchStrategyBase_h_
    00025
    00026 #include "Alps.h"
    00027
    00028 class AlpsModel;
    00029 class AlpsSubTree;
    00030 class AlpsTreeNode;
    00031
    00032 //#############################################################################
    00033
    00044 template<class T>
    00045 class AlpsSearchStrategy
    00046 {
    00047 protected:
    00049     double weight_;
    00050
    00052     int type_;
    00053
    00054 public:
    00056     AlpsSearchStrategy() : weight_(-1.0), type_(AlpsSearchTypeBestFirst){}
    00057
    00059     virtual ~AlpsSearchStrategy() {}
    00060
    00066     virtual bool compare(T x, T y) = 0;
    00067
    00068     bool operator() (T x, T y) {
    00069         return compare(x, y);
    00070     }
    00071
    00076     inline double getWeight() const { return weight_; }
    00077     inline void setWeight(double nw) { weight_ = nw; }
    00079
    00085     virtual AlpsTreeNode* selectNextNode(AlpsSubTree *subTree)
    00086     { AlpsTreeNode *temp = 0; return temp; }
    00087
    00089     virtual void createNewNodes(AlpsSubTree *subTree, AlpsTreeNode *node)
    00090     { }
    00092
    00094     int getType(){ return type_; }
    00095
    00097     void setType(int t) { type_ = t; }
    00098 };
    00099
    00100 //#############################################################################
    00101
    00103 template<class T>
    00104 class AlpsCompare
    00105 {
    00106 public:
    00107     AlpsSearchStrategy<T>* strategy_;
    00108
    00109 public:
    00111     AlpsCompare () : strategy_(0) {}
    00112     virtual ~AlpsCompare() {}
    00113
    00114     void setComareBase(AlpsSearchStrategy<T>* c) {
    00115         strategy_ = c;
    00116     }
    00117
    00118     bool operator() (T x, T y) {
    00119         return strategy_->compare(x, y);
    00120     }
    00121 };
    00122
    00123 //#############################################################################
    00124
    00125 #endif