void savePlayerData(List <PlayerDetail> inputValues)
        {
            FormPlayerData formPlayerData = new FormPlayerData {
                Details = inputValues, Score = ScoreReporter.Report()
            };
            DataStoragePlayerData playerData = new DataStoragePlayerData(formPlayerData);

            _dataStorage.Save(playerData);
        }
Exemple #2
0
 private Action GenerateSolveTask(string pathIn, string pathOut, Func <ISolver> solverMaker, int seed)
 {
     return(() =>
     {
         try
         {
             string category = TotalStatsCategories.FirstOrDefault(c => pathOut.Contains(c));
             BulkSolverStats categoryStats = null;
             if (!string.IsNullOrEmpty(category))
             {
                 lock (_categorizedStats)
                 {
                     if (!_categorizedStats.TryGetValue(category, out categoryStats))
                     {
                         categoryStats = InitializeStats();
                         _categorizedStats[category] = categoryStats;
                     }
                 }
             }
             var reader = new InstanceJsonSerializer
             {
                 Path = pathIn,
             };
             Instance instance = reader.DeserializeInstance();
             var solver = solverMaker();
             solver.Seed = seed;
             solver.Instance = instance;
             if (StartingSolutionsDirectory != null)
             {
                 if (solver is InstanceSolvers.Solvers.Evolutionary evo)
                 {
                     evo.Population = LoadStartingSolutions(SolutionsDirectory, pathIn, instance, evo.PopulationCount, solver);
                     evo.PopulationCount = evo.Population.Count;
                 }
                 else
                 {
                     solver.Solution = LoadStartingSolutions(SolutionsDirectory, pathIn, instance, 1, solver)[0];
                 }
             }
             IReporter reporter = new NullReporter();
             if (ReportProgrssToFile)
             {
                 reporter = new ScoreReporter();
             }
             reporter.Start();
             solver.Reporter = reporter;
             solver.Solve();
             InstanceJsonSerializer serializer = new InstanceJsonSerializer()
             {
                 Path = pathOut,
             };
             serializer.SerializeSolution(solver.Solution, SolutionSerializationMode.DebugTaskData);
             reporter.Save(Path.Combine(new FileInfo(pathOut).Directory.FullName, $"{Path.GetFileNameWithoutExtension(new FileInfo(pathOut).Name)}Report.csv"));
             Console.WriteLine($"Solution {pathOut} was generated, completion {solver.Solution.CompletionScore}, loss {solver.Solution.WeightedLoss}, time {solver.Solution.TimeElapsed.ToString(@"hh\:mm\:ss")}.");
             AddSolutionToStats(_stats, solver);
             AddSolutionToStats(categoryStats, solver);
         }
         catch (FileLoadException e)
         {
             Console.WriteLine(e.Message);
             Console.WriteLine(e.StackTrace);
         }
         //GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
         GC.Collect();
         GC.WaitForPendingFinalizers();
         GC.Collect();
         GC.WaitForPendingFinalizers();
     });
 }