Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Calculators for route costs and probabilities
18 /****************************************************************************/
19 #ifndef RouteCostCalculator_h
20 #define RouteCostCalculator_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <vector>
29 #include <map>
30 #include <cmath>
31 #include <utils/common/StdDefs.h>
32 #include <utils/common/SUMOTime.h>
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
43 template<class R, class E, class V>
45 public:
47 
48  static void cleanup() {
49  delete myInstance;
50  myInstance = 0;
51  }
52 
53  virtual void setCosts(R* route, const double costs, const bool isActive = false) const = 0;
54 
56  virtual void calculateProbabilities(std::vector<R*> alternatives, const V* const veh, const SUMOTime time) = 0;
57 
58  int getMaxRouteNumber() const {
59  return myMaxRouteNumber;
60  }
61 
62  bool keepRoutes() const {
63  return myKeepRoutes;
64  }
65 
66  bool skipRouteCalculation() const {
68  }
69 
70 protected:
74  myMaxRouteNumber = oc.getInt("max-alternatives");
75  myKeepRoutes = oc.getBool("keep-all-routes");
76  mySkipRouteCalculation = oc.getBool("skip-new-routes");
77  }
78 
80  virtual ~RouteCostCalculator() {}
81 
82 private:
84 
87 
90 
93 
94 };
95 
96 
97 // ===========================================================================
98 // static member definitions
99 // ===========================================================================
100 template<class R, class E, class V>
102 
103 
104 #include "GawronCalculator.h"
105 #include "LogitCalculator.h"
106 
107 template<class R, class E, class V>
109  if (myInstance == 0) {
111  if (oc.getString("route-choice-method") == "logit") {
112  myInstance = new LogitCalculator<R, E, V>(oc.getFloat("logit.beta"), oc.getFloat("logit.gamma"), oc.getFloat("logit.theta"));
113  } else if (oc.getString("route-choice-method") == "gawron") {
114  myInstance = new GawronCalculator<R, E, V>(oc.getFloat("gawron.beta"), oc.getFloat("gawron.a"));
115  }
116  }
117  return *myInstance;
118 }
119 #endif
120 
121 /****************************************************************************/
122 
bool skipRouteCalculation() const
int myMaxRouteNumber
The maximum route alternatives number.
long long int SUMOTime
Definition: SUMOTime.h:35
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 double 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:58
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.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
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:90
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