-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chromosome.h
101 lines (81 loc) · 2.69 KB
/
Chromosome.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
101
#ifndef CHROMOSOME_H
#define CHROMOSOME_H
#include <QHash>
#include <QList>
#include <QString>
#include "Result.h"
class GanttChart;
/*!
* \brief The Chromosome class - represnts single schedule as order of operations (genes)
*/
class Chromosome
{
public:
Chromosome();
~Chromosome();
int geneCount() const;
const QList<QString>& genes() const;
bool hasGene(const QString& gene) const;
void addGene(const QString& gene);
QString print() const;
/*!
* \brief Based on Jobshop::instance()->fitnessFunction() returns value of proper fitness function
* calculateValues() must be called before this method in order to evaluate all fitness functions values
* \return Value of fitness function.
*/
double value() const;
///value of fitness funciton meanSquare
double valueMean() const;
///value of fitness function alphaBeta
double valueAlpha() const;
///Calculate all statistics
void calculateValues();
///Completion time of all operations
int completionTime() const;
///Mean flow time
double meanFlow() const;
///Number of tardy(late) jobs
int tardy() const;
///Maximum tardiness
int maxTardy() const;
///Mean tardinnes
double meanTardy() const;
//for sorting
bool operator<(const Chromosome& other) const;
bool operator>(const Chromosome& other) const;
const QList<Result>& results() const;
///Returns scheduled start time for operation in this chromosome (schedule)
int startTime(const QString& operation) const;
/*!
* \brief ganttChart Constructs GanttChart for this chromosome
* \return Pointer to newly created GanttChart
*/
GanttChart* ganttChart();
///generate summary in latex
const QString &latexSummary();
protected:
///value of fitness funciton meanSquare
double m_valueMean;
///value of fitness function alphaBeta
double m_valueAlpha;
///Number of tardy (late) jobs
int m_numberOfTardy;
///Mean flow time
double m_meanFlow;
///Mean tardinnes
double m_meanTardy;
///Basic statistics for each job
QList<Result> m_results;
///String representation of chromosome - sequence of operation IDs
QList<QString> m_genes;
///Starting time for each operation
/// Externistic state in flyweight design pattern
QHash<QString, int> m_operationsStartTime;
GanttChart* m_chart;
QString* m_summary;
friend QDebug operator<< (QDebug d, const Chromosome& chromosome);
friend QList<Chromosome> MSX(const Chromosome& a, const Chromosome& b);
};
QList<Chromosome> MSX(const Chromosome& a, const Chromosome& b);
QDebug operator<< (QDebug d, const Chromosome& chromosome);
#endif // CHROMOSOME_H