21 #ifndef LogitCalculator_h 22 #define LogitCalculator_h 45 template<
class R,
class E,
class V>
55 void setCosts(R* route,
const double costs,
const bool )
const {
56 route->setCosts(costs);
65 for (
typename std::vector<R*>::const_iterator i = alternatives.begin(); i != alternatives.end(); i++) {
68 const std::vector<const E*>& edgesR = pR->getEdgeVector();
69 for (
typename std::vector<const E*>::const_iterator edge = edgesR.begin(); edge != edgesR.end(); ++edge) {
71 lengthR += (*edge)->getTravelTime(veh,
STEPS2TIME(time));
73 double overlapSum = 0;
74 for (
typename std::vector<R*>::const_iterator j = alternatives.begin(); j != alternatives.end(); j++) {
76 double overlapLength = 0.;
78 const std::vector<const E*>& edgesS = pS->getEdgeVector();
79 for (
typename std::vector<const E*>::const_iterator edge = edgesS.begin(); edge != edgesS.end(); ++edge) {
80 lengthS += (*edge)->getTravelTime(veh,
STEPS2TIME(time));
81 if (std::find(edgesR.begin(), edgesR.end(), *edge) != edgesR.end()) {
82 overlapLength += (*edge)->getTravelTime(veh,
STEPS2TIME(time));
85 overlapSum += pow(overlapLength / sqrt(lengthR * lengthS),
myGamma);
90 for (
typename std::vector<R*>::iterator i = alternatives.begin(); i != alternatives.end(); i++) {
92 double weightedSum = 0;
93 for (
typename std::vector<R*>::iterator j = alternatives.begin(); j != alternatives.end(); j++) {
97 pR->setProbability(1. / weightedSum);
105 double min = std::numeric_limits<double>::max();
106 for (
typename std::vector<R*>::const_iterator i = alternatives.begin(); i != alternatives.end(); i++) {
107 const double cost = (*i)->getCosts() / 3600.;
120 double min = std::numeric_limits<double>::max();
121 for (
typename std::vector<R*>::const_iterator i = alternatives.begin(); i != alternatives.end(); i++) {
122 const double cost = (*i)->getCosts() / 3600.;
128 const double meanCost = sum / double(alternatives.size());
129 for (
typename std::vector<R*>::const_iterator i = alternatives.begin(); i != alternatives.end(); i++) {
130 diff += pow((*i)->getCosts() / 3600. - meanCost, 2);
132 const double cvCost = sqrt(diff /
double(alternatives.size())) / meanCost;
135 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