-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyAlgorithm.h
72 lines (61 loc) · 2.41 KB
/
myAlgorithm.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
#ifndef INC_METAHEURISTIC
#define INC_METAHEURISTIC
#include <iostream>
#include <cmath>
#include <vector>
#include "SetUpParams.h"
#include "Problem.h"
#include "Solution.h"
#include "Viewer.h"
using namespace std;
class MyAlgorithm
{
private:
vector<Solution*> _solutions; // individuals in population
const SetUpParams& _setup;
unsigned int _upper_cost, _lower_cost; // lower and upper fitness of individuals in population
vector<double> _results;
Solution* _best_solution;
const Problem& _pbm;
public:
MyAlgorithm(const MyAlgorithm& A);
MyAlgorithm(Problem& pbm, SetUpParams& setup);
~MyAlgorithm();
friend ostream& operator<<(ostream& os, const MyAlgorithm& myAlgo);
friend istream& operator>>(istream& is, MyAlgorithm& myAlgo);
MyAlgorithm& operator=(const MyAlgorithm& myAlgo);
const SetUpParams& setup() const;
void initialize();
void run(Viewer& fenetre);
void evaluateFitness();
void determineBestSolution();
vector<double> MeanPerColumn() const;
double Difference_Mean(int j, const vector<double>& Means, double r) const;
void learnFromTeacher(int k, const vector<double>& Means, double r);
void TeachingPhase(double r);
void learnFromPeer(int P, int Q, double r);
void LearningPhase(double r);
void UpdateBestSolutionOverall(Solution* &OverallBestSolution);
void changeSolutionWithinInterval(vector<double>& tabNewP, int j,double add);
void changeSolutionWithinIntervalAfterFactor(vector<double>& tabNewP, int j, double factor);
double valueAdaptedToPbmInterval(double original, double current);
void speedControl(const vector<double> &oldS, vector<double> &newS) const;
void solutionTranported(int pos);
void TransportationPhase();
void TutorPhase();
const vector<double>& results() const;
double meanResults() const;
double sdResults() const;
void outputSummary(ostream& outputFile);
const vector<Solution*>& solutions() const;
unsigned int upper_cost() const;
unsigned int lower_cost() const;
Solution& solution(const unsigned int index) const;
double fitness(const unsigned int index) const;
double best_cost() const;
double worst_cost() const;
Solution& best_solution() const;
Solution& worst_solution() const;
void evolution(int iter, Viewer& fenetre); /*makes an evolution step*/
};
#endif