-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhospital.h
100 lines (77 loc) · 2.13 KB
/
hospital.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef HOSPITAL_H
#define HOSPITAL_H
// Headers
#include "vector"
#include "string"
#include <ctime>
// Class
class Hospital
{
private:
// Time
clock_t initialTime;
// Problem Parameters
unsigned N, D, S;
std::vector<std::vector<int> > COVERAGE;
std::vector<std::vector<std::vector<int> > > PREFERENCES;
// Restrictions: Nurse Parameters
int NURSE_MIN_DAYS, NURSE_MAX_DAYS;
int NURSE_MIN_CONSECUTIVE_DAYS, NURSE_MAX_CONSECUTIVE_DAYS;
// Restrictions: Shift Parameters
std::vector<std::vector<int> > SHIFT_CONSTRAINTS;
// Algorithm Parameters
unsigned POPULATION_SIZE;
//float PENALTY;
std::vector<int> PENALTY_WEIGHTS;
std::vector<float> MUTATION_PROBABILITY;
float CROSS_OVER_PROBABILITY;
float GENERAL_MUTATION_PROBABILITY;
float GENERAL_CROSS_OVER_PROBABILITY;
// Problem variables
std::vector<std::vector<std::vector<int> > > population;
std::vector<float> populationFitness;
float totalFitness;
float fitness;
std::vector<float> rouletteWheel;
std::vector<int> violatedConstraints;
// Best variables
clock_t bestTime;
std::vector<std::vector<int> > bestSchedule;
std::vector<int> bestViolatedConstraints;
float bestFitness;
// Debug
bool bestHasChanged;
bool DEBUG;
public:
Hospital();
//void init();
bool loadData(std::string filename);
void setTime();
void setDebug(bool debug);
void setSeed(unsigned seed);
void setMutationProbability();
void setCrossOverProbability();
void setPopulationFitness();
void setRouletteWheel();
void setViolatedConstraints();
void setBestSchedule();
void updateBestTime();
void updatePopulationFitness();
void updateRouletteWheel();
void updateViolatedConstraints(int chromosome);
void updateBestSchedule(int chromosome);
void genChromosome(int chromosome);
void genPopulation();
int getRouletteWheelChromosome();
void crossOver(int chromosome1, int chromosome2);
void mutate(int chromosome);
float getFitness(int chromosome);
void runCrossOverProcess();
void runMutationProcess();
void run();
bool hasTheBestChanged();
void print();
void resetViolatedConstraints();
void reset();
};
#endif