colles now prioritize creneaux with restrictions + added configs for MPI/*.
This commit is contained in:
parent
4597723d70
commit
bbcdfe259c
|
@ -56,4 +56,5 @@ obj/
|
|||
bin/
|
||||
output.csv
|
||||
*.log
|
||||
output-S3.csv
|
||||
output-S3.csv
|
||||
output-MPI.csv
|
|
@ -0,0 +1,72 @@
|
|||
Bouverot
|
||||
MATH
|
||||
18 16 9 2024
|
||||
8 18 9 2024
|
||||
+
|
||||
Sabban
|
||||
MATH
|
||||
14 18 9 2024
|
||||
+
|
||||
Giral-Martinez
|
||||
MATH
|
||||
17 18 9 2024
|
||||
18 18 9 2024
|
||||
+
|
||||
Pelletier
|
||||
MATH
|
||||
17 17 9 2024
|
||||
18 17 9 2024
|
||||
+
|
||||
Riveline
|
||||
MATH
|
||||
17 17 9 2024
|
||||
18 17 9 2024
|
||||
+
|
||||
Dailly
|
||||
MATH
|
||||
17 17 9 2024
|
||||
18 17 9 2024
|
||||
+
|
||||
Thiébaud
|
||||
PHYSICS
|
||||
16 20 9 2024
|
||||
+
|
||||
Pignard
|
||||
PHYSICS
|
||||
17 18 9 2024
|
||||
18 18 9 2024
|
||||
+
|
||||
Creuset
|
||||
PHYSICS
|
||||
14 19 9 2024
|
||||
15 19 9 2024
|
||||
+
|
||||
Chevalier
|
||||
PHYSICS
|
||||
17 17 9 2024
|
||||
+
|
||||
Robin
|
||||
PHYSICS
|
||||
17 18 9 2024
|
||||
+
|
||||
Montarou
|
||||
ENGLISH
|
||||
16 18 9 2024
|
||||
17 18 9 2024
|
||||
18 18 9 2024
|
||||
+
|
||||
Graff
|
||||
ENGLISH
|
||||
16 18 9 2024
|
||||
17 18 9 2024
|
||||
18 18 9 2024
|
||||
+
|
||||
LeLouarne
|
||||
ENGLISH
|
||||
18 18 9 2024
|
||||
+
|
||||
Halfon
|
||||
INFO
|
||||
14 19 9 2024
|
||||
+
|
||||
$
|
|
@ -0,0 +1,27 @@
|
|||
18 16 9 2024
|
||||
17 17 9 2024
|
||||
17 17 9 2024
|
||||
17 17 9 2024
|
||||
17 17 9 2024
|
||||
18 17 9 2024
|
||||
18 17 9 2024
|
||||
18 17 9 2024
|
||||
8 18 9 2024
|
||||
14 18 9 2024
|
||||
16 18 9 2024
|
||||
16 18 9 2024
|
||||
17 18 9 2024
|
||||
17 18 9 2024
|
||||
17 18 9 2024
|
||||
17 18 9 2024
|
||||
17 18 9 2024
|
||||
18 18 9 2024
|
||||
18 18 9 2024
|
||||
18 18 9 2024
|
||||
18 18 9 2024
|
||||
18 18 9 2024
|
||||
14 19 9 2024
|
||||
14 19 9 2024+
|
||||
15 19 9 2024
|
||||
16 20 9 2024
|
||||
$
|
7
Makefile
7
Makefile
|
@ -6,10 +6,13 @@ LFLAGS=
|
|||
all: bin/colloscope
|
||||
|
||||
test: bin/colloscope
|
||||
bin/colloscope -v S3-creneaux.txt 31 S3-colleurs.txt 16 7 15 1000 output-S3.csv 3 6
|
||||
bin/colloscope -v S3-creneaux.txt 31 S3-colleurs.txt 16 7 15 3000 output-S3.csv 3 6
|
||||
|
||||
mpi-all: bin/colloscope
|
||||
bin/colloscope -v MPI-creneaux.txt 26 MPI-colleurs.txt 15 12 14 10000 output-MPI.csv 3 999999
|
||||
|
||||
mem: bin/
|
||||
valgrind --leak-check=full ./bin/colloscope -v S3-creneaux.txt 31 S3-colleurs.txt 16 7 15 100 output-S3.csv 3 6
|
||||
valgrind --leak-check=full ./bin/colloscope -v S3-creneaux.txt 21 S3-colleurs.txt 16 7 15 100 output-S3.csv 3 6
|
||||
|
||||
OBJECTS = obj/structure.o obj/algorithm.o obj/display.o obj/logger.o obj/main.o
|
||||
bin/colloscope: $(OBJECTS)
|
||||
|
|
100
S3-tds.txt
100
S3-tds.txt
|
@ -1,29 +1,101 @@
|
|||
14 23 4 2024
|
||||
T-3-1
|
||||
14 18 9 2024
|
||||
T-2-2
|
||||
|
||||
1
|
||||
9
|
||||
10
|
||||
13
|
||||
2
|
||||
3
|
||||
+
|
||||
12 22 4 2024
|
||||
T-1-1
|
||||
14 18 9 2024
|
||||
T-4-3
|
||||
|
||||
1
|
||||
2
|
||||
3
|
||||
5
|
||||
7
|
||||
8
|
||||
11
|
||||
+
|
||||
14 24 4 2024
|
||||
T-1-1
|
||||
14 18 9 2024
|
||||
T-4-1
|
||||
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
6
|
||||
12
|
||||
14
|
||||
+
|
||||
13 22 4 2024
|
||||
T-1-1
|
||||
14 19 9 2024
|
||||
T-2-1
|
||||
|
||||
1
|
||||
9
|
||||
10
|
||||
13
|
||||
2
|
||||
+
|
||||
14 19 9 2024
|
||||
T-4-2
|
||||
|
||||
3
|
||||
5
|
||||
7
|
||||
8
|
||||
11
|
||||
+
|
||||
14 19 9 2024
|
||||
T-4-4
|
||||
|
||||
4
|
||||
6
|
||||
12
|
||||
14
|
||||
+
|
||||
15 19 9 2024
|
||||
T-2-1
|
||||
|
||||
1
|
||||
9
|
||||
10
|
||||
13
|
||||
2
|
||||
+
|
||||
15 19 9 2024
|
||||
T-4-2
|
||||
|
||||
3
|
||||
5
|
||||
7
|
||||
8
|
||||
11
|
||||
+
|
||||
15 19 9 2024
|
||||
T-4-4
|
||||
|
||||
4
|
||||
6
|
||||
12
|
||||
14
|
||||
+
|
||||
14 18 9 2024
|
||||
T-2-2
|
||||
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
+
|
||||
14 18 9 2024
|
||||
T-2-1
|
||||
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
+
|
||||
$
|
|
@ -192,6 +192,9 @@ int free_math_space(creneau* edt, int len_edt, int id) {
|
|||
return howmany;
|
||||
}
|
||||
|
||||
static int* perm0 ;
|
||||
static int perm0len ;
|
||||
|
||||
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, int* skip_count, int mat_halt, int info_app) {
|
||||
topic rotation = start_rotation; // physics/english rotation
|
||||
int math = mth; // math (3/4)
|
||||
|
@ -215,6 +218,8 @@ void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleu
|
|||
int math_dude = 0; // length of colleur*
|
||||
int weeklen;
|
||||
|
||||
bool is_searching_in_blacklisted = true ;
|
||||
|
||||
bool normal_skip = true;
|
||||
|
||||
for(int week = 0; week < n_weeks; week++) {
|
||||
|
@ -242,9 +247,10 @@ void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleu
|
|||
normal_skip = true;
|
||||
|
||||
info++;
|
||||
is_searching_in_blacklisted = true ;
|
||||
// info colle
|
||||
while(info >= info_app) {
|
||||
if(edt[k+r%weeklen].mat == NOTHING && edt[k+r%weeklen].length == 2) {
|
||||
if(edt[k+r%weeklen].mat == NOTHING && edt[k+r%weeklen].length == 2 && (!is_searching_in_blacklisted || edt[k+r%weeklen].blacklisted == true)) {
|
||||
// if creneau is empty
|
||||
// import all colleurs available
|
||||
colleur* dudes = get_colleurs(chads, len_chads, edt[k+r%weeklen].date, &len_dudes);
|
||||
|
@ -273,9 +279,12 @@ void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleu
|
|||
}
|
||||
free(dudes);
|
||||
}
|
||||
if(!found && halt > weeklen) {
|
||||
if(!found && halt > 2*weeklen) {
|
||||
info = 0;
|
||||
*skip_count += (1-normal_skip);
|
||||
warn("skipping info colle for group %d (week %d)", grp, week);
|
||||
} else if(halt > weeklen) {
|
||||
is_searching_in_blacklisted = false ;
|
||||
}
|
||||
r++;
|
||||
halt++;
|
||||
|
@ -285,11 +294,12 @@ void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleu
|
|||
found = false;
|
||||
halt = 0;
|
||||
normal_skip = true;
|
||||
is_searching_in_blacklisted = true ;
|
||||
|
||||
// if there is a math colle to add, enter this loop
|
||||
while(remaining_to_add == 2) {
|
||||
|
||||
if(edt[k+r%weeklen].mat == NOTHING && edt[k+r%weeklen].length == 1) {
|
||||
if(edt[k+r%weeklen].mat == NOTHING && edt[k+r%weeklen].length == 1 && (!is_searching_in_blacklisted || edt[k+r%weeklen].blacklisted == true)) {
|
||||
// if creneau is empty
|
||||
// import all colleurs available
|
||||
colleur* dudes = get_colleurs(chads, len_chads, edt[k+r%weeklen].date, &len_dudes);
|
||||
|
@ -318,12 +328,17 @@ void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleu
|
|||
}
|
||||
}
|
||||
free(perm);
|
||||
} else {
|
||||
error("No colleurs available at (%d %d %d %d)", edt[k+r%weeklen].date.hour, edt[k+r%weeklen].date.day, edt[k+r%weeklen].date.month, edt[k+r%weeklen].date.year);
|
||||
}
|
||||
free(dudes);
|
||||
}
|
||||
if(!found && halt > weeklen) {
|
||||
if(!found && halt > 2*weeklen) {
|
||||
remaining_to_add--;
|
||||
*skip_count += 1;
|
||||
warn("skipping math colle for group %d (week %d)", grp, week);
|
||||
} else if(halt > weeklen) {
|
||||
is_searching_in_blacklisted = false ;
|
||||
}
|
||||
r++;
|
||||
halt++;
|
||||
|
@ -332,10 +347,12 @@ void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleu
|
|||
r = rand()%weeklen;
|
||||
found = false;
|
||||
halt = 0;
|
||||
is_searching_in_blacklisted = true ;
|
||||
|
||||
// do it again for physics/english colles
|
||||
while(remaining_to_add == 1) {
|
||||
if(edt[k+r%weeklen].mat == NOTHING && edt[k+r%weeklen].length == 1) {
|
||||
normal_skip = true;
|
||||
if(edt[k+r%weeklen].mat == NOTHING && edt[k+r%weeklen].length == 1 && (!is_searching_in_blacklisted || edt[k+r%weeklen].blacklisted == true)) {
|
||||
colleur* dudes = get_colleurs(chads, len_chads, edt[k+r%weeklen].date, &len_dudes);
|
||||
len_perm = len_dudes;
|
||||
if(len_dudes != 0) {
|
||||
|
@ -356,15 +373,22 @@ void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleu
|
|||
found = true;
|
||||
remaining_to_add--;
|
||||
}
|
||||
} else if(edt[k+r%weeklen].allow_grps[grp-1] == true) {
|
||||
normal_skip = false;
|
||||
}
|
||||
}
|
||||
free(perm);
|
||||
} else {
|
||||
error("No colleurs available at (%d %d %d %d)", edt[k+r%weeklen].date.hour, edt[k+r%weeklen].date.day, edt[k+r%weeklen].date.month, edt[k+r%weeklen].date.year);
|
||||
}
|
||||
free(dudes);
|
||||
}
|
||||
if(!found && halt > weeks_len[week]) {
|
||||
if(!found && halt > 2*weeklen) {
|
||||
remaining_to_add--;
|
||||
*skip_count += 1;
|
||||
warn("skipping L2 colle for group %d (week %d)", grp, week);
|
||||
} else if(halt > weeklen) {
|
||||
is_searching_in_blacklisted = false ;
|
||||
}
|
||||
r++;
|
||||
halt++;
|
||||
|
@ -415,7 +439,7 @@ int max(int x, int y) {
|
|||
}
|
||||
|
||||
int score(creneau* edt, int len_edt, int grp, int n_weeks) {
|
||||
int score = 100;
|
||||
int score = n_weeks*300;
|
||||
|
||||
int dist = 0;
|
||||
for(int i = 0; i < len_edt; i++) {
|
||||
|
@ -425,9 +449,6 @@ int score(creneau* edt, int len_edt, int grp, int n_weeks) {
|
|||
if(dist == 0) {
|
||||
score -= 4;
|
||||
}
|
||||
/*if(str_equal(edt[i].name, edt[j].name)) {
|
||||
score -= max(0, 28-dist);
|
||||
}*/
|
||||
if(dist == 7 && edt[i].date.hour == edt[j].date.hour) {
|
||||
score -= 5;
|
||||
}
|
||||
|
@ -659,7 +680,7 @@ void aux_2(creneau* edt, int len_edt, colleur* chads, int len_chads, int n_group
|
|||
}
|
||||
current++;
|
||||
}
|
||||
//printf("----------------------------\n");
|
||||
debug("---------------------- %d ----------------------", n_groups);
|
||||
|
||||
int* group_stats = malloc(sizeof(int)*n_groups);
|
||||
int* group_temp = malloc(sizeof(int)*n_groups);
|
||||
|
@ -677,15 +698,16 @@ void aux_2(creneau* edt, int len_edt, colleur* chads, int len_chads, int n_group
|
|||
int** occ_data = generate_matrix(n_groups, len_chads, 0);;
|
||||
info("Testing %d combinations...", n_sim);
|
||||
printf("\n");
|
||||
perm0 = malloc(sizeof(int)*20) ;
|
||||
for(int k = 0; k < n_sim*(1 - (max_score == n_groups*100)); k++) {
|
||||
if(k >= a) {
|
||||
printf("\x1b[1F");
|
||||
printf("\x1b[2K");
|
||||
info("%d%% Completed (current max is %d/%d)", 100*a/n_sim, max_score, 100*n_groups);
|
||||
info("%d%% Completed (current max is %d/%d)", 100*a/n_sim, max_score, n_weeks*300*n_groups);
|
||||
a += n_sim/100;
|
||||
}
|
||||
local_score = 0;
|
||||
local_min = 100;
|
||||
local_min = 909090909;
|
||||
skipped = 0;
|
||||
for(int i = 0; i < n_groups; i++) {
|
||||
add_colles_for_group_MP2I(weeks_len, edt, len_edt, chads, len_chads, n_weeks, i+1, (topic)(2+i%2), i%math_halt, i%info_app, &skipped, math_halt, info_app);
|
||||
|
@ -700,7 +722,7 @@ void aux_2(creneau* edt, int len_edt, colleur* chads, int len_chads, int n_group
|
|||
local_group = i+1;
|
||||
}
|
||||
}
|
||||
local_score -= skipped*30;
|
||||
local_score -= skipped*200;
|
||||
if(local_score > max_score) {
|
||||
max_score = local_score;
|
||||
screwed_group = local_group;
|
||||
|
@ -720,14 +742,14 @@ void aux_2(creneau* edt, int len_edt, colleur* chads, int len_chads, int n_group
|
|||
|
||||
printf("\x1b[1F");
|
||||
printf("\x1b[2K");
|
||||
if(max_score == 100*n_groups) {
|
||||
if(max_score == n_weeks*300*n_groups) {
|
||||
info("Interrupting early due to a perfect score achieved");
|
||||
} else {
|
||||
info("100%% Completed, best score is %d/%d (without skip penalty) with %d skipped colle(s)", max_score+global_skipped*30, 100*n_groups, global_skipped);
|
||||
info("Most screwed group is %d with a score of %d/100", screwed_group, global_min);
|
||||
info("100%% Completed, best score is %d/%d (without skip penalty) with %d skipped colle(s)", max_score+global_skipped*30, n_groups*n_weeks*300, global_skipped);
|
||||
info("Most screwed group is %d with a score of %d/%d", screwed_group, global_min, n_weeks*300);
|
||||
debug("Stats for all groups are :");
|
||||
for(int i = 0; i < n_groups; i++) {
|
||||
debug("Group %d : %d/100", i+1, group_stats[i]);
|
||||
debug("Group %d : %d/%d (or %lf %%)", i+1, group_stats[i], n_weeks*300, ((double)group_stats[i]/(n_weeks*3.0)));
|
||||
}
|
||||
}
|
||||
int end = time(NULL);
|
||||
|
@ -738,6 +760,7 @@ void aux_2(creneau* edt, int len_edt, colleur* chads, int len_chads, int n_group
|
|||
print_arr(occ_data[k], len_chads);
|
||||
}
|
||||
info("Took %ds to find", end-start);
|
||||
free(perm0);
|
||||
free(group_stats);
|
||||
free(group_temp);
|
||||
free(weeks_len);
|
||||
|
|
|
@ -309,6 +309,7 @@ creneau* import_creneaux_oneweek(char* filename, int len_file, int n_weeks, int
|
|||
edt[i].salle.building = 'N';
|
||||
edt[i].salle.id = 0;
|
||||
edt[i].length = 1;
|
||||
edt[i].blacklisted = false ;
|
||||
edt[i].allow_grps = malloc(sizeof(bool)*n_groups);
|
||||
for(int ii = 0; ii < n_groups; ii++) {
|
||||
edt[i].allow_grps[ii] = true;
|
||||
|
@ -349,6 +350,7 @@ creneau* import_creneaux_oneweek(char* filename, int len_file, int n_weeks, int
|
|||
edt[k*len_file+i].salle.id = 0;
|
||||
edt[k*len_file+i].length = edt[i].length;
|
||||
edt[k*len_file+i].allow_grps = malloc(sizeof(bool)*n_groups);
|
||||
edt[k*len_file+i].blacklisted = false ;
|
||||
for(int ii = 0; ii < n_groups; ii++) {
|
||||
edt[k*len_file+i].allow_grps[ii] = true;
|
||||
}
|
||||
|
@ -547,9 +549,11 @@ void import_tds(creneau* edt, int len_edt, int len_oneweek, char* filename) {
|
|||
//info("[%d, %d]", buffer, edtptr + k*len_oneweek);
|
||||
//usleep(1000000);
|
||||
edt[edtptr + k*len_oneweek].allow_grps[buffer-1] = false;
|
||||
edt[edtptr + k*len_oneweek].blacklisted = true;
|
||||
while(equal_d(edt[edtptr + k*len_oneweek].date, edt[edtptr + k*len_oneweek + os].date)) {
|
||||
//info("[%d, %d]", buffer, edtptr + k*len_oneweek + os);
|
||||
edt[edtptr + k*len_oneweek + os].allow_grps[buffer-1] = false;
|
||||
edt[edtptr + k*len_oneweek + os].blacklisted = true ;
|
||||
os++;
|
||||
}
|
||||
k++;
|
||||
|
@ -563,11 +567,15 @@ void import_tds(creneau* edt, int len_edt, int len_oneweek, char* filename) {
|
|||
//usleep(1000000);
|
||||
if((k+ban_init)%ban_cooldown == 0) {
|
||||
edt[edtptr + k*len_oneweek].allow_grps[buffer-1] = false;
|
||||
edt[edtptr + k*len_oneweek].blacklisted = true;
|
||||
//info("banning at week %d for group %d", k, buffer);
|
||||
}
|
||||
while(equal_d(edt[edtptr + k*len_oneweek].date, edt[edtptr + k*len_oneweek + os].date)) {
|
||||
//info("[%d, %d]", buffer, edtptr + k*len_oneweek + os);
|
||||
if((k+ban_init)%ban_cooldown == 0) {
|
||||
edt[edtptr + k*len_oneweek + os].allow_grps[buffer-1] = false;
|
||||
edt[edtptr + k*len_oneweek + os].blacklisted = true ;
|
||||
//info("banning at week %d for group %d", k, buffer);
|
||||
}
|
||||
os++;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ typedef struct room {char building; int id;} room;
|
|||
// rooms
|
||||
// building can be C, M, R or V
|
||||
|
||||
typedef struct creneau {int length; date date; int group; char* name; int namelen; topic mat; room salle; bool* allow_grps;} creneau;
|
||||
typedef struct creneau {int length; date date; int group; char* name; int namelen; topic mat; room salle; bool* allow_grps; bool blacklisted;} creneau;
|
||||
// one créneau de colle
|
||||
// /!\ creneau has to be sorted by ascending dates
|
||||
// with edt being a creneau*, it is required to have edt[0] be a Monday and edt[len(edt)-1] has to be a Friday
|
||||
|
|
Loading…
Reference in New Issue