ODMatrix.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // An O/D (origin/destination) matrix
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef ODMatrix_h
00020 #define ODMatrix_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <iostream>
00033 #include <sstream>
00034 #include <fstream>
00035 #include <vector>
00036 #include <cstdlib>
00037 #include <ctime>
00038 #include <algorithm>
00039 #include <string>
00040 #include <utils/common/SUMOTime.h>
00041 #include "ODCell.h"
00042 #include "ODDistrictCont.h"
00043 #include <utils/distribution/Distribution_Points.h>
00044 
00045 
00046 // ===========================================================================
00047 // class declarations
00048 // ===========================================================================
00049 class OutputDevice;
00050 
00051 
00052 // ===========================================================================
00053 // class definitions
00054 // ===========================================================================
00070 class ODMatrix {
00071 public:
00076     ODMatrix(const ODDistrictCont &dc) throw();
00077 
00078 
00080     ~ODMatrix() throw();
00081 
00082 
00104     void add(SUMOReal vehicleNumber, SUMOTime begin,
00105              SUMOTime end, const std::string &origin, const std::string &destination,
00106              const std::string &vehicleType) throw();
00107 
00108 
00132     void write(SUMOTime begin, SUMOTime end,
00133                OutputDevice &dev, bool uniform, bool noVtype,
00134                const std::string &prefix) throw();
00135 
00136 
00143     SUMOReal getNoLoaded() const throw();
00144 
00145 
00152     SUMOReal getNoWritten() const throw();
00153 
00154 
00161     SUMOReal getNoDiscarded() const throw();
00162 
00163 
00167     void applyCurve(const Distribution_Points &ps) throw();
00168 
00169 
00170 protected:
00175     struct ODVehicle {
00177         std::string id;
00179         SUMOTime depart;
00181         ODCell* cell;
00183         std::string from;
00185         std::string to;
00186 
00187     };
00188 
00189 
00191     typedef std::vector<ODCell*> CellVector;
00192 
00193 
00218     SUMOReal computeEmissions(ODCell *cell,
00219                               size_t &vehName, std::vector<ODVehicle> &into, bool uniform,
00220                               const std::string &prefix) throw();
00221 
00222 
00238     void applyCurve(const Distribution_Points &ps, ODCell *cell,
00239                     CellVector &newCells) throw();
00240 
00241 
00242 protected:
00244     CellVector myContainer;
00245 
00247     const ODDistrictCont &myDistricts;
00248 
00250     SUMOReal myNoLoaded;
00251 
00253     SUMOReal myNoWritten;
00254 
00256     SUMOReal myNoDiscarded;
00257 
00258 
00263     class cell_by_begin_sorter {
00264     public:
00266         explicit cell_by_begin_sorter() { }
00267 
00268 
00279         int operator()(ODCell *p1, ODCell *p2) const {
00280             if (p1->begin == p2->begin) {
00281                 if (p1->origin == p2->origin) {
00282                     return p1->destination < p2->destination;
00283                 }
00284                 return p1->origin < p2->origin;
00285             }
00286             return p1->begin<p2->begin;
00287         }
00288 
00289     };
00290 
00291 
00299     class descending_departure_comperator {
00300     public:
00302         descending_departure_comperator() { }
00303 
00304 
00313         bool operator()(const ODVehicle &p1, const ODVehicle &p2) const {
00314             if (p1.depart==p2.depart) {
00315                 return p1.id>p2.id;
00316             }
00317             return p1.depart>p2.depart;
00318         }
00319 
00320     };
00321 
00322 private:
00324     ODMatrix(const ODMatrix &s);
00325 
00327     ODMatrix &operator=(const ODMatrix &s);
00328 
00329 };
00330 
00331 
00332 #endif
00333 
00334 /****************************************************************************/
00335 

Generated on Wed May 5 00:06:35 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6