MCPcopy Create free account
hub / github.com/devosoft/avida / Task_MatchNumber

Method Task_MatchNumber

avida-core/source/main/cTaskLib.cc:2343–2358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2341}
2342
2343double cTaskLib::Task_MatchNumber(cTaskContext& ctx) const
2344{
2345 double quality = 0.0;
2346 const cArgContainer& args = ctx.GetTaskEntry()->GetArguments();
2347
2348 long long diff = ::llabs((long long)args.GetInt(0) - ctx.GetOutputBuffer()[0]);
2349 int threshold = args.GetInt(1);
2350
2351 if (threshold < 0 || diff <= threshold) { // Negative threshold == infinite
2352 // If within threshold range, quality decays based on absolute difference
2353 double halflife = -1.0 * fabs(args.GetDouble(0));
2354 quality = pow(2.0, static_cast<double>(diff) / halflife);
2355 }
2356
2357 return quality;
2358}
2359
2360
2361void cTaskLib::Load_SortInputs(const cString& name, const cString& argstr, cEnvReqs& envreqs, Feedback& feedback)

Callers

nothing calls this directly

Calls 4

GetTaskEntryMethod · 0.80
GetIntMethod · 0.80
GetArgumentsMethod · 0.45
GetDoubleMethod · 0.45

Tested by

no test coverage detected