📄 basic_edas.hxx
字号:
// coded by H.Handa 02/11/26 Ver.0.1// Time-stamp: <2007-07-13 15:06:51 handa>#ifndef BASIC_EDAs_HH#define BASIC_EDAs_HHusing namespace std;#include "chromoso.h"#include "selectio.h"#include "estimation_and_sampling.hxx"template <class T> class basic_EDAs {protected: list<chromosome<T> *>& pop; list<chromosome<T> *> matched; vector<chromosome<T> *>& pool; list<chromosome<T> *> pool2; environment<T>& env; selection<T>& sel; estimation_and_sampling<T>& eas;public: void calc_objfunc_pop(list<chromosome<T> *>& arg) { list<chromoIntP>::iterator il; for (il = arg.begin(); il != arg.end(); il++) for (int j = 0; j < env.isNoFit(); j++) (*il)->objfunc(j) = env.calc(j, *(*il)); } basic_EDAs<T>(list<chromosome<T> *>& p, estimation_and_sampling<T>& arg, selection<T>& s, environment<T>& e, vector<chromosome<T> *>& pl) : pop(p), env(e), eas(arg), sel(s), pool(pl) { calc_objfunc_pop(pop); list<chromoIntP>::iterator il; for (il = pop.begin(); il != pop.end(); il++) (*il)->fitness() = (*il)->objfunc(); } basic_EDAs<T>(basic_EDAs<T>& arg) { if(this == &arg) return ; pop = arg.pop; pool = arg.pool; pool2 = arg.pool2; matched = arg.matched; env = arg.env; sel = arg.sel; eas = arg.eas; } virtual basic_EDAs<T>& operator=(const basic_EDAs<T>& arg) { if(this == &arg) return *this; pop = arg.pop; pool = arg.pool; pool2 = arg.pool2; matched = arg.matched; env = arg.env; sel = arg.sel; eas = arg.eas; } void generation() { int i; static int flag = 1; for (i = 0; i < env.noi(); i++) { env.generateMatchingSet(pop, matched, i); sel.mating(matched, pool, flag); eas.generating(pool, pool2); } calc_objfunc_pop(pool2); // New population pop is re-formated by taking account into the // genetic information of the selected individuals in pool if needed, // otherwise, the following function might do nothing. sel.postprocessing(pool2, pop, flag); flag = 1 - flag; } int pop_model_data() { return eas.pop_model_data(pop); }};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -