Skip to content

Commit

Permalink
Print number of person trips per area (#328)
Browse files Browse the repository at this point in the history
A trip is connected to the area where it starts,
hence an A->B tour typically produces one trip starting in A
and one trip starting in B. Accordingly secondary destinations
also produce one trip starting in the area of the sec. dest.

External trips are not included.
  • Loading branch information
Jens West authored Jun 15, 2021
1 parent a7143b1 commit bc63603
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Scripts/modelsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,25 @@ def run_iteration(self, previous_iter_impedance, iteration=None):
self.dtm.add_demand(ext_demand)

# Calculate tour sums and mode shares
trip_sum = {mode: self._sum_trips_per_zone(mode, include_dests=False)
tour_sum = {mode: self._sum_trips_per_zone(mode, include_dests=False)
for mode in self.travel_modes}
sum_all = sum(trip_sum.values())
sum_all = sum(tour_sum.values())
mode_shares = {}
ar = ArrayAggregator(sum_all.index)
for mode in trip_sum:
for mode in tour_sum:
self.resultdata.print_data(
trip_sum[mode], "origins_demand.txt", mode)
tour_sum[mode], "origins_demand.txt", mode)
self.resultdata.print_data(
ar.aggregate(trip_sum[mode]), "origin_demand_areas.txt", mode)
ar.aggregate(tour_sum[mode]), "origin_demand_areas.txt", mode)
self.resultdata.print_data(
trip_sum[mode] / sum_all, "origins_shares.txt", mode)
mode_shares[mode] = trip_sum[mode].sum() / sum_all.sum()
tour_sum[mode] / sum_all, "origins_shares.txt", mode)
mode_shares[mode] = tour_sum[mode].sum() / sum_all.sum()
self.mode_share.append(mode_shares)
trip_sum = {mode: self._sum_trips_per_zone(mode)
for mode in self.travel_modes}
for mode in tour_sum:
self.resultdata.print_data(
ar.aggregate(trip_sum[mode]), "trips_areas.txt", mode)

# Add vans and save demand matrices
for ap in self.ass_model.assignment_periods:
Expand Down

0 comments on commit bc63603

Please sign in to comment.