コード例 #1
0
        public void ZeroSizeListTest()
        {
            var   m    = new WeightedMetrics();
            var   list = new List <Utility>();
            float aVal = m.Calculate(list);

            Assert.That(aVal, Is.EqualTo(Zero).Within(Tolerance));
        }
コード例 #2
0
        public void ConstructorTest()
        {
            var m = new WeightedMetrics();

            Assert.IsNotNull(m);
            Assert.GreaterOrEqual(m.PNorm, m.PNormMin);
            Assert.LessOrEqual(m.PNorm, m.PNormMax);
        }
コード例 #3
0
        public void ZeroValuesTest()
        {
            var m    = new WeightedMetrics();
            var list = MeasureTestsHelper.RandomUtilityWeightList(_rnd.Next(1, MaxVecLen), 0.0f);

            float aVal = m.Calculate(list);
            float cVal = MeasureTestsHelper.CalculateChebyshevNorm(list);

            Assert.That(aVal, Is.EqualTo(Zero).Within(Tolerance));
            Assert.That(cVal, Is.EqualTo(Zero).Within(Tolerance));
        }
コード例 #4
0
        public void CalculateTest([Values(-100f, -1f, 0f, 1f, 5f, 10f, 100f, 1000000f)] float p)
        {
            var m  = new WeightedMetrics(p);
            var cP = p.Clamp(m.PNormMin, m.PNormMax);

            Assert.That(m.PNorm, Is.EqualTo(p.Clamp(m.PNormMin, m.PNormMax)).Within(Tolerance));
            var   list = MeasureTestsHelper.RandomUtilityList(_rnd.Next(1, MaxVecLen));
            float aVal = m.Calculate(list);
            float cVal = MeasureTestsHelper.CalculateWeightedMetricsNorm(list, cP);

            Assert.That(aVal, Is.EqualTo(cVal).Within(Tolerance));
            Assert.That(aVal <= One);
            Assert.That(aVal >= Zero);
        }