22 #ifndef LogitCalculator_h 23 #define LogitCalculator_h 46 template<
class R,
class E,
class V>
56 void setCosts(R* route,
const double costs,
const bool )
const {
57 route->setCosts(costs);
66 for (
typename std::vector<R*>::const_iterator i = alternatives.begin(); i != alternatives.end(); i++) {
69 const std::vector<const E*>& edgesR = pR->getEdgeVector();
70 for (
typename std::vector<const E*>::const_iterator edge = edgesR.begin(); edge != edgesR.end(); ++edge) {
72 lengthR += (*edge)->getTravelTime(veh,
STEPS2TIME(time));
74 double overlapSum = 0;
75 for (
typename std::vector<R*>::const_iterator j = alternatives.begin(); j != alternatives.end(); j++) {
77 double overlapLength = 0.;
79 const std::vector<const E*>& edgesS = pS->getEdgeVector();
80 for (
typename std::vector<const E*>::const_iterator edge = edgesS.begin(); edge != edgesS.end(); ++edge) {
81 lengthS += (*edge)->getTravelTime(veh,
STEPS2TIME(time));
82 if (std::find(edgesR.begin(), edgesR.end(), *edge) != edgesR.end()) {
83 overlapLength += (*edge)->getTravelTime(veh,
STEPS2TIME(time));
86 overlapSum += pow(overlapLength / sqrt(lengthR * lengthS),
myGamma);
91 for (
typename std::vector<R*>::iterator i = alternatives.begin(); i != alternatives.end(); i++) {
93 double weightedSum = 0;
94 for (
typename std::vector<R*>::iterator j = alternatives.begin(); j != alternatives.end(); j++) {
98 pR->setProbability(1. / weightedSum);
107 for (
typename std::vector<R*>::const_iterator i = alternatives.begin(); i != alternatives.end(); i++) {
108 const double cost = (*i)->getCosts() / 3600.;
122 for (
typename std::vector<R*>::const_iterator i = alternatives.begin(); i != alternatives.end(); i++) {
123 const double cost = (*i)->getCosts() / 3600.;
129 const double meanCost = sum / double(alternatives.size());
130 for (
typename std::vector<R*>::const_iterator i = alternatives.begin(); i != alternatives.end(); i++) {
131 diff += pow((*i)->getCosts() / 3600. - meanCost, 2);
133 const double cvCost = sqrt(diff /
double(alternatives.size())) / meanCost;
136 return 3.1415926535897932384626433832795 / (sqrt(6.) * cvCost * (min + 1.1)) / 3600.;
Cost calculation with c-logit or logit method.
std::map< const R *, double > myCommonalities
The route commonality factors for c-logit.
void calculateProbabilities(std::vector< R *> alternatives, const V *const veh, const SUMOTime time)
calculate the probabilities in the logit model
double getThetaForCLogit(const std::vector< R *> alternatives) const
calculate the scaling factor in the logit model
LogitCalculator(const double beta, const double gamma, const double theta)
Constructor.
void setCosts(R *route, const double costs, const bool) const
Abstract base class providing static factory method.
const double myTheta
logit theta - value
const double myGamma
logit gamma - value
virtual ~LogitCalculator()
Destructor.
double getBetaForCLogit(const std::vector< R *> alternatives) const
calculate the scaling factor in the logit model
const double myBeta
logit beta - value
LogitCalculator & operator=(const LogitCalculator &s)
invalidated assignment operator