LibCudaOptimize
1.0
|
00001 //*************************************************************************// 00002 // // 00003 // LibCudaOptimize // 00004 // Copyright (C) 2012 Ibislab, University of Parma // 00005 // Authors: Youssef S.G. Nashed, Roberto Ugolotti // 00006 // // 00007 // You should have received a copy of the GNU General Public License // 00008 // along with this program. If not, see <http://www.gnu.org/licenses/> // 00009 // // 00010 //*************************************************************************// 00011 00012 #ifndef DE_Optimizer_H 00013 #define DE_Optimizer_H 00014 00015 #include "IOptimizer.h" 00016 00017 /*open the namespace 00018 this code should be after all the #include lines and before the first line of the code in each file. 00019 by Hamid. 23/07/2012*/ 00020 #ifdef LIBCUDAOPTIMIZE_NAMESPACE 00021 OPEN_NAMESPACE 00022 #endif 00023 00024 // DE behaviour 00025 #define F 0.5f ///< Standard Value for parameter F 00026 #define CR 0.9f ///< Standard Value for Crossover Rate 00027 00029 typedef enum { 00030 DE_RANDOM, 00031 DE_BEST, 00032 DE_TARGET_TO_BEST, 00033 DE_MUTATION_NUM 00034 } DE_MUTATION; 00035 #define DE_DEFAULT_MUTATION DE_RANDOM ///< mutation type used by default 00036 00038 typedef enum { 00039 DE_BINOMIAL, 00040 DE_EXPONENTIAL, 00041 DE_CROSSOVER_NUM 00042 } DE_CROSSOVER; 00043 #define DE_DEFAULT_CROSSOVER DE_BINOMIAL ///< crossover type used by default 00044 00046 class DE_Optimizer : 00047 public virtual IOptimizer 00048 { 00049 protected: 00050 00051 #ifndef PRIVATE_DOXYGEN 00052 SolutionSet m_trialSolutionSet; 00053 DE_MUTATION m_mutation; 00054 DE_CROSSOVER m_crossover; 00055 00056 float m_F; 00057 float m_CR; 00058 #endif 00059 virtual void initSolutions(dim3,dim3); 00060 virtual void fitnessEvaluation(dim3,dim3,bool first=false); 00061 virtual void step(dim3,dim3); 00062 virtual void update(dim3,dim3,bool first=false); 00063 virtual void findBest(); 00064 00065 public: 00067 DE_Optimizer(EvalFuncPtr fPtr=NULL, unsigned int dn=PROBLEM_DIMENSIONS, unsigned int sn=NUM_SETS, unsigned int pn=NUM_SOLUTIONS); 00068 virtual ~DE_Optimizer(); 00069 00070 virtual bool init(); 00071 00073 void setF(float f) {m_F = f;} 00075 void setCR(float cr) {m_CR = cr;} 00083 void setMutation(DE_MUTATION m) {if(m<DE_MUTATION_NUM) m_mutation = m;} 00090 void setCrossover(DE_CROSSOVER x) {if(x<DE_CROSSOVER_NUM) m_crossover = x;} 00091 }; 00092 00093 /*close the namespace 00094 this code should be at the end of the file 00095 by Hamid. 23/07/2012*/ 00096 #ifdef LIBCUDAOPTIMIZE_NAMESPACE 00097 CLOSE_NAMESPACE 00098 #endif 00099 00100 #endif