示例#1
0
 public DefaultSolver(Solver.Config cfg)
 {
     config = cfg;
     random = new Random();
     mutation = new Mutation(config.mutationChance);
     crossover = new Crossover(config.singleFeatureCrossoverChance, config.crossoverChance, random);
 }
示例#2
0
        static Result Benchmark(Solver solver,
                                Problem problem,
                                int numIterations)
        {
            List<Result.RunResult> results = new List<Result.RunResult>();

            for (int i = 0; i < numIterations; ++i)
            {
                Console.Error.Write(string.Format("{0}/{1}", i + 1, numIterations));

                Stopwatch watch = new Stopwatch();
                watch.Start();
                Solution solution = solver.Solve(problem);
                watch.Stop();

                Console.Error.WriteLine(string.Format(" {0}s, {1}", watch.Elapsed.TotalSeconds, solution.Value));

                Result.RunResult result = new Result.RunResult(solution.Value, watch.Elapsed.TotalSeconds);
                results.Add(result);
            }

            return new Result(results);
        }
示例#3
0
 public SimpleSolver(Solver.Config cfg)
 {
     config = cfg;
     random = new Random();
 }