public void BlauSpaceEvaluationTest() { Console.WriteLine("BlauSpaceEvaluationTest"); int dim = 3; string [] names = new string [3] { "x", "y", "z" }; double [] mins = new double [3] { 0.0, 0.0, 0.0 }; double [] maxs = new double [3] { 100.0, 100.0, 100.0 }; IBlauSpace s = BlauSpace.create(dim, names, mins, maxs); int STEPS = 10; int [] STEPSarray = new int[s.Dimension]; for (int j = 0; j < s.Dimension; j++) { STEPSarray[j] = STEPS; } IBlauSpaceLattice bsl = BlauSpaceLattice.create(s, STEPSarray); IBlauSpaceMultiEvaluation mev = new BlauSpaceMultiEvaluation("net worth", bsl); IBlauPoint bp = new BlauPoint(s); bp.setCoordinate(0, 11.0); bp.setCoordinate(1, 22.0); bp.setCoordinate(2, 33.0); mev.set(bp, 10.0); mev.set(bp, 20.0); IBlauPoint bp2 = bp.clone(); mev.set(bp2, 30.0); mev.set(bp2, 40.0); IBlauPoint bp3 = new BlauPoint(s); bp3.setCoordinate(0, 12.0); bp3.setCoordinate(1, 23.0); bp3.setCoordinate(2, 34.0); mev.set(bp3, 50.0); IBlauPoint bpX = new BlauPoint(s); bpX.setCoordinate(0, 22.0); bpX.setCoordinate(1, 33.0); bpX.setCoordinate(2, 44.0); mev.set(bpX, 100.0); IBlauSpaceEvaluation bse = new BlauSpaceEvaluation("net worth", bsl); foreach (IBlauPoint p in mev.AssignedLatticePoints) { LinkedList <IScore> scores = mev.eval(p); double total = 0.0; double count = 0.0; foreach (IScore sc in scores) { total += sc.Value; count += 1.0; } if (p.CompareTo(bp) == 0) { Assert.AreEqual(total, 150.0); Assert.AreEqual(count, 5.0); } if (p.CompareTo(bpX) == 0) { Assert.AreEqual(total, 100.0); Assert.AreEqual(count, 1.0); } double ave = total / count; bse.set(p, ave); Assert.Throws <Exception>(delegate { bse.set(p, ave); }); Assert.Throws <Exception>(delegate { bse.set(p.clone(), ave); }); Assert.AreEqual(bse.eval(p), ave); Assert.AreEqual(bse.eval(p.clone()), ave); } SingletonLogger.Instance().DebugLog(typeof(metrics_tests), "bse: " + bse.ToStringLong()); }
public void BlauSpaceMultiEvaluationTest() { Console.WriteLine("BlauSpaceMultiEvaluationTest"); int dim = 3; string [] names = new string [3] { "x", "y", "z" }; double [] mins = new double [3] { 0.0, 0.0, 0.0 }; double [] maxs = new double [3] { 100.0, 100.0, 100.0 }; IBlauSpace s = BlauSpace.create(dim, names, mins, maxs); int STEPS = 10; int [] STEPSarray = new int[s.Dimension]; for (int j = 0; j < s.Dimension; j++) { STEPSarray[j] = STEPS; } IBlauSpaceLattice bsl = BlauSpaceLattice.create(s, STEPSarray); IBlauSpaceMultiEvaluation mev = new BlauSpaceMultiEvaluation("net worth", bsl); IBlauPoint bp = new BlauPoint(s); bp.setCoordinate(0, 11.0); bp.setCoordinate(1, 22.0); bp.setCoordinate(2, 33.0); mev.set(bp, 10.0); Assert.AreEqual(mev.eval(bp).Count, 1); mev.set(bp, 20.0); Assert.AreEqual(mev.eval(bp).Count, 2); IBlauPoint bp2 = bp.clone(); mev.set(bp2, 30.0); Assert.AreEqual(mev.eval(bp).Count, 3); Assert.AreEqual(mev.eval(bp2).Count, 3); mev.set(bp2, 40.0); Assert.AreEqual(mev.eval(bp).Count, 4); Assert.AreEqual(mev.eval(bp2).Count, 4); Assert.AreEqual(mev.AssignedLatticePoints.Count, 1); IBlauPoint bp3 = new BlauPoint(s); bp3.setCoordinate(0, 12.0); bp3.setCoordinate(1, 23.0); bp3.setCoordinate(2, 34.0); mev.set(bp3, 50.0); Assert.AreEqual(mev.eval(bp).Count, 5); Assert.AreEqual(mev.eval(bp2).Count, 5); Assert.AreEqual(mev.eval(bp3).Count, 5); Assert.AreEqual(mev.AssignedLatticePoints.Count, 1); IBlauPoint bpX = new BlauPoint(s); bpX.setCoordinate(0, 22.0); bpX.setCoordinate(1, 33.0); bpX.setCoordinate(2, 44.0); mev.set(bpX, 100.0); Assert.AreEqual(mev.eval(bp).Count, 5); Assert.AreEqual(mev.eval(bp2).Count, 5); Assert.AreEqual(mev.eval(bp3).Count, 5); Assert.AreEqual(mev.eval(bpX).Count, 1); Assert.AreEqual(mev.AssignedLatticePoints.Count, 2); SingletonLogger.Instance().DebugLog(typeof(metrics_tests), "mev: " + mev.ToStringLong()); }