17 #ifndef SUMO_FAREMODUL_H 18 #define SUMO_FAREMODUL_H 46 if (zoneNumber == 0) {
64 inline int bitcount(
long long int intVal)
const {
66 long long int counter = intVal;
68 while (counter != 0) {
69 counter = counter & (counter - 1);
95 myCounter(std::numeric_limits<int>::max()),
96 myTravelledDistance(std::numeric_limits<double>::max()),
97 myVisistedStops(std::numeric_limits<int>::max()),
108 myTravelledDistance(0),
145 std::vector<double> zonePrices = std::vector<double> {1.9, 3.4, 4.9, 6.2, 7.7, 9.2};
147 double leipzig = 2.7;
151 double shortTrip = 1.6;
152 double shortTripLeipzig = 1.9;
153 double shortTripHalle = 1.7;
154 double maxPrice = 10.6;
170 void init(
const std::vector<std::string>& edges)
override {
172 myFareStates.resize(edges.size());
182 double getEffort(
const int numericalID)
const override {
184 FareState const& state = myFareStates.at(numericalID);
188 effort = std::numeric_limits<double>::max();
194 void update(
const int edge,
const int prev,
const double length)
override {
196 std::string
const& edgeType = myEdges[edge];
199 FareState& state = myFareStates.at(prev);
205 oldPr = computePrice(state);
208 if (edgeType.c_str()[0] !=
'!') {
209 updateFareStatePublic(state, edge, length);
210 }
else if (edgeType ==
"!stop") {
211 updateFareStateStop(state, edge);
212 }
else if (edgeType ==
"!ped") {
213 updateFareStatePedestrian(state, edge);
214 }
else if (edgeType ==
"!access") {
215 updateFareStateAccess(state, edge, prev);
217 updateFareState(state, edge);
219 FareState& stateAtE = myFareStates[edge];
220 double newPr = computePrice(stateAtE);
277 case FareToken ::KLZ:
278 case FareToken ::KLU:
281 case FareToken ::KHU:
282 case FareToken ::KHZ:
286 case FareToken ::START:
293 return std::numeric_limits<double>::max();
298 std::string
output(
const int edge)
const override {
300 FareState const& my = myFareStates[edge];
301 std::stringstream msg;
323 msg <<
":" << computePrice(my);
329 FareToken collectedToken = myStopFareToken[stopEdge];
333 std::cout <<
"Progagating fare state for stop w/o a price!" << std::endl;
339 FareState& stateAtE = myFareStates[stopEdge];
341 stateAtE = currentFareState;
348 case FareToken ::Free:
461 std::cout <<
"Reached invalid position in fareToken selection!" << std::endl;
470 FareState& stateAtE = myFareStates[pedestrianEdge];
472 stateAtE = currentFareState;
488 FareState& stateAtE = myFareStates[publicTransportEdge];
490 stateAtE = currentFareState;
500 FareState& stateAtE = myFareStates[intermodalEdge];
502 stateAtE = currentFareState;
514 FareState& stateAtE = myFareStates[accessEdge];
516 stateAtE = currentFareState;
522 if (myEdges[prev] ==
"!ped") {
561 #endif //SUMO_FAREMODUL_H int getOverlayZone(int zoneNumber)
double myTravelledDistance
std::vector< std::string > myEdges
FareState(FareToken token)
std::map< int, FareToken > myStopFareToken
void update(const int edge, const int prev, const double length) override
void updateFareStatePedestrian(FareState const ¤tFareState, const int pedestrianEdge)
ZoneCounter(unsigned int ct)
std::map< int, int > myStopFareZone
static std::unordered_map< int, long long int > fareZoneToRep
the effort calculator interface
void addStop(const int stopEdge, const Parameterised ¶ms) override
void setInitialState(const int edge) override
std::string output(const int edge) const override
double computePrice(FareState const &fareState) const
void addZone(int zoneNumber)
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter...
std::string tokenToTicket(FareToken const &token)
An upper class for objects with additional parameters.
int bitcount(long long int intVal) const
void init(const std::vector< std::string > &edges) override
std::map< int, FareToken > myStopStartToken
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
std::vector< double > zonePrices
void updateFareState(FareState const ¤tFareState, const int intermodalEdge)
double getEffort(const int numericalID) const override
std::vector< FareState > myFareStates
FareToken stringToToken(std::string str)
void updateFareStateAccess(FareState const ¤tFareState, const int accessEdge, const int prev)
void updateFareStatePublic(FareState const ¤tFareState, const int publicTransportEdge, const double length)
void updateFareStateStop(FareState const ¤tFareState, const int stopEdge)