SUMO - Simulation of Urban MObility

ODMatrix.h

Go to the documentation of this file.
00001 /****************************************************************************/
00008 // An O/D (origin/destination) matrix
00009 /****************************************************************************/
00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00012 /****************************************************************************/
00013 //
00014 //   This file is part of SUMO.
00015 //   SUMO is free software: you can redistribute it and/or modify
00016 //   it under the terms of the GNU General Public License as published by
00017 //   the Free Software Foundation, either version 3 of the License, or
00018 //   (at your option) any later version.
00019 //
00020 /****************************************************************************/
00021 #ifndef ODMatrix_h
00022 #define ODMatrix_h
00023 
00024 
00025 // ===========================================================================
00026 // included modules
00027 // ===========================================================================
00028 #ifdef _MSC_VER
00029 #include <windows_config.h>
00030 #else
00031 #include <config.h>
00032 #endif
00033 
00034 #include <iostream>
00035 #include <sstream>
00036 #include <fstream>
00037 #include <vector>
00038 #include <cstdlib>
00039 #include <ctime>
00040 #include <algorithm>
00041 #include <string>
00042 #include <utils/common/SUMOTime.h>
00043 #include "ODCell.h"
00044 #include "ODDistrictCont.h"
00045 #include <utils/distribution/Distribution_Points.h>
00046 
00047 
00048 // ===========================================================================
00049 // class declarations
00050 // ===========================================================================
00051 class OutputDevice;
00052 
00053 
00054 // ===========================================================================
00055 // class definitions
00056 // ===========================================================================
00072 class ODMatrix {
00073 public:
00078     ODMatrix(const ODDistrictCont& dc) ;
00079 
00080 
00082     ~ODMatrix() ;
00083 
00084 
00106     void add(SUMOReal vehicleNumber, SUMOTime begin,
00107              SUMOTime end, const std::string& origin, const std::string& destination,
00108              const std::string& vehicleType) ;
00109 
00110 
00134     void write(SUMOTime begin, SUMOTime end,
00135                OutputDevice& dev, bool uniform, bool noVtype,
00136                const std::string& prefix) ;
00137 
00138 
00145     SUMOReal getNoLoaded() const ;
00146 
00147 
00154     SUMOReal getNoWritten() const ;
00155 
00156 
00163     SUMOReal getNoDiscarded() const ;
00164 
00165 
00169     void applyCurve(const Distribution_Points& ps) ;
00170 
00171 
00172 protected:
00177     struct ODVehicle {
00179         std::string id;
00181         SUMOTime depart;
00183         ODCell* cell;
00185         std::string from;
00187         std::string to;
00188 
00189     };
00190 
00191 
00193     typedef std::vector<ODCell*> CellVector;
00194 
00195 
00220     SUMOReal computeDeparts(ODCell* cell,
00221                             size_t& vehName, std::vector<ODVehicle> &into, bool uniform,
00222                             const std::string& prefix) ;
00223 
00224 
00240     void applyCurve(const Distribution_Points& ps, ODCell* cell,
00241                     CellVector& newCells) ;
00242 
00243 
00244 protected:
00246     CellVector myContainer;
00247 
00249     const ODDistrictCont& myDistricts;
00250 
00252     SUMOReal myNoLoaded;
00253 
00255     SUMOReal myNoWritten;
00256 
00258     SUMOReal myNoDiscarded;
00259 
00260 
00265     class cell_by_begin_sorter {
00266     public:
00268         explicit cell_by_begin_sorter() { }
00269 
00270 
00281         int operator()(ODCell* p1, ODCell* p2) const {
00282             if (p1->begin == p2->begin) {
00283                 if (p1->origin == p2->origin) {
00284                     return p1->destination < p2->destination;
00285                 }
00286                 return p1->origin < p2->origin;
00287             }
00288             return p1->begin < p2->begin;
00289         }
00290 
00291     };
00292 
00293 
00301     class descending_departure_comperator {
00302     public:
00304         descending_departure_comperator() { }
00305 
00306 
00315         bool operator()(const ODVehicle& p1, const ODVehicle& p2) const {
00316             if (p1.depart == p2.depart) {
00317                 return p1.id > p2.id;
00318             }
00319             return p1.depart > p2.depart;
00320         }
00321 
00322     };
00323 
00324 private:
00326     ODMatrix(const ODMatrix& s);
00327 
00329     ODMatrix& operator=(const ODMatrix& s);
00330 
00331 };
00332 
00333 
00334 #endif
00335 
00336 /****************************************************************************/
00337 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines