fasttrips C++ Extension¶
Detailed documentation for C++ extension functions and data structures.
The following documentation is generated by doxygen and breathe.
- 
namespace fasttrips¶
- Typedefs - 
typedef std::map<std::string, double> Attributes¶
- Generic attributes. 
 - 
typedef std::map<AccessEgressLinkKey, Attributes, struct AccessEgressLinkCompare> AccessEgressLinkAttr¶
 - 
typedef std::map<StopStateKey, StopState> StopStateMap¶
 - 
typedef std::multimap<double, StopStateKey> CostToStopState¶
 - 
typedef std::map<int, Hyperlink> StopStates¶
- The path finding algorithm stores StopState data in this structure. 
 - 
typedef std::map<int, NamedWeights> SupplyModeToNamedWeights¶
 - 
typedef std::map<UserClassPurposeMode, SupplyModeToNamedWeights, struct fasttrips::UCPMCompare> WeightLookup¶
 - 
typedef std::map<int, Attributes> StopToAttr¶
 - 
typedef std::map<int, StopToAttr> StopStopToAttr¶
 - 
typedef std::multimap<RouteStopZone, struct FarePeriod, struct RouteStopZoneCompare> FarePeriodMmap¶
- Maps route id + origin zone + dest zone (any of these may be NA, or -1) => FarePeriod. 
 - 
typedef std::map<std::pair<std::string, std::string>, FareTransfer> FareTransferMap¶
- Fare Transfer Rules. 
 - Enums - 
enum DemandModeType¶
- Values: - 
MODE_ACCESS= -100¶
 - 
MODE_EGRESS= -101¶
 - 
MODE_TRANSFER= -102¶
 - 
MODE_TRANSIT= -103¶
 - 
MODE_UNSET= 0¶
 
- 
 - Functions - 
std::ostream &operator<<(std::ostream &os, const AccessEgressLinkKey &aelk)¶
- method to print the AccessEgressLinkKey 
 - 
bool isTrip(const int &mode)¶
- Hyperpath minimum cost (zero and negative costs are problematic) 
 - 
double fix_time_range(double time)¶
- utility function to make sure time is in [0, 24*60) = [0, 1440) 
 - Variables - 
const double MAX_COST= 999999¶
- Hyperpath cost when no links are there. 
 - 
const double INT_MULT= 10000¶
- What we multiply the fractional cumulative probabilities by to get an integer to compare with random numbers Must be less than, but close to RAND_MAX for the system, which is 32767 on windows 
 - 
struct AccessEgressLinkKey¶
- #include <access_egress.h>Key for access egress links map. 
 - 
struct AccessEgressLinkCompare¶
- #include <access_egress.h>Public Functions - 
bool operator()(const AccessEgressLinkKey &ael1, const AccessEgressLinkKey &ael2) const¶
 
- 
bool 
 - 
class AccessEgressLinks¶
- #include <access_egress.h>Public Functions - 
AccessEgressLinks()¶
- Constructor. 
 - 
~AccessEgressLinks()¶
- Destructor. 
 - 
void clear()¶
 - 
void readLinks(std::ifstream &accegr_file, bool debug_out)¶
 - 
bool hasLinksForTaz(int taz_id) const¶
- Are there access or egress links for the given taz? 
 - 
AccessEgressLinkAttr::const_iterator lower_bound(int taz_id, int supply_mode_num) const¶
- Iterate through the links for the taz id and supply mode. 
 - 
AccessEgressLinkAttr::const_iterator upper_bound(int taz_id, int supply_mode_num) const¶
 - 
AccessEgressLinkAttr::const_iterator lower_bound(int taz_id, int supply_mode_num, int stop_id) const¶
- Iterate through the links for the taz id, supply mode and stop. 
 - 
AccessEgressLinkAttr::const_iterator upper_bound(int taz_id, int supply_mode_num, int stop_id) const¶
 - 
const Attributes *getAccessAttributes(int taz_id, int supply_mode_num, int stop_id, double tp_time) const¶
- accessor - Accessor. 
 
- 
 - 
struct LinkSet¶
- #include <hyperlink.h>Public Functions - 
LinkSet(bool outbound)¶
 Public Members - 
double latest_dep_earliest_arr_¶
- latest departure time from this stop for outbound trips, earliest arrival time to this stop for inbound trips 
 - 
StopStateKey lder_ssk_¶
- trip for the latest departure/earliest arrival 
 - 
double sum_exp_cost_¶
- sum of the exponentiated cost 
 - 
double hyperpath_cost_¶
- hyperpath cost for this stop state 
 - 
int process_count_¶
- increment this every time the stop is processed 
 - 
int max_cum_prob_i_¶
- Set by setupProbabilities() 
 - 
