0

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:

  1. 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 in net_params. And I'm guessing parameters like initial_config is not really needed either.

  2. In the given tutorial files, ADDITIONAL_NET_PARAMS is utilized to pass network paramters like num_vehicles in main.py. However, I didn't define ADDITIONAL_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()' in main.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?

Merely Lee
  • 11
  • 3

0 Answers0