Compare commits
2 Commits
887d7e2654
...
be83812716
Author | SHA1 | Date |
---|---|---|
|
be83812716 | |
|
52fa0c1789 |
|
@ -0,0 +1,34 @@
|
||||||
|
CC=gcc
|
||||||
|
FLAGS=-g -Wall -Wextra -Wpedantic
|
||||||
|
LFLAGS=
|
||||||
|
|
||||||
|
|
||||||
|
all: bin/main
|
||||||
|
|
||||||
|
OBJECTS = obj/main.o obj/structure.o obj/display.o obj/algorithm.o
|
||||||
|
bin/main: bin $(OBJECTS)
|
||||||
|
$(CC) -o $@ $(LFLAGS) $(FLAGS) $(OBJECTS)
|
||||||
|
|
||||||
|
obj/main.o: main.c obj
|
||||||
|
$(CC) -o $@ -c $(FLAGS) $<
|
||||||
|
|
||||||
|
obj/structure.o: structure.c structure.h obj
|
||||||
|
$(CC) -o $@ -c $(FLAGS) $<
|
||||||
|
|
||||||
|
obj/display.o: display.c display.h obj
|
||||||
|
$(CC) -o $@ -c $(FLAGS) $<
|
||||||
|
|
||||||
|
obj/algorithm.o: algorithm.c algorithm.h obj
|
||||||
|
$(CC) -o $@ -c $(FLAGS) $<
|
||||||
|
|
||||||
|
bin:
|
||||||
|
mkdir -p bin
|
||||||
|
|
||||||
|
obj:
|
||||||
|
mkdir -p obj
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf bin/ obj/
|
|
@ -1,4 +1,8 @@
|
||||||
#include "display.c"
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "algorithm.h"
|
||||||
|
|
||||||
bool is_equal_date(date d1, date d2) {
|
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);
|
return (d1.hour == d2.hour && d1.day == d2.day && d2.month == d1.month && d2.year == d1.year);
|
||||||
|
|
|
@ -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
|
|
@ -1,4 +1,6 @@
|
||||||
#include "structure.c"
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "structure.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void remove_lanes(int n) {
|
void remove_lanes(int n) {
|
||||||
|
|
|
@ -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
|
6
main.c
6
main.c
|
@ -1,6 +1,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "algorithm.c"
|
#include "structure.h"
|
||||||
|
#include "algorithm.h"
|
||||||
|
|
||||||
// gcc -g -Wall -Wextra -Wpedantic main.c -lSDL2 -lSDL2_image -lm -o main
|
// 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
|
// ./main MP2I-creneaux.txt 33 MP2I-colleurs.txt 16 6 15 output.csv
|
||||||
|
|
25
structure.c
25
structure.c
|
@ -3,34 +3,11 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
typedef enum topic {NOTHING, MATH, PHYSICS, ENGLISH, FRENCH, INFO} topic;
|
#include "structure.h"
|
||||||
// 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
|
|
||||||
|
|
||||||
//static int width = 1200;
|
//static int width = 1200;
|
||||||
//static int height = 900;
|
//static int height = 900;
|
||||||
int* stats;
|
|
||||||
int* n_colles;
|
|
||||||
|
|
||||||
int date_dist(date d1, date d2) { /* returns distance between d1 and d2 in days
|
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 is sooner than d1, it will return -1 */
|
||||||
if(d2.month == d1.month && d2.year == d1.year) {
|
if(d2.month == d1.month && d2.year == d1.year) {
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
#ifndef STRUCTURE_H_INCLUDED
|
||||||
|
#define STRUCTURE_H_INCLUDED
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
||||||
|
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
|
Loading…
Reference in New Issue