2#include "FunctionMinEvalOp.h"
9 state->getRegistry()->registerEntry(
"function", (voidP) (
new uint(1)), ECF::UINT);
15 voidP sptr = state->getRegistry()->getEntry(
"function");
18 voidP lbound_ptr = state->getGenotypes()[0]->getParameterValue(state,
"lbound");
19 double lbound = *((
double*)lbound_ptr.get());
26double calculateDistance(
double s1[],
double s2[])
29 for(uint i = 0; i < 3; i++)
30 d += (s1[i] - s2[i]) * (s1[i] - s2[i]);
38 const double c = 300000;
41 double receiver[] = {1, -1, 0.25};
42 double receiverTimeError = 0.000001;
45 double s1[] = {0, -400, 1000};
46 double s2[] = {300, 0, 1000};
47 double s3[] = {-600, 0, 1000};
48 double s4[] = {0, 700, 1000};
49 double* sats[4] = {s1, s2, s3, s4};
52 double d1 = calculateDistance(s1, receiver);
53 double d2 = calculateDistance(s2, receiver);
54 double d3 = calculateDistance(s3, receiver);
55 double d4 = calculateDistance(s4, receiver);
56 double dist[4] = {d1, d2, d3, d4};
59 double signalSendTime = 0;
60 double signalTravelTime[4];
61 double signalReceiveTime[4];
62 for(uint i = 0; i < 4; i++) {
63 signalTravelTime[i] = dist[i] / c;
64 signalReceiveTime[i] = signalSendTime + signalTravelTime[i] + receiverTimeError;
70 double fitnessValue = 0;
71 for(uint i = 0; i < 4; i++) {
80 pow(c * (signalReceiveTime[i] - gen->
realValue[3]/100000 - signalSendTime), 2);
81 double satError = posError - timeError;
82 fitnessValue += satError * satError;
85 fitnessValue = sqrt(fitnessValue) / 4;
88 fitness->setValue(fitnessValue);
Fitness for minimization problems.
FloatingPoint class - implements genotype as a vector of floating point values.
FitnessP evaluate(IndividualP individual)
Evaluate a single individual. Method must create and return a Fitness object.
uint iFunction_
function index
void registerParameters(StateP)
Register evaluator parameters. Called before EvaluateOp::initialize method.
bool initialize(StateP)
Initialize the evaluator. Called before first evaluation occurs.
std::vector< double > realValue
vector of floating point values