Exemple #1
0
        private static void Main(string[] args)
        {
            ReadExecutionParams(args);
            Board      board    = DataReader.ReadBoard(_boardFileName);
            SolverBase solver   = InitSolver(board);
            Node       solution = solver.Solve();

            SaveSolutionData(solution);
        }
Exemple #2
0
        public static void Solve(SolverBase <ITSPTW, ITSPTWObjective, IRoute> solver, ITSPTW problem, TSPTWObjectiveBase objective)
        {
            var info = new PerformanceInfoConsumer("solver");

            info.Start();

            var fitness = 0.0;
            var route   = solver.Solve(problem, objective, out fitness);

            info.Stop();

            OsmSharp.Logging.Log.TraceEvent("Program.Solve", Logging.TraceEventType.Information,
                                            string.Format("Finished with {0}", fitness));
        }
Exemple #3
0
 /// <summary>
 /// Solves this problem using the given solver.
 /// </summary>
 public Tour Solve(SolverBase <float, STSProblem, STSPObjective, Tour, STSPFitness> solver)
 {
     return(solver.Solve(this, new STSPObjective()));
 }
Exemple #4
0
        protected void Run(bool doubleSolve = false)
        {
            var errorSb            = new StringBuilder();
            var errorLevels        = new List <string>();
            var inconclusiveLevels = new List <string>();
            var inconclusiveSb     = new StringBuilder();

            foreach (var level in Levels)
            {
                GridHelpers.ResetCache();
                var levelName   = level.Identifier;
                var initializer = level.Initializer;
                var step        = Step.Setup;
                try {
                    Setup(initializer);
                    step = Step.ManualSetup;
                    if (ManualSetup != null)
                    {
                        ManualSetup();
                    }
                    step = Step.Solve;
                    Solver.Solve();
                    if (doubleSolve)
                    {
                        Solver.Solve();
                    }
                    step = Step.Assert;
                    AssertMatrix();
                } catch (Exception ex) {
                    if (ex.Message.Contains("Invalid color!"))
                    {
                        inconclusiveLevels.Add(levelName);
                        AppendLog(inconclusiveSb, ex, step, level);
                    }
                    else
                    {
                        errorLevels.Add(levelName);
                        AppendLog(errorSb, ex, step, level);
                    }
                }
            }
            var totalOutput = Environment.NewLine;

            if (errorSb.Length != 0)
            {
                totalOutput += string.Format("Number of failing levels: {0}{1}", errorLevels.Count, Environment.NewLine);
                errorSb.AppendLine(HorizontalSplitter);
            }
            if (inconclusiveSb.Length != 0)
            {
                totalOutput += string.Format("Number of inconclusive levels: {0}{1}", inconclusiveLevels.Count, Environment.NewLine);
                inconclusiveSb.AppendLine(HorizontalSplitter);
            }
            totalOutput += HorizontalSplitter + errorSb + inconclusiveSb;
            if (errorLevels.Any())
            {
                Assert.Fail(totalOutput);
            }
            if (inconclusiveLevels.Any())
            {
                Assert.Inconclusive(totalOutput);
            }
        }