Add a TimeSlot object, refactor
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
using Core.Entities;
|
||||||
|
|
||||||
|
namespace Core.Calculation;
|
||||||
|
|
||||||
|
public class TeamScheduleTimeSlot
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public Team[] Teams;
|
||||||
|
public Student[] UnscheduledStudents;
|
||||||
|
public IEnumerable<Tuple<Student, IEnumerable<Team>>> StudentOverlaps;
|
||||||
|
|
||||||
|
public bool StudentHasOverlaps(Student student)
|
||||||
|
{
|
||||||
|
return StudentOverlaps.FirstOrDefault(o => o.Item1.Equals(student)) != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -92,7 +92,7 @@ public class TeamScheduler
|
|||||||
var timeSlotTeams = new Team[_timeSlots.Length][];
|
var timeSlotTeams = new Team[_timeSlots.Length][];
|
||||||
|
|
||||||
if (cpSolverStatus is not (CpSolverStatus.Optimal or CpSolverStatus.Feasible))
|
if (cpSolverStatus is not (CpSolverStatus.Optimal or CpSolverStatus.Feasible))
|
||||||
return new TeamSchedulerSolution(timeSlotTeams, cpSolverStatus.ToString());
|
return new TeamSchedulerSolution(timeSlotTeams, _studentObjects.ToArray(), cpSolverStatus.ToString());
|
||||||
|
|
||||||
Debug.WriteLine($"Total cost: {solver.ObjectiveValue}\n");
|
Debug.WriteLine($"Total cost: {solver.ObjectiveValue}\n");
|
||||||
|
|
||||||
@@ -102,6 +102,6 @@ public class TeamScheduler
|
|||||||
timeSlotTeams[s] = teams;
|
timeSlotTeams[s] = teams;
|
||||||
}
|
}
|
||||||
//Debug.WriteLine("No solution found.");
|
//Debug.WriteLine("No solution found.");
|
||||||
return new TeamSchedulerSolution(timeSlotTeams, cpSolverStatus.ToString());
|
return new TeamSchedulerSolution(timeSlotTeams, _studentObjects.ToArray(), cpSolverStatus.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,11 +4,18 @@ namespace Core.Calculation;
|
|||||||
|
|
||||||
public class TeamSchedulerSolution(
|
public class TeamSchedulerSolution(
|
||||||
Team[][] timeSlots,
|
Team[][] timeSlots,
|
||||||
|
Student[] students,
|
||||||
string status)
|
string status)
|
||||||
{
|
{
|
||||||
public Team[][] TimeSlots { get; set; } = timeSlots;
|
public string Status { get; } = status;
|
||||||
public string Status { get; set; } = status;
|
|
||||||
|
|
||||||
|
public TeamScheduleTimeSlot[] TimeSlots { get; set; }
|
||||||
|
= timeSlots.Select( (teams,i) =>
|
||||||
|
new TeamScheduleTimeSlot{Name = i.ToString(), Teams = teams,
|
||||||
|
StudentOverlaps = GetStudentTeamOverlaps(teams),
|
||||||
|
UnscheduledStudents = GetStudentsNotInTimSlot(teams, students)
|
||||||
|
}
|
||||||
|
).ToArray();
|
||||||
|
|
||||||
public static int GetStudentTeamOverlapCount(Team[][] timeSlots)
|
public static int GetStudentTeamOverlapCount(Team[][] timeSlots)
|
||||||
{
|
{
|
||||||
@@ -30,7 +37,6 @@ public class TeamSchedulerSolution(
|
|||||||
select Tuple.Create(gs.First(), gs.Key);
|
select Tuple.Create(gs.First(), gs.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Student[] GetStudentsNotInTimSlot(Team[] timeSlot, Student[] students)
|
public static Student[] GetStudentsNotInTimSlot(Team[] timeSlot, Student[] students)
|
||||||
{
|
{
|
||||||
var studentsInTimeSlot = timeSlot.SelectMany(ts => ts.Students).Distinct();
|
var studentsInTimeSlot = timeSlot.SelectMany(ts => ts.Students).Distinct();
|
||||||
@@ -39,12 +45,11 @@ public class TeamSchedulerSolution(
|
|||||||
where studentsInTimeSlot.FirstOrDefault(e => e.Equals(allStudent)) == null
|
where studentsInTimeSlot.FirstOrDefault(e => e.Equals(allStudent)) == null
|
||||||
select allStudent
|
select allStudent
|
||||||
).ToArray();
|
).ToArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Team[] StudentUnassignedTeams(Student student)
|
public Team[] StudentUnassignedTeams(Student student)
|
||||||
{
|
{
|
||||||
var meetingTeams = TimeSlots.SelectMany(t => t);
|
var meetingTeams = TimeSlots.SelectMany(t => t.Teams);
|
||||||
return
|
return
|
||||||
student.Teams.Where(e => !meetingTeams.Contains(e)).ToArray();
|
student.Teams.Where(e => !meetingTeams.Contains(e)).ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class TeamScheduler_DecisionTree
|
|||||||
|
|
||||||
timeSlots[overlaps.First().Item1].Add(team);
|
timeSlots[overlaps.First().Item1].Add(team);
|
||||||
}
|
}
|
||||||
return new TeamSchedulerSolution(timeSlots.Select(e => e.ToArray()).ToArray(), "Success?");
|
return new TeamSchedulerSolution(timeSlots.Select(e => e.ToArray()).ToArray(), [], "Success?");
|
||||||
}
|
}
|
||||||
|
|
||||||
//public Team[][] SolveRecursive()
|
//public Team[][] SolveRecursive()
|
||||||
|
|||||||
@@ -5,13 +5,17 @@ namespace Core.Calculation;
|
|||||||
public class UnassignedStudentScheduler
|
public class UnassignedStudentScheduler
|
||||||
{
|
{
|
||||||
private readonly Student[] _students;
|
private readonly Student[] _students;
|
||||||
private readonly Team[] _teams;
|
private readonly Team[] _allTeams;
|
||||||
private readonly IList<Team>[] _timeSlots;
|
private readonly IList<Team>[] _timeSlots;
|
||||||
|
|
||||||
public UnassignedStudentScheduler(Team[] teams, Team[][] timeslots)
|
public UnassignedStudentScheduler(Team[] allTeams, TeamScheduleTimeSlot[] timeslots)
|
||||||
|
: this(allTeams, timeslots.Select(e => e.Teams).ToArray())
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public UnassignedStudentScheduler(Team[] allTeams, Team[][] timeslots)
|
||||||
{
|
{
|
||||||
_teams = teams;
|
_allTeams = allTeams;
|
||||||
_students = teams.SelectMany(t => t.Students).Distinct().ToArray();
|
_students = allTeams.SelectMany(t => t.Students).Distinct().ToArray();
|
||||||
_timeSlots = timeslots.Select(ts => ts.Select(t => t.Clone()).ToList()).ToArray<IList<Team>>();
|
_timeSlots = timeslots.Select(ts => ts.Select(t => t.Clone()).ToList()).ToArray<IList<Team>>();
|
||||||
}
|
}
|
||||||
public static IEnumerable<Student> UnassignedStudents(IList<Student> students, IList<Team> timeSlot)
|
public static IEnumerable<Student> UnassignedStudents(IList<Student> students, IList<Team> timeSlot)
|
||||||
@@ -68,7 +72,7 @@ public class UnassignedStudentScheduler
|
|||||||
// find teams where several unassigned students can work together
|
// find teams where several unassigned students can work together
|
||||||
private IEnumerable<Team> GetAvailableTeams_BiggestGroup(
|
private IEnumerable<Team> GetAvailableTeams_BiggestGroup(
|
||||||
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
||||||
_teams
|
_allTeams
|
||||||
.Where(t => scheduledTeams.All(st => st.Id != t.Id))
|
.Where(t => scheduledTeams.All(st => st.Id != t.Id))
|
||||||
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
||||||
.Where(t => t.Students.Count > 1) //|| t.Event.EventFormat is EventFormat.Individual
|
.Where(t => t.Students.Count > 1) //|| t.Event.EventFormat is EventFormat.Individual
|
||||||
@@ -79,7 +83,7 @@ public class UnassignedStudentScheduler
|
|||||||
// find individual events unassigned students can work on
|
// find individual events unassigned students can work on
|
||||||
private IEnumerable<Team> GetAvailableTeams_Individual(
|
private IEnumerable<Team> GetAvailableTeams_Individual(
|
||||||
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
||||||
_teams
|
_allTeams
|
||||||
.Where(t => scheduledTeams.All(st => st.Id != t.Id))
|
.Where(t => scheduledTeams.All(st => st.Id != t.Id))
|
||||||
.Where(t => t.Event.EventFormat == EventFormat.Individual || t.Students.Count == 1)
|
.Where(t => t.Event.EventFormat == EventFormat.Individual || t.Students.Count == 1)
|
||||||
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
||||||
@@ -88,14 +92,14 @@ public class UnassignedStudentScheduler
|
|||||||
// find any unassigned eventDefinition students can work on
|
// find any unassigned eventDefinition students can work on
|
||||||
private IEnumerable<Team> GetAvailableTeams_AnyNotMeetingAlready(
|
private IEnumerable<Team> GetAvailableTeams_AnyNotMeetingAlready(
|
||||||
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
||||||
_teams
|
_allTeams
|
||||||
.Where(t => scheduledTeams.All(st => st.Id != t.Id))
|
.Where(t => scheduledTeams.All(st => st.Id != t.Id))
|
||||||
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
||||||
.Where(t => t.Students.Count > 0);
|
.Where(t => t.Students.Count > 0);
|
||||||
|
|
||||||
private IEnumerable<Team> GetAvailableTeams_Any(
|
private IEnumerable<Team> GetAvailableTeams_Any(
|
||||||
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
||||||
_teams
|
_allTeams
|
||||||
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
||||||
.Where(t => t.Students.Count > 0);
|
.Where(t => t.Students.Count > 0);
|
||||||
|
|
||||||
@@ -103,7 +107,7 @@ public class UnassignedStudentScheduler
|
|||||||
// find teams where several unassigned students can work together
|
// find teams where several unassigned students can work together
|
||||||
private IEnumerable<Team> GetAvailableTeams_LevelOfEffort(
|
private IEnumerable<Team> GetAvailableTeams_LevelOfEffort(
|
||||||
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
||||||
_teams
|
_allTeams
|
||||||
.Where(t => scheduledTeams.All(st => st.Id != t.Id))
|
.Where(t => scheduledTeams.All(st => st.Id != t.Id))
|
||||||
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
||||||
.Where(t => t.Students.Count > 1) //|| t.Event.EventFormat is EventFormat.Individual
|
.Where(t => t.Students.Count > 1) //|| t.Event.EventFormat is EventFormat.Individual
|
||||||
|
|||||||
@@ -11,66 +11,67 @@
|
|||||||
<MudText Typo="Typo.h3">@Configuration["ChapterSettings:Shortname"] TSA Schedule @Configuration["ChapterSettings:CompetitionYear"]</MudText>
|
<MudText Typo="Typo.h3">@Configuration["ChapterSettings:Shortname"] TSA Schedule @Configuration["ChapterSettings:CompetitionYear"]</MudText>
|
||||||
|
|
||||||
<MudPaper Class="pa-4 mt-5">
|
<MudPaper Class="pa-4 mt-5">
|
||||||
@* <MudText>Include: @string.Join(", ", _scheduledTeams) </MudText> *@
|
|
||||||
<MudGrid>
|
<MudGrid>
|
||||||
<MudItem xs="7" sm="8" lg="9">
|
<MudItem xs="7" sm="8" lg="9">
|
||||||
<MudText Typo="Typo.h4">Time Slots</MudText>
|
<MudText Typo="Typo.h4">Time Slots</MudText>
|
||||||
<MudGrid>
|
<MudPaper Class="pa-2 ma-2" Elevation="3">
|
||||||
<MudItem xs="12" sm="6" lg="4">
|
<MudGrid>
|
||||||
<MudNumericField @bind-Value="_parameters.TimeSlots"
|
<MudItem xs="12" sm="6" lg="4">
|
||||||
Label="Time Slots" Min="1" Max="4"></MudNumericField>
|
<MudNumericField @bind-Value="_parameters.TimeSlots"
|
||||||
</MudItem>
|
Label="Time Slots" Min="1" Max="4">
|
||||||
<MudItem xs="12" sm="6" lg="4">
|
</MudNumericField>
|
||||||
<MudButton Variant="Variant.Outlined" OnClick="() => AddHighLevelOfEffort()" FullWidth="true">Add High Effort</MudButton>
|
</MudItem>
|
||||||
</MudItem>
|
<MudFlexBreak/>
|
||||||
<MudItem xs="12" sm="6" lg="4">
|
<MudItem xs="12" sm="6" lg="4">
|
||||||
<MudButton Variant="Variant.Outlined" OnClick="() => AddRegionals()" FullWidth="true">Add Regionals</MudButton>
|
<MudButton Variant="Variant.Outlined" OnClick="() => AddHighLevelOfEffort()" FullWidth="true">Add High Effort</MudButton>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem xs="12" sm="6" lg="4">
|
<MudItem xs="12" sm="6" lg="4">
|
||||||
<MudButton Variant="Variant.Outlined" OnClick="() => RemoveIndividual()" FullWidth="true">Remove Individual</MudButton>
|
<MudButton Variant="Variant.Outlined" OnClick="() => AddRegionals()" FullWidth="true">Add Regionals</MudButton>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem xs="12" sm="6" lg="4">
|
<MudItem xs="12" sm="6" lg="4">
|
||||||
<MudButton Variant="Variant.Outlined" OnClick="() => RemoveLowLevelOfEffort()" FullWidth="true">Remove Low Effort</MudButton>
|
<MudButton Variant="Variant.Outlined" OnClick="() => RemoveIndividual()" FullWidth="true">Remove Individual</MudButton>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem xs="12" sm="6" lg="4">
|
<MudItem xs="12" sm="6" lg="4">
|
||||||
<MudButton Variant="Variant.Outlined" OnClick="() => Invert()" FullWidth="true">Invert</MudButton>
|
<MudButton Variant="Variant.Outlined" OnClick="() => RemoveLowLevelOfEffort()" FullWidth="true">Remove Low Effort</MudButton>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem xs="12" sm="6" lg="4">
|
<MudItem xs="12" sm="6" lg="4">
|
||||||
<MudButton Variant="Variant.Outlined" Color="Color.Warning" OnClick="() => Reset()" FullWidth="true">Reset</MudButton>
|
<MudButton Variant="Variant.Outlined" OnClick="() => Invert()" FullWidth="true">Invert</MudButton>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem xs="12">
|
<MudItem xs="12" sm="6" lg="4">
|
||||||
<MudButton Variant="Variant.Filled" Class="ma-3" OnClick="Solve" Color="Color.Primary" Disabled="@_isSolving">Solve</MudButton>
|
<MudButton Variant="Variant.Outlined" Color="Color.Warning" OnClick="() => Reset()" FullWidth="true">Reset</MudButton>
|
||||||
<MudTooltip Text="Copy to Clipboard">
|
</MudItem>
|
||||||
<MudIconButton OnClick="CopyToClipboard" Icon="@Icons.Material.Filled.ContentCopy"></MudIconButton>
|
<MudItem xs="12">
|
||||||
</MudTooltip>
|
<MudButton Variant="Variant.Filled" Class="ma-3" OnClick="Solve" Color="Color.Primary" Disabled="@_isSolving">Solve</MudButton>
|
||||||
</MudItem>
|
<MudTooltip Text="Copy to Clipboard">
|
||||||
|
<MudIconButton OnClick="CopyToClipboard" Icon="@Icons.Material.Filled.ContentCopy"></MudIconButton>
|
||||||
|
</MudTooltip>
|
||||||
|
</MudItem>
|
||||||
|
|
||||||
</MudGrid>
|
</MudGrid>
|
||||||
<MudTable T="Team[]" ServerData="SolveSchedule" @ref="_solutionData">
|
</MudPaper>
|
||||||
<HeaderContent>
|
|
||||||
</HeaderContent>
|
<MudTable T="TeamScheduleTimeSlot" ServerData="SolveSchedule" @ref="_solutionData">
|
||||||
<RowTemplate>
|
<HeaderContent>
|
||||||
|
</HeaderContent>
|
||||||
|
<RowTemplate>
|
||||||
<MudTd>
|
<MudTd>
|
||||||
@{
|
|
||||||
var overlaps
|
|
||||||
= TeamSchedulerSolution.GetStudentTeamOverlaps(context).ToArray();
|
|
||||||
}
|
|
||||||
<MudGrid Class="d-flex justify-start align-start">
|
<MudGrid Class="d-flex justify-start align-start">
|
||||||
@foreach (var team in context.OrderBy(e => e.ToString()))
|
@foreach (var team in context.Teams.OrderBy(e => e.ToString()))
|
||||||
{
|
{
|
||||||
var removed = !_scheduledTeams.Contains(team);
|
var removed = !_scheduledTeams.Contains(team);
|
||||||
<MudItem xs="12">
|
<MudItem xs="12">
|
||||||
<MudLink Typo="Typo.body1"
|
<MudLink Typo="Typo.body1"
|
||||||
Class="d-flex align-center"
|
Class="d-flex align-center"
|
||||||
Color="Color.Default"
|
Color="Color.Default"
|
||||||
OnClick="@(() => ToggleRequiredTeam(team))">
|
OnClick="@(() => ToggleRequiredTeam(team))">
|
||||||
<MudIcon Icon="@Icons.Material.Filled.Clear"
|
<MudIcon Icon="@Icons.Material.Filled.Clear"
|
||||||
Size="Size.Small"
|
Size="Size.Small"
|
||||||
Class="@(removed ? "" : "d-none")"></MudIcon>
|
Class="@(removed ? "" : "d-none")">
|
||||||
@team -
|
</MudIcon>
|
||||||
|
@team -
|
||||||
@foreach (var student in team.Students)
|
@foreach (var student in team.Students)
|
||||||
{
|
{
|
||||||
var overlap = overlaps.Any(o => o.Item1.Equals(student));
|
var overlap = context.StudentHasOverlaps(student);
|
||||||
var color = overlap ? Color.Warning : Color.Default;
|
var color = overlap ? Color.Warning : Color.Default;
|
||||||
|
|
||||||
<MudText
|
<MudText
|
||||||
@@ -84,17 +85,13 @@
|
|||||||
</MudItem>
|
</MudItem>
|
||||||
}
|
}
|
||||||
</MudGrid>
|
</MudGrid>
|
||||||
</MudTd>
|
</MudTd>
|
||||||
<MudTd>
|
<MudTd>
|
||||||
@{
|
@if (context.UnscheduledStudents.Any())
|
||||||
var unscheduled = TeamSchedulerSolution.GetStudentsNotInTimSlot(context, _students);
|
{
|
||||||
}
|
<MudItem>Unscheduled</MudItem>
|
||||||
@if (unscheduled.Any())
|
<MudGrid>
|
||||||
{
|
@foreach (var student in context.UnscheduledStudents)
|
||||||
|
|
||||||
<MudItem>Unscheduled</MudItem>
|
|
||||||
<MudGrid>
|
|
||||||
@foreach (var student in unscheduled)
|
|
||||||
{
|
{
|
||||||
<MudItem xs="12" sm="6" lg="3">
|
<MudItem xs="12" sm="6" lg="3">
|
||||||
<MudText Typo="Typo.body1" HtmlTag="i">@student.FirstName </MudText>
|
<MudText Typo="Typo.body1" HtmlTag="i">@student.FirstName </MudText>
|
||||||
@@ -111,20 +108,22 @@
|
|||||||
OnClick="@(() => ToggleRequiredTeam(unassignedTeam))">
|
OnClick="@(() => ToggleRequiredTeam(unassignedTeam))">
|
||||||
<MudIcon Icon="@Icons.Material.Filled.Check"
|
<MudIcon Icon="@Icons.Material.Filled.Check"
|
||||||
Size="Size.Small"
|
Size="Size.Small"
|
||||||
Class="@(added ? "" : "d-none")"></MudIcon>
|
Class="@(added ? "" : "d-none")">
|
||||||
|
</MudIcon>
|
||||||
@unassignedTeam
|
@unassignedTeam
|
||||||
</MudLink>
|
</MudLink>
|
||||||
}
|
}
|
||||||
</MudItem>
|
</MudItem>
|
||||||
}
|
}
|
||||||
</MudGrid>
|
</MudGrid>
|
||||||
}
|
}
|
||||||
</MudTd>
|
</MudTd>
|
||||||
</RowTemplate>
|
</RowTemplate>
|
||||||
</MudTable>
|
</MudTable>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem xs="5" sm="4" lg="3">
|
<MudItem xs="5" sm="4" lg="3">
|
||||||
<MudStack>
|
<MudStack>
|
||||||
|
<MudText Typo="Typo.h4">Scheduled Teams</MudText>
|
||||||
<MudItem>@string.Join(", ", (_possibleAdditions ?? []).Select(e => e.ToString()))</MudItem>
|
<MudItem>@string.Join(", ", (_possibleAdditions ?? []).Select(e => e.ToString()))</MudItem>
|
||||||
<MudToggleGroup T="Team"
|
<MudToggleGroup T="Team"
|
||||||
SelectionMode="SelectionMode.MultiSelection"
|
SelectionMode="SelectionMode.MultiSelection"
|
||||||
@@ -152,7 +151,7 @@
|
|||||||
@code {
|
@code {
|
||||||
private Team[]? _teams;
|
private Team[]? _teams;
|
||||||
private Student[]? _students;
|
private Student[]? _students;
|
||||||
MudTable<Team[]> _solutionData;
|
MudTable<TeamScheduleTimeSlot> _solutionData;
|
||||||
private TeamSchedulerSolution _solution;
|
private TeamSchedulerSolution _solution;
|
||||||
private TeamSchedulerOptions _parameters;
|
private TeamSchedulerOptions _parameters;
|
||||||
bool _isSolving;
|
bool _isSolving;
|
||||||
@@ -161,13 +160,13 @@
|
|||||||
|
|
||||||
private async Task AddRegionals()
|
private async Task AddRegionals()
|
||||||
{
|
{
|
||||||
_scheduledTeams
|
_scheduledTeams
|
||||||
= _teams.Where(e => e.Event.RegionalEvent).Concat(_scheduledTeams).Distinct();
|
= _teams.Where(e => e.Event.RegionalEvent).Concat(_scheduledTeams).Distinct();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AddHighLevelOfEffort()
|
private async Task AddHighLevelOfEffort()
|
||||||
{
|
{
|
||||||
_scheduledTeams
|
_scheduledTeams
|
||||||
= _teams.Where(e => e.Event.LevelOfEffort >= 3).Concat(_scheduledTeams).Distinct();
|
= _teams.Where(e => e.Event.LevelOfEffort >= 3).Concat(_scheduledTeams).Distinct();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,27 +208,27 @@
|
|||||||
{
|
{
|
||||||
_parameters =
|
_parameters =
|
||||||
new TeamSchedulerOptions(
|
new TeamSchedulerOptions(
|
||||||
timeSlots: 2,
|
2,
|
||||||
mustIncludeEvents:
|
mustIncludeEvents:
|
||||||
[
|
[
|
||||||
// "Medical Technology", "Electrical Applications" , "RegionalTeam",
|
// "Medical Technology", "Electrical Applications" , "RegionalTeam",
|
||||||
// ,"Dragster", "Flight"
|
// ,"Dragster", "Flight"
|
||||||
],
|
],
|
||||||
extended:
|
extended:
|
||||||
[
|
[
|
||||||
// "Invention", "Construction Challenge", "Mechanical", "Mass", "Micro"
|
// "Invention", "Construction Challenge", "Mechanical", "Mass", "Micro"
|
||||||
//"STEM"
|
//"STEM"
|
||||||
//"Community", "Vlogging"// "Microcontroller"
|
//"Community", "Vlogging"// "Microcontroller"
|
||||||
],
|
],
|
||||||
omittedEvents:
|
omittedEvents:
|
||||||
[
|
[
|
||||||
// "Vlogging", "Junior", "Community Service Video", "Digital Photography",
|
// "Vlogging", "Junior", "Community Service Video", "Digital Photography",
|
||||||
// "STEM"
|
// "STEM"
|
||||||
|
|
||||||
//"Leadership",// "Electrical", //"Construction"
|
//"Leadership",// "Electrical", //"Construction"
|
||||||
// "Forensic",
|
// "Forensic",
|
||||||
//"CAD"
|
//"CAD"
|
||||||
//"I&I Team 1", "I&I Team 2"//, "Website Design",
|
//"I&I Team 1", "I&I Team 2"//, "Website Design",
|
||||||
],
|
],
|
||||||
absentStudents:
|
absentStudents:
|
||||||
[
|
[
|
||||||
@@ -237,14 +236,14 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
_teams
|
_teams
|
||||||
= await Context.Teams
|
= await Context.Teams
|
||||||
.Include(e => e.Event)
|
.Include(e => e.Event)
|
||||||
.Include(e => e.Students)
|
.Include(e => e.Students)
|
||||||
.OrderBy(e => e.Event.Name)
|
.OrderBy(e => e.Event.Name)
|
||||||
.ThenBy(e => e.Identifier)
|
.ThenBy(e => e.Identifier)
|
||||||
.ToArrayAsync();
|
.ToArrayAsync();
|
||||||
|
|
||||||
_students =
|
_students =
|
||||||
await Context.Students
|
await Context.Students
|
||||||
.Include(e => e.Teams)
|
.Include(e => e.Teams)
|
||||||
.ThenInclude(e => e.Captain)
|
.ThenInclude(e => e.Captain)
|
||||||
@@ -253,7 +252,7 @@
|
|||||||
.OrderBy(e => e.FirstName).ToArrayAsync();
|
.OrderBy(e => e.FirstName).ToArrayAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<TableData<Team[]>> SolveSchedule(TableState arg1, CancellationToken arg2)
|
private async Task<TableData<TeamScheduleTimeSlot>> SolveSchedule(TableState arg1, CancellationToken arg2)
|
||||||
{
|
{
|
||||||
_isSolving = true;
|
_isSolving = true;
|
||||||
var teamScheduler = new TeamScheduler(_scheduledTeams, _parameters.TimeSlots);
|
var teamScheduler = new TeamScheduler(_scheduledTeams, _parameters.TimeSlots);
|
||||||
@@ -282,7 +281,7 @@
|
|||||||
await InvokeAsync(StateHasChanged); // let the UI know that the solution has been found
|
await InvokeAsync(StateHasChanged); // let the UI know that the solution has been found
|
||||||
|
|
||||||
_isSolving = false;
|
_isSolving = false;
|
||||||
return new TableData<Team[]> { Items = _solution.TimeSlots};
|
return new TableData<TeamScheduleTimeSlot> { Items = _solution.TimeSlots };
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Solve()
|
private void Solve()
|
||||||
@@ -295,9 +294,9 @@
|
|||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
foreach (var timeslot in _solution.TimeSlots)
|
foreach (var timeslot in _solution.TimeSlots)
|
||||||
{
|
{
|
||||||
var overlaps
|
//var overlaps
|
||||||
= TeamSchedulerSolution.GetStudentTeamOverlaps(timeslot).Select(e => e.Item1).ToArray();
|
// = TeamSchedulerSolution.GetStudentTeamOverlaps(timeslot).Select(e => e.Item1).ToArray();
|
||||||
foreach (var scheduledTeam in timeslot.OrderBy(e => e.ToString()))
|
foreach (var scheduledTeam in timeslot.Teams.OrderBy(e => e.ToString()))
|
||||||
{
|
{
|
||||||
var t = scheduledTeam.ToString();
|
var t = scheduledTeam.ToString();
|
||||||
var s =
|
var s =
|
||||||
@@ -305,7 +304,7 @@
|
|||||||
scheduledTeam.Students
|
scheduledTeam.Students
|
||||||
.OrderBy(e => e == scheduledTeam.Captain)
|
.OrderBy(e => e == scheduledTeam.Captain)
|
||||||
.ThenBy(e => e.FirstName)
|
.ThenBy(e => e.FirstName)
|
||||||
.Select(e => e.FirstName + (overlaps.Contains(e) ? "*": "")));
|
.Select(e => e.FirstName + (timeslot.StudentHasOverlaps(e) ? "*" : "")));
|
||||||
|
|
||||||
if (scheduledTeam.Event.EventFormat is EventFormat.Individual)
|
if (scheduledTeam.Event.EventFormat is EventFormat.Individual)
|
||||||
sb.Append(t);
|
sb.Append(t);
|
||||||
@@ -313,13 +312,12 @@
|
|||||||
sb.Append($"{t} - {s}");
|
sb.Append($"{t} - {s}");
|
||||||
sb.Append(Environment.NewLine);
|
sb.Append(Environment.NewLine);
|
||||||
}
|
}
|
||||||
var unscheduled = TeamSchedulerSolution.GetStudentsNotInTimSlot(timeslot, _students);
|
|
||||||
|
|
||||||
if (unscheduled.Any())
|
if (timeslot.UnscheduledStudents.Any())
|
||||||
{
|
{
|
||||||
sb.Append("--Unscheduled");
|
sb.Append("--Unscheduled");
|
||||||
sb.Append(Environment.NewLine);
|
sb.Append(Environment.NewLine);
|
||||||
foreach (var student in unscheduled)
|
foreach (var student in timeslot.UnscheduledStudents)
|
||||||
{
|
{
|
||||||
var s = student.FirstName;
|
var s = student.FirstName;
|
||||||
var unassignedTeams = _solution.StudentUnassignedTeams(student);
|
var unassignedTeams = _solution.StudentUnassignedTeams(student);
|
||||||
@@ -342,4 +340,5 @@
|
|||||||
Console.WriteLine("Cannot write text to clipboard");
|
Console.WriteLine("Cannot write text to clipboard");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user