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

Method Task_Mult

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

Source from the content-addressed store, hash-verified

2887
2888
2889double cTaskLib::Task_Mult(cTaskContext& ctx) const
2890{
2891 double quality = 0.0;
2892 const cArgContainer& args = ctx.GetTaskEntry()->GetArguments();
2893
2894 const tBuffer<int>& input_buffer = ctx.GetInputBuffer();
2895 const long long test_output = ctx.GetOutputBuffer()[0];
2896 const int input_size = input_buffer.GetNumStored();
2897
2898 long long diff = ((long long)INT_MAX + 1) * 2;
2899
2900 for (int i = 0; i < input_size; i ++) {
2901 for (int j = 0; j < input_size; j ++) {
2902 if (i == j) continue;
2903 long long cur_diff = ::llabs((long long)(input_buffer[i] * input_buffer[j]) - test_output);
2904 if (cur_diff < diff) diff = cur_diff;
2905 }
2906 }
2907
2908 int threshold = args.GetInt(0);
2909
2910 if (threshold < 0 || diff <= threshold) { // Negative threshold == infinite
2911 // If within threshold range, quality decays based on absolute difference
2912 double halflife = -1.0 * fabs(args.GetDouble(0));
2913 quality = pow(2.0, static_cast<double>(diff) / halflife);
2914 }
2915
2916 return quality;
2917}
2918
2919
2920void cTaskLib::Load_Div(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