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-2016 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>
37 #include <cmath>
38 #include <utils/common/StdDefs.h>
39 #include <utils/common/SUMOTime.h>
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
50 template<class R, class E, class V>
52 public:
54 
55  static void cleanup() {
56  delete myInstance;
57  myInstance = 0;
58  }
59 
60  virtual void setCosts(R* route, const SUMOReal costs, const bool isActive = false) const = 0;
61 
63  virtual void calculateProbabilities(std::vector<R*> alternatives, const V* const veh, const SUMOTime time) = 0;
64 
65  int getMaxRouteNumber() const {
66  return myMaxRouteNumber;
67  }
68 
69  bool keepRoutes() const {
70  return myKeepRoutes;
71  }
72 
73  bool skipRouteCalculation() const {
75  }
76 
77 protected:
81  myMaxRouteNumber = oc.getInt("max-alternatives");
82  myKeepRoutes = oc.getBool("keep-all-routes");
83  mySkipRouteCalculation = oc.getBool("skip-new-routes");
84  }
85 
87  virtual ~RouteCostCalculator() {}
88 
89 private:
91 
94 
97 
100 
101 };
102 
103 
104 // ===========================================================================
105 // static member definitions
106 // ===========================================================================
107 template<class R, class E, class V>
109 
110 
111 #include "GawronCalculator.h"
112 #include "LogitCalculator.h"
113 
114 template<class R, class E, class V>
116  if (myInstance == 0) {
118  if (oc.getString("route-choice-method") == "logit") {
119  myInstance = new LogitCalculator<R, E, V>(oc.getFloat("logit.beta"), oc.getFloat("logit.gamma"), oc.getFloat("logit.theta"));
120  } else if (oc.getString("route-choice-method") == "gawron") {
121  myInstance = new GawronCalculator<R, E, V>(oc.getFloat("gawron.beta"), oc.getFloat("gawron.a"));
122  }
123  }
124  return *myInstance;
125 }
126 #endif
127 
128 /****************************************************************************/
129 
bool skipRouteCalculation() const
int myMaxRouteNumber
The maximum route alternatives number.
long long int SUMOTime
Definition: SUMOTime.h:43
Cost calculation with c-logit or logit method.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
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)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
static RouteCostCalculator * myInstance
Cost calculation with Gawron&#39;s method.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
Abstract base class providing static factory method.
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:99
#define SUMOReal
Definition: config.h:213
static RouteCostCalculator< R, E, V > & getCalculator()
virtual void calculateProbabilities(std::vector< R *> alternatives, const V *const veh, const SUMOTime time)=0
calculate the probabilities in the logit model
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)