36template<
class R,
class E,
class V>
46 void setCosts(R* route,
const double costs,
const bool )
const {
47 route->setCosts(costs);
57 for (
const R*
const pR : alternatives) {
59 const std::vector<const E*>& edgesR = pR->getEdgeVector();
60 for (
const E*
const edge : edgesR) {
62 lengthR += edge->getTravelTime(veh, t);
64 double overlapSum = 0;
65 for (
const R*
const pS : alternatives) {
66 double overlapLength = 0.;
68 for (
const E*
const edge : pS->getEdgeVector()) {
69 lengthS += edge->getTravelTime(veh, t);
70 if (std::find(edgesR.begin(), edgesR.end(), edge) != edgesR.end()) {
71 overlapLength += edge->getTravelTime(veh, t);
74 overlapSum += pow(overlapLength / sqrt(lengthR * lengthS),
myGamma);
79 for (R*
const pR : alternatives) {
80 double weightedSum = 0;
81 for (
const R*
const pS : alternatives) {
84 pR->setProbability(1. / weightedSum);
92 double min = std::numeric_limits<double>::max();
93 for (
const R*
const pR : alternatives) {
94 const double cost = pR->getCosts() / 3600.;
107 double min = std::numeric_limits<double>::max();
108 for (
const R*
const pR : alternatives) {
109 const double cost = pR->getCosts() / 3600.;
115 const double meanCost = sum / double(alternatives.size());
116 for (
const R*
const pR : alternatives) {
117 diff += pow(pR->getCosts() / 3600. - meanCost, 2);
119 const double cvCost = sqrt(diff /
double(alternatives.size())) / meanCost;
122 return 3.1415926535897932384626433832795 / (sqrt(6.) * cvCost * (min + 1.1)) / 3600.;
Cost calculation with c-logit or logit method.
LogitCalculator(const double beta, const double gamma, const double theta)
Constructor.
double getBetaForCLogit(const std::vector< R * > alternatives) const
calculate the scaling factor in the logit model
void setCosts(R *route, const double costs, const bool) const
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
const double myGamma
logit gamma - value
const double myBeta
logit beta - value
std::map< const R *, double > myCommonalities
The route commonality factors for c-logit.
const double myTheta
logit theta - value
virtual ~LogitCalculator()
Destructor.
LogitCalculator & operator=(const LogitCalculator &s)
invalidated assignment operator
Abstract base class providing static factory method.