StopStateMap stop_state_map_¶
- the links. (or a set of stop states where compare means the key is unique) 
 - 
CostToStopState cost_map_¶
- multimap of cost -> stop state pointers into the stop_state_set_ above 
 
- 
 - 
class Hyperlink¶
- #include <hyperlink.h>Class that encapulates the link (for deterministic) or hyperlink (for stochastic) to (for inbound) or from (for outbound) a stop. For deterministic path-finding, a hyperlink is just one link. For stochastic path-finding, a hyperlink is comprised of a set of links that depart (for outbound) or arrive (for inbound) from a single stop within a time window. Public Functions - 
Hyperlink()¶
- Default constructor. 
 - 
Hyperlink(int stop_id, bool outbound)¶
- Constructor we should call. 
 - 
~Hyperlink()¶
- Destructor. 
 - 
size_t size() const¶
- How many links make up the hyperlink? 
 - 
size_t size(bool of_trip_links) const¶
- How many links make up the trip/nontrip hyperlink. 
 - 
const StopStateMap &getStopStateMap(bool of_trip_links) const¶
- Accessor for stop state map. 
 - 
bool addLink(const StopState &ss, const Hyperlink *prev_link, bool &rejected, std::ostream &trace_file, const PathSpecification &path_spec, const PathFinder &pf)¶
- Add this link to the hyperlink. For deterministic: we only keep one link. Accept it iff the cost is lower. For stochastic: - If it’s outside the time window, reject it.
- If it’s already here according to the key, then replace the state.
- Return true iff the hyperlink state was affected (e.g. the stop needs to be re-processed)
 
 - 
void clear(bool of_trip_links)¶
- Clears data. 
 - 
const StopState &lowestCostStopState(bool of_trip_links) const¶
- Returns the lowest cost stop state (link) in this hyperlink If for_trip_link, lowest trip link. Otherwise, lowest non-trip link. 
 - 
const StopState &bestGuessLink(bool outbound, double arrdep_time) const¶
- Given an arrival time into this hyperlink (outbound) or a departure time out of this hyperlink (inbound), returns the best guess link 
 - 
double bestGuessCost(bool outbound, double arrdep_time) const¶
- Given an arrival link into this hyperlink (outbound) or a departure time out of this hyperlink (inbound), returns the best guess cost. Time consuming but more accurate. Make it an option? This isn’t currently being used. Initial tests didn’t show it helping things. TODO: remove? 
 - 
double earliestDepartureLatestArrival(bool outbound, bool of_trip_links = true) const¶
- Returns the earliest departure (outbound) or latest arrival (inbound) of the links that make up this hyperlink. 
 - 
double latestDepartureEarliestArrival(bool of_trip_links) const¶
- Returns the trip id for the latest departure (outbound) or earliest arrival (inbound) trip. 
 - 
double calculateNonwalkLabel() const¶
- Calculate the cost of just the non-walk links that make up this hyperlink. 
 - 
int processCount(bool of_trip_links) const¶
- Accessor for the process count. 
 - 
void incrementProcessCount(bool of_trip_links)¶
- Increment process count. 
 - 
double hyperpathCost(bool of_trip_links) const¶
- Accessor for the hyperlink cost. 
 - 
void print(std::ostream &ostr, const PathSpecification &path_spec, const PathFinder &pf) const¶
- Print the hyperlink, including a header and the stop states (links) that make it up. 
 - 
void pruneWindow(std::ostream &trace_file, const PathSpecification &path_spec, const PathFinder &pf, bool of_trip_links)¶
- Go through stop states (links) and remove any outside the time window. 
 - 
int setupProbabilities(const PathSpecification &path_spec, std::ostream &trace_file, const PathFinder &pf, bool trip_linkset, const Path *path_so_far = NULL)¶
- Setup probabilities for hyperlink’s stop states (links) Return the max cum probability for the linkset 
 - 
const StopState &chooseState(const PathSpecification &path_spec, std::ostream &trace_file, const StopState *prev_link = NULL) const¶
- Randomly selects one of the links in this hyperlink based on the cumulative probability set by Hyperlink::setupProbabilities() - Return
- a const reference to the chosen StopState.
 
 - 
void collectFarePeriodProbabilities(const PathSpecification &path_spec, std::ostream &trace_file, const PathFinder &pf, double transfer_probability, std::map<const FarePeriod *, double> &fp_probs) const¶
- Iterates through the trip links and multiplies transer_probability x probability and sums to the fare period in fp_probs. 
 - 
void updateFare(const PathSpecification &path_spec, std::ostream &trace_file, const PathFinder &pf, const FarePeriod *last_trip_fp, bool last_is_prev, const Path &path_so_far, StopState &ss, std::string &trace_xfer_type) const¶
- Parameters
- last_is_prev: is last_trip_fp the previous trip, chronologically?
 
 
 - 
