SUMO - Simulation of Urban MObility

RORouteDef_Alternatives.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // A route with alternative routes
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 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 RORouteDef_Alternatives_h
00020 #define RORouteDef_Alternatives_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 <string>
00033 #include <vector>
00034 #include "RORouteDef.h"
00035 #include <utils/common/RGBColor.h>
00036 
00037 
00038 // ===========================================================================
00039 // class declarations
00040 // ===========================================================================
00041 class ROEdge;
00042 
00043 
00044 // ===========================================================================
00045 // class definitions
00046 // ===========================================================================
00051 class RORouteDef_Alternatives : public RORouteDef {
00052 public:
00054     RORouteDef_Alternatives(const std::string& id, unsigned int lastUsed, const SUMOReal beta,
00055                             const SUMOReal gawronA, const SUMOReal logitGamma, const int maxRoutes,
00056                             const bool keepRoutes, const bool skipRouteCalculation) throw();
00057 
00059     virtual ~RORouteDef_Alternatives() throw();
00060 
00063     virtual void addLoadedAlternative(RORoute* alternative);
00064 
00066     RORoute* buildCurrentRoute(SUMOAbstractRouter<ROEdge,ROVehicle> &router, SUMOTime begin,
00067                                const ROVehicle& veh) const;
00068 
00070     void addAlternative(SUMOAbstractRouter<ROEdge,ROVehicle> &router,
00071                         const ROVehicle* const, RORoute* current, SUMOTime begin);
00072 
00074     RORouteDef* copy(const std::string& id) const;
00075 
00076     void invalidateLast();
00077 
00078     void removeLast();
00079 
00080     virtual OutputDevice& writeXMLDefinition(SUMOAbstractRouter<ROEdge,ROVehicle> &router,
00081             OutputDevice& dev, const ROVehicle* const veh,
00082             bool asAlternatives, bool withExitTimes) const;
00083 
00084 private:
00086     int findRoute(RORoute* opt) const;
00087 
00089     SUMOReal getThetaForCLogit() const;
00090 
00092     void calculateLogitProbabilities();
00093 
00096     SUMOReal gawronF(SUMOReal pdr, SUMOReal pds, SUMOReal x);
00097 
00100     SUMOReal gawronG(SUMOReal a, SUMOReal x);
00101 
00102 private:
00104     mutable bool myNewRoute;
00105 
00107     mutable int myLastUsed;
00108 
00110     typedef std::vector<RORoute*> AlternativesVector;
00111 
00113     AlternativesVector myAlternatives;
00114 
00116     const SUMOReal myBeta;
00117 
00119     const SUMOReal myGawronA;
00120 
00122     const SUMOReal myLogitGamma;
00123 
00125     std::map<const RORoute*, SUMOReal> myCommonalities;
00126 
00128     const int myMaxRouteNumber;
00129 
00131     const bool myKeepRoutes;
00132 
00134     const bool mySkipRouteCalculation;
00135 
00136 
00137 private:
00139     RORouteDef_Alternatives(const RORouteDef_Alternatives& src);
00140 
00142     RORouteDef_Alternatives& operator=(const RORouteDef_Alternatives& src);
00143 
00144 };
00145 
00146 
00147 #endif
00148 
00149 /****************************************************************************/
00150 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines