Exemple #1
0
        public static BenchmarkResult <TK, TD> BenchmarkFirstOnly <TK, TD>(
            CspSolver <TK, TD> cspSolver, CspProblem <TK, TD> problem)
        {
            var stopWatch = new Stopwatch();

            problem.ClearAll();

            stopWatch.Start();
            var first = cspSolver.FindSolutions(problem).First();

            stopWatch.Stop();

            var firstNodesVisited = cspSolver.NodesVisited;
            var firstSolutionTime = stopWatch.ElapsedMilliseconds;

            problem.ClearAll();

            return(new BenchmarkResult <TK, TD>(
                       firstSolutionTime,
                       firstNodesVisited,
                       null,
                       null,
                       null,
                       first));
        }
Exemple #2
0
        public async Task StartAsync()
        {
            int k = await FileBoundary.GetKAsync();

            int[,] visibility = await FileBoundary.ReadVisibilityMatrixAsync();

            int[,] communications = await FileBoundary.ReadCommunicationsMatrixAsync();

            var solver = new CspSolver(k, visibility, communications);
            var result = solver.Solve();
            await FileBoundary.WriteBackResultAsync(result);
        }
Exemple #3
0
        public static BenchmarkResult <TK, TD> BenchmarkAll <TK, TD>(
            CspSolver <TK, TD> cspSolver, CspProblem <TK, TD> problem)
        {
            var stopWatch = new Stopwatch();

            problem.ClearAll();

            stopWatch.Restart();
            _ = cspSolver.FindSolutions(problem).Last();
            stopWatch.Stop();

            problem.ClearAll();

            return(new BenchmarkResult <TK, TD>(
                       null,
                       null,
                       stopWatch.ElapsedMilliseconds,
                       cspSolver.NodesVisited,
                       cspSolver.SolutionCount,
                       null));
        }