예제 #1
0
        public void Test4Reset()
        {
            var route          = new Optimization.Tours.Tour(new int[] { 0, 1, 2, 3, 4 }, 0);
            var pairEnumerable = new PairEnumerable <Tour>(route, route.IsClosed());
            var pairEnumerator = pairEnumerable.GetEnumerator();

            var pairs = new List <Pair>();

            while (pairEnumerator.MoveNext())
            {
                pairs.Add(pairEnumerator.Current);
            }

            Assert.AreEqual(5, pairs.Count);
            Assert.Contains(new Pair(0, 1), pairs);
            Assert.Contains(new Pair(1, 2), pairs);
            Assert.Contains(new Pair(2, 3), pairs);
            Assert.Contains(new Pair(3, 4), pairs);
            Assert.Contains(new Pair(4, 0), pairs);

            pairEnumerator.Reset();

            pairs = new List <Pair>();
            while (pairEnumerator.MoveNext())
            {
                pairs.Add(pairEnumerator.Current);
            }

            Assert.AreEqual(5, pairs.Count);
            Assert.Contains(new Pair(0, 1), pairs);
            Assert.Contains(new Pair(1, 2), pairs);
            Assert.Contains(new Pair(2, 3), pairs);
            Assert.Contains(new Pair(3, 4), pairs);
            Assert.Contains(new Pair(4, 0), pairs);
        }
예제 #2
0
        public void Test6TwoCustomers()
        {
            var route          = new Optimization.Tours.Tour(new int[] { 0, 1 }, 0);
            var pairEnumerable = new PairEnumerable <Tour>(route, route.IsClosed());
            var pairs          = new List <Pair>(pairEnumerable);

            Assert.AreEqual(2, pairs.Count);

            route          = new Optimization.Tours.Tour(new int[] { 0, 1 }, null);
            pairEnumerable = new PairEnumerable <Tour>(route, route.IsClosed());
            pairs          = new List <Pair>(pairEnumerable);

            Assert.AreEqual(1, pairs.Count);
        }
예제 #3
0
        public void Test2Closed()
        {
            var route          = new Optimization.Tours.Tour(new int[] { 0, 1, 2, 3, 4 }, 0);
            var pairEnumerable = new PairEnumerable <Tour>(route, route.IsClosed());
            var pairs          = new List <Pair>(pairEnumerable);

            Assert.AreEqual(5, pairs.Count);
            Assert.Contains(new Pair(0, 1), pairs);
            Assert.Contains(new Pair(1, 2), pairs);
            Assert.Contains(new Pair(2, 3), pairs);
            Assert.Contains(new Pair(3, 4), pairs);
            Assert.Contains(new Pair(4, 0), pairs);

            pairEnumerable = new PairEnumerable <Tour>(route, route.IsClosed(), 0);
            pairs          = new List <Pair>(pairEnumerable);

            Assert.AreEqual(5, pairs.Count);
            Assert.Contains(new Pair(0, 1), pairs);
            Assert.Contains(new Pair(1, 2), pairs);
            Assert.Contains(new Pair(2, 3), pairs);
            Assert.Contains(new Pair(3, 4), pairs);
            Assert.Contains(new Pair(4, 0), pairs);

            pairEnumerable = new PairEnumerable <Tour>(route, route.IsClosed(), 1);
            pairs          = new List <Pair>(pairEnumerable);

            Assert.AreEqual(4, pairs.Count);
            Assert.Contains(new Pair(1, 2), pairs);
            Assert.Contains(new Pair(2, 3), pairs);
            Assert.Contains(new Pair(3, 4), pairs);
            Assert.Contains(new Pair(4, 0), pairs);

            pairEnumerable = new PairEnumerable <Tour>(route, route.IsClosed(), 2);
            pairs          = new List <Pair>(pairEnumerable);

            Assert.AreEqual(3, pairs.Count);
            Assert.Contains(new Pair(2, 3), pairs);
            Assert.Contains(new Pair(3, 4), pairs);
            Assert.Contains(new Pair(4, 0), pairs);

            pairEnumerable = new PairEnumerable <Tour>(route, route.IsClosed(), 3);
            pairs          = new List <Pair>(pairEnumerable);

            Assert.AreEqual(2, pairs.Count);
            Assert.Contains(new Pair(3, 4), pairs);
            Assert.Contains(new Pair(4, 0), pairs);

            pairEnumerable = new PairEnumerable <Tour>(route, route.IsClosed(), 4);
            pairs          = new List <Pair>(pairEnumerable);

            Assert.AreEqual(1, pairs.Count);
            Assert.Contains(new Pair(4, 0), pairs);
        }