double getFareWithTransfer(const PathSpecification &path_spec, std::ostream &trace_file, const PathFinder &pf, const FarePeriod &fare_period, const std::map<int, Hyperlink> &stop_states) const¶
- Estimate the fare during pathfinding given transfer possibilities. This is called on the previous (transfer) link by PathFinder::updateStopStatesForTrips(). 
 Public Static Functions - 
void printStopStateHeader(std::ostream &ostr, const PathSpecification &path_spec)¶
- Print the stop state header. For printing stop states in table form. 
 - 
void printStopState(std::ostream &ostr, int stop_id, const StopState &ss, const PathSpecification &path_spec, const PathFinder &pf)¶
- Print the given stop state. 
 - 
void printLinkSet(std::ostream &ostr, int stop_id, bool is_trip, const LinkSet &linkset, const PathSpecification &path_spec, const PathFinder &pf)¶
- Print the given Link Set. 
 Public Static Attributes - 
double TIME_WINDOW_= 0.0¶
- See fasttrips.Assignment.TIME_WINDOW This could be configured per stop in the future. 
 - 
double UTILS_CONVERSION_= 0.0¶
 - 
double STOCH_DISPERSION_= 0.0¶
 - 
bool TRANSFER_FARE_IGNORE_PATHFINDING_= false¶
 - 
bool TRANSFER_FARE_IGNORE_PATHENUM_= false¶
 Private Functions - 
void removeFromCostMap(const StopStateKey &ssk, const StopState &ss)¶
- Remove the given stop state from cost_map_. 
 - 
void resetLatestDepartureEarliestArrival(bool of_trip_links, const PathSpecification &path_spec)¶
- Reset latest departure/earliest arrival. 
 - 
void updateLowCostPath(const StopStateKey &ssk, const Hyperlink *prev_link, std::ostream &trace_file, const PathSpecification &path_spec, const PathFinder &pf)¶
- Update the low cost path for this stop state. 
 
- 
 - 
struct LabelStop¶
- #include <LabelStopQueue.h>Struct containing just a label and a stop id, this is stored in the fasttrips::LabelStopQueue (a priority queue) to find the lowest label stops. 
 - 
struct Stop¶
- #include <LabelStopQueue.h>Supply data: Stops. 
 - 
struct LabelStopCompare¶
- #include <LabelStopQueue.h>Comparator to enable the fasttrips::LabelStopQueue to return the lowest labeled stop. 
 - 
class LabelStopQueueError: public runtime_error¶
- #include <LabelStopQueue.h>
 - 
class LabelStopQueue¶
- #include <LabelStopQueue.h>This is just like a priority queue but with the additonal constraint that each (stop ID, is trip bool) can only be in the queue once. This is to save work; if we mark a stop for processing by adding it onto the queue, and then do that again shortly after, we don’t actually want to process twice. We only want to process it once, for the lowest label. Public Functions - 
LabelStopQueue()¶
 - 
~LabelStopQueue()¶
 - 
LabelStop pop_top(const std::map<int, Stop> &stop_num_to_stop, bool trace, std::ofstream &trace_file)¶
- Pop the top valid LabelStop 
 - 
size_t size() const¶
 - 
bool empty() const¶
 Private Members - 
std::priority_queue<LabelStop, std::vector<LabelStop>, struct LabelStopCompare> labelstop_priority_queue_¶
 - 
std::map<std::pair<int, bool>, LabelCount> labelstop_map_¶
- Keep track of the lowest label and the count for each (stop, is_trip bool) 
 - 
int valid_count_¶
 - 
struct LabelCount¶
 
- 
 - 
struct PathInfo¶
- #include <path.h>In stochastic path finding, this is the information we’ll collect about the path. 
 - 
class Path¶
- #include <path.h>This class represents a concrete path. Public Functions - 
Path()¶
- Default constructor. 
 - 
Path(bool outbound, bool enumerating)¶
- Constructor. 
 - 
~Path()¶
- Desctructor. 
 - 
size_t size() const¶
- How many links are in this path? 
 - 
double cost() const¶
 - 
double fare() const¶
 - 
double initialCost() const¶
- initial understanding of the cost before path was finalized 
 - 
double initialFare() const¶
- initial understanding of the fare before path was finalized 
 - 
void clear()¶
 - 
int boardsForFarePeriod(const std::string &fare_period) const¶
 - 
bool operator<(const Path &other) const¶
- Comparison operator; determines ordering in PathSet. - Comparison. 
 - 
double getFareWithTransfer(const PathFinder &pf, const std::string &last_fare_period, const FarePeriod *fare_period) const¶
- Returns the fare given the relevant fare period, adjusting for transfer from last fare period as applicable. 
 - 
