Created
December 18, 2016 02:53
-
-
Save Heasummn/988c1e0382cc1577a93fb01b3e6cec17 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <string.h> | |
#include <assert.h> | |
#define LESSON_NAME_MAX 12 | |
#define SCHOOL_DAYS_IN_WEEK 5 | |
#define TEACHER_NAME_MAX 5 | |
#define LESSONS_PER_DAY_MAX 8 | |
#define NUMBER_OF_CLASSES 9 | |
#define SIZE_OF_POPULATION 100 | |
enum lesson_number {dan, mat, eng, tys, fys, his, sam, val, geo, bio, gym, rel, pra, fri}; | |
struct individual{ | |
int lesson_num[LESSONS_PER_DAY_MAX][SCHOOL_DAYS_IN_WEEK]; | |
int fitness; | |
int perfection; | |
int lessons_with_parallel; | |
int lessons_with_both; | |
int heavy_lesson_after; | |
int heavy_lesson_before; | |
int teacher_overbooked; | |
int best_gena7; | |
int best_gena8; | |
int best_gena9; | |
}; | |
struct class{ | |
char teacher_name[TEACHER_NAME_MAX]; | |
char lesson_name[LESSON_NAME_MAX]; | |
int number_of_lessons; | |
char class_name[TEACHER_NAME_MAX]; | |
}; | |
struct requirements{ | |
int dan_req; | |
int mat_req; | |
int eng_req; | |
int tys_req; | |
int fys_req; | |
int his_req; | |
int sam_req; | |
int val_req; | |
int geo_req; | |
int bio_req; | |
int gym_req; | |
int rel_req; | |
int pra_req; | |
int fri_req; | |
}; | |
typedef struct individual individual; | |
typedef struct class class; | |
typedef struct requirements requirements; | |
int main(void){ | |
int i; | |
individual **population = (individual **)calloc(NUMBER_OF_CLASSES, sizeof(individual *)); | |
for(i = 0; i < SIZE_OF_POPULATION; i++){ | |
population[i] = (individual *)calloc(SIZE_OF_POPULATION, sizeof(individual)); | |
} | |
requirements *requirements_classes; | |
requirements_classes = (requirements *)calloc(NUMBER_OF_CLASSES, sizeof(requirements)); | |
individual **old_population = (individual **)calloc(NUMBER_OF_CLASSES, sizeof(individual *)); | |
for(i = 0; i < SIZE_OF_POPULATION; i++){ | |
old_population[i] = (individual *)calloc(SIZE_OF_POPULATION, sizeof(individual)); | |
} | |
for(i = 0; i < SIZE_OF_POPULATION; i++){ | |
free(population[i]); | |
} | |
free(population); | |
free(requirements_classes); | |
for(i = 0; i < SIZE_OF_POPULATION; i++){ | |
free(old_population[i]); | |
} | |
free(old_population); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment