SUMO - Simulation of Urban MObility
RouteCostCalculator.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Calculators for route costs and probabilities
20 /****************************************************************************/
21 #ifndef RouteCostCalculator_h
22 #define RouteCostCalculator_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <vector>
35 #include <map>
36 #include <cmath>
37 #include <utils/common/StdDefs.h>
38 #include <utils/common/SUMOTime.h>
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
49 template<class R, class E, class V>
51 public:
53 
54  static void cleanup() {
55  delete myInstance;
56  myInstance = 0;
57  }
58 
59  virtual void setCosts(R* route, const double costs, const bool isActive = false) const = 0;
60 
62  virtual void calculateProbabilities(std::vector<R*> alternatives, const V* const veh, const SUMOTime time) = 0;
63 
64  int getMaxRouteNumber() const {
65  return myMaxRouteNumber;
66  }
67 
68  bool keepRoutes() const {
69  return myKeepRoutes;
70  }
71 
72  bool skipRouteCalculation() const {
74  }
75 
76 protected:
80  myMaxRouteNumber = oc.getInt("max-alternatives");
81  myKeepRoutes = oc.getBool("keep-all-routes");
82  mySkipRouteCalculation = oc.getBool("skip-new-routes");
83  }
84 
86  virtual ~RouteCostCalculator() {}
87 
88 private:
90 
93 
96 
99 
100 };
101 
102 
103 // ===========================================================================
104 // static member definitions
105 // ===========================================================================
106 template<class R, class E, class V>
108 
109 
110 #include "GawronCalculator.h"
111 #include "LogitCalculator.h"
112 
113 template<class R, class E, class V>
115  if (myInstance == 0) {
117  if (oc.getString("route-choice-method") == "logit") {
118  myInstance = new LogitCalculator<R, E, V>(oc.getFloat("logit.beta"), oc.getFloat("logit.gamma"), oc.getFloat("logit.theta"));
119  } else if (oc.getString("route-choice-method") == "gawron") {
120  myInstance = new GawronCalculator<R, E, V>(oc.getFloat("gawron.beta"), oc.getFloat("gawron.a"));
121  }
122  }
123  return *myInstance;
124 }
125 #endif
126 
127 /****************************************************************************/
128 
int myMaxRouteNumber
The maximum route alternatives number.
Cost calculation with c-logit or logit method.
RouteCostCalculator()
Constructor.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
int getMaxRouteNumber() const
virtual void setCosts(R *route, const double costs, const bool isActive=false) const =0
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
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:98
long long int SUMOTime
Definition: TraCIDefs.h:51
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)