Example #1
0
 /// <summary>
 /// Построение матрицы оценок. [i,j] элемент матрицы:
 /// = 0, если про точки i и j нельзя однозначно установить порядок
 /// = -1, если j-ая точка лежит левее i-ой
 /// = 1, если j-ая точка лежит правее i-ой
 /// </summary>
 /// <param name="setRatings"> список оценок у точек </param>
 /// <returns> матрица оценок </returns>
 public static int[,] GetMatrixOfPartialOrder(ref Segment[] setRatings)
 {
     int setRatingsCount = setRatings.Length;
     int[,] matrixOfPartialOrder = new int[setRatingsCount, setRatingsCount];
     for (int i = 0; i < setRatingsCount; i++)
     {
         matrixOfPartialOrder[i,i] = 0;
         for (int j = i + 1; j < setRatingsCount; j++)
         {
             if (setRatings[i].end < setRatings[j].begin)
             {
                 matrixOfPartialOrder[i, j] = 1;
                 matrixOfPartialOrder[j, i] = -1;
                 continue;
             }
             if (setRatings[i].begin > setRatings[j].begin && setRatings[i].begin > setRatings[j].end)
             {
                 matrixOfPartialOrder[i, j] = -1;
                 matrixOfPartialOrder[j, i] = 1;
                 continue;
             }
             matrixOfPartialOrder[i, j] = 0;
             matrixOfPartialOrder[j, i] = 0;
         }
     }
     return matrixOfPartialOrder;
 }
Example #2
0
        public static void TestMethod1()
        {
            int Count = 3;
            Segment[] ratings = new Segment[Count];

            List<Segment> list = new List<Segment>()
                {
                    new Segment(5, 10),
                    new Segment(7, 9),
                    new Segment(7.0001, 8.5),
                };

            SetRating r = new SetRating(list);
            Segment s = SetRating.Intersection(r);
            ratings[0] = s;

            list = new List<Segment>()
                {
                    new Segment(0.003, 14),
                    new Segment(0.01, 10),
                    new Segment(5, 15),
                    new Segment(4, 20),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[1] = s;

            list = new List<Segment>()
                {
                    new Segment(2, 12),
                    new Segment(3, 4),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[2] = s;

            SetRating.Output(SetRating.GetMatrixOfPartialOrder(ref ratings));

            Console.WriteLine("_________________________");
        }
Example #3
0
        public static void TestMethod4()
        {
            int Count = 5;

            Segment[] ratings = new Segment[Count];
            List<Segment> list = new List<Segment>()
                {
                    new Segment(2, 5),
                    new Segment(-1, 9),
                };

            SetRating r = new SetRating(list);
            Segment s = SetRating.Intersection(r);
            ratings[0] = s;

            list = new List<Segment>()
                {
                    new Segment(12, 14),
                    new Segment(12, 15),
                    new Segment(12, 14),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[1] = s;

            list = new List<Segment>()
                {
                    new Segment(1, 2),
                    new Segment(2, 3),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[2] = s;

            list = new List<Segment>()
                {
                    new Segment(2, 9),
                    new Segment(6, 13),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[3] = s;

            list = new List<Segment>()
                {
                    new Segment(2, 29),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[4] = s;

            SetRating.Output(SetRating.GetMatrixOfPartialOrder(ref ratings));

            Console.WriteLine("_________________________");
        }
Example #4
0
        public static void TestMethod()
        {
            int Count = 3;
            Segment[] ratings = new Segment[Count];

            List<Segment> list = new List<Segment>()
                {
                    new Segment(0.0001, 0.0002),
                    new Segment(0.00011, 0.00021),
                    new Segment(0.000111, 0.000211),
                    new Segment(0.0001111, 0.0002111)
                };

            SetRating r = new SetRating(list);
            Segment s = SetRating.Intersection(r);
            ratings[0] = s;

            list = new List<Segment>()
                {
                    new Segment(0.001, 0.01),
                    new Segment(0.0011, 0.011),
                    new Segment(0.00111, 0.0111),
                    new Segment(0.001111, 0.01111),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[1] = s;

            list = new List<Segment>()
                {
                    new Segment(0.1, 1),
                    new Segment(0.11, 1.1),
                    new Segment(0.111, 1.11),
                    new Segment(0.1111, 1.111),
                };

            r = new SetRating(list);
            s = SetRating.Intersection(r);
            ratings[2] = s;

            SetRating.Output(SetRating.GetMatrixOfPartialOrder(ref ratings));

            Console.WriteLine("_________________________");
        }