Exemplo n.º 1
0
        private static void checkParetoRankings(ParetoComparer <MockDualObjective> comparer, MockDualObjective rank_1_a, MockDualObjective rank_1_b, MockDualObjective rank_1_c, MockDualObjective rank_2_a, MockDualObjective rank_2_b, MockDualObjective rank_2_c, MockDualObjective rank_3_a, MockDualObjective rank_3_b)
        {
            Assert.AreEqual(-1, comparer.Compare(rank_1_a, rank_2_a));
            Assert.AreEqual(+1, comparer.Compare(rank_2_a, rank_1_a));

            Assert.AreEqual(-1, comparer.Compare(rank_1_a, rank_3_b));

            Assert.AreEqual(0, comparer.Compare(rank_1_a, rank_1_a));
            Assert.AreEqual(0, comparer.Compare(rank_1_a, rank_1_b));
            Assert.AreEqual(0, comparer.Compare(rank_1_a, rank_1_c));
            Assert.AreEqual(0, comparer.Compare(rank_1_b, rank_1_c));

            MockDualObjective[] scores = new MockDualObjective[] { rank_2_c, rank_1_b, rank_3_b, rank_2_b, rank_1_a, rank_1_c, rank_3_a, rank_2_a };
            ParetoRanking <MockDualObjective> paretoRanking = new ParetoRanking <MockDualObjective>(scores, comparer);

            MockDualObjective[] rank1 = paretoRanking.GetParetoRank(1);
            Assert.AreEqual(3, rank1.Length);
            Assert.IsTrue(rank1.Contains(rank_1_a));
            Assert.IsTrue(rank1.Contains(rank_1_b));
            Assert.IsTrue(rank1.Contains(rank_1_c));
            MockDualObjective[] rank2 = paretoRanking.GetParetoRank(2);
            Assert.AreEqual(3, rank2.Length);
            Assert.IsTrue(rank2.Contains(rank_2_a));
            Assert.IsTrue(rank2.Contains(rank_2_b));
            Assert.IsTrue(rank2.Contains(rank_2_c));
            MockDualObjective[] rank3 = paretoRanking.GetParetoRank(3);
            Assert.AreEqual(2, rank3.Length);
            Assert.IsTrue(rank3.Contains(rank_3_a));
            Assert.IsTrue(rank3.Contains(rank_3_b));
        }
Exemplo n.º 2
0
        private static void checkParetoRankings(ParetoComparer<MockDualObjective> comparer, MockDualObjective rank_1_a, MockDualObjective rank_1_b, MockDualObjective rank_1_c, MockDualObjective rank_2_a, MockDualObjective rank_2_b, MockDualObjective rank_2_c, MockDualObjective rank_3_a, MockDualObjective rank_3_b)
        {
            Assert.AreEqual(-1, comparer.Compare(rank_1_a, rank_2_a));
            Assert.AreEqual(+1, comparer.Compare(rank_2_a, rank_1_a));

            Assert.AreEqual(-1, comparer.Compare(rank_1_a, rank_3_b));

            Assert.AreEqual(0, comparer.Compare(rank_1_a, rank_1_a));
            Assert.AreEqual(0, comparer.Compare(rank_1_a, rank_1_b));
            Assert.AreEqual(0, comparer.Compare(rank_1_a, rank_1_c));
            Assert.AreEqual(0, comparer.Compare(rank_1_b, rank_1_c));

            MockDualObjective[] scores = new MockDualObjective[] { rank_2_c, rank_1_b, rank_3_b, rank_2_b, rank_1_a, rank_1_c, rank_3_a, rank_2_a };
            ParetoRanking<MockDualObjective> paretoRanking = new ParetoRanking<MockDualObjective>(scores, comparer);
            MockDualObjective[] rank1 = paretoRanking.GetParetoRank(1);
            Assert.AreEqual(3, rank1.Length);
            Assert.IsTrue(rank1.Contains(rank_1_a));
            Assert.IsTrue(rank1.Contains(rank_1_b));
            Assert.IsTrue(rank1.Contains(rank_1_c));
            MockDualObjective[] rank2 = paretoRanking.GetParetoRank(2);
            Assert.AreEqual(3, rank2.Length);
            Assert.IsTrue(rank2.Contains(rank_2_a));
            Assert.IsTrue(rank2.Contains(rank_2_b));
            Assert.IsTrue(rank2.Contains(rank_2_c));
            MockDualObjective[] rank3 = paretoRanking.GetParetoRank(3);
            Assert.AreEqual(2, rank3.Length);
            Assert.IsTrue(rank3.Contains(rank_3_a));
            Assert.IsTrue(rank3.Contains(rank_3_b));
        }
