@using Core.Calculation @using Microsoft.EntityFrameworkCore @page "/teams/scheduler" @inject IConfiguration Configuration @inject AppDbContext Context @Configuration["ChapterSettings:Shortname"] TSA Schedule @Configuration["ChapterSettings:CompetitionYear"] @Configuration["ChapterSettings:Shortname"] TSA Schedule @Configuration["ChapterSettings:CompetitionYear"] Time Slots @{ var ol = TeamSchedulerSolution.GetStudentTeamOverlaps(context);} @foreach (var t in context) { @t.ToString() - @string.Join(", ", t.Students.Select(s => s.FirstName + " " + (ol.Any(o => o.Item1.Equals(s)) ? "*" : "" )) ) } @* @foreach (var overlap in ol) { @string.Join(", ", overlap.Item1) } *@ @{ var notInTimeSLot = TeamSchedulerSolution.GetStudentsNotInTimSlot(context, _students); } @if (notInTimeSLot.Any()) { Not scheduled: @string.Join(", ", notInTimeSLot.Select(s => s.FirstName)) } @code { private Team[]? _teams; private Student[]? _students; MudTable _solutionData; private TeamSchedulerSolution _solution; protected override async Task OnInitializedAsync() { _teams = await Context.Teams .Include(e => e.Event) .Include(e => e.Students) .OrderBy(e => e.Event.Name) .ThenBy(e => e.Number) .ToArrayAsync(); _students = await Context.Students .Include(e => e.Teams) .ThenInclude(e => e.Captain) .Include(e => e.EventRankings) .ThenInclude(e => e.EventDefinition) .OrderBy(e => e.FirstName).ToArrayAsync(); } private async Task> SolveSchedule(TableState arg1, CancellationToken arg2) { //_isSolving = true; var scheduleOptions = new TeamSchedulerOptions( timeSlots: 4, mustIncludeEvents: [ // "Medical Technology", "Electrical Applications" , "RegionalTeam", // ,"Dragster", "Flight" ], extended: [ // "Invention", "Construction Challenge", "Mechanical", "Mass", "Micro" //"STEM" //"Community", "Vlogging"// "Microcontroller" ], omittedEvents: [ // "Vlogging", "Junior", "Community Service Video", "Digital Photography", // "STEM" //"Leadership",// "Electrical", //"Construction" // "Forensic", //"CAD" //"I&I Team 1", "I&I Team 2"//, "Website Design", ], absentStudents: [ ] ); var mustIncludeTeams = _teams; mustIncludeTeams = mustIncludeTeams.Where(t => t.Event.EventFormat != EventFormat.Individual).ToArray(); mustIncludeTeams = mustIncludeTeams.Where(t => !t.ToString().Contains("#1")).ToArray(); //mustIncludeTeams = mustIncludeTeams.Where(t => !t.ToString().Contains("Photo")).ToArray(); var teamScheduler = new TeamScheduler(mustIncludeTeams, 3); // teamScheduler // .ScheduleSeparate( // _teams.First(e => e.Event.Name.Contains("Data Science")), // _teams.First(e => e.Event.Name.Contains("Microcontroller Design")) // ); _solution = teamScheduler.Solve(); await InvokeAsync(StateHasChanged); // let the UI know that the solution has been found return new TableData { Items = _solution.TimeSlots}; } }