Exemplo n.º 1
0
        public void Next()
        {
            var state = CreateBenzeneToNaphthalene(AtomMatcher.CreateAnyMatcher(), BondMatcher.CreateAnyMatcher());
            var it    = new StateStream(state).GetEnumerator();

            it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 0, 1, 2, 7, 8, 9 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 0, 9, 8, 7, 2, 1 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 1, 0, 9, 8, 7, 2 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 1, 2, 7, 8, 9, 0 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 2, 1, 0, 9, 8, 7 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 2, 3, 4, 5, 6, 7 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 2, 7, 6, 5, 4, 3 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 2, 7, 8, 9, 0, 1 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 3, 2, 7, 6, 5, 4 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 3, 4, 5, 6, 7, 2 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 4, 3, 2, 7, 6, 5 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 4, 5, 6, 7, 2, 3 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 5, 4, 3, 2, 7, 6 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 5, 6, 7, 2, 3, 4 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 6, 5, 4, 3, 2, 7 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 6, 7, 2, 3, 4, 5 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 7, 2, 1, 0, 9, 8 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 7, 2, 3, 4, 5, 6 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 7, 6, 5, 4, 3, 2 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 7, 8, 9, 0, 1, 2 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 8, 7, 2, 1, 0, 9 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 8, 9, 0, 1, 2, 7 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 9, 0, 1, 2, 7, 8 }, it.Current)); it.MoveNext();
            Assert.IsTrue(Compares.AreDeepEqual(new int[] { 9, 8, 7, 2, 1, 0 }, it.Current)); it.MoveNext();
        }
Exemplo n.º 2
0
        public void HasNext()
        {
            var state = CreateNaphthaleneToBenzene(AtomMatcher.CreateAnyMatcher(), BondMatcher.CreateAnyMatcher());
            var it    = new StateStream(state);

            Assert.IsFalse(it.Any());
        }
Exemplo n.º 3
0
        public void AnyMatch()
        {
            BondMatcher matcher = BondMatcher.CreateAnyMatcher();
            IBond       bond1   = new Mock <IBond>().Object;
            IBond       bond2   = new Mock <IBond>().Object;
            IBond       bond3   = new Mock <IBond>().Object;

            Assert.IsTrue(matcher.Matches(bond1, bond2));
            Assert.IsTrue(matcher.Matches(bond2, bond1));
            Assert.IsTrue(matcher.Matches(bond1, bond3));
            Assert.IsTrue(matcher.Matches(bond1, null));
            Assert.IsTrue(matcher.Matches(null, null));
        }
Exemplo n.º 4
0
        public void HasNext2()
        {
            var state = CreateBenzeneToNaphthalene(AtomMatcher.CreateAnyMatcher(), BondMatcher.CreateAnyMatcher());
            int cnt   = 0;
            var it    = new StateStream(state);

            foreach (var i in it)
            {
                Assert.IsNotNull(i);
                cnt++;
            }
            Assert.AreEqual(24, cnt);
        }
Exemplo n.º 5
0
        public void Add()
        {
            UllmannState state = CreateBenzeneToNaphthalene(AtomMatcher.CreateAnyMatcher(), BondMatcher.CreateAnyMatcher());

            Assert.IsTrue(Compares.AreDeepEqual(
                              new int[][] {
                new[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                new[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                new[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                new[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                new[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                new[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
            },
                              state.matrix.Fix()
                              ));
            Assert.IsTrue(state.Add(0, 0));
            Assert.IsTrue(Compares.AreDeepEqual(
                              new int[][] {
                new[] { 1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
                new[] { -1, 1, -1, -1, -1, -1, -1, -1, -1, 1 },
                new[] { 1, -1, 1, -1, -1, -1, -1, -1, 1, -1 },
                new[] { -1, 1, -1, 1, -1, -1, -1, 1, -1, 1 },
                new[] { 1, -1, 1, -1, -1, -1, -1, -1, 1, -1 },
                new[] { -1, 1, -1, -1, -1, -1, -1, -1, -1, 1 }
            },
                              state.matrix.Fix()));
            Assert.IsTrue(state.Add(1, 9));
            Assert.IsTrue(Compares.AreDeepEqual(
                              new int[][] {
                new[] { 1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
                new[] { -1, -2, -1, -1, -1, -1, -1, -1, -1, 1 },
                new[] { 1, -1, -2, -1, -1, -1, -1, -1, 1, -1 },
                new[] { -1, 1, -1, -2, -1, -1, -1, 1, -1, 1 },
                new[] { 1, -1, 1, -1, -1, -1, -1, -1, 1, -1 },
                new[] { -1, 1, -1, -1, -1, -1, -1, -1, -1, 1 }
            },
                              state.matrix.Fix()));
            Assert.IsTrue(state.Add(2, 8));
            Assert.IsTrue(Compares.AreDeepEqual(
                              new int[][] {
                new[] { 1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
                new[] { -1, -2, -1, -1, -1, -1, -1, -1, -1, 1 },
                new[] { -3, -1, -2, -1, -1, -1, -1, -1, 1, -1 },
                new[] { -1, -3, -1, -2, -1, -1, -1, 1, -1, 1 },
                new[] { 1, -1, 1, -1, -1, -1, -1, -1, 1, -1 },
                new[] { -1, 1, -1, -1, -1, -1, -1, -1, -1, 1 }
            },
                              state.matrix.Fix()));
            Assert.IsTrue(state.Add(3, 7));
            Assert.IsTrue(Compares.AreDeepEqual(
                              new int[][] {
                new[] { 1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
                new[] { -1, -2, -1, -1, -1, -1, -1, -1, -1, 1 },
                new[] { -3, -1, -2, -1, -1, -1, -1, -1, 1, -1 },
                new[] { -1, -3, -1, -2, -1, -1, -1, 1, -1, -4 },
                new[] { -4, -1, 1, -1, -1, -1, -1, -1, 1, -1 },
                new[] { -1, 1, -1, -1, -1, -1, -1, -1, -1, 1 }
            },
                              state.matrix.Fix()));
            Assert.IsTrue(state.Add(4, 2));
            Assert.IsTrue(Compares.AreDeepEqual(
                              new int[][] {
                new[]  { 1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
                new[] { -1, -2, -1, -1, -1, -1, -1, -1, -1, 1 },
                new[] { -3, -1, -2, -1, -1, -1, -1, -1, 1, -1 },
                new[] { -1, -3, -1, -2, -1, -1, -1, 1, -1, -4 },
                new[] { -4, -1, 1, -1, -1, -1, -1, -1, -5, -1 },
                new[] { -1, 1, -1, -1, -1, -1, -1, -1, -1, -5 }
            },
                              state.matrix.Fix()));
            Assert.IsTrue(state.Add(5, 1));
            Assert.IsTrue(Compares.AreDeepEqual(
                              new int[][] {
                new[] { 1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
                new[] { -1, -2, -1, -1, -1, -1, -1, -1, -1, 1 },
                new[] { -3, -1, -2, -1, -1, -1, -1, -1, 1, -1 },
                new[] { -1, -3, -1, -2, -1, -1, -1, 1, -1, -4 },
                new[] { -4, -1, 1, -1, -1, -1, -1, -1, -5, -1 },
                new[] { -1, 1, -1, -1, -1, -1, -1, -1, -1, -5 }
            },
                              state.matrix.Fix()));
        }
Exemplo n.º 6
0
        public void TestNextM()
        {
            UllmannState state = CreateBenzeneToNaphthalene(AtomMatcher.CreateAnyMatcher(), BondMatcher.CreateAnyMatcher());

            Assert.AreEqual(state.NextM(0, -1), 0);
            Assert.AreEqual(state.NextM(0, 0), 1);
            Assert.AreEqual(state.NextM(0, 1), 2);
            state.m2[1] = 0; // 1 has been mapped and should be skipped over
            Assert.AreEqual(state.NextM(0, 0), 2);
        }
Exemplo n.º 7
0
        public void TestNextN()
        {
            UllmannState state = CreateBenzeneToNaphthalene(AtomMatcher.CreateAnyMatcher(), BondMatcher.CreateAnyMatcher());

            Assert.AreEqual(state.NextN(0), 0);
            state.size = 1;
            Assert.AreEqual(state.NextN(0), 1);
            state.size = 2;
            Assert.AreEqual(state.NextN(0), 2);
        }
Exemplo n.º 8
0
        public void Accessors()
        {
            UllmannState state = CreateBenzeneToNaphthalene(AtomMatcher.CreateAnyMatcher(), BondMatcher.CreateAnyMatcher());

            state.size = 1;
            Assert.AreEqual(state.Count, 1);
            Assert.AreEqual(state.NMax(), state.g1.Length);
            Assert.AreEqual(state.MMax(), state.g2.Length);
        }
Exemplo n.º 9
0
        public void Mapping()
        {
            UllmannState state = CreateBenzeneToNaphthalene(AtomMatcher.CreateAnyMatcher(), BondMatcher.CreateAnyMatcher());

            state.m1[0] = 1;
            state.m1[1] = 2;
            Assert.IsTrue(Compares.AreDeepEqual(state.m1, state.Mapping()));
            Assert.AreNotSame(state.m1, state.Mapping());
        }
Exemplo n.º 10
0
        public void InfeasibleRemainCount()
        {
            VFSubState state = CreateBenzeneToNaphthalene(AtomMatcher.CreateAnyMatcher(), BondMatcher.CreateAnyMatcher());

            Assert.IsTrue(state.Feasible(0, 0)); // 0,0 is feasible
                                                 // XXX: depends on molecule order not changing
            state.m1[1] = 1;
            state.m1[5] = 5;
            state.t2[1] = 1;
            state.t2[9] = 1;
            Assert.IsFalse(state.Feasible(0, 0)); // 0,0 is infeasible
        }
Exemplo n.º 11
0
        public void InfeasibleTerminalCount()
        {
            VFState state = CreateBenzeneToNaphthalene(AtomMatcher.CreateAnyMatcher(), BondMatcher.CreateAnyMatcher());

            Assert.IsTrue(state.Feasible(4, 4)); // 4, 4 is feasible
            state.Add(0, 0);
            state.Add(1, 1);
            state.Add(2, 2);
            state.Add(3, 3);
            Assert.IsFalse(state.Feasible(4, 4)); // 4, 4 is infeasible
        }