[chore:] working ai-slop movement for better compensation
This commit is contained in:
66
crafter.cs
66
crafter.cs
@@ -126,6 +126,72 @@ public class CourseCrafter
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Kurs umdisponieren (besser verteilen)
|
||||||
|
// Kurs umdisponieren (besser verteilen)
|
||||||
|
bool changed;
|
||||||
|
int maxIterations = 20;
|
||||||
|
int iteration = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
changed = false;
|
||||||
|
iteration++;
|
||||||
|
|
||||||
|
// nach Sport gruppieren
|
||||||
|
var sports = GeneratedCourses
|
||||||
|
.GroupBy(c => c.Instance.Sport.ID);
|
||||||
|
|
||||||
|
foreach (var sportGroup in sports)
|
||||||
|
{
|
||||||
|
var courses = sportGroup.ToList();
|
||||||
|
|
||||||
|
// paarweise vergleichen
|
||||||
|
for (int i = 0; i < courses.Count; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < courses.Count; j++)
|
||||||
|
{
|
||||||
|
if (i == j) continue;
|
||||||
|
|
||||||
|
var cA = courses[i];
|
||||||
|
var cB = courses[j];
|
||||||
|
|
||||||
|
// nur sinnvoll, wenn Unterschied
|
||||||
|
if (cA.Instance.Students.Count <= cB.Instance.Students.Count + 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Kandidaten aus A nach B verschieben
|
||||||
|
for (int k = cA.Instance.Students.Count - 1; k >= 0; k--)
|
||||||
|
{
|
||||||
|
string stud = cA.Instance.Students[k];
|
||||||
|
|
||||||
|
// 1. Zielsemester frei?
|
||||||
|
if (!isStudentFree(cB.Semester, stud))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 2. Zielkurs hat noch Platz?
|
||||||
|
if (cB.Instance.Students.Count >= cB.Instance.Sport.MaxStudents)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 3. Quellkurs darf nicht unter Min fallen
|
||||||
|
if (cA.Instance.Students.Count - 1 < cA.Instance.Sport.MinStudents)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// --- MOVE durchführen ---
|
||||||
|
cA.Instance.Students.RemoveAt(k);
|
||||||
|
students_in_semester[cA.Semester - 1].Remove(stud);
|
||||||
|
|
||||||
|
cB.Instance.Students.Add(stud);
|
||||||
|
students_in_semester[cB.Semester - 1].Add(stud);
|
||||||
|
|
||||||
|
changed = true;
|
||||||
|
break; // nach jedem Move neu bewerten
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (changed && iteration < maxIterations);
|
||||||
|
|
||||||
int getSemester()
|
int getSemester()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user