-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvrptwinstancegenerator.h
196 lines (139 loc) · 5.5 KB
/
vrptwinstancegenerator.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#ifndef VRPTWINSTANCEGENERATOR_H
#define VRPTWINSTANCEGENERATOR_H
#include <string>
#include "dataTypes.h"
#include "MersenneTwister.h"
class VRPTWInstanceGenerator
{
private:
//! Seed to generate the set of random costumers.
unsigned matrixSeed;
//! Seed to generate the time windows.
unsigned timeWindowSeed;
//! Seed to generate the demands.
unsigned demandSeed;
//! Seed to generate the service times.
unsigned serviceTimeSeed;
//! Size of the instance (number of costumers)
unsigned size;
//! Raw info to generate the instance
rawInfoVector distanceTable;
rawInfoVector timeTable;
//! Specifications of the instance
tTimeWindow timeWindows;
tDemand demands;
tServiceTime serviceTimes;
//! Maximum capacity of each vehicle of the fleet
capacityType vehicleMaxCapacity;
//! Number of max allowed vehicles for this instance
unsigned sizeOfFleet;
//! Costumer ids
std::vector<unsigned> ids;
//! Costumers positions
costumersPosType positions;
//! Matrices
matrixType distanceMatrix;
matrixType timeMatrix;
//! Prefix for output-files
std::string prefix;
//! Solomon-type output structure
std::vector<unsigned> timeWindowsIndexes;
idsType demandsIndexes;
idsType serviceTimesIndexes;
//! Vector of costumers appearing in this instance
std::vector<unsigned> randomIds;
protected:
//! Method that, given a table and 'from' 'to' information, returns the length in time or distance
double getData(const rawInfoVector&, unsigned, unsigned);
//! This method will receive a random number generator and a vector of accumulative probability and will return a category
unsigned getCategoryRandomly(double, const accProbabilityType&);
//! Method to output errors
void error(const std::string&);
//! Method to output warnings
void warning(const std::string&);
//! Method to get the position of a costumer within vector
unsigned getPosition(unsigned);
//! Method to generate the distance matrix for this instance
void generateDistanceMatrix();
//! Method to generate the time matrix for this instance
void generateTimeMatrix();
public:
//! Default Ctor.
VRPTWInstanceGenerator();
//! Default Destructor.
~VRPTWInstanceGenerator();
//! Method that reads the distance between each par of costumers
/*!
\param distanceFileName is the name of the file containing the distances.
*/
void readDistancesFile(const char* distanceFileName);
//! Method that reads the time between each par of costumers
/*!
\param timeFileName is the name of the file containing the times.
*/
void readTimesFile(const char* timeFilename);
//! Method that reads the real ids of the costumers
/*!
\param distanceFileName is the name of the file containing the distances.
*/
void readIds(const char* idsFileName);
//! Method that reads the position of the costumers
/*!
\param idslatlngFileName is the name of the file containing the distances.
*/
void readPositions(const char* idslatlngFileName);
//! Method that parsers the time windows specifications
/*!
\param fileName is the name of the file containing the time windows specifications.
*/
void readTimeWindowsFile(const char* fileName);
//! Method that parsers the demands specifications
/*!
\param fileName is the name of the file containing the demands specifications.
*/
void readDemandsFile(const char* fileName);
//! Method that parsers the service times specifications
/*!
\param fileName is the name of the file containing the service times specifications.
*/
void readServiceTimesFile(const char* fileName);
//! Sets the size of the instance
void setSize(unsigned);
//! Sets the seeds to generate the data for this instance
void setSeed(const std::string&, unsigned);
//! Sets the prefix for the output files
void setPrefix(const std::string&);
//! Method that generates the distance and time windows matrices with random costumers
void generateMatrices();
//! Method that associates a type of time window to each costumer
void generateTimeWindows();
//! Method that associates a type of demand to each costumer
void generateDemands();
//! Method that associates a type of service time to each costumer
void generateServiceTimes();
//! Method that call all generates
void generateAll();
// Print
//! Method to print the parameters
void printParameters();
//! Method to print the time matrix
void printTimeMatrix();
//! Method to print the distance matrix
void printDistanceMatrix();
//! Method to print the specifications
void printSpecifications();
//! Method that prints all
void print();
//! Method that prints all
void printAll();
// Write output
//! Method that writes the distance matrix to a file
void writeDistanceMatrix();
//! Method that writes the time matrix to a file
void writeTimeMatrix();
//! Method that writes the specification to a file
void writeSpecifications();
//! Method that call all writes
void writeAll();
};
#endif // VRPTWINSTANCEGENERATOR_H