bool addLink(int stop_id, const StopState &link, std::ostream &trace_file, const PathSpecification &path_spec, const PathFinder &pf)¶
- Add link to the path, modifying if necessary Return feasibility (infeasible if two out of order trips) 
 - 
void calculateCost(std::ostream &trace_file, const PathSpecification &path_spec, const PathFinder &pf, bool hush = false)¶
- Calculates the cost for the entire given path, and checks for capacity issues. Sets the resulting cost and also updates link costs - Calculate the path cost now that we know all the links. This may result in different costs than the original costs. This updates the path’s StopState.cost_ attributes and returns the cost 
 - 
void print(std::ostream &ostr, const PathSpecification &path_spec, const PathFinder &pf) const¶
 - 
void printCompat(std::ostream &ostr, const PathSpecification &path_spec, const PathFinder &pf) const¶
 Private Members - 
bool outbound_¶
- is this path outbound (preferred arrival) or inbound (preferred departure)? 
 - 
bool enumerating_¶
- are we enumarating paths? or labeling? 
 - 
double fare_¶
- Total fare of this path. 
 - 
double cost_¶
- Cost of this path. 
 - 
bool capacity_problem_¶
- Does this path have a capacity problem? 
 - 
double initial_fare_¶
- Initial total fare. - For debugging/investigation. When we first enumerate this path by adding links via Path::addLink(), we’re guessing at fares and costs. When we finally complete the path and call Path::calculateCost(), we will know cost and fare with full information. These variables are for saving our initial understanding to see how far off we were. These are set in calculateCost(). 
 - 
double initial_cost_¶
- Initial cost. 
 
- 
 - 
struct UserClassPurposeMode¶
- #include <pathfinder.h>Weight lookup. Public Members - 
std::string user_class_¶
 - 
std::string purpose_¶
 - 
DemandModeType demand_mode_type_¶
 - 
std::string demand_mode_¶
 
- 
std::string 
 - 
struct UCPMCompare¶
- #include <pathfinder.h>Comparator to enable the fasttrips::WeightLookup to use UserClassMode as a lookup. Public Functions - 
bool operator()(const UserClassPurposeMode &ucpm1, const UserClassPurposeMode &ucpm2) const¶
 
- 
bool 
 - 
struct Weight¶
- #include <pathfinder.h>
 - 
struct TazStopCost¶
- #include <pathfinder.h>Supply data: access/egress time and cost between TAZ and stops. 
 - 
struct TripInfo¶
- #include <pathfinder.h>Supply data: Transit trip data, indexed by trip ID. 
 - 
struct TripStopTime¶
- #include <pathfinder.h>Supply data: Transit vehicle schedules. 
 - 
struct TripStopCompare¶
- #include <pathfinder.h>Comparator for the PathFinder::bump_wait_ std::map. 
 - 
struct RouteStopZone¶
- #include <pathfinder.h>For fare lookups FarePeriod index. 
 - 
struct RouteStopZoneCompare¶
- #include <pathfinder.h>Public Functions - 
bool operator()(const RouteStopZone &rsz1, const RouteStopZone &rsz2) const¶
 
- 
bool 
 - 
struct FarePeriod¶
- #include <pathfinder.h>For fare lookups: FarePeriod definition. Public Members - 
std::string fare_id_¶
- Fare ID. 
 - 
std::string fare_period_¶
- Name of the fare period. 
 - 
double start_time_¶
- Start time of the fare period. 
 - 
double end_time_¶
- End time of the fare period. 
 - 
double price_¶
- Currency unspecified but matches value_of_time_. 
 - 
int transfers_¶
- Number of free transfers allowed on this fare. 
 - 
double transfer_duration_¶
- Transfer duration, in seconds. -1 if no requirement. 
 
- 
std::string 
 - 
struct FareTransfer¶
- #include <pathfinder.h>For fare transfer rules. Public Members - 
FareTransferType type_¶
- what type of transfer is this 
 - 
double amount_¶
- fare transfer type 
 
- 
FareTransferType 
 - 
struct PerformanceInfo¶
- #include <pathfinder.h>Performance information to return. Public Members - 
int label_iterations_¶
- Number of label iterations performed. 
 - 
int num_labeled_stops_¶
- Number of stops labeled. 
 - 
int max_process_count_¶
- Maximum number of times a stop was processed. 
 - 
long milliseconds_labeling_¶
- Number of seconds spent in labeling. 
 - 
long milliseconds_enumerating_¶
- Number of seconds spent in enumerating. 
 - 
long workingset_bytes_¶
- Working set size, in bytes. 
 - 
long privateusage_bytes_¶
- Private memory usage, in bytes. 
 - 
long mem_timestamp_¶
- Time of memory query, in seconds since epoch. 
 
