added creneaux blacklist
This commit is contained in:
parent
dbadd95868
commit
d798dc8319
|
@ -259,7 +259,7 @@ void add_colles_for_group_MP2I(int* weeks_len, creneau* edt, int len_edt, colleu
|
||||||
// - he does not have another colle at the same time (is_overlap)
|
// - he does not have another colle at the same time (is_overlap)
|
||||||
// if a colle has been addded, interrupt the for andwhile loops
|
// if a colle has been addded, interrupt the for andwhile loops
|
||||||
for(int dude = 0; dude < len_perm*(1-found); dude++) {
|
for(int dude = 0; dude < len_perm*(1-found); dude++) {
|
||||||
if(dudes[perm[dude]].mat == INFO) {
|
if(dudes[perm[dude]].mat == INFO && edt[k+r%weeklen].allow_grps[grp-1] == true ) {
|
||||||
add_colle(edt, dudes, grp, k+r%weeklen, perm[dude]);
|
add_colle(edt, dudes, grp, k+r%weeklen, perm[dude]);
|
||||||
found = true;
|
found = true;
|
||||||
info = 0;
|
info = 0;
|
||||||
|
@ -654,6 +654,7 @@ void aux_2(creneau* edt, int len_edt, colleur* chads, int len_chads, int n_group
|
||||||
}
|
}
|
||||||
current++;
|
current++;
|
||||||
}
|
}
|
||||||
|
//printf("----------------------------\n");
|
||||||
|
|
||||||
int* group_stats = malloc(sizeof(int)*n_groups);
|
int* group_stats = malloc(sizeof(int)*n_groups);
|
||||||
int* group_temp = malloc(sizeof(int)*n_groups);
|
int* group_temp = malloc(sizeof(int)*n_groups);
|
||||||
|
|
|
@ -108,12 +108,14 @@ int main(int argc, char **argv) {
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
//creneau* edt = import_creneaux("file.txt", 76);
|
//creneau* edt = import_creneaux("file.txt", 76);
|
||||||
creneau* edt = import_creneaux_oneweek(path_creneaux, n_creneaux, n_weeks);
|
creneau* edt = import_creneaux_oneweek(path_creneaux, n_creneaux, n_weeks, n_groups);
|
||||||
int len_edt = n_creneaux*n_weeks;
|
int len_edt = n_creneaux*n_weeks;
|
||||||
|
|
||||||
//colleur* dudes = import_colleurs("some_data.txt", 13, len_creneau);
|
//colleur* dudes = import_colleurs("some_data.txt", 13, len_creneau);
|
||||||
colleur* dudes = import_colleurs_oneweek(path_colleurs, n_colleurs, n_weeks, n_creneaux);
|
colleur* dudes = import_colleurs_oneweek(path_colleurs, n_colleurs, n_weeks, n_creneaux);
|
||||||
|
|
||||||
|
import_tds(edt, len_edt, n_creneaux, "S3-tds.txt");
|
||||||
|
|
||||||
debug("Entries are : ");
|
debug("Entries are : ");
|
||||||
debug("Creneaux filename : %s", path_creneaux);
|
debug("Creneaux filename : %s", path_creneaux);
|
||||||
debug("Number of creneaux (for one week) : %d", n_creneaux);
|
debug("Number of creneaux (for one week) : %d", n_creneaux);
|
||||||
|
@ -130,6 +132,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
for(int i = 0; i < len_edt; i++) {
|
for(int i = 0; i < len_edt; i++) {
|
||||||
free(edt[i].name);
|
free(edt[i].name);
|
||||||
|
free(edt[i].allow_grps);
|
||||||
}
|
}
|
||||||
free(edt);
|
free(edt);
|
||||||
|
|
||||||
|
|
|
@ -278,7 +278,7 @@ date increment_date(date d, int inc) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
creneau* import_creneaux_oneweek(char* filename, int len_file, int n_weeks) {
|
creneau* import_creneaux_oneweek(char* filename, int len_file, int n_weeks, int n_groups) {
|
||||||
// import creneau data from a file then copy paste it for specified amount of weeks
|
// import creneau data from a file then copy paste it for specified amount of weeks
|
||||||
FILE* ptr = fopen(filename, "r");
|
FILE* ptr = fopen(filename, "r");
|
||||||
char c = fgetc(ptr);
|
char c = fgetc(ptr);
|
||||||
|
@ -309,6 +309,10 @@ creneau* import_creneaux_oneweek(char* filename, int len_file, int n_weeks) {
|
||||||
edt[i].salle.building = 'N';
|
edt[i].salle.building = 'N';
|
||||||
edt[i].salle.id = 0;
|
edt[i].salle.id = 0;
|
||||||
edt[i].length = 1;
|
edt[i].length = 1;
|
||||||
|
edt[i].allow_grps = malloc(sizeof(bool)*n_groups);
|
||||||
|
for(int ii = 0; ii < n_groups; ii++) {
|
||||||
|
edt[i].allow_grps[ii] = true;
|
||||||
|
}
|
||||||
} else if(to_fill == 1) {
|
} else if(to_fill == 1) {
|
||||||
edt[i].date.day = buffer;
|
edt[i].date.day = buffer;
|
||||||
} else if(to_fill == 2) {
|
} else if(to_fill == 2) {
|
||||||
|
@ -344,6 +348,10 @@ creneau* import_creneaux_oneweek(char* filename, int len_file, int n_weeks) {
|
||||||
edt[k*len_file+i].salle.building = 'N';
|
edt[k*len_file+i].salle.building = 'N';
|
||||||
edt[k*len_file+i].salle.id = 0;
|
edt[k*len_file+i].salle.id = 0;
|
||||||
edt[k*len_file+i].length = edt[i].length;
|
edt[k*len_file+i].length = edt[i].length;
|
||||||
|
edt[k*len_file+i].allow_grps = malloc(sizeof(bool)*n_groups);
|
||||||
|
for(int ii = 0; ii < n_groups; ii++) {
|
||||||
|
edt[k*len_file+i].allow_grps[ii] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,3 +494,83 @@ int str_to_int(char* s) {
|
||||||
}
|
}
|
||||||
return buffer/10;
|
return buffer/10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool equal_d(date d1, date d2) {
|
||||||
|
return (d1.hour == d2.hour && d2.day == d1.day && d1.month == d2.month && d1.year == d2.year);
|
||||||
|
}
|
||||||
|
|
||||||
|
int locate_date(creneau* edt, int len_edt, date d) {
|
||||||
|
int i = 0;
|
||||||
|
while(i < len_edt && !equal_d(edt[i].date, d)) {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i == len_edt) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
void import_tds(creneau* edt, int len_edt, int len_oneweek, char* filename) {
|
||||||
|
FILE* ptr = fopen(filename, "r");
|
||||||
|
char c = fgetc(ptr);
|
||||||
|
int edtptr = 0;
|
||||||
|
|
||||||
|
int current = 0;
|
||||||
|
int place = 0;
|
||||||
|
|
||||||
|
int buffer = 0;
|
||||||
|
|
||||||
|
date d;
|
||||||
|
|
||||||
|
while(c != EOF && c != '$') {
|
||||||
|
//printf("%c", c);
|
||||||
|
if(c == '+') {
|
||||||
|
current = 0;
|
||||||
|
place = 0;
|
||||||
|
buffer = 0;
|
||||||
|
c = fgetc(ptr); // always a \n
|
||||||
|
} else if(c == '\n' && current != 0) {
|
||||||
|
if(current == 1) {
|
||||||
|
edtptr = locate_date(edt, len_edt, d);
|
||||||
|
} else {
|
||||||
|
int k = 0;
|
||||||
|
int os = 1;
|
||||||
|
while(edtptr + k*len_oneweek >= 0 && edtptr + k*len_oneweek < len_edt) {
|
||||||
|
//info("[%d, %d]", buffer, edtptr + k*len_oneweek);
|
||||||
|
//usleep(1000000);
|
||||||
|
edt[edtptr + k*len_oneweek].allow_grps[buffer-1] = false;
|
||||||
|
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;
|
||||||
|
os++;
|
||||||
|
}
|
||||||
|
k++;
|
||||||
|
os = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
current++;
|
||||||
|
buffer = 0;
|
||||||
|
} else if((c == '\n' && current == 0) || c == ' ') {
|
||||||
|
if(place == 0) {
|
||||||
|
d.hour = buffer;
|
||||||
|
} else if(place == 1) {
|
||||||
|
d.day = buffer;
|
||||||
|
} else if(place == 2) {
|
||||||
|
d.month = buffer;
|
||||||
|
} else {
|
||||||
|
d.year = buffer;
|
||||||
|
current = 1;
|
||||||
|
}
|
||||||
|
place++;
|
||||||
|
buffer = 0;
|
||||||
|
} else if((int)(c) >= 48 && (int)(c) <= 57) {
|
||||||
|
buffer *= 10;
|
||||||
|
buffer += (int)(c) - 48;
|
||||||
|
}
|
||||||
|
c = fgetc(ptr);
|
||||||
|
}
|
||||||
|
fclose(ptr);
|
||||||
|
|
||||||
|
info("Imported special creneaux successfully");
|
||||||
|
}
|
|
@ -40,7 +40,7 @@ typedef struct room {char building; int id;} room;
|
||||||
// rooms
|
// rooms
|
||||||
// building can be C, M, R or V
|
// 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;} creneau;
|
typedef struct creneau {int length; date date; int group; char* name; int namelen; topic mat; room salle; bool* allow_grps;} creneau;
|
||||||
// one créneau de colle
|
// one créneau de colle
|
||||||
// /!\ creneau has to be sorted by ascending dates
|
// /!\ 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
|
// 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
|
||||||
|
@ -66,7 +66,7 @@ colleur *import_colleurs(char *filename, int n_colleurs, int max_available);
|
||||||
|
|
||||||
date increment_date(date d, int inc);
|
date increment_date(date d, int inc);
|
||||||
|
|
||||||
creneau *import_creneaux_oneweek(char *filename, int len_file, int n_weeks);
|
creneau *import_creneaux_oneweek(char *filename, int len_file, int n_weeks, int n_groups);
|
||||||
|
|
||||||
void expand(colleur *guy, int id, int n_weeks);
|
void expand(colleur *guy, int id, int n_weeks);
|
||||||
|
|
||||||
|
@ -74,4 +74,10 @@ colleur *import_colleurs_oneweek(char *filename, int n_colleurs, int n_weeks, in
|
||||||
|
|
||||||
int str_to_int(char *s);
|
int str_to_int(char *s);
|
||||||
|
|
||||||
|
bool equal_d(date d1, date d2);
|
||||||
|
|
||||||
|
int locate_date(creneau* edt, int len_edt, date d);
|
||||||
|
|
||||||
|
void import_tds(creneau* edt, int len_edt, int len_oneweek, char* filename);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue