Ejemplo n.º 1
0
        private static void ParseClause(string line, ref Formula form)
        {
            // if its not ending with 0, there is mistake in file
            var tmp = line.Split(" ");

            // check last 0
            if (int.Parse(tmp[tmp.Length - 1]) != 0)
            {
                return;
            }

            var literals = new List <Tuple <int, bool> >();

            // add clause
            for (var i = 0; i < tmp.Length - 1; i++)
            {
                var num   = int.Parse(tmp[i]);
                var neg   = num < 0;
                var index = Math.Abs(num);

                literals.Add(Tuple.Create(index, neg));
            }

            form.AddClause(literals);
        }