- 
int 
 - 
class PathFinder¶
- #include <pathfinder.h>This is the class that does all the work. Setup the network supply first. Path finding parameters - 
double BUMP_BUFFER_¶
 - 
double DEPART_EARLY_ALLOWED_MIN_¶
 - 
double ARRIVE_LATE_ALLOWED_MIN_¶
 - 
int STOCH_PATHSET_SIZE_¶
 - 
int STOCH_MAX_STOP_PROCESS_COUNT_¶
 - 
int MAX_NUM_PATHS_¶
 - 
double MIN_PATH_PROBABILITY_¶
 Public Functions - 
PathFinder()¶
- PathFinder constructor. - This doesn’t really do anything. 
 - 
int processNumber() const¶
 - 
int transferSupplyMode() const¶
- This is the transfer supply mode number. 
 - 
const Attributes *getAccessAttributes(int taz_id, int supply_mode_num, int stop_id, double tp_time) const¶
- Accessor for access link attributes. 
 - 
const Attributes *getTransferAttributes(int origin_stop_id, int destination_stop_id) const¶
- Accessor for transfer link attributes. 
 - 
int getRouteIdForTripId(int trip_id_num) const¶
- Accessor for route id. 
 - 
const TripStopTime &getTripStopTime(int trip_id, int stop_seq) const¶
- Accessor for TripStopTime for given trip id, stop sequence. 
 - 
double tallyLinkCost(const int supply_mode_num, const PathSpecification &path_spec, std::ostream &trace_file, const NamedWeights &weights, const Attributes &attributes, bool hush = false) const¶
- Tally the link cost, which is the sum of the weighted attributes. - Return
- the cost.
 
 - 
const NamedWeights *getNamedWeights(const std::string &user_class, const std::string &purpose, DemandModeType demand_mode_type, const std::string &demand_mode, int suppy_mode_num) const¶
- Access the named weights given user/link information. Returns NULL if not found. 
 - 
void initializeParameters(double time_window, double bump_buffer, double utils_conversion, double depart_early_allowed_min, double arrive_late_allowed_min, int stoch_pathset_size, double stoch_dispersion, int stoch_max_stop_process_count, bool transfer_fare_ignore_pf, bool transfer_fare_ignore_pe, int max_num_paths, double min_path_probability)¶
- Setup the path finding parameters. 
 - 
void initializeSupply(const char *output_dir, int process_num, int *stoptime_index, double *stoptime_times, int num_stoptimes)¶
- Setup the network supply. This should happen once, before any pathfinding. - Parameters
- output_dir: The directory in which to output trace files (if any)
- process_num: The process number for this instance
- stoptime_index: For populating PathFinder::trip_stop_times_, this array contains trip IDs, sequence numbers, stop IDs
- stoptime_times: For populating PathFinder::trip_stop_times_, this array contains transit vehicle arrival times, departure times, and overcap pax at a stop.
- num_stoptimes: The number of stop times described in the previous two arrays.
 
 
 - 
void setBumpWait(int *bw_index, double *bw_data, int num_bw)¶
- Setup the information for bumped passengers. - Parameters
- bw_index: For populating PathFinder::bump_wait_, this array contains the fasttrips::TripStop fields.
- bw_data: For populating the PathFinder::bum_wait_, this contains the arrival time of the first would-be waiting passenger
- num_bw: The number of trip stops with bump waits described in the previous two arrays.
 
 
 - 
void reset()¶
- Reset - clear state. 
 - 
~PathFinder()¶
- Destructor. - This doesn’t really do anything because the instance variables are all STL structures which take care of freeing memory. 
 - 
int findPathSet(PathSpecification path_spec, PathSet &pathset, PerformanceInfo &performance_info) const¶
- Find the path set! This method is the WHOLE POINT of our existence! - See PathFinder::initializeStopStates, PathFinder::labelStops, PathFinder::finalTazState, and PathFinder::getFoundPath - Return
- Return code signifying return status
- Parameters
- path_spec: The specifications of that path to find
- path: This is really a return fasttrips::Path
- path_info: Also for returng information (e.g. about the Path cost)
 
 
 - 
double getScheduledDeparture(int trip_id, int stop_id, int sequence) const¶
- Returns the departure time for the transit vehicle from the given stop/seq for the given trip. Returns -1 on failure. 
 - 
const FarePeriod *getFarePeriod(int route_id, int board_stop_id, int alight_stop_id, double trip_depart_time) const¶
- Returns the fare for the transit vehicle of the given route. 
 - 
const FareTransfer *getFareTransfer(const std::string from_fare_period, const std::string to_fare_period) const¶
- Returns the fare transfer given two fare periods. 
 - 
void printTimeDuration(std::ostream &ostr, const double &timedur) const¶
 - 
