forked from woodbri/vrpdptw
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Solution.h
67 lines (49 loc) · 1.31 KB
/
Solution.h
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
#ifndef SOLUTION_H
#define SOLUTION_H
#include <vector>
#include <cmath>
#include "Problem.h"
#include "Route.h"
const double EPSILON = 0.001;
class Solution {
public:
Problem& P;
std::vector<Route> R;
std::vector<int> mapOtoR;
double totalDistance;
double totalCost;
Solution(Problem& p) : P(p) {
totalDistance = 0;
totalCost = 0;
mapOtoR.clear();
mapOtoR.resize(P.O.size());
for (int i=0; i<P.O.size(); i++)
mapOtoR[i] = -1;
R.clear();
};
void dump();
void sequentialConstruction();
void initialConstruction();
void computeCosts();
double getCost();
double getDistance();
double getAverageRouteDurationLength();
Solution& operator=( const Solution& rhs ) {
if ( this != &rhs ) {
totalDistance = rhs.totalDistance;
totalCost = rhs.totalCost;
P = rhs.P;
R = rhs.R;
mapOtoR = rhs.mapOtoR;
}
return *this;
};
bool operator == (Solution &another) const {
return R.size() == another.R.size() &&
abs(totalCost - another.totalCost) < EPSILON;
};
bool operator < (Solution &another) const {
return R.size() < another.R.size() || totalCost < another.totalCost;
};
};
#endif