static void Main(string[] args) { var employees = FileHandling.readEmployees(); var allPossibleRosters = new SingleDay(employees.Count); var lengthOfTheMonth = 31; employees = SingleDay.CreateRoster(lengthOfTheMonth, allPossibleRosters, employees); FileHandling.WriteToFile(employees, lengthOfTheMonth); }
static public List <Employee> CreateRoster(int lengthOfTheMonth, SingleDay allPossibleRosters, List <Employee> employees) { var result = employees; for (int i = 9; i <= lengthOfTheMonth + 8; i++) { Console.WriteLine(i); var numberOfAllPossibleSolutions = allPossibleRosters.OneDay.Count; var bestSolution = new List <int>(); var valueOfBestSolution = -100000000; for (int j = 0; j < numberOfAllPossibleSolutions; j++) { for (int k = 0; k < result.Count; k++) { if (result[k].Shifts.ContainsKey(i) && result[k].Shifts[i] != 3) { result[k].Shifts.Remove(i); } if (!result[k].Shifts.ContainsKey(i)) { result[k].Shifts.Add(i, allPossibleRosters.OneDay[j][k]); } } var valueOfCheckedSolution = SingleDay.CheckADay(result, i); if (valueOfCheckedSolution > valueOfBestSolution) { valueOfBestSolution = valueOfCheckedSolution; bestSolution = allPossibleRosters.OneDay[j]; } } Console.WriteLine(valueOfBestSolution); for (int k = 0; k < result.Count; k++) { if (result[k].Shifts.ContainsKey(i) && result[k].Shifts[i] != 3) { result[k].Shifts.Remove(i); } if (result[k].Shifts.ContainsKey(i) && result[k].Shifts[i] == 3) { result[k].NumberOfHPs++; } if (!result[k].Shifts.ContainsKey(i)) { result[k].Shifts.Add(i, bestSolution[k]); if (bestSolution[k] == 0) { result[k].NumberOfDayshifts++; } if (bestSolution[k] == 1) { result[k].NumberOfNightshifts++; } if (bestSolution[k] == 2) { result[k].NumberOfOFFs++; } } } } return(result); }