Compare commits

..

No commits in common. "be838127168d0482a8e38f8baed9c01442209028" and "887d7e2654f8283e5583edf2c6aee0c003ce5b7b" have entirely different histories.

8 changed files with 29 additions and 157 deletions

View File

@ -1,34 +0,0 @@
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/

View File

@ -1,8 +1,4 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "algorithm.h"
#include "display.c"
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);

View File

@ -1,40 +0,0 @@
#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

View File

@ -1,6 +1,4 @@
#include <stdio.h>
#include "structure.h"
#include "structure.c"
/*
void remove_lanes(int n) {
@ -300,4 +298,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);
}
}
}

View File

@ -1,12 +0,0 @@
#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
View File

@ -1,10 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include "structure.h"
#include "algorithm.h"
#include "algorithm.c"
// 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

View File

@ -3,11 +3,34 @@
#include <assert.h>
#include <stdbool.h>
#include <unistd.h>
#include <time.h>
#include "structure.h"
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
//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) {
@ -460,4 +483,4 @@ int str_to_int(char* s) {
i++;
}
return buffer/10;
}
}

View File

@ -1,55 +0,0 @@
#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