Ejemplo n.º 1
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
        }
Ejemplo n.º 2
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
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public void AnyMatch()
        {
            AtomMatcher matcher = AtomMatcher.CreateAnyMatcher();
            var         m_atom1 = new Mock <IAtom>();
            var         m_atom2 = new Mock <IAtom>();
            var         m_atom3 = new Mock <IAtom>();

            m_atom1.SetupGet(n => n.AtomicNumber).Returns(6);
            m_atom2.SetupGet(n => n.AtomicNumber).Returns(7);
            m_atom3.SetupGet(n => n.AtomicNumber).Returns(8);
            Assert.IsTrue(matcher.Matches(m_atom1.Object, m_atom2.Object));
            Assert.IsTrue(matcher.Matches(m_atom2.Object, m_atom1.Object));
            Assert.IsTrue(matcher.Matches(m_atom1.Object, m_atom3.Object));
            Assert.IsTrue(matcher.Matches(m_atom3.Object, m_atom1.Object));
            Assert.IsTrue(matcher.Matches(m_atom2.Object, m_atom3.Object));
            Assert.IsTrue(matcher.Matches(m_atom1.Object, null));
            Assert.IsTrue(matcher.Matches(null, null));
        }
Ejemplo n.º 5
0
        public void InfeasibleBonds()
        {
            var m = new Mock <BondMatcher>(); BondMatcher mock = m.Object;

            m.Setup(n => n.Matches(It.IsAny <IBond>(), It.IsAny <IBond>())).Returns(false);
            VFSubState state = CreateBenzeneToNaphthalene(AtomMatcher.CreateAnyMatcher(), mock);

            state.m1[0] = 0;
            state.m1[1] = 1;
            state.m1[2] = 2;
            state.m1[3] = 3;
            state.m1[4] = 4;
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    Assert.IsFalse(state.Feasible(i, j));
                }
            }
        }
Ejemplo n.º 6
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()));
        }