-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
41 lines (30 loc) · 956 Bytes
/
main.cpp
File metadata and controls
41 lines (30 loc) · 956 Bytes
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
#include <iostream>
#include <memory>
#include "codelibrary/visualization/plot.h"
#include "codelibrary/visualization/terminal/svg_terminal.h"
#include "solver/solver_nsls.h"
#include "test/test_zdt.h"
#include "test/test_lz.h"
using namespace std;
int main() {
std::unique_ptr<moo::BasicTest> test(new moo::LZ1Test());
moo::Population population;
moo::SolverNSLS<> solver;
solver.Initialize(*(test.get()), 100, &population);
for (int i = 0; i < 100; ++i) {
solver.SingleStep(&population);
}
// Draw results.
std::vector<cl::RPoint2D> points;
for (const moo::Individual& ind : population) {
points.emplace_back(ind.objectives[0], ind.objectives[1]);
}
cl::plot::PointPlotter plotter;
plotter.set_title(test->name);
plotter.Plot(points);
cl::SVGTerminal terminal;
plotter.Show(&terminal);
terminal.SaveToFile("result.svg");
system("result.svg");
return 0;
}