From 6fdb5589d6cec81d935cef7ddbc126a9441fd6f6 Mon Sep 17 00:00:00 2001 From: alexandre Date: Sun, 14 Apr 2024 12:13:01 +0200 Subject: [PATCH] // --- MP2I-creneaux.txt | 2 - algorithm.c | 25 ++++-- main.c | 8 +- output.csv | 194 ++++++++++++++++++++++------------------------ 4 files changed, 112 insertions(+), 117 deletions(-) diff --git a/MP2I-creneaux.txt b/MP2I-creneaux.txt index b994bd8..a02abeb 100644 --- a/MP2I-creneaux.txt +++ b/MP2I-creneaux.txt @@ -1,6 +1,4 @@ 12 5 2 2024 -12 5 2 2024 -13 5 2 2024 13 5 2 2024 14 6 2 2024 14 6 2 2024 diff --git a/algorithm.c b/algorithm.c index e98155e..65fadb1 100644 --- a/algorithm.c +++ b/algorithm.c @@ -706,8 +706,8 @@ void generate_colles_v1(creneau* edt, int len_edt, colleur* chads, int n_chads, // ----------------------------------------------------- // void add_colle(creneau* edt, colleur* chads, int grp, int id_edt, int id_chad) { edt[id_edt].group = grp; - str_copy(chads[id_chad].name, chads[id_chad].namelen, edt[id_edt].name); edt[id_edt].namelen = chads[id_chad].namelen; + str_copy(chads[id_chad].name, chads[id_chad].namelen, edt[id_edt].name); edt[id_edt].mat = chads[id_chad].mat; } @@ -769,6 +769,8 @@ void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleu int* perm = malloc(sizeof(int)*30); // randomize who to pick int len_perm = 0; // length of int* + bool has_math_dude = false; // length of colleur* + for(int week = 0; week < n_weeks; week++) { int weeklen = weeks_len[week]; @@ -886,7 +888,13 @@ void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleu len_perm = len_dudes; if(len_dudes != 0) { generate_random_perm(perm, len_perm); - for(int dude = 0; dude < len_perm*(1-found); dude++) { + has_math_dude = false; + for(int dude = 0; dude < len_perm*(1-has_math_dude); dude++) { + if(dudes[perm[dude]].mat == MATH) { + has_math_dude = true; + } + } + for(int dude = 0; dude < len_perm*(1-found)*(1-has_math_dude); dude++) { //printf("%d\n", chads[perm[dude]]); if(dudes[perm[dude]].mat == rotation) { add_colle(edt, dudes, grp, k+r%16, perm[dude]); @@ -963,13 +971,14 @@ int score(creneau* edt, int len_edt, int grp) { if(dist == 0) { score -= 7; } - if(str_equal(edt[i].name, edt[j].name)) { - score -= 5*min(0, 28-dist); - } + /*if(str_equal(edt[i].name, edt[j].name)) { + printf("%d\n", dist); + score -= max(0, 28-dist); + }*/ if(dist == 7 && edt[i].date.hour == edt[j].date.hour) { score -= 5; } - if(dist < 7 && edt[i].date.hour == 18 && edt[j].date.hour == 18) { + if(dist < 5 && edt[i].date.hour == 18 && edt[j].date.hour == 18) { score -= 10; } } @@ -1028,7 +1037,7 @@ 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 < 1; i++) { //rintf("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,i%8, &skipped); + add_colles_for_group_MP2I(weeks_len, edt, len_edt, chads, len_chads, n_weeks, i+1, (topic)(2+i%2), i%4, i%8, &skipped); } for(int i = 0; i < n_groups; i++) { //printf("Score for group %d : %d\n", i+1, score(edt, len_edt, i+1)); @@ -1057,7 +1066,7 @@ void aux_2(creneau* edt, int len_edt, colleur* chads, int len_chads, int n_group if(max_score == 100*n_groups) { printf("Interrupting early due to a perfect score achieved\n"); } else { - printf("100% Completed, best score is %d/%d with %d skipped colles\n", max_score, 100*n_groups, global_skipped); + printf("100% Completed, best score is %d/%d with %d skipped colle(s)\n", max_score, 100*n_groups, global_skipped); printf("Most screwed group is %d with a score of %d/100\n", screwed_group, global_min); } int end = time(NULL); diff --git a/main.c b/main.c index be6725b..6bc17d7 100644 --- a/main.c +++ b/main.c @@ -7,11 +7,11 @@ int main() { srand(time(NULL)); //creneau* edt = import_creneaux("file.txt", 76); - creneau* edt = import_creneaux_oneweek("MP2I-creneaux.txt", 31, 6); - int len_edt = 31*6; + creneau* edt = import_creneaux_oneweek("MP2I-creneaux.txt", 29, 6); + int len_edt = 29*6; //colleur* dudes = import_colleurs("some_data.txt", 13, len_creneau); - colleur* dudes = import_colleurs_oneweek("MP2I-colleurs.txt", 16, 6, 31); + colleur* dudes = import_colleurs_oneweek("MP2I-colleurs.txt", 16, 6, 29); int n_colleurs = 16; //print_all_edt(edt, len_edt, 6, 31); @@ -24,7 +24,7 @@ int main() { /*int* a = malloc(sizeof(int)*10); generate_random_perm(a, 10); print_arr(a, 10);*/ - aux_2(edt, len_edt, dudes, n_colleurs, 15, 6, 5000); + aux_2(edt, len_edt, dudes, n_colleurs, 15, 6, 1500); //generate_colles_v1(edt, len_creneau, dudes, n_colleurs, 9, 4); //generate_colles_v1(edt, len_creneau, dudes, n_colleurs, 15, 4); diff --git a/output.csv b/output.csv index 9e17631..d87d033 100644 --- a/output.csv +++ b/output.csv @@ -1,25 +1,23 @@ hour,day,month,year,length,group,colleur,matiere -12,5,2,2024,1,2,Chevalier,Physique -12,5,2,2024,1,10,Chevalier,Physique +12,5,2,2024,1,14,Chevalier,Physique 13,5,2,2024,1,15,Herbaut,Anglais -13,5,2,2024,1,3,Herbaut,Anglais -14,6,2,2024,1,1,Belaggoune,Anglais -14,6,2,2024,1,14,Chevalier,Physique -14,6,2,2024,1,10,Mullaert,Maths -17,6,2,2024,1,4,Chevalier,Physique -17,6,2,2024,1,8,Chevalier,Physique -18,6,2,2024,1,3,Rapin,Maths -13,7,2,2024,1,2,Carpintero,Maths -14,7,2,2024,1,5,Le_Gouriellec,Anglais -14,7,2,2024,1,7,Bouverot,Maths -14,7,2,2024,1,4,Carpintero,Maths -14,7,2,2024,1,6,Boully,Maths -14,7,2,2024,2,0,none,none -15,7,2,2024,1,8,Bouverot,Maths +14,6,2,2024,1,3,Mullaert,Maths +14,6,2,2024,1,0,none,none +14,6,2,2024,1,0,none,none +17,6,2,2024,1,2,Chevalier,Physique +17,6,2,2024,1,6,Colin,Physique +18,6,2,2024,1,8,Rapin,Maths +13,7,2,2024,1,4,Carpintero,Maths +14,7,2,2024,1,7,Boully,Maths +14,7,2,2024,1,6,Bouverot,Maths +14,7,2,2024,1,0,none,none +14,7,2,2024,1,2,Carpintero,Maths +14,7,2,2024,2,8,Colleur_Dinfo,Info +15,7,2,2024,1,10,Bouverot,Maths 15,7,2,2024,1,11,Boully,Maths 15,7,2,2024,1,0,none,none 16,7,2,2024,1,0,none,none -16,7,2,2024,2,8,Colleur_Dinfo,Info +16,7,2,2024,2,0,none,none 17,7,2,2024,1,0,none,none 17,7,2,2024,1,0,none,none 18,7,2,2024,1,0,none,none @@ -30,27 +28,25 @@ hour,day,month,year,length,group,colleur,matiere 16,9,2,2024,1,0,none,none 17,9,2,2024,1,14,Oubaha,Maths 18,9,2,2024,1,15,Oubaha,Maths -12,12,2,2024,1,3,Chevalier,Physique -12,12,2,2024,1,9,Chevalier,Physique +12,12,2,2024,1,15,Chevalier,Physique 13,12,2,2024,1,14,Herbaut,Anglais -13,12,2,2024,1,2,Herbaut,Anglais -14,13,2,2024,1,4,Belaggoune,Anglais -14,13,2,2024,1,15,Chevalier,Physique -14,13,2,2024,1,5,Chevalier,Physique -17,13,2,2024,1,7,Colin,Physique -17,13,2,2024,1,13,Colin,Physique +14,13,2,2024,1,0,none,none +14,13,2,2024,1,5,Mullaert,Maths +14,13,2,2024,1,0,none,none +17,13,2,2024,1,1,Chevalier,Physique +17,13,2,2024,1,7,Chevalier,Physique 18,13,2,2024,1,7,Rapin,Maths -13,14,2,2024,1,12,Carpintero,Maths -14,14,2,2024,1,6,Le_Gouriellec,Anglais -14,14,2,2024,1,8,Bouverot,Maths -14,14,2,2024,1,1,Carpintero,Maths -14,14,2,2024,1,3,Boully,Maths -14,14,2,2024,2,7,Colleur_Dinfo,Info +13,14,2,2024,1,8,Carpintero,Maths +14,14,2,2024,1,3,Bouverot,Maths +14,14,2,2024,1,0,none,none +14,14,2,2024,1,1,Boully,Maths +14,14,2,2024,1,12,Carpintero,Maths +14,14,2,2024,2,15,Colleur_Dinfo,Info 15,14,2,2024,1,4,Boully,Maths 15,14,2,2024,1,9,Bouverot,Maths 15,14,2,2024,1,0,none,none 16,14,2,2024,1,0,none,none -16,14,2,2024,2,15,Colleur_Dinfo,Info +16,14,2,2024,2,7,Colleur_Dinfo,Info 17,14,2,2024,1,0,none,none 17,14,2,2024,1,0,none,none 18,14,2,2024,1,0,none,none @@ -61,24 +57,22 @@ hour,day,month,year,length,group,colleur,matiere 16,16,2,2024,1,0,none,none 17,16,2,2024,1,13,Oubaha,Maths 18,16,2,2024,1,15,Oubaha,Maths -12,19,2,2024,1,6,Chevalier,Physique -12,19,2,2024,1,8,Chevalier,Physique +12,19,2,2024,1,14,Chevalier,Physique 13,19,2,2024,1,15,Herbaut,Anglais -13,19,2,2024,1,5,Herbaut,Anglais 14,20,2,2024,1,1,Mullaert,Maths -14,20,2,2024,1,10,Chevalier,Physique -14,20,2,2024,1,12,Chevalier,Physique -17,20,2,2024,1,14,Colin,Physique -17,20,2,2024,1,0,none,none -18,20,2,2024,1,5,Rapin,Maths -13,21,2,2024,1,6,Carpintero,Maths -14,21,2,2024,1,7,Le_Gouriellec,Anglais -14,21,2,2024,1,1,Le_Gouriellec,Anglais -14,21,2,2024,1,4,Carpintero,Maths -14,21,2,2024,1,2,Boully,Maths +14,20,2,2024,1,0,none,none +14,20,2,2024,1,0,none,none +17,20,2,2024,1,4,Colin,Physique +17,20,2,2024,1,8,Chevalier,Physique +18,20,2,2024,1,2,Rapin,Maths +13,21,2,2024,1,4,Carpintero,Maths +14,21,2,2024,1,5,Boully,Maths +14,21,2,2024,1,8,Bouverot,Maths +14,21,2,2024,1,9,Carpintero,Maths +14,21,2,2024,1,0,none,none 14,21,2,2024,2,6,Colleur_Dinfo,Info -15,21,2,2024,1,8,Boully,Maths -15,21,2,2024,1,9,Bouverot,Maths +15,21,2,2024,1,6,Boully,Maths +15,21,2,2024,1,10,Bouverot,Maths 15,21,2,2024,1,0,none,none 16,21,2,2024,1,0,none,none 16,21,2,2024,2,14,Colleur_Dinfo,Info @@ -87,29 +81,27 @@ hour,day,month,year,length,group,colleur,matiere 18,21,2,2024,1,0,none,none 14,22,2,2024,1,0,none,none 15,22,2,2024,1,0,none,none -18,22,2,2024,1,10,Rapin,Maths +18,22,2,2024,1,12,Rapin,Maths 18,22,2,2024,1,0,none,none 16,23,2,2024,1,0,none,none -17,23,2,2024,1,12,Oubaha,Maths -18,23,2,2024,1,13,Oubaha,Maths -12,26,2,2024,1,5,Chevalier,Physique -12,26,2,2024,1,7,Chevalier,Physique +17,23,2,2024,1,13,Oubaha,Maths +18,23,2,2024,1,14,Oubaha,Maths +12,26,2,2024,1,15,Chevalier,Physique 13,26,2,2024,1,14,Herbaut,Anglais -13,26,2,2024,1,6,Herbaut,Anglais -14,27,2,2024,1,1,Chevalier,Physique -14,27,2,2024,1,15,Chevalier,Physique -14,27,2,2024,1,4,Belaggoune,Anglais -17,27,2,2024,1,3,Chevalier,Physique -17,27,2,2024,1,9,Colin,Physique -18,27,2,2024,1,3,Rapin,Maths -13,28,2,2024,1,7,Carpintero,Maths -14,28,2,2024,1,5,Carpintero,Maths -14,28,2,2024,1,1,Boully,Maths -14,28,2,2024,1,6,Bouverot,Maths -14,28,2,2024,1,8,Le_Gouriellec,Anglais +14,27,2,2024,1,14,Mullaert,Maths +14,27,2,2024,1,0,none,none +14,27,2,2024,1,0,none,none +17,27,2,2024,1,13,Colin,Physique +17,27,2,2024,1,0,none,none +18,27,2,2024,1,5,Rapin,Maths +13,28,2,2024,1,2,Carpintero,Maths +14,28,2,2024,1,7,Bouverot,Maths +14,28,2,2024,1,3,Boully,Maths +14,28,2,2024,1,1,Carpintero,Maths +14,28,2,2024,1,0,none,none 14,28,2,2024,2,5,Colleur_Dinfo,Info -15,28,2,2024,1,9,Boully,Maths -15,28,2,2024,1,10,Bouverot,Maths +15,28,2,2024,1,6,Boully,Maths +15,28,2,2024,1,9,Bouverot,Maths 15,28,2,2024,1,0,none,none 16,28,2,2024,1,0,none,none 16,28,2,2024,2,13,Colleur_Dinfo,Info @@ -118,29 +110,27 @@ hour,day,month,year,length,group,colleur,matiere 18,28,2,2024,1,0,none,none 14,29,2,2024,1,0,none,none 15,29,2,2024,1,0,none,none -18,29,2,2024,1,11,Rapin,Maths +18,29,2,2024,1,10,Rapin,Maths 18,29,2,2024,1,0,none,none 16,1,3,2024,1,0,none,none -17,1,3,2024,1,13,Oubaha,Maths -18,1,3,2024,1,14,Oubaha,Maths +17,1,3,2024,1,11,Oubaha,Maths +18,1,3,2024,1,13,Oubaha,Maths 12,4,3,2024,1,12,Chevalier,Physique -12,4,3,2024,1,6,Chevalier,Physique 13,4,3,2024,1,15,Herbaut,Anglais -13,4,3,2024,1,11,Herbaut,Anglais -14,5,3,2024,1,4,Chevalier,Physique -14,5,3,2024,1,14,Chevalier,Physique -14,5,3,2024,1,7,Mullaert,Maths -17,5,3,2024,1,0,none,none -17,5,3,2024,1,0,none,none -18,5,3,2024,1,2,Rapin,Maths -13,6,3,2024,1,8,Carpintero,Maths -14,6,3,2024,1,3,Bouverot,Maths -14,6,3,2024,1,3,Le_Gouriellec,Anglais -14,6,3,2024,1,9,Le_Gouriellec,Anglais -14,6,3,2024,1,6,Boully,Maths +14,5,3,2024,1,0,none,none +14,5,3,2024,1,0,none,none +14,5,3,2024,1,3,Mullaert,Maths +17,5,3,2024,1,2,Chevalier,Physique +17,5,3,2024,1,14,Chevalier,Physique +18,5,3,2024,1,4,Rapin,Maths +13,6,3,2024,1,6,Carpintero,Maths +14,6,3,2024,1,8,Carpintero,Maths +14,6,3,2024,1,2,Bouverot,Maths +14,6,3,2024,1,11,Boully,Maths +14,6,3,2024,1,0,none,none 14,6,3,2024,2,4,Colleur_Dinfo,Info -15,6,3,2024,1,4,Bouverot,Maths -15,6,3,2024,1,10,Boully,Maths +15,6,3,2024,1,7,Boully,Maths +15,6,3,2024,1,10,Bouverot,Maths 15,6,3,2024,1,0,none,none 16,6,3,2024,1,0,none,none 16,6,3,2024,2,12,Colleur_Dinfo,Info @@ -149,29 +139,27 @@ hour,day,month,year,length,group,colleur,matiere 18,6,3,2024,1,0,none,none 14,7,3,2024,1,0,none,none 15,7,3,2024,1,0,none,none -18,7,3,2024,1,11,Rapin,Maths +18,7,3,2024,1,12,Rapin,Maths 18,7,3,2024,1,0,none,none 16,8,3,2024,1,0,none,none -17,8,3,2024,1,12,Oubaha,Maths -18,8,3,2024,1,14,Oubaha,Maths -12,11,3,2024,1,5,Chevalier,Physique -12,11,3,2024,1,9,Chevalier,Physique +17,8,3,2024,1,14,Oubaha,Maths +18,8,3,2024,1,15,Oubaha,Maths +12,11,3,2024,1,13,Chevalier,Physique 13,11,3,2024,1,14,Herbaut,Anglais -13,11,3,2024,1,8,Herbaut,Anglais -14,12,3,2024,1,1,Mullaert,Maths -14,12,3,2024,1,11,Chevalier,Physique -14,12,3,2024,1,12,Belaggoune,Anglais -17,12,3,2024,1,15,Colin,Physique -17,12,3,2024,1,13,Chevalier,Physique -18,12,3,2024,1,3,Rapin,Maths -13,13,3,2024,1,4,Carpintero,Maths -14,13,3,2024,1,4,Le_Gouriellec,Anglais -14,13,3,2024,1,5,Carpintero,Maths -14,13,3,2024,1,7,Boully,Maths -14,13,3,2024,1,8,Bouverot,Maths +14,12,3,2024,1,5,Mullaert,Maths +14,12,3,2024,1,0,none,none +14,12,3,2024,1,0,none,none +17,12,3,2024,1,15,Chevalier,Physique +17,12,3,2024,1,0,none,none +18,12,3,2024,1,7,Rapin,Maths +13,13,3,2024,1,8,Carpintero,Maths +14,13,3,2024,1,9,Carpintero,Maths +14,13,3,2024,1,11,Boully,Maths +14,13,3,2024,1,1,Bouverot,Maths +14,13,3,2024,1,0,none,none 14,13,3,2024,2,3,Colleur_Dinfo,Info -15,13,3,2024,1,9,Bouverot,Maths -15,13,3,2024,1,11,Boully,Maths +15,13,3,2024,1,3,Bouverot,Maths +15,13,3,2024,1,4,Boully,Maths 15,13,3,2024,1,0,none,none 16,13,3,2024,1,0,none,none 16,13,3,2024,2,11,Colleur_Dinfo,Info