Compare commits
2 Commits
be83812716
...
d4f0d54bc8
Author | SHA1 | Date |
---|---|---|
|
d4f0d54bc8 | |
|
e29c0b21c5 |
5
Makefile
5
Makefile
|
@ -5,7 +5,10 @@ LFLAGS=
|
||||||
|
|
||||||
all: bin/main
|
all: bin/main
|
||||||
|
|
||||||
OBJECTS = obj/main.o obj/structure.o obj/display.o obj/algorithm.o
|
test: bin/main
|
||||||
|
bin/main MP2I-creneaux.txt 33 MP2I-colleurs.txt 16 6 15 output.csv
|
||||||
|
|
||||||
|
OBJECTS = obj/structure.o obj/algorithm.o obj/display.o obj/main.o
|
||||||
bin/main: bin $(OBJECTS)
|
bin/main: bin $(OBJECTS)
|
||||||
$(CC) -o $@ $(LFLAGS) $(FLAGS) $(OBJECTS)
|
$(CC) -o $@ $(LFLAGS) $(FLAGS) $(OBJECTS)
|
||||||
|
|
||||||
|
|
22
algorithm.c
22
algorithm.c
|
@ -2,6 +2,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "structure.h"
|
||||||
#include "algorithm.h"
|
#include "algorithm.h"
|
||||||
|
|
||||||
bool is_equal_date(date d1, date d2) {
|
bool is_equal_date(date d1, date d2) {
|
||||||
|
@ -59,16 +60,19 @@ int get_fst_offset(creneau* edt, date d) {
|
||||||
return (date_dist(edt[0].date, d));
|
return (date_dist(edt[0].date, d));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Feuille morte :
|
||||||
|
|
||||||
bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end) {
|
bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end) {
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
|
|
||||||
/* conditions (AND) :
|
conditions (AND) :
|
||||||
0) Only 1 colle at a time
|
* 0) Only 1 colle at a time
|
||||||
1) Alternate between physics and english
|
* 1) Alternate between physics and english
|
||||||
2) Pattern for math colles is exactly 3-1-3-1-...
|
* 2) Pattern for math colles is exactly 3-1-3-1-...
|
||||||
3) Between 1 and 2 colles per week and per group (exclusing special colles such as Info)
|
* 3) Between 1 and 2 colles per week and per group (exclusing special colles such as Info)
|
||||||
4) Special colles (aka INFO) at least 1 every 6 weeks
|
* 4) Special colles (aka INFO) at least 1 every 6 weeks
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
int end_id = get_next_friday(edt, len_edt, end); // index of first date that is later than end
|
int end_id = get_next_friday(edt, len_edt, end); // index of first date that is later than end
|
||||||
if(end_id == -1) {
|
if(end_id == -1) {
|
||||||
|
@ -158,7 +162,6 @@ bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end) {
|
||||||
// 2) Math colles
|
// 2) Math colles
|
||||||
// version 2
|
// version 2
|
||||||
|
|
||||||
/*
|
|
||||||
int math = 0;
|
int math = 0;
|
||||||
int abort_2 = 0;
|
int abort_2 = 0;
|
||||||
for(int i = end_id-1; i >= 0+abort_2*(end_id); i--) {
|
for(int i = end_id-1; i >= 0+abort_2*(end_id); i--) {
|
||||||
|
@ -185,7 +188,7 @@ bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end) {
|
||||||
if(edt[i].group == grp && edt[i].mat == MATH) {
|
if(edt[i].group == grp && edt[i].mat == MATH) {
|
||||||
math += 1;
|
math += 1;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
int t = 0;
|
int t = 0;
|
||||||
int math = 0;
|
int math = 0;
|
||||||
|
@ -291,7 +294,6 @@ bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
for(int i = end_id-1; i >= 0; i--) {
|
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 || (date_dist(edt[0].date, edt[i].date)%7 == 4 && date_dist(edt[0].date, edt[i+1].date)%7 != 4)) {
|
||||||
// Check week
|
// Check week
|
||||||
|
|
|
@ -13,7 +13,7 @@ int get_next_friday(creneau* edt, int len_creneau, date d);
|
||||||
|
|
||||||
int get_fst_offset(creneau* edt, date d);
|
int get_fst_offset(creneau* edt, date d);
|
||||||
|
|
||||||
bool is_allowed_MP2I(creneau* edt, int len_edt, int grp, date end);
|
//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);
|
int heuristique_MP2I(creneau* edt, int len_edt, int grp, date end);
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,12 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* Feuilles mortes :
|
||||||
|
|
||||||
extern int* stats;
|
extern int* stats;
|
||||||
extern int* n_colles;
|
extern int* n_colles;
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
typedef enum topic {NOTHING, MATH, PHYSICS, ENGLISH, FRENCH, INFO} topic;
|
typedef enum topic {NOTHING, MATH, PHYSICS, ENGLISH, FRENCH, INFO} topic;
|
||||||
// colles subjects
|
// colles subjects
|
||||||
|
|
Loading…
Reference in New Issue