Skip to content

Commit

Permalink
small organizing
Browse files Browse the repository at this point in the history
  • Loading branch information
i-am-sijia committed Jul 11, 2024
1 parent 2e77132 commit cd51508
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
6 changes: 3 additions & 3 deletions tm2py/components/demand/prepare_demand.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,12 +677,12 @@ def _read_demand(self, file_config, time_period, skim_set, num_zones):
# Load demand from cross-referenced source file,
# the named demand model component under the key highway_demand_file
if (
self.controller.config.run.warmstart.warmstart
self.controller.config.warmstart.warmstart
and self.controller.iteration == 0
):
source = self.controller.config.run.warmstart
source = file_config["source"]
path = self.controller.get_abs_path(
source.household_transit_demand_file
self.controller.config[source].transit_demand_file
).__str__()
else:
source = file_config["source"]
Expand Down
45 changes: 21 additions & 24 deletions tm2py/components/network/transit/transit_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,30 +433,31 @@ def transit_emmebank(self):
def run(self):
"""Run transit assignments."""

if self.controller.iteration == 0:
self.transit_emmebank.zero_matrix
if self.controller.config.warmstart.warmstart:
if self.controller.config.warmstart.use_warmstart_demand:
self.sub_components["prepare transit demand"].run()
else:
# give error message to user about not warmstarting transit
raise Exception(
f"ERROR: transit has to be warmstarted, please either specify use_warmstart_skim or use_warmstart_demand"
)
else:
self.sub_components["prepare transit demand"].run()

for time_period in self.time_period_names:
# update auto times
print("updating auto time in transit network")
self.transit_network.update_auto_times(time_period)

if self.controller.iteration == 0:
use_ccr = False
congested_transit_assignment = False
# update auto times
print("updating auto time in transit network")
self.transit_network.update_auto_times(time_period)

# run extended transit assignment and skimming
# if run warm start, trim the demands based on extended transit assignment and run congested assignment
# otherwise run with 0 demands
# TODO I think the demand import part should be outside of the time period loop
if self.controller.config.warmstart.warmstart:
# import transit demands
print(
"running uncongested transit assignment with warmstart demand"
)
self.sub_components["prepare transit demand"].run()
self.run_transit_assign(
time_period, use_ccr, congested_transit_assignment
)
else:
self.transit_emmebank.zero_matrix # TODO: need further test
# TODO is transit assignment needed for skimming?
print("running uncongested transit assignment with warmstart demand")
self.run_transit_assign(
time_period, use_ccr, congested_transit_assignment
)

else: # iteration >=1
use_ccr = self.config.use_ccr
Expand All @@ -466,10 +467,6 @@ def run(self):
congested_transit_assignment = (
self.config.congested_transit_assignment
)
# update auto times
self.transit_network.update_auto_times(time_period)
# import transit demands
self.sub_components["prepare transit demand"].run()

self.run_transit_assign(
time_period, use_ccr, congested_transit_assignment
Expand Down

0 comments on commit cd51508

Please sign in to comment.