00001
00020 #include "problemcec2005.h"
00021 #include "cec2005/cec2005.h"
00022
00023 using namespace realea;
00024
00025 ProblemCEC2005::ProblemCEC2005(Random *random, unsigned int dim) {
00026 m_random = random;
00027 m_ndim = dim;
00028 m_init = false;
00029 }
00030
00031 ProblemCEC2005::~ProblemCEC2005(void) {
00032 if (m_init) {
00033 finish_cec2005();
00034 }
00035 }
00036
00037
00038
00039
00040 void ProblemCEC2005::init(unsigned int fun) {
00041 if (m_init) {
00042 finish_cec2005();
00043 m_init = false;
00044 }
00045
00046 init_cec2005(m_random, fun, m_ndim);
00047 m_init = true;
00048 }
00049
00050 tFitness eval_probcec2005(const tGen *x, int dim) {
00051 double result = eval_cec2005(x,dim);
00052 return result;
00053 }
00054
00055
00056 ProblemPtr ProblemCEC2005::get(unsigned int fun) {
00057 string name;
00058 double min, max, optime;
00059
00060
00061 init(fun);
00062 getInfo_cec2005(fun, name, min, max, optime);
00063
00064 ProblemPtr prob (new Problem());
00065 prob->setDimension(m_ndim);
00066
00067 for (unsigned i = 0; i < m_ndim; ++i) {
00068 prob->setDomainValues(i, min, max, true);
00069 }
00070
00071
00072 prob->setOptimize(0, 1e-8);
00073 prob->setMaxEval(10000*m_ndim);
00074 prob->setMinimize();
00075
00076
00077 prob->setEval(eval_probcec2005);
00078 return prob;
00079 }