SUMO - Simulation of Urban MObility
RouteCostCalculator.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Calculators for route costs and probabilities
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2002-2015 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef RouteCostCalculator_h
23 #define RouteCostCalculator_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <vector>
36 #include <map>
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
46 template<class R, class E, class V>
48 public:
50 
51  static void cleanup() {
52  delete myInstance;
53  myInstance = 0;
54  }
55 
56  virtual void setCosts(R* route, const SUMOReal costs, const bool isActive = false) const = 0;
57 
59  virtual void calculateProbabilities(std::vector<R*> alternatives, const V* const veh, const SUMOTime time) = 0;
60 
61  unsigned int getMaxRouteNumber() const {
62  return myMaxRouteNumber;
63  }
64 
65  bool keepRoutes() const {
66  return myKeepRoutes;
67  }
68 
69  bool skipRouteCalculation() const {
71  }
72 
73 protected:
77  myMaxRouteNumber = oc.getInt("max-alternatives");
78  myKeepRoutes = oc.getBool("keep-all-routes");
79  mySkipRouteCalculation = oc.getBool("skip-new-routes");
80  }
81 
83  virtual ~RouteCostCalculator() {}
84 
85 private:
87 
89  unsigned int myMaxRouteNumber;
90 
93 
96 
97 };
98 
99 
100 // ===========================================================================
101 // static member definitions
102 // ===========================================================================
103 template<class R, class E, class V>
105 
106 
107 #include "GawronCalculator.h"
108 #include "LogitCalculator.h"
109 
110 template<class R, class E, class V>
112  if (myInstance == 0) {
114  if (oc.getString("route-choice-method") == "logit") {
115  myInstance = new LogitCalculator<R, E, V>(oc.getFloat("logit.beta"), oc.getFloat("logit.gamma"), oc.getFloat("logit.theta"));
116  } else if (oc.getString("route-choice-method") == "gawron") {
117  myInstance = new GawronCalculator<R, E, V>(oc.getFloat("gawron.beta"), oc.getFloat("gawron.a"));
118  }
119  }
120  return *myInstance;
121 }
122 #endif
123 
124 /****************************************************************************/
125 
long long int SUMOTime
Definition: SUMOTime.h:43
Cost calculation with c-logit or logit method.
unsigned int myMaxRouteNumber
The maximum route alternatives number.
RouteCostCalculator()
Constructor.
virtual void setCosts(R *route, const SUMOReal costs, const bool isActive=false) const =0
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
unsigned int getMaxRouteNumber() const
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
static RouteCostCalculator * myInstance
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
Cost calculation with Gawron&#39;s method.
virtual void calculateProbabilities(std::vector< R * > alternatives, const V *const veh, const SUMOTime time)=0
calculate the probabilities in the logit model
Abstract base class providing static factory method.
bool skipRouteCalculation() const
bool myKeepRoutes
Information whether all routes should be saved.
bool mySkipRouteCalculation
Information whether new routes should be calculated.
virtual ~RouteCostCalculator()
Destructor.
A storage for options typed value containers)
Definition: OptionsCont.h:108
#define SUMOReal
Definition: config.h:214
static RouteCostCalculator< R, E, V > & getCalculator()
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)