diff --git a/algorithm.c b/algorithm.c index 69a95a9..bfc6f16 100644 --- a/algorithm.c +++ b/algorithm.c @@ -1,4 +1,8 @@ -#include "display.c" +#include +#include +#include + +#include "algorithm.h" bool is_equal_date(date d1, date d2) { return (d1.hour == d2.hour && d1.day == d2.day && d2.month == d1.month && d2.year == d1.year); diff --git a/algorithm.h b/algorithm.h new file mode 100644 index 0000000..411894b --- /dev/null +++ b/algorithm.h @@ -0,0 +1,40 @@ +#ifndef ALGORITHM_H_INCLUDED +#define ALGORITHM_H_INCLUDED + +#include "structure.h" + +bool is_equal_date(date d1, date d2); + +int get_date_index(creneau* edt, int len_creneau, date d); + +array get_all_date_index(creneau* edt, int len_edt, date d); + +int get_next_friday(creneau* edt, int len_creneau, date d); + +int get_fst_offset(creneau* edt, date d); + +bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end); + +int heuristique_MP2I(creneau* edt, int len_edt, int grp, date end); + +colleur *get_colleurs(colleur *cl, int len_cl, date d, int *how_many); + +void add_colle(creneau *edt, colleur *chads, int grp, int id_edt, int id_chad); + +void remove_coll(creneau *edt, int id_edt); + +bool is_overlap(creneau *edt, int len_edt, int id); + +bool is_overlap_creneau(creneau* edt, int len_edt, int id, int grp); + +int free_math_space(creneau *edt, int len_edt, int id); + +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); + +void write_to_file(char *filename, creneau *edt, int len_edt); + +int score(creneau *edt, int len_edt, int grp); + +void aux_2(creneau *edt, int len_edt, colleur *chads, int len_chads, int n_groups, int n_weeks, int n_sim, char *outname); + +#endif diff --git a/display.c b/display.c index bac2c0e..9eaa417 100644 --- a/display.c +++ b/display.c @@ -1,4 +1,6 @@ -#include "structure.c" +#include + +#include "structure.h" /* void remove_lanes(int n) { @@ -298,4 +300,4 @@ void print_all_colleurs(colleur* chads, int n_chads) { for(int c = 0; c < n_chads; c++) { printf("Colleur %s with %d available :\n", chads[c].name, chads[c].n_disp); } -} \ No newline at end of file +} diff --git a/display.h b/display.h new file mode 100644 index 0000000..3347023 --- /dev/null +++ b/display.h @@ -0,0 +1,12 @@ +#ifndef DISPLAY_H_INCLUDED +#define DISPLAY_H_INCLUDED + +#include "structure.h" + +void print_one_week(creneau *edt, int len_creneau, date start); + +void print_all_edt(creneau *edt, int len_edt, int n_weeks, int len_oneweek); + +void print_all_colleurs(colleur *chads, int n_chads); + +#endif diff --git a/main.c b/main.c index 09dac7d..980d469 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,10 @@ #include +#include +#include +#include -#include "algorithm.c" +#include "structure.h" +#include "algorithm.h" // gcc -g -Wall -Wextra -Wpedantic main.c -lSDL2 -lSDL2_image -lm -o main // ./main MP2I-creneaux.txt 33 MP2I-colleurs.txt 16 6 15 output.csv diff --git a/structure.c b/structure.c index 1bf2b55..ae8a499 100644 --- a/structure.c +++ b/structure.c @@ -3,34 +3,11 @@ #include #include #include -#include -typedef enum topic {NOTHING, MATH, PHYSICS, ENGLISH, FRENCH, INFO} topic; -// colles subjects - -typedef struct date {int hour; int day; int month; int year;} date; /* format is {hour, day, month, year} */ -// nothing to say here - -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;} 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 - -typedef struct colleur {char* name; int namelen; topic mat; date* disp; int n_disp;} colleur; -// available creneaux for the colleurs - -typedef struct array {int* a; int len; int memlen;} array; -// yes +#include "structure.h" //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 */ if(d2.month == d1.month && d2.year == d1.year) { @@ -483,4 +460,4 @@ int str_to_int(char* s) { i++; } return buffer/10; -} \ No newline at end of file +} diff --git a/structure.h b/structure.h new file mode 100644 index 0000000..e3ae56d --- /dev/null +++ b/structure.h @@ -0,0 +1,55 @@ +#ifndef STRUCTURE_H_INCLUDED +#define STRUCTURE_H_INCLUDED + +#include + + +extern int* stats; +extern int* n_colles; + + +typedef enum topic {NOTHING, MATH, PHYSICS, ENGLISH, FRENCH, INFO} topic; +// colles subjects + +typedef struct date {int hour; int day; int month; int year;} date; /* format is {hour, day, month, year} */ +// nothing to say here + +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;} 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 + +typedef struct colleur {char* name; int namelen; topic mat; date* disp; int n_disp;} colleur; +// available creneaux for the colleurs + +typedef struct array {int* a; int len; int memlen;} array; +// yes + + +int date_dist(date d1, date d2); + +bool is_sorted(creneau *edt, int len); + +creneau *import_creneaux(char *filename, int size); + +bool str_equal(char *s1, char *s2); + +void str_copy(char *src, int l1, char *dest); + +colleur *import_colleurs(char *filename, int n_colleurs, int max_available); + +date increment_date(date d, int inc); + +creneau *import_creneaux_oneweek(char *filename, int len_file, int n_weeks); + +void expand(colleur *guy, int id, int n_weeks); + +colleur *import_colleurs_oneweek(char *filename, int n_colleurs, int n_weeks, int len_oneweek); + +int str_to_int(char *s); + +#endif