From 228e1e30ddaee36e68c8d301e225aeadfa05c608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Mogu=C3=A9rou?= Date: Wed, 24 Apr 2024 14:33:07 +0200 Subject: [PATCH] Fixed collsions --- src/algorithm.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/algorithm.c b/src/algorithm.c index 294ef40..ba9ac76 100644 --- a/src/algorithm.c +++ b/src/algorithm.c @@ -1238,7 +1238,7 @@ int** occurencies(creneau* edt, int len_edt, colleur* dudes, int n_groups, int n printf("\n"); // caused a minor panic */ bool halt = false; - for(int it = 0; it < 3*(1-is_debug); it++) { + for(int it = 0; it < 5*(1-is_debug); it++) { for(int grp = 0; grp < n_groups; grp++) { for(int dud = 0; dud < n_colleurs; dud++) { if(res[grp][dud] > max_occ && get_mat_from_id(dudes, n_colleurs, dud) != INFO) { @@ -1266,11 +1266,36 @@ int** occurencies(creneau* edt, int len_edt, colleur* dudes, int n_groups, int n edt[id_src].group += edt[id_dest].group; edt[id_dest].group = edt[id_src].group - edt[id_dest].group; edt[id_src].group -= edt[id_dest].group; + + if(is_overlap_creneau(edt, len_edt, id_src, grp2+1)) { + res[grp][dud] -= 1; + res[grp2][dud2] -= 1; + res[grp2][dud] += 1; + res[grp][dud2] += 1; + + //printf("%d %d | ", edt[id_src].group, edt[id_dest].group); + edt[id_src].group += edt[id_dest].group; + edt[id_dest].group = edt[id_src].group - edt[id_dest].group; + edt[id_src].group -= edt[id_dest].group; + } else if(is_overlap_creneau(edt, len_edt, id_dest, grp+1)) { + res[grp][dud] -= 1; + res[grp2][dud2] -= 1; + res[grp2][dud] += 1; + res[grp][dud2] += 1; + + //printf("%d %d | ", edt[id_src].group, edt[id_dest].group); + edt[id_src].group += edt[id_dest].group; + edt[id_dest].group = edt[id_src].group - edt[id_dest].group; + edt[id_src].group -= edt[id_dest].group; + } else { + halt = true; + dud--; + } + //printf("%d %d\n", edt[id_src].group, edt[id_dest].group); //printf("[%d %d - %d] <==> [%d %d - %d]\n", grp+1, id_src, edt[id_src].group, grp2+1, id_dest, edt[id_dest].group); - halt = true; - dud--; + } } } @@ -1348,6 +1373,7 @@ void aux_2(creneau* edt, int len_edt, colleur* chads, int len_chads, int n_group //add_colles_for_group_MP2I(weeks_len, edt, len_edt, chads, len_chads, n_weeks, i+1, (topic)(2+i%2), i%4, i%6, &skipped); add_colles_for_group_MP2I(weeks_len, edt, len_edt, chads, len_chads, n_weeks, i+1, (topic)(2+i%2), i%3, i%info_app, &skipped, math_halt, info_app); } + //int** temp_data = generate_matrix(n_groups, len_chads, 0); int** temp_data = occurencies(edt, len_edt, chads, n_groups, len_chads, n_weeks, false); for(int i = 0; i < n_groups; i++) { //printf("Score for group %d : %d\n", i+1, score(edt, len_edt, i+1));