コード例 #1
0
        private static AlgorithmResult RunSchedulerAlgorithm(int?instanceNumber = null, bool copyToClipboard = true)
        {
            var dto = SchedulingBenchmarkInstanceReader.FromXml(instanceNumber ?? InstanceNumber);
            var schedulingBenchmarkModel = DtoToSchedulingBenchmarkModelMapper.MapToSchedulingBenchmarkModel(dto);
            var sw = new Stopwatch();

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            sw.Start();
            var result = SchedulerAlgorithmRunner.Run(schedulingBenchmarkModel);

            sw.Stop();

            if (copyToClipboard)
            {
                Clipboard.Copy(result.ToRosterViewerFormat());
            }

            var(feasible, messages) = FeasibilityEvaluator.Evaluate(result);

            messages.Sort();

            return(new AlgorithmResult
            {
                Name = "Scheduler Algorithm Solution",
                Result = result,
                Penalty = OptimalityEvaluator.CalculatePenalty(result),
                Feasible = feasible,
                FeasibilityMessages = messages,
                Duration = sw.Elapsed
            });
        }
コード例 #2
0
        public ExpectedTestResultsGenerator(int instanceNumber)
        {
            var dto = SchedulingBenchmarkInstanceReader.FromXml(instanceNumber);
            var schedulingBenchmarkModel = DtoToSchedulingBenchmarkModelMapper.MapToSchedulingBenchmarkModel(dto);

            _result               = SchedulerAlgorithmRunner.Run(schedulingBenchmarkModel);
            _aggregates           = EvaluationDataAggregator.GetAggregate(_result).ToDictionary(a => a.EmployeeId);
            _feasibilityEvaluator = new FeasibilityEvaluator(_result);
        }
コード例 #3
0
        public static void RunPerf()
        {
            var dto          = SchedulingBenchmarkInstanceReader.FromXml(InstanceNumber);
            var runCount     = 0;
            var totalRunTime = TimeSpan.Zero;
            var totalGc0     = 0;
            var totalGc1     = 0;
            var totalGc2     = 0;

            while (true)
            {
                runCount++;

                var schedulingBenchmarkModel = DtoToSchedulingBenchmarkModelMapper.MapToSchedulingBenchmarkModel(dto);
                var sw = new Stopwatch();

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                var gc0 = GC.CollectionCount(0);
                var gc1 = GC.CollectionCount(1);
                var gc2 = GC.CollectionCount(2);

                sw.Start();
                SchedulerAlgorithmRunner.Run(schedulingBenchmarkModel);
                sw.Stop();

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                totalGc0 += (GC.CollectionCount(0) - gc0);
                totalGc1 += (GC.CollectionCount(1) - gc1);
                totalGc2 += (GC.CollectionCount(2) - gc2);

                totalRunTime += sw.Elapsed;

                Thread.Sleep(300);
                Console.Clear();
                Console.WriteLine($"Average running time:\t{totalRunTime / runCount}");
                Console.WriteLine($"Average GC0 collects:\t{totalGc0 / runCount}");
                Console.WriteLine($"Average GC1 collects:\t{totalGc1 / runCount}");
                Console.WriteLine($"Average GC2 collects:\t{totalGc2 / runCount}");
            }
        }
コード例 #4
0
 public void IterationSetup()
 {
     _schedulingBenchmarkModel = DtoToSchedulingBenchmarkModelMapper.MapToSchedulingBenchmarkModel(_dto);
 }