void printTime(std::ostream &ostr, const double &timemin) const¶
 - 
void printMode(std::ostream &ostr, const int &mode, const int &trip_id) const¶
 - 
const std::string &stopStringForId(int stop_id) const¶
- Accessor for stop strings. Assumes valid stop id. 
 - 
const std::string &tripStringForId(int trip_id) const¶
- Accessor for trip strings. Assumes valid trip id. 
 - 
const std::string &modeStringForNum(int mode_num) const¶
- Accessor for mode strings. Assumes valid mode number. 
 Public Static Attributes - 
const int MAX_DATETIME= 48*60¶
 - 
const int RET_SUCCESS= 0¶
- Success. Paths found. - Return statuses for PathFinder::findPathSet() 
 - 
const int RET_FAIL_INIT_STOP_STATES= 1¶
 - 
const int RET_FAIL_SET_REACHABLE= 2¶
 - 
const int RET_FAIL_END_NOT_FOUND= 3¶
- end taz not reached 
 - 
const int RET_FAIL_NO_PATHS_GEN= 4¶
- no paths successfully walked 
 - 
const int RET_FAIL_NO_PATH_PROB= 5¶
- no paths with probability found (?) 
 Protected Functions - 
void readIntermediateFiles()¶
- Read the intermediate files mapping integer IDs to strings for modes, stops, trips, and routes. 
 - 
void readTripIds()¶
 - 
void readStopIds()¶
 - 
void readRouteIds()¶
 - 
void readFarePeriods()¶
 - 
void readModeIds()¶
 - 
void readAccessLinks()¶
 - 
void readTransferLinks()¶
 - 
void readTripInfo()¶
 - 
void readWeights()¶
 - 
void addStopState(const PathSpecification &path_spec, std::ofstream &trace_file, const int stop_id, const StopState &ss, const Hyperlink *prev_link, StopStates &stop_states, LabelStopQueue &label_stop_queue) const¶
 - 
bool initializeStopStates(const PathSpecification &path_spec, std::ofstream &trace_file, StopStates &stop_states, LabelStopQueue &cost_stop_queue) const¶
- Initialize the stop states from the access (for inbound) or egress (for outbound) links from the start TAZ. - Return
- success. This method will only fail if there are no access/egress links for the starting TAZ.
 
 - 
void updateStopStatesForTransfers(const PathSpecification &path_spec, std::ofstream &trace_file, StopStates &stop_states, LabelStopQueue &label_stop_queue, int label_iteration, const LabelStop ¤t_label_stop) const¶
- Iterate through all the stops that transfer to(outbound)/from(inbound) the current_label_stop and update the stop_states with information about how accessible those stops are as a transfer to/from the current_label_stop. - Part of the labeling loop. Assuming the current_label_stop was just pulled off the label_stop_queue, this method will iterate through transfers to (for outbound) or from (for inbound) the current stop and update the next stop given the current stop state. 
 - 
void updateStopStatesForFinalLinks(const PathSpecification &path_spec, std::ofstream &trace_file, const std::map<int, int> &reachable_final_stops, StopStates &stop_states, LabelStopQueue &label_stop_queue, int label_iteration, const LabelStop ¤t_label_stop, double &est_max_path_cost) const¶
- Part of the labeling loop. Assuming the current_label_stop was just pulled off the label_stop_queue, this method will iterate through access links to (for outbound) or egress links from (for inbound) the current stop and update the next stop given the current stop state. 
 - 
void updateStopStatesForTrips(const PathSpecification &path_spec, std::ofstream &trace_file, StopStates &stop_states, LabelStopQueue &label_stop_queue, int label_iteration, const LabelStop ¤t_label_stop, std::unordered_set<int> &trips_done) const¶
- Iterate through all the stops that are accessible by transit vehicle trip to(outbound)/from(inbound) the current_label_stop and update the stop_states with information about how accessible those stops are as a transit trip to/from the current_label_stop. 
 - 
int labelStops(const PathSpecification &path_spec, std::ofstream &trace_file, const std::map<int, int> &reachable_final_stops, StopStates &stop_states, LabelStopQueue &label_stop_queue, int &max_process_count) const¶
- Label stops by: - while the label_stop_queue has stops AND we don’t think we’re done*- pulling the lowest-labeled stop
- adding the stops accessible by transfer (PathFinder::updateStopStatesForTransfers)
- adding the stops accessible by transit trip (PathFinder::updateStopStatesForTrips)
 
 - Assume we’re done if we’ve reached the final TAZ already and the current cost is some percent bigger than threshhold based on the lowest cost and the minimum probability. 
- while the label_stop_queue has stops AND we don’t think we’re done*
 - 
