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

Method Task_Log2

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

Source from the content-addressed store, hash-verified

3018}
3019
3020double cTaskLib::Task_Log2(cTaskContext& ctx) const
3021{
3022 double quality = 0.0;
3023 const cArgContainer& args = ctx.GetTaskEntry()->GetArguments();
3024
3025 const tBuffer<int>& input_buffer = ctx.GetInputBuffer();
3026 const long long test_output = ctx.GetOutputBuffer()[0];
3027 const int input_size = input_buffer.GetNumStored();
3028
3029 long long diff = ((long long)INT_MAX + 1) * 2;
3030
3031 for (int i = 0; i < input_size; i ++) {
3032 long long cur_diff = ::llabs((long long)(log2(fabs(double(input_buffer[i] ? input_buffer[i] : 1)))) - test_output);
3033 if (cur_diff < diff) diff = cur_diff;
3034 }
3035
3036 int threshold = args.GetInt(0);
3037
3038 if (threshold < 0 || diff <= threshold) { // Negative threshold == infinite
3039 // If within threshold range, quality decays based on absolute difference
3040 double halflife = -1.0 * fabs(args.GetDouble(0));
3041 quality = pow(2.0, static_cast<double>(diff) / halflife);
3042 }
3043
3044 return quality;
3045}
3046
3047
3048void cTaskLib::Load_Log10(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