forked from woodbri/vrpdptw
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvrpdptw.cpp
More file actions
89 lines (72 loc) · 1.82 KB
/
vrpdptw.cpp
File metadata and controls
89 lines (72 loc) · 1.82 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <stdexcept>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <math.h>
#include "Node.h"
#include "Order.h"
#include "Problem.h"
#include "Route.h"
#include "Solution.h"
#include "Plot.h"
#include "TabuSearch.h"
// create a static global variable for the problem
// this gets passed around as a reference in many of the objects
// that need to refer to it for data
static Problem P;
void Usage()
{
std::cout << "Usage: vrpdptw in.txt\n";
}
int main (int argc, char **argv)
{
if (argc < 2) {
Usage();
return 1;
}
char * infile = argv[1];
try {
P.loadProblem(infile);
std::cout << "Problem '" << infile << "'loaded\n";
P.dump();
Solution S(P);
S.sequentialConstruction();
//S.initialConstruction();
S.computeCosts();
std::cout << "Initial Solution: SCost: " << S.getCost() << std::endl;
S.dump();
#if 1
TabuSearch TS(S);
TS.debugTabu = true;
TS.debugPlots = false;
Solution B = TS.solve();
std::cout << "TabuSearch Results (1)" << std::endl;
B.dump();
#if 0
TabuSearch TS2(B);
Solution C = TS2.solve();
std::cout << "TabuSearch Results (2)" << std::endl;
C.dump();
#endif
#else
Solution B = S;
for (int i=0; i<2; i++){
TabuSearch TS(B);
B = TS.solve();
std::cout << "TabuSearch Results (" << i+1 << ")" << std::endl;;
B.dump();
}
#endif
Plot plot(B);
std::string title = "vrpdptw.png Final";
plot.out("vrpdptw.png", true, 800, 800, (char*)title.c_str());
}
catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
}