bool setReachableFinalStops(const PathSpecification &path_spec, std::ofstream &trace_file, std::map<int, int> &reachable_final_stops) const¶
- This fills the reachable_final_stops map with stop_id -> number of supply links between the final stop and the final TAZ. - Return
- True if some final stops are reachable, False if there are none
 
 - 
bool finalizeTazState(const PathSpecification &path_spec, std::ofstream &trace_file, StopStates &stop_states, LabelStopQueue &label_stop_queue, int label_iteration) const¶
- This is like the reverse of PathFinder::initializeStopStates. Once all the stops are labeled, try to get from the labeled stop to the end TAZ (origin for outbound, destination for inbound). - Return
- sucess.
 
 - 
bool hyperpathGeneratePath(const PathSpecification &path_spec, std::ofstream &trace_file, StopStates &stop_states, Path &path) const¶
- Given all the labeled stops and taz, traces back and generates a specific path. We do this by setting up probabilities for each option and then choosing via PathFinder::chooseState. - Return
- success
 
 - 
Path choosePath(const PathSpecification &path_spec, std::ofstream &trace_file, PathSet &paths, int max_prob_i) const¶
- Given a set of paths, randomly selects one based on the cumulative probability (fasttrips::PathInfo.prob_i_) - Returns a reference to that path, which is stored in paths. 
 - 
int getPathSet(const PathSpecification &path_spec, std::ofstream &trace_file, StopStates &stop_states, PathSet &pathset) const¶
 - 
void getTripsWithinTime(int stop_id, bool outbound, double timepoint, std::vector<TripStopTime> &return_trips) const¶
- If outbound, then we’re searching backwards, so this returns trips that arrive at the given stop in time to depart at timepoint. If inbound, then we’re searching forwards, so this returns trips that depart at the given stop time after timepoint - If outbound, then we’re searching backwards, so this returns trips that arrive at the stop in time to depart at timepoint (timepoint-TIME_WINDOW_, timepoint] If inbound, then we’re searching forwards, so this returns trips that depart at the stop time after timepoint [timepoint, timepoint+TIME_WINDOW_) 
 Protected Attributes - 
std::string output_dir_¶
- directory in which to write trace files 
 - 
int process_num_¶
- for multi-processing 
 - 
WeightLookup weight_lookup_¶
- (User class, demand_mode_type, demand_mode) -> supply_mode -> weight_map 
 - 
AccessEgressLinks access_egress_links_¶
- Access/Egress information: taz id -> supply_mode -> stop id -> (start time, end time) -> attribute map. 
 - 
StopStopToAttr transfer_links_o_d_¶
- Transfer information: stop id -> stop id -> attributes. 
 - 
StopStopToAttr transfer_links_d_o_¶
 - 
std::map<int, std::vector<TripStopTime>> trip_stop_times_¶
- Trip information: trip id -> vector of [trip id, sequence, stop id, arrival time, departure time, overcap]. 
 - 
std::map<int, std::vector<TripStopTime>> stop_trip_times_¶
- Stop information: stop id -> vector of [trip id, sequence, stop id, arrival time, departure time, overcap]. 
 - 
std::map<int, int> route_fares_¶
 - 
FarePeriodMmap fare_periods_¶
 - 
FareTransferMap fare_transfer_rules_¶
 - 
std::map<int, std::string> trip_num_to_str_¶
 - 
std::map<int, std::string> route_num_to_str_¶
 - 
std::map<int, std::string> mode_num_to_str_¶
 - 
int transfer_supply_mode_¶
 - 
std::map<TripStop, double, struct TripStopCompare> bump_wait_¶
- From simulation: When there are capacity limitations on a vehicle and passengers cannot board a vehicle, this is the time the bumped passengers arrive at a stop and wait for a vehicle they cannot board. - This structure maps the fasttrips::TripStop to the arrival time of the first waiting would-be passenger. 
 Protected Static Attributes - 
Attributes *ZERO_WALK_TRANSFER_ATTRIBUTES_= NULL¶
- Access this through getTransferAttributes() 
 
- 
double 
 - 
struct PathSpecification¶
- #include <pathspec.h>The definition of the path we’re trying to find. Public Members - 
int iteration_¶
- Iteration. 
 - 
int pathfinding_iteration_¶
- Pathfinding iteration. 
 - 
bool hyperpath_¶
- If true, find path using stochastic algorithm. 
 - 
int origin_taz_id_¶
- Origin of path. 
 - 
int destination_taz_id_¶
- Destination of path. 
 - 
bool outbound_¶
- If true, the preferred time is for arrival, otherwise it’s departure. 
 - 
double preferred_time_¶
- Preferred time of arrival or departure, minutes after midnight. 
 - 
double value_of_time_¶
- Value of time, in currency_type/hour. 
 - 
