SUMO - Simulation of Urban MObility
ROCostCalculator.h
Go to the documentation of this file.
00001 /****************************************************************************/
00008 // Calculators for route costs and probabilities
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 ROCostCalculator_h
00022 #define ROCostCalculator_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 <vector>
00035 #include <map>
00036 
00037 
00038 // ===========================================================================
00039 // class declarations
00040 // ===========================================================================
00041 class RORoute;
00042 class ROVehicle;
00043 
00044 
00045 // ===========================================================================
00046 // class definitions
00047 // ===========================================================================
00052 class ROCostCalculator {
00053 public:
00054     static ROCostCalculator& getCalculator();
00055 
00056     static void cleanup();
00057 
00058     virtual void setCosts(RORoute* route, const SUMOReal costs, const bool isActive=false) const = 0;
00059 
00061     virtual void calculateProbabilities(const ROVehicle* const veh, std::vector<RORoute*> alternatives) = 0;
00062 
00063 protected:
00065     ROCostCalculator();
00066 
00068     virtual ~ROCostCalculator();
00069 
00070 private:
00071     static ROCostCalculator* myInstance;
00072 
00073 };
00074 
00075 
00080 class ROGawronCalculator : public ROCostCalculator {
00081 public:
00083     ROGawronCalculator(const SUMOReal beta, const SUMOReal a);
00084 
00086     virtual ~ROGawronCalculator();
00087 
00088     void setCosts(RORoute* route, const SUMOReal costs, const bool isActive=false) const;
00089 
00091     void calculateProbabilities(const ROVehicle* const veh, std::vector<RORoute*> alternatives);
00092 
00093 private:
00096     SUMOReal gawronF(const SUMOReal pdr, const SUMOReal pds, const SUMOReal x) const;
00097 
00100     SUMOReal gawronG(const SUMOReal a, const SUMOReal x) const;
00101 
00102 private:
00104     const SUMOReal myBeta;
00105 
00107     const SUMOReal myA;
00108 
00109 };
00110 
00111 
00116 class ROLogitCalculator : public ROCostCalculator {
00117 public:
00119     ROLogitCalculator(const SUMOReal beta, const SUMOReal gamma,
00120                       const SUMOReal theta);
00121 
00123     virtual ~ROLogitCalculator();
00124 
00125     void setCosts(RORoute* route, const SUMOReal costs, const bool isActive=false) const;
00126 
00128     void calculateProbabilities(const ROVehicle* const veh, std::vector<RORoute*> alternatives);
00129 
00130 private:
00132     SUMOReal getBetaForCLogit(const std::vector<RORoute*> alternatives) const;
00133 
00135     SUMOReal getThetaForCLogit(const std::vector<RORoute*> alternatives) const;
00136 
00137 private:
00139     const SUMOReal myBeta;
00140 
00142     const SUMOReal myGamma;
00143 
00145     const SUMOReal myTheta;
00146 
00148     std::map<const RORoute*, SUMOReal> myCommonalities;
00149 
00150 };
00151 
00152 
00153 #endif
00154 
00155 /****************************************************************************/
00156 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines