22 #ifndef LogitCalculator_h 23 #define LogitCalculator_h 46 template<
class R,
class E,
class V>
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));
75 for (
typename std::vector<R*>::const_iterator j = alternatives.begin(); j != alternatives.end(); j++) {
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++) {
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 SUMOReal cost = (*i)->getCosts() / 3600.;
122 for (
typename std::vector<R*>::const_iterator i = alternatives.begin(); i != alternatives.end(); i++) {
123 const SUMOReal cost = (*i)->getCosts() / 3600.;
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 SUMOReal cvCost = sqrt(diff /
SUMOReal(alternatives.size())) / meanCost;
136 return 3.1415926535897932384626433832795 / (sqrt(6.) * cvCost * (min + 1.1)) / 3600.;
Cost calculation with c-logit or logit method.
SUMOReal getThetaForCLogit(const std::vector< R * > alternatives) const
calculate the scaling factor in the logit model
const SUMOReal myGamma
logit gamma - value
void setCosts(R *route, const SUMOReal costs, const bool) const
void calculateProbabilities(std::vector< R * > alternatives, const V *const veh, const SUMOTime time)
calculate the probabilities in the logit model
Abstract base class providing static factory method.
SUMOReal getBetaForCLogit(const std::vector< R * > alternatives) const
calculate the scaling factor in the logit model
std::map< const R *, SUMOReal > myCommonalities
The route commonality factors for c-logit.
virtual ~LogitCalculator()
Destructor.
const SUMOReal myBeta
logit beta - value
LogitCalculator(const SUMOReal beta, const SUMOReal gamma, const SUMOReal theta)
Constructor.
const SUMOReal myTheta
logit theta - value
LogitCalculator & operator=(const LogitCalculator &s)
invalidated assignment operator