Skip to content

Commit

Permalink
activitygen and most cfg files for SUMO 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Lara CODECA committed May 1, 2019
1 parent ef5694a commit 8aa7ee4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
30 changes: 19 additions & 11 deletions activitygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
if 'SUMO_TOOLS' in os.environ:
sys.path.append(os.environ['SUMO_TOOLS'])
import sumolib
# import libsumo as traci
import traci
import traci.constants as tc
else:
Expand Down Expand Up @@ -65,6 +64,13 @@ def _args():
parser.add_argument(
'-c', type=str, dest='config', required=True,
help='JSON configuration file.')
parser.add_argument(
'--profiling', dest='profiling', action='store_true',
help='Enable Python3 cProfile feature.')
parser.add_argument(
'--no-profiling', dest='profiling', action='store_false',
help='Disable Python3 cProfile feature.')
parser.set_defaults(profiling=False)
return parser.parse_args()

def _load_configurations(filename):
Expand Down Expand Up @@ -397,7 +403,7 @@ def _compute_trips_per_slice(self):
## For statistical purposes.
_modes_stats[_selected_mode] += 1

except (TripGenerationGenericError):
except TripGenerationGenericError:
_person_trip = None
_error_counter += 1
if _error_counter % 10 == 0:
Expand Down Expand Up @@ -1313,26 +1319,28 @@ def _saving_trips_to_files(self):
def _main():
""" Person Trip Activity-based Mobility Generation with PoIs and TAZ. """

args = _args()

## ======================== PROFILER ======================== ##
profiler = cProfile.Profile()
profiler.enable()
if args.profiling:
profiler = cProfile.Profile()
profiler.enable()
## ======================== PROFILER ======================== ##

args = _args()

logging.info('Loading configuration file %s.', args.config)
conf = _load_configurations(args.config)

mobility = MobilityGenerator(conf, profiling=False)
mobility = MobilityGenerator(conf, profiling=args.profiling)
mobility.mobility_generation()
mobility.save_mobility()
mobility.close_traci()

## ======================== PROFILER ======================== ##
profiler.disable()
results = io.StringIO()
pstats.Stats(profiler, stream=results).sort_stats('cumulative').print_stats(25)
print(results.getvalue())
if args.profiling:
profiler.disable()
results = io.StringIO()
pstats.Stats(profiler, stream=results).sort_stats('cumulative').print_stats(25)
print(results.getvalue())
## ======================== PROFILER ======================== ##

logging.info('Done.')
Expand Down
4 changes: 2 additions & 2 deletions most.activitygen.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"seed": 19860406,
"seed": 42,
"outputPrefix": "out/test.",

"sumocfg": "duarouter.sumocfg",
Expand All @@ -22,7 +22,7 @@
},

"population": {
"entities" : 1000,
"entities" : 10000,
"tazDefinition": "MoSTScenario/tools/mobility/taz/most.complete.taz.xml",
"tazWeights": "MoSTScenario/tools/mobility/taz/most.complete.taz.weight.csv",
"buildingsWeight": "MoSTScenario/tools/mobility/taz/buildings/",
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 8aa7ee4

Please sign in to comment.