I use .net.xml
and .rou.xml
as templates in network.py
to generate networks. Related code is posted below:
temp_dir = ".\UrbanRoadway\ur_scenario"
net_params = NetParams(
template={
# network geometry features
"net": os.path.join(temp_dir, "urbanroadway.net.xml"),
# features associated with the routes vehicles take
"rou": os.path.join(temp_dir, "urbanroadway.rou.xml")
})
class UrbanRoadwayNetwork(Network):
def __init__(self,
name,
vehicles,
net_params,
initial_config=InitialConfig(),
traffic_lights=TrafficLightParams()):
pass
My problems are:
Am I doing the right thing by using template file like this? This way the class
UrbanRoadwayNetwork
does nothing else but simply passes the template net innet_params
. And I'm guessing parameters likeinitial_config
is not really needed either.In the given tutorial files,
ADDITIONAL_NET_PARAMS
is utilized to pass network paramters likenum_vehicles
in main.py. However, I didn't defineADDITIONAL_NET_PARAMS
in my network file as shown above. Is there any other approach instead of explictly define that? Or, shall I just pass these paramters using 'argparse.ArgumentParser()' inmain.py
?
Tried to use 'argparse.ArgumentParser()' to pass related parameters or just explictly define those in main.py.
Both approaches mentioned are required to match the parameters defined in template files (to me, .net.xml
and .rou.xml
), which increases the difficulty of modifying maintenance while reducing program scalability. Is there any better methods for doin this?