public void AddEvaluatorTest() { var cev = new CompositeEvaluator(); var ptA1 = new Pointf(0.0f, 0.0f); var ptB1 = new Pointf(0.2f, 0.3f); var ev1 = new LinearEvaluator(ptA1, ptB1); var ptA2 = new Pointf(0.22f, 0.32f); var ptB2 = new Pointf(0.3f, 0.4f); var ev2 = new PowerEvaluator(ptA2, ptB2, 3.0f); var ptA3 = new Pointf(0.35f, 0.34f); var ptB3 = new Pointf(0.55f, 0.55f); var ev3 = new SigmoidEvaluator(ptA3, ptB3, -0.4f); var ptA4 = new Pointf(0.55f, 0.55f); var ptB4 = new Pointf(1.0f, 1.0f); var ev4 = new SigmoidEvaluator(ptA4, ptB4, 0.6f); var minXmaxX = new Pointf(0.0f, 1.0f); cev.Add(ev1); Assert.AreEqual(ptA1, cev.PtA); Assert.AreEqual(ptB1, cev.PtB); cev.Add(ev2); cev.Add(ev3); cev.Add(ev4); Console.WriteLine(cev.Evaluators.Count); Assert.AreEqual(4, cev.Evaluators.Count); Assert.AreEqual(cev.MinX, minXmaxX.X); Assert.AreEqual(cev.MaxX, minXmaxX.Y); }
public void EvaluateTest( float xA1, float yA1, float xB1, float yB1, float xA2, float yA2, float xB2, float yB2, float xA3, float yA3, float xB3, float yB3, float xA4, float yA4, float xB4, float yB4) { var ptA1 = new Pointf(xA1, yA1); var ptB1 = new Pointf(xB1, yB1); var ev1 = new LinearEvaluator(ptA1, ptB1); var ptA2 = new Pointf(xA2, yA2); var ptB2 = new Pointf(xB2, yB2); var ev2 = new PowerEvaluator(ptA2, ptB2, 3.0f); var ptA3 = new Pointf(xA3, yA3); var ptB3 = new Pointf(xB3, yB3); var ev3 = new SigmoidEvaluator(ptA3, ptB3, -0.4f); var ptA4 = new Pointf(xA4, yA4); var ptB4 = new Pointf(xB4, yB4); var ev4 = new SigmoidEvaluator(ptA4, ptB4, 0.6f); var minX = Math.Min(Math.Min(xA1, xA2), Math.Min(xA3, xA4)); var maxX = Math.Max(Math.Max(xB1, xB2), Math.Max(xB3, xB4)); var compositeXInterval = new Interval <float>(minX, maxX); var cev = new CompositeEvaluator(); // AddConsideration them out of order to ensure the ordering works. cev.Add(ev2); cev.Add(ev4); cev.Add(ev3); cev.Add(ev1); Assert.That(cev.Evaluators.Count == 4); var xqArray = CrMath.LinearSpaced(_evN, minX * 0.999f, 1.001f * maxX); for (int i = 0; i < _evN - 1; i++) { var cVal = CombinedEvaluatorEvaluate(xqArray[i], ev1, ev2, ev3, ev4); Utility cResult = cVal; var aResult = cev.Evaluate(xqArray[i]); Assert.That(aResult, Is.EqualTo(cResult.Value).Within(Tolerance)); Assert.That(aResult <= 1.0f); Assert.That(aResult >= 0.0f); } // Check the end points var utilA = cev.Evaluate(compositeXInterval.LowerBound); var utilB = cev.Evaluate(compositeXInterval.UpperBound); Assert.That(utilA, Is.EqualTo(ev1.PtA.Y).Within(Tolerance)); Assert.That(utilB, Is.EqualTo(ev4.PtB.Y).Within(Tolerance)); }
void Initialize() { var ptA = new Pointf(0.0f, 1.0f); var ptB = new Pointf(5.0f, 0.8f); var ev1 = new LinearEvaluator(ptA, ptB); var ptA1 = new Pointf(5.0f, 0.8f); var ptB1 = new Pointf(10.0f, 0.0f); var ev2 = new SigmoidEvaluator(ptA1, ptB1, -0.5f); var cev = new CompositeEvaluator(); cev.Add(ev1); cev.Add(ev2); _ev = cev; }
void Initialize() { var ptA1 = new Pointf(0f, 0f); var ptB1 = new Pointf(20f, 0.2f); var powEv = new PowerEvaluator(ptA1, ptB1, 2f); var ptA2 = new Pointf(20f, 0.2f); var ptB2 = new Pointf(100f, 1f); var linEv = new LinearEvaluator(ptA2, ptB2); var cmpEv = new CompositeEvaluator(); cmpEv.Add(powEv); cmpEv.Add(linEv); Evaluator = cmpEv; }