From ec09ea2330db27f26897c2258e85128c897a2f8a Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 12 Apr 2024 20:33:31 +0200 Subject: [PATCH] complete rewrite of generation fct to be much faster and cleaner --- algorithm.c | 487 +++++++++++++++++++++++++++++++++++++++----------- main.c | 40 +++-- some_data.txt | 67 ------- structure.c | 1 + 4 files changed, 408 insertions(+), 187 deletions(-) diff --git a/algorithm.c b/algorithm.c index 8a21a7c..8d403b3 100644 --- a/algorithm.c +++ b/algorithm.c @@ -68,6 +68,7 @@ bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end) { int end_id = get_next_friday(edt, len_edt, end); // index of first date that is later than end if(end_id == -1) { + stats[4]++; return true; } @@ -104,13 +105,14 @@ bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end) { int pc = 0; char has_to_be = 'n'; // 'n' = not set, 'a' = AGL and 'p' = PC for(int i = end_id-1; i >= 0; i--) { + //for(int i = -1; i >= 0; i--) { if(i != end_id-1 && (i == 0 || (date_dist(edt[0].date, edt[i].date)%7 == 4 && date_dist(edt[0].date, edt[i+1].date)%7 != 4))) { //printf("Checking AGL/PC...\n"); // currently pointed date is the last friday of the week // since we are going down, friday <==> reset variables and check for conflicts if(agl + pc != 1) { if(debug) { - printf("Missing english or physics colle at index %d for group %d (found %d)\n", i, grp, agl+pc); + printf("Invalid number of english/physics colle at index %d for group %d (found %d)\n", i, grp, agl+pc); } stats[1]++; return false; @@ -118,13 +120,13 @@ bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end) { if(debug) { printf("Wrong number of physics colle at index %d for group %d\n", i, grp); } - //stats[1]++; + stats[1]++; return false; - } else if(has_to_be == 'a' && agl != 1) { + } else if(has_to_be == 'a' && agl != 1) { if(debug) { printf("Wrong number of english colle at index %d for group %d\n", i, grp); } - //stats[1]++; + stats[1]++; return false; } if(has_to_be == 'n') { @@ -150,35 +152,74 @@ bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end) { // 2) Math colles + // version 2 + + /* int math = 0; - int last_no_math = -1; - for(int i = end_id-1; i >= 0; i--) { + int abort_2 = 0; + for(int i = end_id-1; i >= 0+abort_2*(end_id); i--) { if(i == 0 || (date_dist(edt[0].date, edt[i].date)%7 == 4 && date_dist(edt[0].date, edt[i+1].date)%7 != 4)) { - if(math != 0 && math != 1) { - if(debug) { - printf("Invalid number of math colles at index %d for group %d\n", i, grp); - } - stats[2]++; - return false; - } else if(math == 0) { - if(last_no_math != -1 && last_no_math != 3) { + abort_2 = 1; + if(n_colles[grp-1] == 3) { + if(math != 0) { if(debug) { - printf("Invalid rotation of math colles at index %d for group %d\n", i, grp); + printf("Invalid number of math colles at index %d for group %d (found %d)\n", i, grp, math); } stats[2]++; return false; } - last_no_math = 0; - } else if(last_no_math > 3) { + } else { + if(math != 1) { + if(debug) { + printf("Invalid number of math colles at index %d for group %d (found %d)\n", i, grp, math); + } + stats[2]++; + return false; + } + } + } + if(edt[i].group == grp && edt[i].mat == MATH) { + math += 1; + } + }*/ + + int t = 0; + int math = 0; + int last_no_math = -1; + bool not_seen_empty = true; + for(int i = end_id-1; i >= 0; i--) { + if(i == 0 || (date_dist(edt[0].date, edt[i].date)%7 == 4 && date_dist(edt[0].date, edt[i+1].date)%7 != 4)) { + //if(i == 0 || i%16 == 15) { + t++; + if(math != 1 && math != 0) { if(debug) { - printf("Too many math colles at index %d for group %d\n", i, grp); + printf("Invalid number of math colles at index %d for group %d (found %d)\n", i, grp, math); } stats[2]++; return false; - } else { - if(last_no_math != -1) { - last_no_math += 1; + } else if(math == 0) { + if(!not_seen_empty && last_no_math != -1 && last_no_math != 3) { + if(debug) { + printf("Invalid rotation of math colles at index %d for group %d\n", i, grp); + } + //rintf("--> %d <--\n", t); + stats[2]++; + return false; } + last_no_math = 0; + not_seen_empty = false; + } else { + if(last_no_math > 3) { + if(debug) { + printf("Too many math colles at index %d for group %d\n", i, grp); + } + stats[2]++; + return false; + } + if(last_no_math == -1) { + last_no_math++; + } + last_no_math++; } math = 0; } @@ -186,22 +227,30 @@ bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end) { math += 1; } } + if(last_no_math > 3) { + if(debug) { + printf("Too many math colles at index %d for group %d\n", 0, grp); + } + stats[2]++; + return false; + } // 3) Count - int n_colles = 0; + int ncolles = 0; for(int i = end_id-1; i >= 0; i--) { if(i == 0 || (date_dist(edt[0].date, edt[i].date)%7 == 4 && date_dist(edt[0].date, edt[i+1].date)%7 != 4)) { - if(n_colles != 1 && n_colles != 2) { + if(ncolles != 1 && ncolles != 2) { + //if(ncolles != n_colles[grp-1]) { if(debug) { - printf("Invalid number of colles at index %d for group %d (found %d)\n", i, grp, n_colles); + printf("Invalid number of colles at index %d for group %d (found %d)\n", i, grp, ncolles); } stats[3]++; return false; } - n_colles= 0; + ncolles= 0; } if(edt[i].group == grp) { - n_colles++; + ncolles++; } } @@ -372,7 +421,7 @@ int heuristique_MP2I(creneau* edt,int len_edt, int grp, date end) { // typedef struct colleur {char* name; int namelen; topic mat; date* disp; int n_disp;} colleur; colleur* get_colleurs(colleur* cl, int len_cl, date d, int* how_many) { - colleur* res = malloc(sizeof(colleur)*20); // max. 3 colles per creneau + colleur* res = malloc(sizeof(colleur)*30); // max. 3 colles per creneau //printf("X\n"); int ptr = 0; //printf("[]\n"); @@ -380,7 +429,7 @@ colleur* get_colleurs(colleur* cl, int len_cl, date d, int* how_many) { for(int j = 0; j < cl[i].n_disp; j++) { if(is_equal_date(cl[i].disp[j], d)) { //printf("%s\n", cl[i].name); - if(ptr >= 20) { + if(ptr >= 30) { printf("warning : too many colleurs detected for a creneau\n"); *how_many = 0; return res; @@ -395,6 +444,24 @@ colleur* get_colleurs(colleur* cl, int len_cl, date d, int* how_many) { return res; } +void swap(int* arr, int i, int j) { + if(i != j) { + arr[i] += arr[j]; + arr[j] = arr[i] - arr[j]; + arr[i] -= arr[j]; + } +} + +void generate_random_perm(int* arr, int len) { + // generate a random perm of int between 0 and len-1 + for(int i = 0; i < len; i++) { + arr[i] = i; + } + for(int i = 0; i < len; i++) { + swap(arr, i, rand()%len); + } +} + void print_arr(int* arr, int len) { printf("["); for(int i = 0; i < len; i++) { @@ -403,10 +470,27 @@ void print_arr(int* arr, int len) { printf("]\n"); } +/* +void shiftright_ncolles(int n_grps) { + for(int i = 0; i < n_grps; i++) { + n_colles[i] = (n_colles[i]+1)%4; + } +} + +void shiftleft_ncolles(int n_grps) { + for(int i = 0; i < n_grps; i++) { + if(n_colles[i] == 0) { + n_colles[i] = 3; + } else { + n_colles[i]--; + } + } +} + void aux(int* abort, int* weeks_len, creneau* edt, int len_edt, colleur* chads, int n_chads, int n_groups, int n_weeks, int current_grp, int current_week, int current_offset, int starting_group, bool is_first) { // append colles for specified week and group //usleep(100000); - print_arr(stats, 5); + print_arr(stats, 10); if(current_week > n_weeks) { printf("Done\n"); *abort = true; @@ -417,8 +501,12 @@ void aux(int* abort, int* weeks_len, creneau* edt, int len_edt, colleur* chads, colleur* available_j = malloc(sizeof(colleur)); int picked_i = 0; int picked_j = 0; + bool pass_i; + bool pass_j; bool is_valid_i = false; bool is_valid_j = false; + int* perms_i = malloc(sizeof(int)*30); + int* perms_j = malloc(sizeof(int)*30); int succ = current_grp+1; if(succ == n_groups+1) { succ = 1; @@ -438,97 +526,122 @@ void aux(int* abort, int* weeks_len, creneau* edt, int len_edt, colleur* chads, //get_colleurs(colleur* cl, int len_cl, date d, int* how_many) { available_i = get_colleurs(chads, n_chads, edt[current_offset+i].date, &n_available_i); if(n_available_i != 0) { - // choose someone available - picked_i = rand()%n_available_i; + generate_random_perm(perms_i, n_available_i); + for(int ii = 0; ii < n_available_i; ii++) { + picked_i = perms_i[ii]; - // add the 1st colle - edt[current_offset+i].group = current_grp; - str_copy(available_i[picked_i].name, available_i[picked_i].namelen, edt[current_offset+i].name); - edt[current_offset+i].mat = available_i[picked_i].mat; - - is_valid_i = is_allowed_MP2I(edt, len_edt, current_grp, edt[current_offset+i].date); - } else { - is_valid_i = false; - } - - if(is_valid_i && *abort == 0) { - // /!\ DONT FORGET THE RECURSIVE CALL HERE (in case a group has only 1 colle that week) - //aux(weeks_len, edt, chads, n_chads, n_groups, n_weeks, current_grp, current_week, current_offset, starting_group, is_first); - - if(succ == starting_group) { - //printf("---------------------------------------------------------\n"); - aux(abort, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, current_grp, current_week+1, current_offset+weeks_len[current_week-1], current_grp, true); - } else { - if(current_grp == n_groups) { - aux(abort, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, 1, current_week, current_offset, starting_group, false); + if(n_colles[current_grp-1] == 3) { + pass_i = available_i[picked_i].mat == PHYSICS || available_i[picked_i].mat == ENGLISH; } else { - aux(abort, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, current_grp+1, current_week, current_offset, starting_group, is_first); + pass_i = available_i[picked_i].mat == MATH; } - } - } - - for(int j = 0; j < (1-(*abort))*weeks_len[current_week-1]; j++) { // loop for 1st colle - //printf("j(%d -> %d)j\n", current_grp, current_offset+j); - //printf(" "); - //printf("[%d]\n", current_offset+i); - //printf("I\n"); - if(edt[current_offset+j].group == 0) { - free(available_j); - //get_colleurs(colleur* cl, int len_cl, date d, int* how_many) { - available_j = get_colleurs(chads, n_chads, edt[current_offset+j].date, &n_available_j); - if(n_available_j != 0) { + if(pass_i) { // choose someone available - picked_j = rand()%n_available_j; + //picked_i = rand()%n_available_i; // add the 1st colle - edt[current_offset+j].group = current_grp; - str_copy(available_j[picked_j].name, available_j[picked_j].namelen, edt[current_offset+j].name); - edt[current_offset+j].mat = available_i[picked_j].mat; + edt[current_offset+i].group = current_grp; + str_copy(available_i[picked_i].name, available_i[picked_i].namelen, edt[current_offset+i].name); + edt[current_offset+i].mat = available_i[picked_i].mat; - is_valid_j = is_allowed_MP2I(edt, len_edt, current_grp, edt[current_offset+j].date); - } else { - is_valid_j = false; - } + is_valid_i = is_allowed_MP2I(edt, len_edt, current_grp, edt[current_offset+i].date, 'i'); - if(is_valid_j && *abort == 0) { - // THE RECURSIVE CALL - //aux(weeks_len, edt, chads, n_chads, n_groups, n_weeks, current_grp, current_week, current_offset, starting_group, is_first); - - if(succ == starting_group) { - //printf("---------------------------------------------------------\n"); - aux(abort, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, current_grp, current_week+1, current_offset+weeks_len[current_week-1], current_grp, true); - } else { - if(current_grp == n_groups) { - aux(abort, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, 1, current_week, current_offset, starting_group, false); + if(is_valid_i && *abort == 0) { + // /!\ DONT FORGET THE RECURSIVE CALL HERE (in case a group has only 1 colle that week) + //aux(weeks_len, edt, chads, n_chads, n_groups, n_weeks, current_grp, current_week, current_offset, starting_group, is_first); + + if(succ == starting_group) { + //printf("---------------------------------------------------------\n"); + shiftright_ncolles(n_groups); + aux(abort, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, current_grp, current_week+1, current_offset+weeks_len[current_week-1], current_grp, true); + shiftleft_ncolles(n_groups); } else { - aux(abort, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, current_grp+1, current_week, current_offset, starting_group, is_first); + if(current_grp == n_groups) { + aux(abort, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, 1, current_week, current_offset, starting_group, false); + } else { + aux(abort, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, current_grp+1, current_week, current_offset, starting_group, is_first); + } + } + } else { + stats[8]++; + } + + for(int j = 0; j < (1-(*abort))*weeks_len[current_week-1]*(n_colles[current_grp-1] != 3); j++) { // loop for 2nd colle + //printf("j(%d -> %d)j\n", current_grp, current_offset+j); + //printf(" "); + //printf("[%d]\n", current_offset+i); + //printf("I\n"); + if(edt[current_offset+j].group == 0) { + free(available_j); + //get_colleurs(colleur* cl, int len_cl, date d, int* how_many) { + available_j = get_colleurs(chads, n_chads, edt[current_offset+j].date, &n_available_j); + if(n_available_j != 0) { + generate_random_perm(perms_j, n_available_j); + for(int jj = 0; jj < n_available_j; jj++) { + // choose someone available + //picked_j = rand()%n_available_j; + picked_j = perms_j[jj]; + + if(available_j[picked_j].mat != MATH) { + + // add the 1st colle + edt[current_offset+j].group = current_grp; + str_copy(available_j[picked_j].name, available_j[picked_j].namelen, edt[current_offset+j].name); + edt[current_offset+j].mat = available_i[picked_j].mat; + + is_valid_j = is_allowed_MP2I(edt, len_edt, current_grp, edt[current_offset+j].date, 'j'); + + if(is_valid_j && *abort == 0) { + // THE RECURSIVE CALL + //aux(weeks_len, edt, chads, n_chads, n_groups, n_weeks, current_grp, current_week, current_offset, starting_group, is_first); + + if(succ == starting_group) { + //printf("---------------------------------------------------------\n"); + shiftright_ncolles(n_groups); + aux(abort, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, current_grp, current_week+1, current_offset+weeks_len[current_week-1], current_grp, true); + shiftleft_ncolles(n_groups); + } else { + if(current_grp == n_groups) { + aux(abort, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, 1, current_week, current_offset, starting_group, false); + } else { + aux(abort, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, current_grp+1, current_week, current_offset, starting_group, is_first); + } + } + } else { + stats[9]++; + } + + if(*abort == 0) { + // remove 2nd colle in case it's blocked + edt[current_offset+j].group = 0; + edt[current_offset+j].name[0] = '\0'; + edt[current_offset+j].mat = NOTHING; + } + } + } + } else { + //printf("Occupied 2nd colle\n"); + } } } - } - if(n_available_j != 0 && *abort == 0) { - // remove 2nd colle in case it's blocked - edt[current_offset+j].group = 0; - edt[current_offset+j].name[0] = '\0'; - edt[current_offset+j].mat = NOTHING; + if(*abort == 0) { + // remove 1st colle in case it's blocked + edt[current_offset+i].group = 0; + edt[current_offset+i].name[0] = '\0'; + edt[current_offset+i].mat = NOTHING; + } } - } else { - //printf("Occupied 2nd colle\n"); } } - - if(n_available_i != 0 && *abort == 0) { - // remove 1st colle in case it's blocked - edt[current_offset+i].group = 0; - edt[current_offset+i].name[0] = '\0'; - edt[current_offset+i].mat = NOTHING; - } } else { //printf("Occupied 1st colle\n"); } } free(available_i); free(available_j); + free(perms_i); + free(perms_j); } //printf("[terminated : group %d with week %d]\n", current_grp, current_week); } @@ -551,25 +664,195 @@ void generate_colles_v1(creneau* edt, int len_edt, colleur* chads, int n_chads, print_arr(weeks_len, n_weeks); - stats = malloc(sizeof(int)*5); - for(int i = 0; i < 5; i++) { + stats = malloc(sizeof(int)*10); + for(int i = 0; i < 10; i++) { stats[i] = 0; } + n_colles = malloc(sizeof(int)*n_groups); + for(int i = 0; i < n_groups; i++) { + n_colles[i] = i%4; + } + // invariant : if n_colles[grp-1] = 3 then grp has only 1 colle that week + + + //print_arr(n_colles, n_groups); + //assert(0); + printf("Entering aux\n"); int abort = 0; int* ptrbool = &abort; aux(ptrbool, weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, 1, 1, 0, 1, true); //aux(weeks_len, edt, len_edt, chads, n_chads, n_groups, n_weeks, 1, current_week, current_offset, starting_group, false); + system("clear"); print_one_week(edt, len_edt, edt[0].date); + printf("\n"); print_one_week(edt, len_edt, edt[16].date); + printf("\n"); + print_one_week(edt, len_edt, edt[32].date); + printf("\n"); + print_one_week(edt, len_edt, edt[48].date); free(weeks_len); free(stats); + free(n_colles); printf("It's over\n"); } +*/ + +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; + edt[id_edt].mat = chads[id_chad].mat; +} + +void remove_colle(creneau* edt, int id_edt) { + edt[id_edt].group = 0; + str_copy("", 0, edt[id_edt].name); + edt[id_edt].namelen = 0; + edt[id_edt].mat = NOTHING; +} + +bool is_overlap(creneau* edt, int len_edt, int id) { + int k = 1; + while(id+k < len_edt && is_equal_date(edt[id].date, edt[id+k].date)) { + if(str_equal(edt[id].name, edt[id+k].name)) { + return true; + } + k++; + } + k = 1; + while(id-k >= 0 && is_equal_date(edt[id].date, edt[id-k].date)) { + if(str_equal(edt[id].name, edt[id-k].name)) { + return true; + } + k++; + } + return false; +} + +void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, colleur* chads, int len_chads, int n_weeks, int grp, topic start_rotation, int mth) { + topic rotation = start_rotation; + int math = mth; + + int r; + int k = 0; //offset + int halt = 0; + bool found; + + int remaining_to_add = 0; + colleur* dudes = malloc(sizeof(colleur)*2); + int len_dudes = 0; + + int* perm = malloc(sizeof(int)*30); + int len_perm = 0; + + for(int week = 0; week < n_weeks; week++) { + + // update what colles to add + if(math == 0) { + math = 3; + } else { + remaining_to_add++; + math--; + } + remaining_to_add++; + if(rotation == ENGLISH) { + rotation = PHYSICS; + } else { + rotation = ENGLISH; + } + + r = rand()%16; + halt = 0; + + found = false; + + while(remaining_to_add == 2) { + if(edt[k+r%16].group == 0) { + free(dudes); + dudes = get_colleurs(chads, len_chads, edt[k+r%16].date, &len_dudes); + len_perm = len_dudes; + if(len_dudes != 0) { + generate_random_perm(perm, len_perm); + for(int dude = 0; dude < len_perm*(1-found); dude++) { + if(chads[perm[dude]].mat == MATH) { + add_colle(edt, chads, grp, k+r%16, perm[dude]); + found = true; + remaining_to_add--; + } + } + } + } + if(!found && halt > weeks_len[week]) { + remaining_to_add--; + printf("Warning : skipping math colle for week %d and group %d\n", week+1, grp); + } + r++; + halt++; + } + r = rand()%16; + found = false; + halt = 0; + + while(remaining_to_add == 1) { + if(edt[k+r%16].group == 0) { + dudes = get_colleurs(chads, len_chads, edt[k+r%16].date, &len_dudes); + len_perm = len_dudes; + if(len_dudes != 0) { + generate_random_perm(perm, len_perm); + for(int dude = 0; dude < len_perm*(1-found); dude++) { + if(chads[perm[dude]].mat == rotation) { + add_colle(edt, chads, grp, k+r%16, perm[dude]); + found = true; + remaining_to_add--; + } + } + } + } + if(!found && halt > weeks_len[week]) { + remaining_to_add--; + printf("Warning : skipping secondary colle for week %d and group %d\n", week+1, grp); + } + r++; + halt++; + } + + k += weeks_len[week]; + remaining_to_add = 0; + } + free(dudes); +} + + +void aux_2(creneau* edt, int len_edt, colleur* chads, int len_chads, int n_groups, int n_weeks) { + int* weeks_len = malloc(sizeof(int)*n_weeks); + int ptr = 0; + int current = 1; + for(int k = 1; k < len_edt; k++) { + if(date_dist(edt[k-1].date, edt[k].date) > 1 || k == len_edt-1) { + weeks_len[ptr] = current + (k == len_edt - 1); + current = 0; + ptr++; + } + current++; + } + + for(int i = 0; i < n_groups; i++) { + add_colles_for_group_MP2I(weeks_len, edt, chads, len_chads, n_weeks, i+1, (topic)(2+i%2), i%4); + } + + print_one_week(edt, len_edt, edt[0].date); + printf("\n"); + print_one_week(edt, len_edt, edt[16].date); + printf("\n"); + print_one_week(edt, len_edt, edt[32].date); + printf("\n"); + print_one_week(edt, len_edt, edt[48].date); +} @@ -582,5 +865,3 @@ void generate_colles_v1(creneau* edt, int len_edt, colleur* chads, int n_chads, - - diff --git a/main.c b/main.c index 17a481d..7b3358c 100644 --- a/main.c +++ b/main.c @@ -9,32 +9,38 @@ int main() { creneau* edt = import_creneaux("file.txt", 64); int len_creneau = 64; - colleur* dudes = import_colleurs("some_data.txt", 13, 64); - int n_colleurs = 13; + colleur* dudes = import_colleurs("some_data.txt", 12, 64); + int n_colleurs = 12; //printf("%d %d %d %d\n", edt[10].date.hour, edt[10].date.day, edt[10].date.month, edt[10].date.year); //printf("%d\n", date_dist(d1, d1)); //printf("%d %d %d %d\n", edt[70].date.hour, edt[70].date.day, edt[70].date.month, edt[70].date.year); //print_one_week(rend, edt, 112, d1); - /* + + /*edt[8].group = 1; + edt[8].mat = MATH; edt[9].group = 1; - edt[9].mat = INFO; - edt[9].name = "Rapin"; - edt[20].group = 1; - edt[20].mat = PHYSICS; - edt[13].group = 1; - edt[13].mat = ENGLISH; - edt[13].name = "Rapin"; - edt[21].group = 1; - edt[21].mat = MATH; - if(is_allowed_MP2I(edt,len_creneau, 1, d1)) { - printf("Score : %d\n", heuristique_MP2I(edt, 112, 1, d1)); - } - */ + edt[9].mat = PHYSICS; + edt[23].group = 1; + edt[23].mat = ENGLISH; + edt[41].group = 1; + edt[41].mat = PHYSICS; + edt[57].group = 1; + edt[57].mat = ENGLISH; + edt[58].group = 1; + edt[58].mat = MATH; + if(is_allowed_MP2I(edt,len_creneau, 1, edt[60].date, 'i')) { + printf("True\n"); + }*/ + // {char* name; int namelen; topic mat; date* disp; int n_disp;} colleur; - generate_colles_v1(edt, len_creneau, dudes, n_colleurs, 8, 4); + /*int* a = malloc(sizeof(int)*10); + generate_random_perm(a, 10); + print_arr(a, 10);*/ + aux_2(edt, len_creneau, dudes, n_colleurs, 9, 4); + //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/some_data.txt b/some_data.txt index f0d582b..9823d95 100644 --- a/some_data.txt +++ b/some_data.txt @@ -802,71 +802,4 @@ ENGLISH 17 1 3 2024 18 1 3 2024 + -Jospin -INFO -12 5 2 2024 -13 5 2 2024 -18 5 2 2024 -17 6 2 2024 -18 6 2 2024 -14 7 2 2024 -15 7 2 2024 -16 7 2 2024 -17 7 2 2024 -18 7 2 2024 -14 8 2 2024 -15 8 2 2024 -18 8 2 2024 -16 9 2 2024 -17 9 2 2024 -18 9 2 2024 -12 12 2 2024 -13 12 2 2024 -18 12 2 2024 -17 13 2 2024 -18 13 2 2024 -14 14 2 2024 -15 14 2 2024 -16 14 2 2024 -17 14 2 2024 -18 14 2 2024 -14 15 2 2024 -15 15 2 2024 -18 15 2 2024 -16 16 2 2024 -17 16 2 2024 -18 16 2 2024 -12 19 2 2024 -13 19 2 2024 -18 19 2 2024 -17 20 2 2024 -18 20 2 2024 -14 21 2 2024 -15 21 2 2024 -16 21 2 2024 -17 21 2 2024 -18 21 2 2024 -14 22 2 2024 -15 22 2 2024 -18 22 2 2024 -16 23 2 2024 -17 23 2 2024 -18 23 2 2024 -12 26 2 2024 -13 26 2 2024 -18 26 2 2024 -17 27 2 2024 -18 27 2 2024 -14 28 2 2024 -15 28 2 2024 -16 28 2 2024 -17 28 2 2024 -18 28 2 2024 -14 29 2 2024 -15 29 2 2024 -18 29 2 2024 -16 1 3 2024 -17 1 3 2024 -18 1 3 2024 -+ $ \ No newline at end of file diff --git a/structure.c b/structure.c index c0276d8..96e16f8 100644 --- a/structure.c +++ b/structure.c @@ -25,6 +25,7 @@ typedef struct array {int* a; int len; int memlen;} array; //static int width = 1200; //static int height = 900; int* stats; +int* n_colles; int date_dist(date d1, date d2) { /* returns distance between d1 and d2 in days if d2 is sooner than d1, it will return -1 */