SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ODMatrix.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // An O/D (origin/destination) matrix
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2006-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <iostream>
35 #include <algorithm>
36 #include <list>
37 #include <iterator>
39 #include <utils/common/StdDefs.h>
41 #include <utils/common/ToString.h>
46 #include <utils/common/SUMOTime.h>
49 #include <utils/xml/XMLSubSys.h>
50 #include "ODAmitranHandler.h"
51 #include "ODMatrix.h"
52 
53 #ifdef CHECK_MEMORY_LEAKS
54 #include <foreign/nvwa/debug_new.h>
55 #endif // CHECK_MEMORY_LEAKS
56 
57 
58 // ===========================================================================
59 // method definitions
60 // ===========================================================================
62  : myDistricts(dc), myNoLoaded(0), myNoWritten(0), myNoDiscarded(0) {}
63 
64 
66  for (std::vector<ODCell*>::iterator i = myContainer.begin(); i != myContainer.end(); ++i) {
67  delete *i;
68  }
69  myContainer.clear();
70 }
71 
72 
73 void
74 ODMatrix::add(SUMOReal vehicleNumber, SUMOTime begin,
75  SUMOTime end, const std::string& origin, const std::string& destination,
76  const std::string& vehicleType) {
77  myNoLoaded += vehicleNumber;
78  if (myDistricts.get(origin) == 0 && myDistricts.get(destination) == 0) {
79  WRITE_WARNING("Missing origin '" + origin + "' and destination '" + destination + "' (" + toString(vehicleNumber) + " vehicles).");
80  } else if (myDistricts.get(origin) == 0 && vehicleNumber > 0) {
81  WRITE_ERROR("Missing origin '" + origin + "' (" + toString(vehicleNumber) + " vehicles).");
82  myNoDiscarded += vehicleNumber;
83  } else if (myDistricts.get(destination) == 0 && vehicleNumber > 0) {
84  WRITE_ERROR("Missing destination '" + destination + "' (" + toString(vehicleNumber) + " vehicles).");
85  myNoDiscarded += vehicleNumber;
86  } else {
87  if (myDistricts.get(origin)->sourceNumber() == 0) {
88  WRITE_ERROR("District '" + origin + "' has no source.");
89  myNoDiscarded += vehicleNumber;
90  } else if (myDistricts.get(destination)->sinkNumber() == 0) {
91  WRITE_ERROR("District '" + destination + "' has no sink.");
92  myNoDiscarded += vehicleNumber;
93  } else {
94  ODCell* cell = new ODCell();
95  cell->begin = begin;
96  cell->end = end;
97  cell->origin = origin;
98  cell->destination = destination;
99  cell->vehicleType = vehicleType;
100  cell->vehicleNumber = vehicleNumber;
101  myContainer.push_back(cell);
102  }
103  }
104 }
105 
106 
107 SUMOReal
109  size_t& vehName, std::vector<ODVehicle>& into,
110  bool uniform, const std::string& prefix) {
111  int vehicles2insert = (int) cell->vehicleNumber;
112  // compute whether the fraction forces an additional vehicle insertion
113  if (RandHelper::rand() < cell->vehicleNumber - (SUMOReal)vehicles2insert) {
114  vehicles2insert++;
115  }
116  if (vehicles2insert == 0) {
117  return cell->vehicleNumber;
118  }
119 
120  const SUMOReal offset = (SUMOReal)(cell->end - cell->begin) / (SUMOReal) vehicles2insert / (SUMOReal) 2.;
121  for (int i = 0; i < vehicles2insert; ++i) {
122  ODVehicle veh;
123  veh.id = prefix + toString(vehName++);
124 
125  if (uniform) {
126  veh.depart = (SUMOTime)(offset + cell->begin + ((SUMOReal)(cell->end - cell->begin) * (SUMOReal) i / (SUMOReal) vehicles2insert));
127  } else {
128  veh.depart = (SUMOTime)RandHelper::rand(cell->begin, cell->end);
129  }
130 
133  veh.cell = cell;
134  into.push_back(veh);
135  }
136  return cell->vehicleNumber - vehicles2insert;
137 }
138 
139 
140 void
141 ODMatrix::writeDefaultAttrs(OutputDevice& dev, const bool noVtype,
142  const ODCell* const cell) {
143  const OptionsCont& oc = OptionsCont::getOptions();
144  if (!noVtype && cell->vehicleType != "") {
146  }
148  if (oc.isSet("departlane") && oc.getString("departlane") != "default") {
149  dev.writeAttr(SUMO_ATTR_DEPARTLANE, oc.getString("departlane"));
150  }
151  if (oc.isSet("departpos")) {
152  dev.writeAttr(SUMO_ATTR_DEPARTPOS, oc.getString("departpos"));
153  }
154  if (oc.isSet("departspeed") && oc.getString("departspeed") != "default") {
155  dev.writeAttr(SUMO_ATTR_DEPARTSPEED, oc.getString("departspeed"));
156  }
157  if (oc.isSet("arrivallane")) {
158  dev.writeAttr(SUMO_ATTR_ARRIVALLANE, oc.getString("arrivallane"));
159  }
160  if (oc.isSet("arrivalpos")) {
161  dev.writeAttr(SUMO_ATTR_ARRIVALPOS, oc.getString("arrivalpos"));
162  }
163  if (oc.isSet("arrivalspeed")) {
164  dev.writeAttr(SUMO_ATTR_ARRIVALSPEED, oc.getString("arrivalspeed"));
165  }
166 }
167 
168 
169 void
171  OutputDevice& dev, const bool uniform, const bool noVtype,
172  const std::string& prefix, const bool stepLog) {
173  if (myContainer.size() == 0) {
174  return;
175  }
176  std::map<std::pair<std::string, std::string>, SUMOReal> fractionLeft;
177  size_t vehName = 0;
178  sort(myContainer.begin(), myContainer.end(), cell_by_begin_sorter());
179  // recheck begin time
180  begin = MAX2(begin, myContainer.front()->begin);
181  std::vector<ODCell*>::iterator next = myContainer.begin();
182  std::vector<ODVehicle> vehicles;
183  SUMOTime lastOut = -DELTA_T;
184  // go through the time steps
185  for (SUMOTime t = begin; t != end;) {
186  if (stepLog && t - lastOut >= DELTA_T) {
187  std::cout << "Parsing time " + time2string(t) << '\r';
188  lastOut = t;
189  }
190  // recheck whether a new cell got valid
191  bool changed = false;
192  while (next != myContainer.end() && (*next)->begin <= t && (*next)->end > t) {
193  std::pair<std::string, std::string> odID = std::make_pair((*next)->origin, (*next)->destination);
194  // check whether the current cell must be extended by the last fraction
195  if (fractionLeft.find(odID) != fractionLeft.end()) {
196  (*next)->vehicleNumber += fractionLeft[odID];
197  fractionLeft[odID] = 0;
198  }
199  // get the new departures (into tmp)
200  const size_t oldSize = vehicles.size();
201  const SUMOReal fraction = computeDeparts(*next, vehName, vehicles, uniform, prefix);
202  if (oldSize != vehicles.size()) {
203  changed = true;
204  }
205  if (fraction != 0) {
206  fractionLeft[odID] = fraction;
207  }
208  ++next;
209  }
210  if (changed) {
211  sort(vehicles.begin(), vehicles.end(), descending_departure_comperator());
212  }
213  for (std::vector<ODVehicle>::reverse_iterator i = vehicles.rbegin(); i != vehicles.rend() && (*i).depart == t; ++i) {
214  myNoWritten++;
216  dev.writeAttr(SUMO_ATTR_FROM, (*i).from).writeAttr(SUMO_ATTR_TO, (*i).to);
217  writeDefaultAttrs(dev, noVtype, i->cell);
218  dev.closeTag();
219  }
220  while (vehicles.size() != 0 && vehicles.back().depart == t) {
221  vehicles.pop_back();
222  }
223  if (!vehicles.empty()) {
224  t = vehicles.back().depart;
225  }
226  if (next != myContainer.end() && (t > (*next)->begin || vehicles.empty())) {
227  t = (*next)->begin;
228  }
229  if (next == myContainer.end() && vehicles.empty()) {
230  break;
231  }
232  }
233 }
234 
235 
236 void
237 ODMatrix::writeFlows(const SUMOTime begin, const SUMOTime end,
238  OutputDevice& dev, bool noVtype,
239  const std::string& prefix) {
240  if (myContainer.size() == 0) {
241  return;
242  }
243  size_t flowName = 0;
244  sort(myContainer.begin(), myContainer.end(), cell_by_begin_sorter());
245  // recheck begin time
246  for (std::vector<ODCell*>::const_iterator i = myContainer.begin(); i != myContainer.end(); ++i) {
247  const ODCell* const c = *i;
248  if (c->end > begin && c->begin < end) {
249  dev.openTag(SUMO_TAG_FLOW).writeAttr(SUMO_ATTR_ID, prefix + toString(flowName++));
252  writeDefaultAttrs(dev, noVtype, *i);
253  dev.closeTag();
254  }
255  }
256 }
257 
258 
259 std::string
261  std::string line;
262  do {
263  line = lr.readLine();
264  if (line[0] != '*') {
265  return StringUtils::prune(line);
266  }
267  } while (lr.good() && lr.hasMore());
268  throw ProcessError();
269 }
270 
271 
272 SUMOTime
273 ODMatrix::parseSingleTime(const std::string& time) {
274  if (time.find('.') == std::string::npos) {
275  throw OutOfBoundsException();
276  }
277  std::string hours = time.substr(0, time.find('.'));
278  std::string minutes = time.substr(time.find('.') + 1);
279  return TIME2STEPS(TplConvert::_2int(hours.c_str()) * 3600 + TplConvert::_2int(minutes.c_str()) * 60);
280 }
281 
282 
283 std::pair<SUMOTime, SUMOTime>
285  std::string line = getNextNonCommentLine(lr);
286  try {
288  SUMOTime begin = parseSingleTime(st.next());
289  SUMOTime end = parseSingleTime(st.next());
290  if (begin >= end) {
291  throw ProcessError("Begin time is larger than end time.");
292  }
293  return std::make_pair(begin, end);
294  } catch (OutOfBoundsException&) {
295  throw ProcessError("Broken period definition '" + line + "'.");
296  } catch (NumberFormatException&) {
297  throw ProcessError("Broken period definition '" + line + "'.");
298  }
299 }
300 
301 SUMOReal
303  std::string line = getNextNonCommentLine(lr);
304  SUMOReal factor = -1;
305  try {
306  factor = TplConvert::_2SUMOReal(line.c_str()) * scale;
307  } catch (NumberFormatException&) {
308  throw ProcessError("Broken factor: '" + line + "'.");
309  }
310  return factor;
311 }
312 
313 void
315  std::string vehType, bool matrixHasVehType) {
316  PROGRESS_BEGIN_MESSAGE("Reading matrix '" + lr.getFileName() + "' stored as VMR");
317  // parse first defs
318  std::string line;
319  if (matrixHasVehType) {
320  line = getNextNonCommentLine(lr);
321  if (vehType == "") {
322  vehType = StringUtils::prune(line);
323  }
324  }
325 
326  // parse time
327  std::pair<SUMOTime, SUMOTime> times = readTime(lr);
328  SUMOTime begin = times.first;
329  SUMOTime end = times.second;
330 
331  // factor
332  SUMOReal factor = readFactor(lr, scale);
333 
334  // districts
335  line = getNextNonCommentLine(lr);
336  int districtNo = TplConvert::_2int(StringUtils::prune(line).c_str());
337  // parse district names (normally ints)
338  std::vector<std::string> names;
339  do {
340  line = getNextNonCommentLine(lr);
342  while (st2.hasNext()) {
343  names.push_back(st2.next());
344  }
345  } while ((int) names.size() != districtNo);
346 
347  // parse the cells
348  for (std::vector<std::string>::iterator si = names.begin(); si != names.end(); ++si) {
349  std::vector<std::string>::iterator di = names.begin();
350  //
351  do {
352  line = getNextNonCommentLine(lr);
353  if (line.length() == 0) {
354  continue;
355  }
356  try {
358  while (st2.hasNext()) {
359  assert(di != names.end());
360  SUMOReal vehNumber = TplConvert::_2SUMOReal(st2.next().c_str()) * factor;
361  if (vehNumber != 0) {
362  add(vehNumber, begin, end, *si, *di, vehType);
363  }
364  if (di == names.end()) {
365  throw ProcessError("More entries than districts found.");
366  }
367  ++di;
368  }
369  } catch (NumberFormatException&) {
370  throw ProcessError("Not numeric vehicle number in line '" + line + "'.");
371  }
372  if (!lr.hasMore()) {
373  break;
374  }
375  } while (di != names.end());
376  }
378 }
379 
380 
381 void
383  std::string vehType, bool matrixHasVehType) {
384  PROGRESS_BEGIN_MESSAGE("Reading matrix '" + lr.getFileName() + "' stored as OR");
385  // parse first defs
386  std::string line;
387  if (matrixHasVehType) {
388  line = getNextNonCommentLine(lr);
389  int type = TplConvert::_2int(StringUtils::prune(line).c_str());
390  if (vehType == "") {
391  vehType = toString(type);
392  }
393  }
394 
395  // parse time
396  std::pair<SUMOTime, SUMOTime> times = readTime(lr);
397  SUMOTime begin = times.first;
398  SUMOTime end = times.second;
399 
400  // factor
401  SUMOReal factor = readFactor(lr, scale);
402 
403  // parse the cells
404  while (lr.hasMore()) {
405  line = getNextNonCommentLine(lr);
406  if (line.length() == 0) {
407  continue;
408  }
410  if (st2.size() == 0) {
411  continue;
412  }
413  try {
414  std::string sourceD = st2.next();
415  std::string destD = st2.next();
416  SUMOReal vehNumber = TplConvert::_2SUMOReal(st2.next().c_str()) * factor;
417  if (vehNumber != 0) {
418  add(vehNumber, begin, end, sourceD, destD, vehType);
419  }
420  } catch (OutOfBoundsException&) {
421  throw ProcessError("Missing at least one information in line '" + line + "'.");
422  } catch (NumberFormatException&) {
423  throw ProcessError("Not numeric vehicle number in line '" + line + "'.");
424  }
425  }
427 }
428 
429 
430 
431 SUMOReal
433  return myNoLoaded;
434 }
435 
436 
437 SUMOReal
439  return myNoWritten;
440 }
441 
442 
443 SUMOReal
445  return myNoDiscarded;
446 }
447 
448 
449 void
450 ODMatrix::applyCurve(const Distribution_Points& ps, ODCell* cell, std::vector<ODCell*>& newCells) {
451  for (size_t i = 0; i < ps.getAreaNo(); ++i) {
452  ODCell* ncell = new ODCell();
453  ncell->begin = TIME2STEPS(ps.getAreaBegin(i));
454  ncell->end = TIME2STEPS(ps.getAreaEnd(i));
455  ncell->origin = cell->origin;
456  ncell->destination = cell->destination;
457  ncell->vehicleType = cell->vehicleType;
458  ncell->vehicleNumber = cell->vehicleNumber * ps.getAreaPerc(i);
459  newCells.push_back(ncell);
460  }
461 }
462 
463 
464 void
466  std::vector<ODCell*> oldCells = myContainer;
467  myContainer.clear();
468  for (std::vector<ODCell*>::iterator i = oldCells.begin(); i != oldCells.end(); ++i) {
469  std::vector<ODCell*> newCells;
470  applyCurve(ps, *i, newCells);
471  copy(newCells.begin(), newCells.end(), back_inserter(myContainer));
472  delete *i;
473  }
474 }
475 
476 void
478  std::vector<std::string> files = oc.getStringVector("od-matrix-files");
479  for (std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i) {
480  LineReader lr(*i);
481  if (!lr.good()) {
482  throw ProcessError("Could not open '" + (*i) + "'.");
483  }
484  std::string type = lr.readLine();
485  // get the type only
486  if (type.find(';') != std::string::npos) {
487  type = type.substr(0, type.find(';'));
488  }
489  // parse type-dependant
490  if (type.length() > 1 && type[1] == 'V') {
491  // process ptv's 'V'-matrices
492  if (type.find('N') != std::string::npos) {
493  throw ProcessError("'" + *i + "' does not contain the needed information about the time described.");
494  }
495  readV(lr, oc.getFloat("scale"), oc.getString("vtype"), type.find('M') != std::string::npos);
496  } else if (type.length() > 1 && type[1] == 'O') {
497  // process ptv's 'O'-matrices
498  if (type.find('N') != std::string::npos) {
499  throw ProcessError("'" + *i + "' does not contain the needed information about the time described.");
500  }
501  readO(lr, oc.getFloat("scale"), oc.getString("vtype"), type.find('M') != std::string::npos);
502  } else {
503  throw ProcessError("'" + *i + "' uses an unknown matrix type '" + type + "'.");
504  }
505  }
506  std::vector<std::string> amitranFiles = oc.getStringVector("od-amitran-files");
507  for (std::vector<std::string>::iterator i = amitranFiles.begin(); i != amitranFiles.end(); ++i) {
508  if (!FileHelpers::isReadable(*i)) {
509  throw ProcessError("Could not access matrix file '" + *i + "' to load.");
510  }
511  PROGRESS_BEGIN_MESSAGE("Loading matrix in Amitran format from '" + *i + "'");
512  ODAmitranHandler handler(*this, *i);
513  if (!XMLSubSys::runParser(handler, *i)) {
515  } else {
517  }
518  }
519 }
520 
521 
523 ODMatrix::parseTimeLine(const std::vector<std::string>& def, bool timelineDayInHours) {
524  bool interpolating = !timelineDayInHours;
525  PositionVector points;
526  SUMOReal prob = 0;
527  if (timelineDayInHours) {
528  if (def.size() != 24) {
529  throw ProcessError("Assuming 24 entries for a day timeline, but got " + toString(def.size()) + ".");
530  }
531  for (int chour = 0; chour < 24; ++chour) {
532  prob = TplConvert::_2SUMOReal(def[chour].c_str());
533  points.push_back(Position((SUMOReal)(chour * 3600), prob));
534  }
535  points.push_back(Position((SUMOReal)(24 * 3600), prob));
536  } else {
537  size_t i = 0;
538  while (i < def.size()) {
539  StringTokenizer st2(def[i++], ":");
540  if (st2.size() != 2) {
541  throw ProcessError("Broken time line definition: missing a value in '" + def[i - 1] + "'.");
542  }
543  int time = TplConvert::_2int(st2.next().c_str());
544  prob = TplConvert::_2SUMOReal(st2.next().c_str());
545  points.push_back(Position((SUMOReal) time, prob));
546  }
547  }
548  return Distribution_Points("N/A", points, interpolating);
549 }
550 
551 /****************************************************************************/
SUMOReal getNoLoaded() const
Returns the number of loaded vehicles.
Definition: ODMatrix.cpp:432
SUMOReal myNoLoaded
Number of loaded vehicles.
Definition: ODMatrix.h:321
void writeDefaultAttrs(OutputDevice &dev, const bool noVtype, const ODCell *const cell)
Helper function for flow and trip output writing the depart and arrival attributes.
Definition: ODMatrix.cpp:141
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:257
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
Used for sorting the cells by the begin time they describe.
Definition: ODMatrix.h:334
std::string next()
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:58
bool readLine(LineHandler &lh)
Reads a single (the next) line from the file and reports it to the given LineHandler.
Definition: LineReader.cpp:80
static SUMOReal _2SUMOReal(const E *const data)
Definition: TplConvert.h:223
static const int WHITECHARS
void write(SUMOTime begin, const SUMOTime end, OutputDevice &dev, const bool uniform, const bool noVtype, const std::string &prefix, const bool stepLog)
Writes the vehicles stored in the matrix assigning the sources and sinks.
Definition: ODMatrix.cpp:170
Retrieves a file linewise and reports the lines to a handler.
Definition: LineReader.h:58
SUMOReal getAreaPerc(size_t index) const
SUMOReal myNoWritten
Number of written vehicles.
Definition: ODMatrix.h:324
const ODDistrictCont & myDistricts
The districts to retrieve sources/sinks from.
Definition: ODMatrix.h:318
SUMOReal getAreaEnd(size_t index) const
An internal representation of a single vehicle.
Definition: ODMatrix.h:228
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:61
T MAX2(T a, T b)
Definition: StdDefs.h:74
void add(SUMOReal vehicleNumber, SUMOTime begin, SUMOTime end, const std::string &origin, const std::string &destination, const std::string &vehicleType)
Builds a single cell from the given values, verifying them.
Definition: ODMatrix.cpp:74
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
std::string from
The edge the vehicles shall start at.
Definition: ODMatrix.h:236
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything's ok.
Definition: XMLSubSys.cpp:114
SUMOTime parseSingleTime(const std::string &time)
Definition: ODMatrix.cpp:273
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
void loadMatrix(OptionsCont &oc)
read a VISUM-matrix with the V Format
Definition: ODMatrix.cpp:477
T get(const std::string &id) const
Retrieves an item.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
#define PROGRESS_FAILED_MESSAGE()
Definition: MsgHandler.h:204
unsigned int sinkNumber() const
Returns the number of sinks.
Definition: ODDistrict.cpp:82
SUMOReal getNoDiscarded() const
Returns the number of discarded vehicles.
Definition: ODMatrix.cpp:444
~ODMatrix()
Destructor.
Definition: ODMatrix.cpp:65
A single O/D-matrix cell.
Definition: ODCell.h:56
void readV(LineReader &lr, SUMOReal scale, std::string vehType, bool matrixHasVehType)
read a VISUM-matrix with the V Format
Definition: ODMatrix.cpp:314
std::string origin
Name of the origin district.
Definition: ODCell.h:67
std::string getRandomSourceFromDistrict(const std::string &name) const
Returns the id of a random source from the named district.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
void readO(LineReader &lr, SUMOReal scale, std::string vehType, bool matrixHasVehType)
read a VISUM-matrix with the O Format
Definition: ODMatrix.cpp:382
ODCell * cell
The cell of the ODMatrix which generated the vehicle.
Definition: ODMatrix.h:234
A container for districts.
SUMOReal getAreaBegin(size_t index) const
#define PROGRESS_BEGIN_MESSAGE(msg)
Definition: MsgHandler.h:202
unsigned int sourceNumber() const
Returns the number of sources.
Definition: ODDistrict.cpp:88
SUMOReal getNoWritten() const
Returns the number of written vehicles.
Definition: ODMatrix.cpp:438
SUMOReal vehicleNumber
The number of vehicles.
Definition: ODCell.h:58
Used for sorting vehicles by their departure (latest first)
Definition: ODMatrix.h:370
size_t size() const
SUMOReal myNoDiscarded
Number of discarded vehicles.
Definition: ODMatrix.h:327
std::vector< ODCell * > myContainer
The loaded cells.
Definition: ODMatrix.h:315
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
SUMOTime begin
The begin time this cell describes.
Definition: ODCell.h:61
bool good() const
Returns the information whether the stream is readable.
Definition: LineReader.cpp:229
void writeFlows(const SUMOTime begin, const SUMOTime end, OutputDevice &dev, const bool noVtype, const std::string &prefix)
Writes the flows stored in the matrix.
Definition: ODMatrix.cpp:237
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
SUMOReal readFactor(LineReader &lr, SUMOReal scale)
Definition: ODMatrix.cpp:302
std::string getFileName() const
Returns the name of the used file.
Definition: LineReader.cpp:183
std::pair< SUMOTime, SUMOTime > readTime(LineReader &lr)
Definition: ODMatrix.cpp:284
void push_back(const PositionVector &p)
Appends all positions from the given vector.
static int _2int(const E *const data)
Definition: TplConvert.h:114
std::string getNextNonCommentLine(LineReader &lr)
Definition: ODMatrix.cpp:260
SUMOTime depart
The departure time of the vehicle.
Definition: ODMatrix.h:232
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
Definition: StringUtils.cpp:56
A storage for options typed value containers)
Definition: OptionsCont.h:108
An XML-Handler for districts.
void applyCurve(const Distribution_Points &ps)
Splits the stored cells dividing them on the given time line.
Definition: ODMatrix.cpp:465
int SUMOTime
Definition: SUMOTime.h:43
std::string vehicleType
Name of the vehicle type.
Definition: ODCell.h:73
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
std::string destination
Name of the destination district.
Definition: ODCell.h:70
bool closeTag()
Closes the most recently opened tag.
#define SUMOReal
Definition: config.h:218
#define DELTA_T
Definition: SUMOTime.h:50
bool hasMore() const
Returns whether another line may be read (the file was not read completely)
Definition: LineReader.cpp:64
std::string getRandomSinkFromDistrict(const std::string &name) const
Returns the id of a random sink from the named district.
SUMOTime end
The end time this cell describes.
Definition: ODCell.h:64
#define PROGRESS_DONE_MESSAGE()
Definition: MsgHandler.h:203
std::string to
The edge the vehicles shall end at.
Definition: ODMatrix.h:238
ODMatrix(const ODDistrictCont &dc)
Constructor.
Definition: ODMatrix.cpp:61
SUMOReal computeDeparts(ODCell *cell, size_t &vehName, std::vector< ODVehicle > &into, bool uniform, const std::string &prefix)
Computes the vehicle departs stored in the given cell and saves them in "into".
Definition: ODMatrix.cpp:108
std::string id
The id of the vehicle.
Definition: ODMatrix.h:230
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Distribution_Points parseTimeLine(const std::vector< std::string > &def, bool timelineDayInHours)
split the given timeline
Definition: ODMatrix.cpp:523
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.