-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptimizer.cpp
More file actions
58 lines (42 loc) · 1.58 KB
/
Copy pathOptimizer.cpp
File metadata and controls
58 lines (42 loc) · 1.58 KB
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
#include "Optimizer.h"
#include <iomanip>
using namespace NGroupingChallenge;
COptimizer::COptimizer(CGroupingEvaluator& cEvaluator)
: c_evaluator(cEvaluator)
{
random_device c_seed_generator;
c_random_engine.seed(c_seed_generator());
}
COptimizer::~COptimizer() {
delete populationManager;
}
void COptimizer::vInitialize()
{
/*numeric_limits<double> c_double_limits;
d_current_best_fitness = c_double_limits.max();
v_current_best.clear();
v_current_best.resize(c_evaluator.iGetNumberOfPoints());*/
populationManager = new PopulationManager(c_evaluator, c_evaluator.iGetNumberOfPoints(), c_evaluator.iGetUpperBound());
v_current_best = populationManager->getBest();
d_current_best_fitness = populationManager->getBestScore();
}
void COptimizer::vRunIteration()
{
/*vector<int> v_candidate(c_evaluator.iGetNumberOfPoints());
uniform_int_distribution<int> c_candidate_distribution(c_evaluator.iGetLowerBound(), c_evaluator.iGetUpperBound());
for (size_t i = 0; i < v_candidate.size(); i++)
{
v_candidate[i] = c_candidate_distribution(c_random_engine);
}
double d_candidate_fitness = c_evaluator.dEvaluate(v_candidate);
if (d_candidate_fitness < d_current_best_fitness)
{
v_current_best = v_candidate;
d_current_best_fitness = d_candidate_fitness;
}
cout << d_current_best_fitness << endl;*/
populationManager->iteration();
v_current_best = populationManager->getBest();
d_current_best_fitness = populationManager->getBestScore();
std::cout << std::setprecision(15) << populationManager->getBestScore() << "\n";
}