Exemplo n.º 3
0
        public void TestParetoRanking()
        {
            ParetoComparer <MockDualObjective> comparer = new ParetoComparer <MockDualObjective>();

            MockDualObjective rank_1_a = new MockDualObjective(1, 1);
            MockDualObjective rank_1_b = new MockDualObjective(0, 2);
            MockDualObjective rank_1_c = new MockDualObjective(2, 0);
            MockDualObjective rank_2_a = new MockDualObjective(2, 2);
            MockDualObjective rank_2_b = new MockDualObjective(3, 1);
            MockDualObjective rank_2_c = new MockDualObjective(1, 3);
            MockDualObjective rank_3_a = new MockDualObjective(3, 3);
            MockDualObjective rank_3_b = new MockDualObjective(2, 4);

            checkParetoRankings(comparer, rank_1_a, rank_1_b, rank_1_c, rank_2_a, rank_2_b, rank_2_c, rank_3_a, rank_3_b);

            rank_1_a = new MockDualObjective(1, -1, true);
            rank_1_b = new MockDualObjective(0, -2, true);
            rank_1_c = new MockDualObjective(2, -0, true);
            rank_2_a = new MockDualObjective(2, -2, true);
            rank_2_b = new MockDualObjective(3, -1, true);
            rank_2_c = new MockDualObjective(1, -3, true);
            rank_3_a = new MockDualObjective(3, -3, true);
            rank_3_b = new MockDualObjective(2, -4, true);

            checkParetoRankings(comparer, rank_1_a, rank_1_b, rank_1_c, rank_2_a, rank_2_b, rank_2_c, rank_3_a, rank_3_b);
        }
Exemplo n.º 4
0
        public void TestParetoRanking()
        {
            ParetoComparer<MockDualObjective> comparer = new ParetoComparer<MockDualObjective>();

            MockDualObjective rank_1_a = new MockDualObjective(1, 1);
            MockDualObjective rank_1_b = new MockDualObjective(0, 2);
            MockDualObjective rank_1_c = new MockDualObjective(2, 0);
            MockDualObjective rank_2_a = new MockDualObjective(2, 2);
            MockDualObjective rank_2_b = new MockDualObjective(3, 1);
            MockDualObjective rank_2_c = new MockDualObjective(1, 3);
            MockDualObjective rank_3_a = new MockDualObjective(3, 3);
            MockDualObjective rank_3_b = new MockDualObjective(2, 4);

            checkParetoRankings(comparer, rank_1_a, rank_1_b, rank_1_c, rank_2_a, rank_2_b, rank_2_c, rank_3_a, rank_3_b);

            rank_1_a = new MockDualObjective(1, -1, true);
            rank_1_b = new MockDualObjective(0, -2, true);
            rank_1_c = new MockDualObjective(2, -0, true);
            rank_2_a = new MockDualObjective(2, -2, true);
            rank_2_b = new MockDualObjective(3, -1, true);
            rank_2_c = new MockDualObjective(1, -3, true);
            rank_3_a = new MockDualObjective(3, -3, true);
            rank_3_b = new MockDualObjective(2, -4, true);

            checkParetoRankings(comparer, rank_1_a, rank_1_b, rank_1_c, rank_2_a, rank_2_b, rank_2_c, rank_3_a, rank_3_b);
        }