private bool checkPossible(int day) { for (int t = 0; t < teachers.Count; t++) { int demand = 0; for (int g = 0; g < dayState[1].groups.Count; g++) { demand += dayState[1].groups[g].subject2Teacher.Where(tup => (!(tup.Item2 is null)) && tup.Item2.Equals(teachers[t]) == true) .Sum(x => dayState[1].groups[g].getSubjectWeekLim(dayState[1].groups[g].findSubject(x.Item1))); } for (int d = day; d <= workDays; d++) { demand -= dayState[d].teacherLeftLessons[t]; } if (demand > 0) { return(false); } } System.Console.WriteLine("do tuka"); for (int g = 0; g < dayState[1].groups.Count; g++) { for (int s = 0; s < dayState[1].groups[g].subject2Teacher.Count; s++) { if (dayState[1].groups[g].subject2Teacher[s].Item2 is null) { continue; } int tInd = groupSubject2Teacher[g, s]; int demand = dayState[1].groups[g].getSubjectWeekLim(s); for (int d = day; d <= workDays; d++) { IEnumerable <Multilesson> important = multilessons[d].Where(m => m.g.Equals(groups[g]) == true && m.s.Equals(dayState[1].groups[g].subject2Teacher[s].Item1) == true); int rm = 0; if (important.Any() == false) { rm = Math.Min(dayState[d].groups[g].getDayBottleneck(s), dayState[d].teacherLeftLessons[tInd]); rm = Math.Min(rm, dayState[d].groupLeftLessons[g]); } else { rm = important.Sum(m => m.val.r); } demand -= rm; } if (demand > 0) { System.Console.WriteLine("nqma da mozhem da gi vzemem"); return(false); } } for (int s = 0; s < dayState[1].groups[g].subject2Teacher.Count; s++) { int demand = dayState[1].groups[g].getSubjectWeekLim(s); for (int d = day; d <= workDays; d++) { demand -= multilessons[d].Where(m => m.g.Equals(groups[g]) == true && m.s.Equals(groups[g].subject2Teacher[s]) == true).Sum(m => m.val.l); } if (demand < 0) { System.Console.WriteLine("oldqhte se"); return(false); } } } for (int g = 0; g < groups.Count; g++) { bool fail = false; void dfs(TreeNode x) { if (x.GetType() == typeof(SubjectTreeNode)) { return; } LimitationGroup lg = (x as LimitationTreeNode).lg; if (!(lg is null)) { int demand = dayState[1].groups[g].subject2Teacher.Where(tup => tup.Item1.limGroups.Any(x => x.Equals(lg) == true) == true) .Sum(tup => dayState[1].groups[g].getSubjectWeekLim(dayState[1].groups[g].findSubject(tup.Item1))); for (int d = day; d <= workDays; d++) { IEnumerable <Multilesson> important = multilessons[d].Where(m => m.g.Equals(groups[g]) == true && m.s.limGroups.Contains((x as LimitationTreeNode).lg) == true); int rm = 0; if (important.Any() == false) { rm = Math.Min(dayState[d].groups[g].getLimGroupDayLim((x as LimitationTreeNode).lg), dayState[d].groupLeftLessons[g]); } else { rm = important.Sum(m => m.val.r); } demand -= rm; } if (demand > 0) { fail = true; } } foreach (TreeNode y in x.children) { dfs(y); } } dfs(higharchy); if (fail == true) { return(false); } } for (int g = 0; g < groups.Count; g++) { int lessonsLeft = dayState[1].groups[g].subject2Teacher.Sum(tup => dayState[1].groups[g].getSubjectWeekLim(dayState[1].groups[g].findSubject(tup.Item1))); for (int d = day; d <= workDays; d++) { lessonsLeft += dayState[d].groups[g].curriculum.Count; } if (!((workDays - day + 1) * minLessons <= lessonsLeft && lessonsLeft <= (workDays - day + 1) * maxLessons)) { return(false); } } return(true); }
public LimitationTreeNode(string name, LimitationGroup lg) : this() { this.name = name; this.lg = lg; }
public LimitationTreeNode(LimitationTreeNode other) : base(other) { this.lg = other.lg; }
public LimitationTreeNode(LimitationGroup lg) : this() { this.name = lg.name; this.lg = lg; }