00001
00020 #include "problemtablefactory.h"
00021 #include <cassert>
00022
00023 using namespace realea;
00024
00025 ProblemTableFactory::ProblemTableFactory(unsigned maxeval, FUNCTION *fun, unsigned max) {
00026 m_fun = fun;
00027 m_max = max;
00028 m_maxeval = maxeval;
00029 }
00030
00031 ProblemTableFactory::~ProblemTableFactory(void) {
00032 m_fun = NULL;
00033 };
00034
00035 ProblemPtr ProblemTableFactory::get(unsigned int ident) {
00036 ProblemPtr prob (new Problem());
00037
00038 assert(ident >= 1 && ident <= m_max);
00039
00040
00041 FUNCTION *fun = &(m_fun[ident-1]);
00042
00043 unsigned ndim = fun->genes;
00044 prob->setDimension(ndim);
00045 double min = fun->range[0];
00046 double max = fun->range[1];
00047
00048 for (unsigned i = 0; i < ndim; ++i) {
00049 prob->setDomainValues(i, min, max, true);
00050 }
00051
00052 prob->setOptimize(fun->optime, 0);
00053 prob->setMaxEval(m_maxeval);
00054 prob->setMinimize();
00055
00056 prob->setEval(fun->eval);
00057
00058 return prob;
00059 }