def execute(context): config_path = "%s/%s" % ( context.path("matsim.simulation.prepare"), context.stage("matsim.simulation.prepare") ) # Run routing eqasim.run(context, "org.eqasim.sao_paulo.RunSimulation", [ "--config-path", config_path, "--config:controler.lastIteration", str(1), "--config:controler.writeEventsInterval", str(1), "--config:controler.writePlansInterval", str(1), ]) assert os.path.exists("%s/simulation_output/output_events.xml.gz" % context.path())
def execute(context): config_path = "%s/%s" % (context.path("matsim.simulation.prepare"), context.stage("matsim.simulation.prepare")) # Run simulation #eqasim.run(context, "org.eqasim.san_francisco.RunSimulation", [ # "--config-path", config_path, # "--config:controler.lastIteration", str(30), # "--config:controler.writeEventsInterval", str(10), # "--config:controler.writePlansInterval", str(10), # "--config:planscalcroute.teleportedModeParameters[mode=walk].beelineDistanceFactor", str(1.35), # "--config:planscalcroute.teleportedModeParameters[mode=bike].teleportedModeSpeed", str(9.1), # "--config:planscalcroute.teleportedModeParameters[mode=walk].teleportedModeSpeed", str(4.0), # "--config:transitRouter.searchRadius", str(9000.0), # "--config:transitRouter.maxBeelineWalkConnectionDistance", str(4500.0), # "--mode-parameter:walk.alpha_u", str(0.1), # "--mode-parameter:bike.alpha_u", str(-1.2), # "--config:eqasim.crossingPenalty", str(7.5), # "--config:strategy.strategysettings[strategyName=DiscreteModeChoice].weight", str(0.1), # "--config:strategy.strategysettings[strategyName=KeepLastSelected].weight", str(0.9) # #]) eqasim.run( context, "org.eqasim.%s.RunSimulation" % context.config("eqasim_java_package"), [ "--config-path", config_path, "--config:controler.lastIteration", str(30), "--config:controler.writeEventsInterval", str(10), "--config:controler.writePlansInterval", str(10), "--config:planscalcroute.teleportedModeParameters[mode=walk].beelineDistanceFactor", str(1.35), "--config:planscalcroute.teleportedModeParameters[mode=bike].teleportedModeSpeed", str(9.1), "--config:planscalcroute.teleportedModeParameters[mode=walk].teleportedModeSpeed", str(4.0), "--config:transitRouter.searchRadius", str(9000.0), "--config:transitRouter.maxBeelineWalkConnectionDistance", str(4500.0), "--config:eqasim.crossingPenalty", str(7.5), "--config:strategy.strategysettings[strategyName=DiscreteModeChoice].weight", str(0.1), "--config:strategy.strategysettings[strategyName=KeepLastSelected].weight", str(0.9) ]) assert os.path.exists("%s/simulation_output/output_events.xml.gz" % context.path())
def execute(context): config_path = "%s/%s" % (context.path("matsim.simulation.prepare"), context.stage("matsim.simulation.prepare")) # Run routing eqasim.run(context, "org.eqasim.sao_paulo.RunSimulation", [ "--config-path", config_path, "--config:controler.lastIteration", str(90), "--config:controler.writeEventsInterval", str(10), "--config:controler.writePlansInterval", str(10), "--config:strategy.strategysettings[strategyName=DiscreteModeChoice].weight", str(0.1), "--config:strategy.strategysettings[strategyName=KeepLastSelected].weight", str(0.9), ])
def execute(context): # Prepare input files facilities_path = "%s/%s" % ( context.path("matsim.scenario.facilities"), context.stage("matsim.scenario.facilities") ) population_path = "%s/%s" % ( context.path("matsim.scenario.population"), context.stage("matsim.scenario.population") ) network_path = "%s/%s" % ( context.path("matsim.scenario.supply.processed"), context.stage("matsim.scenario.supply.processed")["network_path"] ) sp_path = "%s/Spatial/SC2010_RMSP_CEM_V3_center_transformed.shp" % context.config("data_path") df_zones_census = gpd.read_file("%s/Spatial/%s" % (context.config("data_path"), context.config("shapefile_city_name"))) df_zones_census.crs = {"init":"epsg:4326"} df_zones_census = df_zones_census.to_crs({"init":"epsg:29183"}) df_zones_census.to_file("%s/Spatial/SC2010_RMSP_CEM_V3_center_transformed.shp" % context.config("data_path")) eqasim.run(context, "org.eqasim.core.scenario.preparation.RunPreparation", [ "--input-facilities-path", facilities_path, "--output-facilities-path", "sao_paulo_facilities.xml.gz", "--input-population-path", population_path, "--output-population-path", "prepared_population.xml.gz", "--input-network-path", network_path, "--output-network-path", "sao_paulo_network.xml.gz", "--threads", context.config("processes") ]) eqasim.run(context, "org.eqasim.sao_paulo.preparation.RunImputeInnerSPAttribute", [ "--sp-path", sp_path, "--attribute-name", "city", "--input-path", "prepared_population.xml.gz", "--output-path", "prepared_population.xml.gz" ]) assert os.path.exists("%s/sao_paulo_facilities.xml.gz" % context.path()) assert os.path.exists("%s/prepared_population.xml.gz" % context.path()) assert os.path.exists("%s/sao_paulo_network.xml.gz" % context.path()) # Copy remaining input files households_path = "%s/%s" % ( context.path("matsim.scenario.households"), context.stage("matsim.scenario.households") ) shutil.copy(households_path, "%s/sao_paulo_households.xml.gz" % context.cache_path) transit_schedule_path = "%s/%s" % ( context.path("matsim.scenario.supply.processed"), context.stage("matsim.scenario.supply.processed")["schedule_path"] ) shutil.copy(transit_schedule_path, "%s/sao_paulo_transit_schedule.xml.gz" % context.cache_path) transit_vehicles_path = "%s/%s" % ( context.path("matsim.scenario.supply.gtfs"), context.stage("matsim.scenario.supply.gtfs")["vehicles_path"] ) shutil.copy(transit_vehicles_path, "%s/sao_paulo_transit_vehicles.xml.gz" % context.cache_path) # Generate base configuration eqasim.run(context, "org.eqasim.core.scenario.config.RunGenerateConfig", [ "--sample-size", context.config("sampling_rate"), "--threads", context.config("processes"), "--prefix", "sao_paulo_", "--random-seed", context.config("random_seed"), "--output-path", "generic_config.xml" ]) assert os.path.exists("%s/generic_config.xml" % context.path()) # Adapt config for Sao Paulo eqasim.run(context, "org.eqasim.sao_paulo.scenario.RunAdaptConfig", [ "--input-path", "generic_config.xml", "--output-path", "sao_paulo_config.xml" ]) assert os.path.exists("%s/sao_paulo_config.xml" % context.path()) # Route population eqasim.run(context, "org.eqasim.core.scenario.routing.RunPopulationRouting", [ "--config-path", "sao_paulo_config.xml", "--output-path", "sao_paulo_population.xml.gz", "--threads", context.config("processes"), "--config:plans.inputPlansFile", "prepared_population.xml.gz" ]) assert os.path.exists("%s/sao_paulo_population.xml.gz" % context.path()) # Validate scenario eqasim.run(context, "org.eqasim.core.scenario.validation.RunScenarioValidator", [ "--config-path", "sao_paulo_config.xml" ]) # Cleanup os.remove("%s/prepared_population.xml.gz" % context.path()) return "sao_paulo_config.xml"
def execute(context): # Prepare input files facilities_path = "%s/%s" % (context.path("matsim.scenario.facilities"), context.stage("matsim.scenario.facilities")) population_path = "%s/%s" % (context.path("matsim.scenario.population"), context.stage("matsim.scenario.population")) network_path = "%s/%s" % ( context.path("matsim.scenario.supply.processed"), context.stage("matsim.scenario.supply.processed")["network_path"]) eqasim.run( context, "org.eqasim.core.scenario.preparation.RunPreparation", [ "--input-facilities-path", facilities_path, "--output-facilities-path", "%sfacilities.xml.gz" % context.config("output_prefix"), "--input-population-path", population_path, "--output-population-path", "prepared_population.xml.gz", "--input-network-path", network_path, "--output-network-path", "%snetwork.xml.gz" % context.config("output_prefix"), "--threads", context.config("processes") ]) assert os.path.exists("%s/%sfacilities.xml.gz" % (context.path(), context.config("output_prefix"))) assert os.path.exists("%s/prepared_population.xml.gz" % context.path()) assert os.path.exists("%s/%snetwork.xml.gz" % (context.path(), context.config("output_prefix"))) # Copy remaining input files households_path = "%s/%s" % (context.path("matsim.scenario.households"), context.stage("matsim.scenario.households")) shutil.copy( households_path, "%s/%shouseholds.xml.gz" % (context.cache_path, context.config("output_prefix"))) transit_schedule_path = "%s/%s" % ( context.path("matsim.scenario.supply.processed"), context.stage("matsim.scenario.supply.processed")["schedule_path"]) shutil.copy( transit_schedule_path, "%s/%stransit_schedule.xml.gz" % (context.cache_path, context.config("output_prefix"))) transit_vehicles_path = "%s/%s" % ( context.path("matsim.scenario.supply.gtfs"), context.stage("matsim.scenario.supply.gtfs")["vehicles_path"]) shutil.copy( transit_vehicles_path, "%s/%stransit_vehicles.xml.gz" % (context.cache_path, context.config("output_prefix"))) if context.config("generate_vehicles_file"): vehicles_path = "%s/%s" % (context.path("matsim.scenario.vehicles"), context.stage("matsim.scenario.vehicles")) shutil.copy( vehicles_path, "%s/%svehicles.xml.gz" % (context.cache_path, context.config("output_prefix"))) # Generate base configuration eqasim.run(context, "org.eqasim.core.scenario.config.RunGenerateConfig", [ "--sample-size", context.config("sampling_rate"), "--threads", context.config("processes"), "--prefix", context.config("output_prefix"), "--random-seed", context.config("random_seed"), "--output-path", "generic_config.xml" ]) assert os.path.exists("%s/generic_config.xml" % context.path()) # Adapt config for Île-de-France eqasim.run(context, "org.eqasim.ile_de_france.scenario.RunAdaptConfig", [ "--input-path", "generic_config.xml", "--output-path", "%sconfig.xml" % context.config("output_prefix") ]) assert os.path.exists("%s/%sconfig.xml" % (context.path(), context.config("output_prefix"))) # Add urban attributes to population and network # (but only if Paris is included in the scenario!) df_codes = context.stage("data.spatial.codes") if "75" in df_codes["departement_id"].unique().astype(str): df_shape = context.stage("data.spatial.departments")[[ "departement_id", "geometry" ]].rename(columns=dict(departement_id="id")) df_shape["id"] = df_shape["id"].astype(str) df_shape.to_file("%s/departments.shp" % context.path()) eqasim.run( context, "org.eqasim.core.scenario.spatial.RunImputeSpatialAttribute", [ "--input-population-path", "prepared_population.xml.gz", "--output-population-path", "prepared_population.xml.gz", "--input-network-path", "%snetwork.xml.gz" % context.config("output_prefix"), "--output-network-path", "%snetwork.xml.gz" % context.config("output_prefix"), "--shape-path", "departments.shp", "--shape-attribute", "id", "--shape-value", "75", "--attribute", "isUrban" ]) eqasim.run(context, "org.eqasim.core.scenario.spatial.RunAdjustCapacity", [ "--input-path", "%snetwork.xml.gz" % context.config("output_prefix"), "--output-path", "%snetwork.xml.gz" % context.config("output_prefix"), "--shape-path", "departments.shp", "--shape-attribute", "id", "--shape-value", "75", "--factor", str(0.8) ]) # Route population eqasim.run( context, "org.eqasim.core.scenario.routing.RunPopulationRouting", [ "--config-path", "%sconfig.xml" % context.config("output_prefix"), "--output-path", "%spopulation.xml.gz" % context.config("output_prefix"), "--threads", context.config("processes"), "--config:plans.inputPlansFile", "prepared_population.xml.gz" ]) assert os.path.exists("%s/%spopulation.xml.gz" % (context.path(), context.config("output_prefix"))) # Validate scenario eqasim.run( context, "org.eqasim.core.scenario.validation.RunScenarioValidator", ["--config-path", "%sconfig.xml" % context.config("output_prefix")]) # Cleanup os.remove("%s/prepared_population.xml.gz" % context.path()) return "%sconfig.xml" % context.config("output_prefix")
def execute(context): eqasim_java_package = context.config("eqasim_java_package") # Prepare input files facilities_path = "%s/%s" % (context.path("matsim.scenario.facilities"), context.stage("matsim.scenario.facilities")) population_path = "%s/%s" % (context.path("matsim.scenario.population"), context.stage("matsim.scenario.population")) network_path = "%s/%s" % ( context.path("matsim.scenario.supply.processed"), context.stage("matsim.scenario.supply.processed")["network_path"]) imputation_spatial_path = "%s/Spatial/%s" % ( context.config("data_path"), context.config("spatial_imputation_file")) eqasim.run( context, "org.eqasim.core.scenario.preparation.RunPreparation", [ "--input-facilities-path", facilities_path, "--output-facilities-path", "%s_facilities.xml.gz" % eqasim_java_package, "--input-population-path", population_path, "--output-population-path", "prepared_population.xml.gz", "--input-network-path", network_path, "--output-network-path", "%s_network.xml.gz" % eqasim_java_package, "--threads", context.config("processes") ]) if (context.config("region") == "sf"): eqasim.run( context, "org.eqasim.%s.preparation.RunImputeInnerSFAttribute" % eqasim_java_package, [ "--sf-path", imputation_spatial_path, "--input-path", "prepared_population.xml.gz", "--output-path", "prepared_population.xml.gz" ]) elif (context.config("region") == "la"): imputation_spatial_path = "%s/Spatial/%s" % (context.config( "data_path"), context.config("spatial_imputation_file_la")) eqasim.run( context, "org.eqasim.%s.preparation.RunImputeInnerLAAttribute" % eqasim_java_package, [ "--la-path", imputation_spatial_path, "--input-path", "prepared_population.xml.gz", "--output-path", "prepared_population.xml.gz", "--attribute-name", "city" ]) imputation_spatial_path = "%s/Spatial/%s" % (context.config( "data_path"), context.config("spatial_imputation_file_orange")) eqasim.run( context, "org.eqasim.%s.preparation.RunImputeInnerLAAttribute" % eqasim_java_package, [ "--la-path", imputation_spatial_path, "--input-path", "prepared_population.xml.gz", "--output-path", "prepared_population.xml.gz", "--attribute-name", "orangeCounty" ]) else: raise Exception( "This region name is not supported, Try one of the following [sf, la]" ) eqasim.run(context, "org.eqasim.%s.scenario.RunNetworkFixer" % eqasim_java_package, [ "--input-path", "%s_network.xml.gz" % eqasim_java_package, "--output-path", "%s_network.xml.gz" % eqasim_java_package ]) assert os.path.exists("%s/%s_facilities.xml.gz" % (context.path(), eqasim_java_package)) assert os.path.exists("%s/prepared_population.xml.gz" % context.path()) assert os.path.exists("%s/%s_network.xml.gz" % (context.path(), eqasim_java_package)) # Copy remaining input files households_path = "%s/%s" % (context.path("matsim.scenario.households"), context.stage("matsim.scenario.households")) shutil.copy( households_path, "%s/%s_households.xml.gz" % (context.cache_path, eqasim_java_package)) transit_schedule_path = "%s/%s" % ( context.path("matsim.scenario.supply.processed"), context.stage("matsim.scenario.supply.processed")["schedule_path"]) shutil.copy( transit_schedule_path, "%s/%s_transit_schedule.xml.gz" % (context.cache_path, eqasim_java_package)) transit_vehicles_path = "%s/%s" % ( context.path("matsim.scenario.supply.gtfs"), context.stage("matsim.scenario.supply.gtfs")["vehicles_path"]) shutil.copy( transit_vehicles_path, "%s/%s_transit_vehicles.xml.gz" % (context.cache_path, eqasim_java_package)) # Generate base configuration eqasim.run(context, "org.eqasim.core.scenario.config.RunGenerateConfig", [ "--sample-size", context.config("sampling_rate"), "--threads", context.config("processes"), "--prefix", "%s_" % eqasim_java_package, "--random-seed", context.config("random_seed"), "--output-path", "generic_config.xml" ]) assert os.path.exists("%s/generic_config.xml" % context.path()) # Adapt config eqasim.run(context, "org.eqasim.%s.scenario.RunAdaptConfig" % eqasim_java_package, [ "--input-path", "generic_config.xml", "--output-path", "%s_config.xml" % eqasim_java_package ]) assert os.path.exists("%s/%s_config.xml" % (context.path(), eqasim_java_package)) # Route population eqasim.run( context, "org.eqasim.core.scenario.routing.RunPopulationRouting", [ "--config-path", "%s_config.xml" % eqasim_java_package, "--output-path", "%s_population.xml.gz" % eqasim_java_package, "--threads", context.config("processes"), "--config:plans.inputPlansFile", "prepared_population.xml.gz" ]) assert os.path.exists("%s/%s_population.xml.gz" % (context.path(), eqasim_java_package)) # Validate scenario eqasim.run(context, "org.eqasim.core.scenario.validation.RunScenarioValidator", ["--config-path", "%s_config.xml" % eqasim_java_package]) # Cleanup os.remove("%s/prepared_population.xml.gz" % context.path()) return "%s_config.xml" % eqasim_java_package
def execute(context): # Prepare input files facilities_path = "%s/%s" % ( context.path("matsim.scenario.facilities"), context.stage("matsim.scenario.facilities") ) population_path = "%s/%s" % ( context.path("matsim.scenario.population"), context.stage("matsim.scenario.population") ) network_path = "%s/%s" % ( context.path("matsim.scenario.supply.processed"), context.stage("matsim.scenario.supply.processed")["network_path"] ) eqasim.run(context, "org.eqasim.core.scenario.preparation.RunPreparation", [ "--input-facilities-path", facilities_path, "--output-facilities-path", "ile_de_france_facilities.xml.gz", "--input-population-path", population_path, "--output-population-path", "prepared_population.xml.gz", "--input-network-path", network_path, "--output-network-path", "ile_de_france_network.xml.gz", "--threads", context.config("processes") ]) assert os.path.exists("%s/ile_de_france_facilities.xml.gz" % context.path()) assert os.path.exists("%s/prepared_population.xml.gz" % context.path()) assert os.path.exists("%s/ile_de_france_network.xml.gz" % context.path()) # Copy remaining input files households_path = "%s/%s" % ( context.path("matsim.scenario.households"), context.stage("matsim.scenario.households") ) shutil.copy(households_path, "%s/ile_de_france_households.xml.gz" % context.cache_path) transit_schedule_path = "%s/%s" % ( context.path("matsim.scenario.supply.processed"), context.stage("matsim.scenario.supply.processed")["schedule_path"] ) shutil.copy(transit_schedule_path, "%s/ile_de_france_transit_schedule.xml.gz" % context.cache_path) transit_vehicles_path = "%s/%s" % ( context.path("matsim.scenario.supply.gtfs"), context.stage("matsim.scenario.supply.gtfs")["vehicles_path"] ) shutil.copy(transit_vehicles_path, "%s/ile_de_france_transit_vehicles.xml.gz" % context.cache_path) # Generate base configuration eqasim.run(context, "org.eqasim.core.scenario.config.RunGenerateConfig", [ "--sample-size", context.config("sampling_rate"), "--threads", context.config("processes"), "--prefix", "ile_de_france_", "--random-seed", context.config("random_seed"), "--output-path", "generic_config.xml" ]) assert os.path.exists("%s/generic_config.xml" % context.path()) # Adapt config for Île-de-France eqasim.run(context, "org.eqasim.ile_de_france.scenario.RunAdaptConfig", [ "--input-path", "generic_config.xml", "--output-path", "ile_de_france_config.xml" ]) assert os.path.exists("%s/ile_de_france_config.xml" % context.path()) # Route population eqasim.run(context, "org.eqasim.core.scenario.routing.RunPopulationRouting", [ "--config-path", "ile_de_france_config.xml", "--output-path", "ile_de_france_population.xml.gz", "--threads", context.config("processes"), "--config:plans.inputPlansFile", "prepared_population.xml.gz" ]) assert os.path.exists("%s/ile_de_france_population.xml.gz" % context.path()) # Validate scenario eqasim.run(context, "org.eqasim.core.scenario.validation.RunScenarioValidator", [ "--config-path", "ile_de_france_config.xml" ]) # Cleanup os.remove("%s/prepared_population.xml.gz" % context.path()) return "ile_de_france_config.xml"