Ejemplo n.º 1
0
        private void PrintStats()
        {
            foreach (var algoList in _schedulareStatisticsList)
            {
                var algName = algoList.Key;

                CommonLogic.ApeandToFile(algName);

                CommonLogic.ApeandToFile($"Satisfaction Avarage = {algoList.Value.SatisfactionAvarage}");

                var satStdDev = Math.Round(algoList.Value.SchedulareSatisfactionList.Select(x => x.Satisfaction).StdDev(), 3);

                CommonLogic.ApeandToFile($"Satisfaction standard deviation = {satStdDev}");

                CommonLogic.ApeandToFile($"Weight Avarage = {algoList.Value.WeightAvarage}");

                var weightStdDev = Math.Round(algoList.Value.SchedulareSatisfactionList.Select(x => x.Weight).StdDev(), 3);

                CommonLogic.ApeandToFile($"Weight standard deviation = {weightStdDev}");

                CommonLogic.ApeandToFile($"Execute Time Avarage = {algoList.Value.ExecuteTimeAvarage}");

                CommonLogic.ApeandToFile($"Most Unfortunate Worker Avarage = { Math.Round(algoList.Value.MostUnfortunateWorkerPerAvarage, 3 )}%");
            }

            CommonLogic.ApeandToFile(string.Empty);
        }
Ejemplo n.º 2
0
        private void PrintOnStartInfo(int executionAmount)
        {
            var algoRunInSeconds = _factory.GetAll().FirstOrDefault().Value.ALGORITHM_RUN_TIME_SECONDS;

            CommonLogic.ApeandToFile($"EXECUTION_AMOUNT - {executionAmount}");
            CommonLogic.ApeandToFile($"ALGORITHM_RUN_TIME_SECONDS - {algoRunInSeconds}");
            Console.WriteLine($"EXECUTION_AMOUNT - {executionAmount}");
            Console.WriteLine($"ALGORITHM_RUN_TIME_SECONDS - {algoRunInSeconds}");
        }
Ejemplo n.º 3
0
        protected int UnwantedShift(Schedulare schedulare, ShiftsContainer shiftsContainer, ref int weight)
        {
            try
            {
                foreach (var employee in shiftsContainer.EmployeeConstraints)
                {
                    var currEmpConstraints = employee.WeeklyConstraints.Where(x => !x.Value.ContainsContent("Free day")).ToList();

                    foreach (var day in schedulare.Days)
                    {
                        foreach (var shift in day.Shifts)
                        {
                            if (!shift.Workers.Any(x => x.Name.CompareContent(employee.Name)))
                            {
                                continue;
                            }

                            var constraintDay = currEmpConstraints.FirstOrDefault(x => x.Key.CompareContent(day.Name));

                            if (constraintDay.Key == null)
                            {
                                continue;
                            }

                            // if the employee asked for this shift skip
                            if (constraintDay.Value.CompareContent(shift.Name))
                            {
                                continue;
                            }

                            weight += _unwantedShift;
                        }
                    }
                }

                return(weight);
            }
            catch (Exception e)
            {
                CommonLogic.ApeandToFile(e.ToString());
            }
            return(default);
Ejemplo n.º 4
0
        private void PrintDebugData(ShiftsContainer shiftsContainer, SchedulareState state, string algoName)
        {
            Console.WriteLine(algoName);
            double percentageOfSatisfaction = CommonLogic.GetPercentageOfSatisfaction(state.Node.Value, shiftsContainer);

            Console.WriteLine($"Weight = {state.Weight}");
            Console.WriteLine($"Satisfaction = {percentageOfSatisfaction}");
            state.MostUnfortunateWorkerPer = CommonLogic.LocateAndPrintMostUnfortunateWorker(state.Node.Value, shiftsContainer);
            CommonLogic.PrintSchedulare(state.Node.Value, shiftsContainer);

            CommonLogic.ApeandToFile(algoName, FILENAME);
            CommonLogic.ApeandToFile($"Weight = {state.Weight}", FILENAME);
            CommonLogic.ApeandToFile($"Satisfaction = {percentageOfSatisfaction}", FILENAME);
            string schedulareStateJson = JsonConvert.SerializeObject(state.Node.Value);

            CommonLogic.ApeandToFile(schedulareStateJson, FILENAME);
            string shiftsContainerJson = JsonConvert.SerializeObject(shiftsContainer);

            CommonLogic.ApeandToFile(shiftsContainerJson, FILENAME);
        }