예제 #1
0
        public void TestAll(int size, string ops, int expectedCount)
        {
            var       force = new BinaryBruteForcerOld(ops.Split(' '));
            Stopwatch sw    = Stopwatch.StartNew();
            var       all   = force.Enumerate(size);

            Console.WriteLine("new calculated, size = {0}", all.Count());
            //Assert.AreEqual(expectedCount, all.Count());
            Console.WriteLine(sw.Elapsed);

            //            Console.WriteLine("All:");
            //            foreach (var ar in all)
            //                Console.WriteLine(ar.Printable());

            var force2 = new BinaryBruteForcer(ops.Split(' '));
            var all2   = force2.Enumerate(size);

            Console.WriteLine("new optim calculated, size = {0}", all2.Count());

            var setOfAll = new HashSet <string>(all2.Select(t => t.Printable()));
            var diff     = all.Where(t => !setOfAll.Contains(t.Printable()));

            foreach (var ar in diff.Take(50))
            {
                Console.WriteLine(ar.Printable());
            }
        }
예제 #2
0
 public void TestIncludeBin(int size)
 {
     Console.WriteLine("size = {0}", size);
     foreach (var problem in GetAllSamples().Where(p => p.Size == size))
     {
         Console.WriteLine("problem #{0}", problem.Id);
         var bruter    = new BinaryBruteForcer(problem.AllOperators);
         var solutions = new HashSet <string>(bruter.Enumerate(size - 1).Select(expr => expr.Printable()));
         if (!solutions.Contains(Parser.ParseFunction(problem.SolutionString).Printable()))
         {
             Console.WriteLine("op: {0}, ", string.Join(", ", problem.AllOperators));
             Console.WriteLine(string.Join("\t", solutions));
             Assert.Fail();
         }
     }
 }