00001 #include <ecf/ECF.h>
00002 #include "FunctionMinEvalOp.h"
00003 #include <float.h>
00004
00005
00006
00007 extern void cec14_test_func(double *, double *,int,int,int);
00008 double *OShift,*M,*y,*z,*x_bound;
00009 int ini_flag=0,n_flag,func_flag,*SS;
00010
00011
00012 void FunctionMinEvalOp::registerParameters(StateP state)
00013 {
00014 state->getRegistry()->registerEntry("cec.function", (voidP) (new uint(1)), ECF::UINT,
00015 "Sets the CEC test function number (default: 1)");
00016 }
00017
00018
00019 bool FunctionMinEvalOp::initialize(StateP state)
00020 {
00021 voidP sptr = state->getRegistry()->getEntry("cec.function");
00022 iFunction_ = *((uint*) sptr.get());
00023
00024
00025 if(iFunction_ < 1 || iFunction_ > 30) {
00026 ECF_LOG_ERROR(state, "CEC EvalOp: There are only 30 test functions in this test suite!");
00027 throw("");
00028 }
00029
00030
00031
00032
00033 return true;
00034 }
00035
00036
00037 FitnessP FunctionMinEvalOp::evaluate(IndividualP individual)
00038 {
00039
00040
00041 FitnessP fitness (new FitnessMin);
00042
00043
00044 FloatingPoint::FloatingPoint* gen = (FloatingPoint::FloatingPoint*) individual->getGenotype().get();
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 double realTemp = 0, value = 0;
00055
00056 int n = (int) gen->realValue.size();
00057
00058 cec14_test_func(&gen->realValue[0], &value, n, 1, iFunction_);
00059
00060 fitness->setValue(value);
00061 return fitness;
00062 }