Exemplo n.º 1
0
        public TaskRunMeta Run(Problem problem, Solution solution)
        {
            var result = new TaskRunMeta
            {
                StartedAt  = DateTime.UtcNow,
                TaskName   = problem.Name,
                SolverName = solution.Name,
            };
            var timer = Stopwatch.StartNew();

            var solver = solution.Solver(problem);

            var commands = solver.Solve().ToArray();
            var state    = new DeluxeState(problem.SourceMatrix, problem.TargetMatrix);

            new Interpreter(state).Run(commands);

            result.SecondsSpent = (int)timer.Elapsed.TotalSeconds;
            result.EnergySpent  = state.Energy;
            result.Solution     = CommandSerializer.Save(commands).SerializeSolutionToString();
            result.IsSuccess    = true;
            return(result);
        }
 public Interpreter(DeluxeState state)
 {
     this.state = state;
 }