bool trace_¶
- If true, log copious details of the pathfinding into a trace log. 
 - 
std::string person_id_¶
- Person ID. 
 - 
std::string person_trip_id_¶
- Person Trip ID. 
 - 
std::string user_class_¶
- User class string. 
 - 
std::string purpose_¶
- Purpose string. 
 - 
std::string access_mode_¶
- Access demand mode. 
 - 
std::string transit_mode_¶
- Transit demand mode. 
 - 
std::string egress_mode_¶
- Egress demand mode. 
 
- 
int 
 - 
struct StopStateKey¶
- #include <pathspec.h>The pathfinding algorithm is a labeling algorithm which associates each stop with a state (or link), encapsulated here. If the sought path is outbound, then the preferred time is an arrival time at the destination, so the labeling algorithm starts at the destination and works backwards. If the sought path is inbound, then the preferred time is a departure time from the origin, so the labeling algorithm starts at the origin and works forwards. Thus, the attributes here have different meanings if the path sought is outbound versus inbound, and the convention is outbound/inbound for the variable names. The StopState is basically the state at this stop with details of the link after (for outbound) or before (inbound) the stop in the found path. NOTE: for trip states, deparr_time_ and arrdep_time_ are both for the vehicle because the passenger times can be inferred from the surrounding states. In particular, for outbound trips, the deparr_time_ for trip states is not necessarily the person departure time. For inbound trips, the arrdep_time_ for trip states is not necessarily the person departure time. Public Functions - 
bool operator==(const StopStateKey &rhs) const¶
 - 
bool operator!=(const StopStateKey &rhs) const¶
 - 
bool operator<(const StopStateKey &rhs) const¶
 Public Members - 
int deparr_mode_¶
- Departure mode for outbound, arrival mode for inbound. One of fasttrips::MODE_ACCESS, fasttrips::MODE_EGRESS, fasttrips::MODE_TRANSFER, or fasttrips::MODE_TRANSIT 
 - 
int trip_id_¶
- Trip ID if deparr_mode_ is fasttrips::MODE_TRANSIT, or the supply_mode_num for access, egress 
 - 
int stop_succpred_¶
- Successor stop for outbound, predecessor stop for inbound. 
 - 
int seq_¶
- The sequence number of this stop on this trip. (-1 if not trip) 
 - 
int seq_succpred_¶
- The sequence number of the successor/predecessor stop. 
 
- 
bool 
 - 
struct StopState¶
- #include <pathspec.h>Stop states are basically links in a hyperpath. Note that the time fields (deparr_time_ and arrdep_time_) are based around the preferred arrival or departure time and can be negative or over 24*60 if the travel crosses the midnight boundary. For example, if the preferred arrival time is 12:10a then links before it might have negative values. Public Functions - 
StopState()¶
 - 
StopState(double deparr_time, int deparr_mode, int trip_id, int stop_succpred, int seq, int seq_succpred, double link_time, double link_fare, double link_cost, double link_dist, double cost, int iteration, double arrdep_time, double link_ivtwt, const FarePeriod *fp = NULL)¶
 Public Members - 
double deparr_time_¶
- Departure time for outbound, arrival time for inbound. 
 - 
int deparr_mode_¶
- Departure mode for outbound, arrival mode for inbound. One of fasttrips::MODE_ACCESS, fasttrips::MODE_EGRESS, fasttrips::MODE_TRANSFER, or fasttrips::MODE_TRANSIT 
 - 
int trip_id_¶
- Trip ID if deparr_mode_ is fasttrips::MODE_TRANSIT, or the supply_mode_num for access, egress 
 - 
int stop_succpred_¶
- Successor stop for outbound, predecessor stop for inbound. 
 - 
int seq_¶
- The sequence number of this stop on this trip. (-1 if not trip) 
 - 
int seq_succpred_¶
- The sequence number of the successor/predecessor stop. 
 - 
double link_time_¶
- Link time. For trips, includes wait time. Just walk time for others. 
 - 
double link_fare_¶
- Link fare. Financial cost of the link. 
 - 
double link_cost_¶
- Link generalized cost. 
 - 
double link_ivtwt_¶
- Link in-vehicle time path weight. 
 - 
double link_dist_¶
- Link distance, in units of shape_dist_traveled. 
 - 
double cost_¶
- Cost from previous link(s) and this link together. 
 - 
int iteration_¶
- Labeling iteration that generated this stop state. 
 - 
double arrdep_time_¶
- Arrival time for outbound, departure time for inbound. 
 - 
const FarePeriod *fare_period_¶
- Trip links may have a FarePeriod. 
 - 
double probability_¶
- The probability of this link. 
 - 
int cum_prob_i_¶
- Cumulative integer version of probability. 
 
- 
 
- 
typedef std::map<std::string, double>