SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ODMatrix.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // An O/D (origin/destination) matrix
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef ODMatrix_h
22 #define ODMatrix_h
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 <sstream>
36 #include <fstream>
37 #include <vector>
38 #include <cstdlib>
39 #include <ctime>
40 #include <algorithm>
41 #include <string>
42 #include <utils/common/SUMOTime.h>
43 #include "ODCell.h"
44 #include "ODDistrictCont.h"
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
51 class OutputDevice;
52 
53 
54 // ===========================================================================
55 // class definitions
56 // ===========================================================================
72 class ODMatrix {
73 public:
78  ODMatrix(const ODDistrictCont& dc) ;
79 
80 
82  ~ODMatrix() ;
83 
84 
106  void add(SUMOReal vehicleNumber, SUMOTime begin,
107  SUMOTime end, const std::string& origin, const std::string& destination,
108  const std::string& vehicleType) ;
109 
110 
135  void write(SUMOTime begin, SUMOTime end,
136  OutputDevice& dev, bool uniform, bool noVtype,
137  const std::string& prefix, bool stepLog) ;
138 
139 
146  SUMOReal getNoLoaded() const ;
147 
148 
155  SUMOReal getNoWritten() const ;
156 
157 
164  SUMOReal getNoDiscarded() const ;
165 
166 
170  void applyCurve(const Distribution_Points& ps) ;
171 
172 
173 protected:
178  struct ODVehicle {
180  std::string id;
186  std::string from;
188  std::string to;
189 
190  };
191 
192 
194  typedef std::vector<ODCell*> CellVector;
195 
196 
222  size_t& vehName, std::vector<ODVehicle> &into, bool uniform,
223  const std::string& prefix) ;
224 
225 
241  void applyCurve(const Distribution_Points& ps, ODCell* cell,
242  CellVector& newCells) ;
243 
244 
245 protected:
248 
251 
254 
257 
260 
261 
267  public:
269  explicit cell_by_begin_sorter() { }
270 
271 
282  int operator()(ODCell* p1, ODCell* p2) const {
283  if (p1->begin == p2->begin) {
284  if (p1->origin == p2->origin) {
285  return p1->destination < p2->destination;
286  }
287  return p1->origin < p2->origin;
288  }
289  return p1->begin < p2->begin;
290  }
291 
292  };
293 
294 
303  public:
306 
307 
316  bool operator()(const ODVehicle& p1, const ODVehicle& p2) const {
317  if (p1.depart == p2.depart) {
318  return p1.id > p2.id;
319  }
320  return p1.depart > p2.depart;
321  }
322 
323  };
324 
325 private:
327  ODMatrix(const ODMatrix& s);
328 
330  ODMatrix& operator=(const ODMatrix& s);
331 
332 };
333 
334 
335 #endif
336 
337 /****************************************************************************/
338