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

Method Task_Div

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

Source from the content-addressed store, hash-verified

2932
2933
2934double cTaskLib::Task_Div(cTaskContext& ctx) const
2935{
2936 double quality = 0.0;
2937 const cArgContainer& args = ctx.GetTaskEntry()->GetArguments();
2938
2939 const tBuffer<int>& input_buffer = ctx.GetInputBuffer();
2940 const long long test_output = ctx.GetOutputBuffer()[0];
2941 const int input_size = input_buffer.GetNumStored();
2942
2943 long long diff = ((long long)INT_MAX + 1) * 2;
2944
2945 for (int i = 0; i < input_size; i ++) {
2946 for (int j = 0; j < input_size; j ++) {
2947 if (i == j || input_buffer[j] == 0) continue;
2948 long long cur_diff = ::llabs((long long)(input_buffer[i] / input_buffer[j]) - test_output);
2949 if (cur_diff < diff) diff = cur_diff;
2950 }
2951 }
2952
2953 int threshold = args.GetInt(0);
2954
2955 if (threshold < 0 || diff <= threshold) { // Negative threshold == infinite
2956 // If within threshold range, quality decays based on absolute difference
2957 double halflife = -1.0 * fabs(args.GetDouble(0));
2958 quality = pow(2.0, static_cast<double>(diff) / halflife);
2959 }
2960
2961 return quality;
2962}
2963
2964
2965void cTaskLib::Load_Log(const cString& name, const cString& argstr, cEnvReqs&, Feedback& feedback)

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected