public void AverageGainTest() { int?[] cutoffs = new int?[] { 5, 10, 15, 20, 30, 100, 200, 500, 1000, null }; nFire.Evaluators.Graded.IGainFunction[] gainFunctions = new Evaluators.Graded.IGainFunction[]{ new nFire.Evaluators.Graded.LinearGain(), new nFire.Evaluators.Graded.ExponentialGain(2.0), new nFire.Evaluators.Graded.ExponentialGain(3.0)}; nFire.Evaluators.Graded.AverageGain ag = new nFire.Evaluators.Graded.AverageGain(); nFire.Evaluators.Graded.CumulatedGain cg = new nFire.Evaluators.Graded.CumulatedGain(); for (int gainFunction = 0; gainFunction < gainFunctions.Length; gainFunction++) { ag.GainFunction = gainFunctions[gainFunction]; cg.GainFunction = gainFunctions[gainFunction]; for (int cutoff = 0; cutoff < cutoffs.Length; cutoff++) { ag.Cutoff = cutoffs[cutoff]; cg.Cutoff = cutoffs[cutoff]; int cut = cutoffs[cutoff] == null ? 500 : (int)cutoffs[cutoff]; var res = this.Task.EvaluateAllQueries<double>(this.Task.Systems["STANDARD"], ag); var res2 = this.Task.EvaluateAllQueries<double>(this.Task.Systems["STANDARD"], cg); Assert.AreEqual(res2[this.Task.Queries["301"]] / cut, res[this.Task.Queries["301"]], 0.00005); Assert.AreEqual(res2[this.Task.Queries["302"]] / cut, res[this.Task.Queries["302"]], 0.00005); Assert.AreEqual(res2[this.Task.Queries["303"]] / cut, res[this.Task.Queries["303"]], 0.00005); } } }
public void CumulatedGainTest() { int?[] cutoffs = new int?[] { 5, 10, 15, 20, 30, 100, 200, 500, 1000, null }; nFire.Evaluators.Graded.IGainFunction[] gainFunctions = new Evaluators.Graded.IGainFunction[]{ new nFire.Evaluators.Graded.LinearGain(), new nFire.Evaluators.Graded.ExponentialGain(2.0), new nFire.Evaluators.Graded.ExponentialGain(3.0)}; double[][] res301 = new double[][]{ new double[]{ 0, 2, 2, 5, 7, 23, 42, 74, 74, 74 }, new double[] { 0, 4, 4, 10, 14, 46, 84, 156, 156, 156 }, new double[]{0, 6, 6, 15, 21, 69, 126, 291, 291, 291} }; double[][] res302 = new double[][]{ new double[] { 12, 21, 36, 48, 66, 126, 132, 150, 150, 150 }, new double[] { 32, 56, 96, 128, 176, 336, 352, 400, 400, 400 }, new double[]{108, 189, 324, 432, 594, 1134, 1188, 1350, 1350, 1350} }; double[][] res303 = new double[][]{ new double[] { 0, 0, 0, 2, 2, 14, 16, 16, 16, 16 }, new double[] { 0, 0, 0, 4, 4, 28, 32, 32, 32, 32 }, new double[]{0, 0, 0, 9, 9, 63, 72, 72, 72, 72} }; nFire.Evaluators.Graded.CumulatedGain cg = new nFire.Evaluators.Graded.CumulatedGain(); for (int gainFunction = 0; gainFunction < gainFunctions.Length; gainFunction++) { cg.GainFunction = gainFunctions[gainFunction]; for (int cutoff = 0; cutoff < cutoffs.Length; cutoff++) { cg.Cutoff = cutoffs[cutoff]; var res = this.Task.EvaluateAllQueries<double>(this.Task.Systems["STANDARD"], cg); Assert.AreEqual(res301[gainFunction][cutoff], res[this.Task.Queries["301"]], 0.00005); Assert.AreEqual(res302[gainFunction][cutoff], res[this.Task.Queries["302"]], 0.00005); Assert.AreEqual(res303[gainFunction][cutoff], res[this.Task.Queries["303"]], 0.00005); } } }