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

- File List
- File Members

# /home/coin/svn-release/Blis-0.93.2/Blis/src/BlisHeuristic.h

Go to the documentation of this file.

    00001 /*===========================================================================*
    00002  * This file is part of the BiCePS Linear Integer 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-2011, Lehigh University, Yan Xu, and Ted Ralphs.       *
    00021  * All Rights Reserved.                                                      *
    00022  *===========================================================================*/
    00023
    00024
    00025 //#############################################################################
    00026 // This file is modified from COIN/Cbc/CbcHeuristic.hpp
    00027 //#############################################################################
    00028
    00029
    00030 #ifndef BlisHeuristic_h_
    00031 #define BlisHeuristic_h_
    00032
    00033 #include <string>
    00034 #include <vector>
    00035
    00036 #include "CoinPackedMatrix.hpp"
    00037 #include "OsiCuts.hpp"
    00038
    00039 #include "Blis.h"
    00040
    00041 class BlisModel;
    00042
    00043
    00044 //#############################################################################
    00045
    00046
    00048 class BlisHeuristic {
    00049
    00050  private:
    00051
    00053     BlisHeuristic & operator = (const BlisHeuristic& rhs);
    00054
    00055  protected:
    00056
    00058     BlisModel *model_;
    00059
    00061     char *name_;
    00062
    00070     BlisHeurStrategy strategy_;
    00071
    00073     int heurCallFrequency_;
    00074
    00076     int numSolutions_;
    00077
    00079     double time_;
    00080
    00082     int calls_;
    00083
    00085     int noSolsCalls_;
    00086
    00087 public:
    00088
    00090     BlisHeuristic() {
    00091         model_ = NULL;
    00092         name_ = strdup("Unknown");
    00093         strategy_ = BlisHeurStrategyAuto;
    00094         heurCallFrequency_ = 1;
    00095         numSolutions_ = 0;
    00096         time_ = 0.0;
    00097         calls_ = 0;
    00098         noSolsCalls_ = 0;
    00099     }
    00100
    00102     BlisHeuristic(BlisModel *model, const char *name,
    00103                   BlisHeurStrategy strategy, int heurCallFrequency) {
    00104         model_ = model;
    00105         if (name) {
    00106             name_ = strdup(name);
    00107         }
    00108         else {
    00109             name_ = strdup("Unknown");
    00110         }
    00111         strategy_ = strategy;
    00112         heurCallFrequency_ = heurCallFrequency;
    00113         numSolutions_ = 0;
    00114         time_ = 0.0;
    00115         calls_ = 0;
    00116         noSolsCalls_ = 0;
    00117     }
    00118
    00120     virtual ~BlisHeuristic() { if (name_) free(name_); }
    00121
    00123     BlisHeuristic(const BlisHeuristic & rhs) {
    00124         model_ = rhs.model_;
    00125         name_ = strdup(rhs.name_);
    00126         strategy_ = rhs.strategy_; // What if disabled?
    00127         heurCallFrequency_ = rhs.heurCallFrequency_;
    00128         numSolutions_ = 0;
    00129         time_ = 0.0;
    00130         calls_ = 0;
    00131         noSolsCalls_ = 0;
    00132     }
    00133
    00135     virtual void setModel(BlisModel * model) { model_ = model ;}
    00136
    00139     virtual void setStrategy(BlisHeurStrategy strategy) {strategy_ = strategy;}
    00140     virtual BlisHeurStrategy strategy() const { return strategy_; }
    00141     //@]
    00142
    00145     virtual void setHeurCallFrequency(int freq) { heurCallFrequency_ = freq; }
    00146     virtual int heurCallFrequency() const { return heurCallFrequency_; }
    00147     //@]
    00148
    00150     virtual BlisHeuristic * clone() const {
    00151         BlisHeuristic *h = NULL;
    00152         assert(0);
    00153         return h;
    00154     }
    00155
    00161     virtual bool searchSolution(double & objectiveValue,
    00162                                double * newSolution)=0;
    00163
    00172     virtual bool searchSolution(double & objectiveValue,
    00173                                double * newSolution,
    00174                                OsiCuts & cs) { return 0; }
    00175
    00177     inline const char * name() const { return name_; }
    00178
    00180     inline void addNumSolutions(int num=1) { numSolutions_ += num; }
    00181
    00183     inline int numSolutions() const { return numSolutions_; }
    00184
    00186     inline void addTime(double t=0.0) { time_ += t; }
    00187
    00189     inline double time() const { return time_; }
    00190
    00192     inline void addCalls(int c=1) { calls_ += c; }
    00193
    00195     inline int calls() const { return calls_; }
    00196
    00198     inline int noSolCalls() const { return noSolsCalls_; }
    00199
    00201     inline void addNoSolCalls(int n=1) { noSolsCalls_ += n; }
    00202 };
    00203
    00204 #endif
    00205