added info colles support

This commit is contained in:
alexandre 2024-04-13 11:33:15 +02:00
parent 3499ee60e4
commit 3ae13ae33b
3 changed files with 129 additions and 10 deletions

View File

@ -736,9 +736,10 @@ bool is_overlap(creneau* edt, int len_edt, int id) {
return false; return false;
} }
void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleur* chads, int len_chads, int n_weeks, int grp, topic start_rotation, int mth) { void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleur* chads, int len_chads, int n_weeks, int grp, topic start_rotation, int mth, int inf) {
topic rotation = start_rotation; topic rotation = start_rotation; // physics/english rotation
int math = mth; int math = mth; // math (3/4)
int info = inf; // info (1/6)
int r; // randomize the 1st date int r; // randomize the 1st date
int k = 0; // offset int k = 0; // offset
@ -767,18 +768,59 @@ void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleu
remaining_to_add++; remaining_to_add++;
math--; math--;
} }
remaining_to_add++;
if(rotation == ENGLISH) { if(rotation == ENGLISH) {
rotation = PHYSICS; rotation = PHYSICS;
} else { } else {
rotation = ENGLISH; rotation = ENGLISH;
} }
remaining_to_add++; // physics/english
// initialize/reset variables // initialize/reset variables
r = rand()%weeklen; r = rand()%weeklen;
halt = 0; halt = 0;
found = false; found = false;
info++;
// info colle
while(info == 5) {
if(edt[k+r%weeklen].group == 0 && edt[k+r%weeklen].length == 2) {
// if creneau is empty
// import all colleurs available
free(dudes);
dudes = get_colleurs(chads, len_chads, edt[k+r%weeklen].date, &len_dudes);
len_perm = len_dudes;
// if there are colleurs available
if(len_dudes != 0) {
// randomize the order of colleurs
generate_random_perm(perm, len_perm);
// for each one of them, add his colle for selected group pf and only if
// - he is a INFO colleur
// if a colle has been addded, interrupt the for and while loops
for(int dude = 0; dude < len_perm*(1-found); dude++) {
if(chads[perm[dude]].mat == INFO) {
add_colle(edt, chads, grp, k+r%weeklen, perm[dude]);
found = true;
info = 0;
}
}
}
}
if(!found && halt > weeklen) {
info = 0;
printf("Warning : skipping info colle for week %d and group %d\n", week+1, grp);
}
r++;
halt++;
}
// reset the variables
r = rand()%16;
found = false;
halt = 0;
// if there is a math colle to add, enter this loop // if there is a math colle to add, enter this loop
while(remaining_to_add == 2) { while(remaining_to_add == 2) {
@ -898,16 +940,16 @@ void aux_2(creneau* edt, int len_edt, colleur* chads, int len_chads, int n_group
for(int i = 0; i < n_groups; i++) { for(int i = 0; i < n_groups; i++) {
printf("Adding colles for group %d...\n", i+1); printf("Adding colles for group %d...\n", i+1);
add_colles_for_group_MP2I(weeks_len, edt, len_edt, chads, len_chads, n_weeks, i+1, (topic)(2+i%2), i%4); add_colles_for_group_MP2I(weeks_len, edt, len_edt, chads, len_chads, n_weeks, i+1, (topic)(2+i%2), i%4,1+i%4);
} }
print_one_week(edt, len_edt, edt[0].date); print_one_week(edt, len_edt, edt[0].date);
printf("\n"); printf("\n");
print_one_week(edt, len_edt, edt[16].date); print_one_week(edt, len_edt, edt[19].date);
printf("\n"); printf("\n");
print_one_week(edt, len_edt, edt[32].date); print_one_week(edt, len_edt, edt[38].date);
printf("\n"); printf("\n");
print_one_week(edt, len_edt, edt[48].date); print_one_week(edt, len_edt, edt[57].date);
write_to_file("output.csv", edt, len_edt); write_to_file("output.csv", edt, len_edt);
printf("Completed\n"); printf("Completed\n");

4
main.c
View File

@ -9,8 +9,8 @@ int main() {
creneau* edt = import_creneaux("file.txt", 76); creneau* edt = import_creneaux("file.txt", 76);
int len_creneau = 76; int len_creneau = 76;
colleur* dudes = import_colleurs("some_data.txt", 12, 68); colleur* dudes = import_colleurs("some_data.txt", 13, len_creneau);
int n_colleurs = 12; int n_colleurs = 13;
// {char* name; int namelen; topic mat; date* disp; int n_disp;} colleur; // {char* name; int namelen; topic mat; date* disp; int n_disp;} colleur;

77
output.csv Normal file
View File

@ -0,0 +1,77 @@
hour,day,month,year,length,group,colleur,matiere
12,5,2,2024,1,2,Rapin,Maths
13,5,2,2024,1,1,Herbaud,Anglais
18,5,2,2024,1,2,Chibani,Physique
17,6,2,2024,1,3,Rapin,Maths
18,6,2,2024,1,3,Belaggoune,Anglais
14,7,2,2024,1,4,Chevalier,Physique
14,7,2,2024,2,4,Jospin,Info
14,7,2,2024,2,0,none,none
14,7,2,2024,2,0,none,none
15,7,2,2024,1,5,Mann,Anglais
16,7,2,2024,1,4,Mullaert,Maths
17,7,2,2024,1,7,Mullaert,Maths
18,7,2,2024,1,7,Belaggoune,Anglais
14,8,2,2024,1,6,Chevalier,Physique
15,8,2,2024,1,6,Mullaert,Maths
18,8,2,2024,1,0,none,none
16,9,2,2024,1,0,none,none
17,9,2,2024,1,0,none,none
18,9,2,2024,1,0,none,none
12,12,2,2024,1,0,none,none
13,12,2,2024,1,2,Le_Gourielec,Anglais
18,12,2,2024,1,5,Boully,Maths
17,13,2,2024,1,4,Le_Gourielec,Anglais
18,13,2,2024,1,3,Carpintero,Maths
14,14,2,2024,1,5,Chevalier,Physique
14,14,2,2024,2,3,Jospin,Info
14,14,2,2024,2,7,Jospin,Info
14,14,2,2024,2,0,none,none
15,14,2,2024,1,1,Chevalier,Physique
16,14,2,2024,1,1,Carpintero,Maths
17,14,2,2024,1,3,Poupy,Physique
18,14,2,2024,1,4,Boully,Maths
14,15,2,2024,1,7,Rapin,Maths
15,15,2,2024,1,6,Mann,Anglais
18,15,2,2024,1,7,Colin,Physique
16,16,2,2024,1,0,none,none
17,16,2,2024,1,0,none,none
18,16,2,2024,1,0,none,none
12,19,2,2024,1,4,Colin,Physique
13,19,2,2024,1,6,Poupy,Physique
18,19,2,2024,1,7,Belaggoune,Anglais
17,20,2,2024,1,4,Rapin,Maths
18,20,2,2024,1,0,none,none
14,21,2,2024,1,5,Mann,Anglais
14,21,2,2024,2,2,Jospin,Info
14,21,2,2024,2,6,Jospin,Info
14,21,2,2024,2,0,none,none
15,21,2,2024,1,1,Le_Gourielec,Anglais
16,21,2,2024,1,2,Boully,Maths
17,21,2,2024,1,1,Rapin,Maths
18,21,2,2024,1,2,Colin,Physique
14,22,2,2024,1,5,Carpintero,Maths
15,22,2,2024,1,6,Rapin,Maths
18,22,2,2024,1,3,Mann,Anglais
16,23,2,2024,1,0,none,none
17,23,2,2024,1,0,none,none
18,23,2,2024,1,0,none,none
12,26,2,2024,1,0,none,none
13,26,2,2024,1,7,Chibani,Physique
18,26,2,2024,1,5,Colin,Physique
17,27,2,2024,1,4,Mann,Anglais
18,27,2,2024,1,0,none,none
14,28,2,2024,1,5,Carpintero,Maths
14,28,2,2024,2,1,Jospin,Info
14,28,2,2024,2,5,Jospin,Info
14,28,2,2024,2,0,none,none
15,28,2,2024,1,1,Poupy,Physique
16,28,2,2024,1,1,Rapin,Maths
17,28,2,2024,1,2,Le_Gourielec,Anglais
18,28,2,2024,1,2,Rapin,Maths
14,29,2,2024,1,3,Rapin,Maths
15,29,2,2024,1,6,Carpintero,Maths
18,29,2,2024,1,6,Belaggoune,Anglais
16,1,3,2024,1,7,Rapin,Maths
17,1,3,2024,1,0,none,none
18,1,3,2024,1,0,none,none
1 hour day month year length group colleur matiere
2 12 5 2 2024 1 2 Rapin Maths
3 13 5 2 2024 1 1 Herbaud Anglais
4 18 5 2 2024 1 2 Chibani Physique
5 17 6 2 2024 1 3 Rapin Maths
6 18 6 2 2024 1 3 Belaggoune Anglais
7 14 7 2 2024 1 4 Chevalier Physique
8 14 7 2 2024 2 4 Jospin Info
9 14 7 2 2024 2 0 none none
10 14 7 2 2024 2 0 none none
11 15 7 2 2024 1 5 Mann Anglais
12 16 7 2 2024 1 4 Mullaert Maths
13 17 7 2 2024 1 7 Mullaert Maths
14 18 7 2 2024 1 7 Belaggoune Anglais
15 14 8 2 2024 1 6 Chevalier Physique
16 15 8 2 2024 1 6 Mullaert Maths
17 18 8 2 2024 1 0 none none
18 16 9 2 2024 1 0 none none
19 17 9 2 2024 1 0 none none
20 18 9 2 2024 1 0 none none
21 12 12 2 2024 1 0 none none
22 13 12 2 2024 1 2 Le_Gourielec Anglais
23 18 12 2 2024 1 5 Boully Maths
24 17 13 2 2024 1 4 Le_Gourielec Anglais
25 18 13 2 2024 1 3 Carpintero Maths
26 14 14 2 2024 1 5 Chevalier Physique
27 14 14 2 2024 2 3 Jospin Info
28 14 14 2 2024 2 7 Jospin Info
29 14 14 2 2024 2 0 none none
30 15 14 2 2024 1 1 Chevalier Physique
31 16 14 2 2024 1 1 Carpintero Maths
32 17 14 2 2024 1 3 Poupy Physique
33 18 14 2 2024 1 4 Boully Maths
34 14 15 2 2024 1 7 Rapin Maths
35 15 15 2 2024 1 6 Mann Anglais
36 18 15 2 2024 1 7 Colin Physique
37 16 16 2 2024 1 0 none none
38 17 16 2 2024 1 0 none none
39 18 16 2 2024 1 0 none none
40 12 19 2 2024 1 4 Colin Physique
41 13 19 2 2024 1 6 Poupy Physique
42 18 19 2 2024 1 7 Belaggoune Anglais
43 17 20 2 2024 1 4 Rapin Maths
44 18 20 2 2024 1 0 none none
45 14 21 2 2024 1 5 Mann Anglais
46 14 21 2 2024 2 2 Jospin Info
47 14 21 2 2024 2 6 Jospin Info
48 14 21 2 2024 2 0 none none
49 15 21 2 2024 1 1 Le_Gourielec Anglais
50 16 21 2 2024 1 2 Boully Maths
51 17 21 2 2024 1 1 Rapin Maths
52 18 21 2 2024 1 2 Colin Physique
53 14 22 2 2024 1 5 Carpintero Maths
54 15 22 2 2024 1 6 Rapin Maths
55 18 22 2 2024 1 3 Mann Anglais
56 16 23 2 2024 1 0 none none
57 17 23 2 2024 1 0 none none
58 18 23 2 2024 1 0 none none
59 12 26 2 2024 1 0 none none
60 13 26 2 2024 1 7 Chibani Physique
61 18 26 2 2024 1 5 Colin Physique
62 17 27 2 2024 1 4 Mann Anglais
63 18 27 2 2024 1 0 none none
64 14 28 2 2024 1 5 Carpintero Maths
65 14 28 2 2024 2 1 Jospin Info
66 14 28 2 2024 2 5 Jospin Info
67 14 28 2 2024 2 0 none none
68 15 28 2 2024 1 1 Poupy Physique
69 16 28 2 2024 1 1 Rapin Maths
70 17 28 2 2024 1 2 Le_Gourielec Anglais
71 18 28 2 2024 1 2 Rapin Maths
72 14 29 2 2024 1 3 Rapin Maths
73 15 29 2 2024 1 6 Carpintero Maths
74 18 29 2 2024 1 6 Belaggoune Anglais
75 16 1 3 2024 1 7 Rapin Maths
76 17 1 3 2024 1 0 none none
77 18 1 3 2024 1 0 none none