/home/coin/SVN-release/CoinAll-1.1.0/Bcps/examples/Blis/BlisHeuristic.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 
00026 //#############################################################################
00027 // This file is modified from COIN/Cbc/CbcHeuristic.hpp
00028 //#############################################################################
00029 
00030 
00031 #ifndef BlisHeuristic_h_
00032 #define BlisHeuristic_h_
00033 
00034 #include <string>
00035 #include <vector>
00036 
00037 #include "CoinPackedMatrix.hpp"
00038 #include "OsiCuts.hpp"
00039 
00040 class BlisModel;
00041 
00042 
00043 //#############################################################################
00044 
00045 
00047 class BlisHeuristic {
00048 
00049  private:
00050 
00052     BlisHeuristic & operator = (const BlisHeuristic& rhs);
00053     
00054  protected:
00055 
00057     BlisModel *model_;
00058     
00060     char *name_;
00061     
00068     int strategy_;
00069 
00071     int numSolutions_;
00072 
00074     double time_;
00075 
00077     int calls_;
00078     
00079  public:
00080 
00082     BlisHeuristic() {
00083         model_ = NULL;
00084         name_ = strdup("Unknown");
00085         strategy_ = 0;
00086         numSolutions_ = 0;
00087         time_ = 0.0;
00088         calls_ = 0;
00089     }
00090     
00092     BlisHeuristic(BlisModel *model, const char *name, int strategy) {
00093         model_ = model;
00094         if (name) {
00095             name_ = strdup(name);
00096         }
00097         else {
00098             name_ = strdup("Unknown");
00099         }
00100         strategy_ = strategy;
00101         numSolutions_ = 0;
00102         time_ = 0.0;
00103         calls_ = 0;
00104     }
00105 
00107     virtual ~BlisHeuristic() { if (name_) free(name_); }
00108 
00110     BlisHeuristic(const BlisHeuristic & rhs) {        
00111         model_ = rhs.model_;
00112         name_ = strdup(rhs.name_);
00113         strategy_ = rhs.strategy_; // What if disabled?
00114         numSolutions_ = 0;
00115         time_ = 0.0;
00116         calls_ = 0;
00117     }
00118  
00120     virtual void setModel(BlisModel * model) { model_ = model ;}
00121     
00124     virtual void setStrategy(int strategy) { strategy_ = strategy; }
00125     virtual int strategy() { return strategy_; }
00126     //@]
00127 
00129     virtual BlisHeuristic * clone() const = 0;
00130     
00136     virtual bool searchSolution(double & objectiveValue, 
00137                                 double * newSolution)=0;
00138     
00147     virtual int searchSolution(double & objectiveValue,
00148                                double * newSolution,
00149                                OsiCuts & cs) { return 0; }
00150     
00152     int numSolutions() { return numSolutions_; }
00153     
00155     inline double time() { return time_; }
00156     
00158     inline int calls() { return calls_; }
00159 };
00160 
00161 #endif
00162 

Generated on Sun Nov 14 14:06:30 2010 for Coin-All by  doxygen 1.4.7