-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem.cpp
83 lines (68 loc) · 1.76 KB
/
Problem.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
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
#include "Problem.h"
#include <chrono>
#include <fstream>
#include <iostream>
#include <time.h>
#include "allegro5/allegro.h" // tylko do al_rest
void Problem::prepare(bool graphicMode)
{
graph.read(sourceFileName);
graph.setMaxLootVolume(trunk);
generator.setMaxValue(maxValue);
generator.setMaxVolume(maxValue);
solver.setG(&graph);
if (graphicMode)
{
drawing.setG(&graph);
drawing.initialization(screenWidth, screenHeight);
}
}
void Problem::run(bool graphicMode)
{
std::chrono::steady_clock::time_point begin;
std::chrono::steady_clock::time_point end;
if (graphicMode)
{
drawing.draw();
begin = std::chrono::steady_clock::now();
std::vector<Path*> paths = *(solver.findSolutionAndDrawAll());
end = std::chrono::steady_clock::now();
for (auto a : paths)
drawing.drawPath(a);
if (graph.getBestPath() != nullptr)
{
result = *graph.getBestPath();
drawing.drawResult(&result);
}
al_rest(30);
}
else
{
begin = std::chrono::steady_clock::now();
solver.findSolution();
end = std::chrono::steady_clock::now();
}
duration = std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count();
}
long int Problem::getDuration()
{
return duration;
}
void Problem::generateRandomData(int gSize, int density, double abroadFactor)
{
generator.initialize(screenWidth, screenHeight, sourceFileName);
generator.generateRandomData(gSize, density, abroadFactor);
}
void Problem::generateNiceData(int gSize, double abroadFactor, bool graphicMode)
{
if (gSize > 100 && graphicMode)
{
std::cout << "Zbyt du¿y problem dla tryvu graficznego" << std::endl;
return;
}
generator.initialize(screenWidth, screenHeight, sourceFileName);
generator.generateNiceData(gSize, abroadFactor, graphicMode);
}
void Problem::writeToFile()
{
}