-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
47 lines (40 loc) · 948 Bytes
/
main.cpp
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
#include "GA-Binary/ga_binary.hpp"
#include "GA-Real/ga_real.hpp"
#include "Nelder-Mead/nelder_mead.hpp"
#include "PSO/pso.hpp"
int main(int argc, char const *argv[])
{
size_t N = 1;
if (argc > 1) {
N = std::stoi(argv[1]);
}
else {
return 0;
}
size_t maxIterations = 100000 * N;
double acc = 0.001;
double real_val = -9.10385; // for N = 5
size_t dim = 3 * N;
/* // Nelder-Mead
double **p = new double *[dim + 1];
for (size_t t = 0; t < dim + 1; t++) {
p[t] = new double[dim];
for (size_t z = 0; z < dim; z++) {
p[t][z] = RandomGenerator::generateDouble(-2.5, 2.5);
}
}
NelderMead obj = NelderMead(dim, p, &ELJ);
obj.setParameters(maxIterations, acc, real_val);
obj.minimize();
for (size_t t = 0; t < dim + 1; t++) {
if (p[t] != nullptr) {
delete[] p[t];
}
}
delete[] p;
*/
PSO obj = PSO(dim, &ELJ, -2.5, 2.5);
obj.setParameters(maxIterations, acc, real_val, dim);
obj.minimize(true);
return 0;
}