コード例 #1
0
ファイル: FormulaTest.cs プロジェクト: Wilbertz/Millenium
        public void Test_0002_SubstituteAsFalse()
        {
            IEnumerable<IClause> clauses = new []
            {
                new Clause(new [] { 2, 3, 6 }, new [] { 1, 4 }),
                new Clause(new [] { 1, 5, 6 }, new [] { 2, 3, 7 })
            };

            Formula target = new Formula(clauses);
            int variable = 1;
            target.SubstituteAsFalse(variable);
        }
コード例 #2
0
        public void Test_0001_DPLLAlgorithmConstructor()
        {
            IEnumerable<IClause> clauses = new []
            {
                new Clause(new [] { 2, 3, 6 }, new [] { 1, 4 }),
                new Clause(new [] { 1, 5, 6 }, new [] { 2, 3, 7 })
            };
            Formula formula = new Formula(clauses);
            Assert.IsNotNull(formula);

            DpllAlgorithm algorithm = new DpllAlgorithm(formula);
            Assert.IsNotNull(algorithm);
        }
コード例 #3
0
        public void Test_0002_DPLLAlgorithmSolve()
        {
            IEnumerable<IClause> clauses = new []
            {
                new Clause(new [] { 2, 3, 6 }, new [] { 1, 4 }),
                new Clause(new [] { 1, 5, 6 }, new [] { 2, 3, 7 })
            };
            Formula formula = new Formula(clauses);
            Assert.IsNotNull(formula);

            DpllAlgorithm algorithm = new DpllAlgorithm(formula);
            Assert.IsNotNull(algorithm);

            Dictionary<int, bool> solution = new Dictionary<int, bool>(algorithm.Solve());
            Assert.IsNotNull(solution);
        }
コード例 #4
0
ファイル: FormulaTest.cs プロジェクト: Wilbertz/Millenium
        public void Test_0001_FormulaConstructor()
        {
            IEnumerable<IClause> clauses = new []
            {
                new Clause(new [] { 2, 3, 6 }, new [] { 1, 4 }),
                new Clause(new [] { 1, 5, 6 }, new [] { 2, 3, 7 })
            };
            Formula target = new Formula(clauses);
            Assert.IsNotNull(target);

            HashSet<int> variables = new HashSet<int>(target.Variables);
            Assert.IsTrue(variables.Contains(1), "Could not get variable 1");
            Assert.IsTrue(variables.Contains(2), "Could not get variable 2");
            Assert.IsTrue(variables.Contains(3), "Could not get variable 3");
            Assert.IsTrue(variables.Contains(4), "Could not get variable 4");
            Assert.IsTrue(variables.Contains(5), "Could not get variable 5");
            Assert.IsTrue(variables.Contains(6), "Could not get variable 6");
            Assert.IsTrue(variables.Contains(7), "Could not get variable 7");
            Assert.IsFalse(variables.Contains(8), "Could get variable 8");

            Assert.IsTrue(variables.Count == 7);

            Assert.IsFalse(target.IsUnsat);
        }
コード例 #5
0
ファイル: FormulaTest.cs プロジェクト: Wilbertz/Millenium
        public void Test_0004_Clone()
        {
            IEnumerable<IClause> clauses = new []
            {
                new Clause(new [] { 2, 3, 6 }, new [] { 1, 4 }),
                new Clause(new [] { 1, 5, 6 }, new [] { 2, 3, 7 })
            };

            Formula target = new Formula(clauses);

            Formula clone = target.Clone() as Formula;
            Assert.IsNotNull(clone);
        }