实验排课再次修正
This commit is contained in:
@@ -254,8 +254,15 @@ public sealed class AutomaticScheduleGenerator(AppDbContext db)
|
||||
x.TeachingTaskId == task.Id && x.DayOfWeek == day);
|
||||
var dayLoad = entries.Count(x => x.DayOfWeek == day);
|
||||
var roomWaste = room is null ? 0 : Math.Max(0, room.Capacity - task.Capacity);
|
||||
var experimentGeneralClassroomPenalty =
|
||||
kind == ScheduleEntryKind.Experiment &&
|
||||
constraint?.AllowedExperimentVenueNatures == 0 &&
|
||||
room?.TeachingVenueNature == TeachingVenueNature.GeneralClassroom
|
||||
? 100_000
|
||||
: 0;
|
||||
var score = sameTaskDay * 1000 + dayLoad * 10 + start +
|
||||
roomWaste / 10 + startWeek;
|
||||
roomWaste / 10 + startWeek +
|
||||
experimentGeneralClassroomPenalty;
|
||||
candidates.Add((proposed, score));
|
||||
}
|
||||
}
|
||||
@@ -290,11 +297,20 @@ public sealed class AutomaticScheduleGenerator(AppDbContext db)
|
||||
student.Status == StudentStatus.Active) ?? 0));
|
||||
return classrooms.Where(room =>
|
||||
room.Capacity >= minimumCapacity &&
|
||||
(constraint?.RequiredCampusId is not Guid requiredCampusId ||
|
||||
(kind == ScheduleEntryKind.Experiment ||
|
||||
constraint?.RequiredCampusId is not Guid requiredCampusId ||
|
||||
room.Building!.CampusId == requiredCampusId) &&
|
||||
(constraint?.RequiredBuildingId is not Guid requiredBuildingId ||
|
||||
(kind == ScheduleEntryKind.Experiment ||
|
||||
constraint?.RequiredBuildingId is not Guid requiredBuildingId ||
|
||||
room.BuildingId == requiredBuildingId) &&
|
||||
(allowedRoomIds.Count == 0 || allowedRoomIds.Contains(room.Id)) &&
|
||||
(kind != ScheduleEntryKind.Experiment ||
|
||||
constraint?.ExperimentRequiredCampusId is not Guid experimentCampusId ||
|
||||
room.Building!.CampusId == experimentCampusId) &&
|
||||
(kind != ScheduleEntryKind.Experiment ||
|
||||
constraint?.ExperimentRequiredBuildingId is not Guid experimentBuildingId ||
|
||||
room.BuildingId == experimentBuildingId) &&
|
||||
(kind == ScheduleEntryKind.Experiment ||
|
||||
allowedRoomIds.Count == 0 || allowedRoomIds.Contains(room.Id)) &&
|
||||
(kind != ScheduleEntryKind.Experiment || constraint is null ||
|
||||
constraint.AllowedExperimentVenueNatures == 0 ||
|
||||
(room.TeachingVenueNature & constraint.AllowedExperimentVenueNatures) != 0) &&
|
||||
|
||||
Reference in New Issue
Block a user