Skip to content

Commit

Permalink
Aimsun fixes (#753)
Browse files Browse the repository at this point in the history
* get rid of save prompt in aimsun

* bug: getLanesLength2D sums all lane lengths

* was using wrong key for speed limit

* add flow directory to PYTHONPATH

* length2D is the proper way to get edge length
  • Loading branch information
temetski committed Oct 15, 2019
1 parent 1906340 commit 054d393
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 2 additions & 0 deletions flow/core/kernel/network/aimsun.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def generate_network(self, network):
if os.path.exists(check_file_path):
os.remove(check_file_path)

# we need to make flow directories visible to aimsun's python2.7
os.environ["PYTHONPATH"] = config.PROJECT_PATH
# path to the supplementary file that is used to generate an aimsun
# network from a template
template_path = network.net_params.template
Expand Down
8 changes: 4 additions & 4 deletions flow/utils/aimsun/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def generate_net(nodes,
config.PROJECT_PATH, "flow/utils/aimsun/run.py"), True)

# save
gui.saveAs('flow.ang')
gui.save(model, 'flow.ang', GGui.GGuiSaveType.eSaveAs)


def generate_net_osm(file_name, inflows, veh_types):
Expand Down Expand Up @@ -374,7 +374,7 @@ def generate_net_osm(file_name, inflows, veh_types):
config.PROJECT_PATH, "flow/utils/aimsun/run.py"), True)

# save
gui.saveAs('flow.ang')
gui.save(model, 'flow.ang', GGui.GGuiSaveType.eSaveAs)


def get_junctions(nodes):
Expand Down Expand Up @@ -685,7 +685,7 @@ def create_meter(model, edge):
"""
section = model.getCatalog().findByName(edge, model.getType("GKSection"))
meter_length = 2
pos = section.getLanesLength2D() - meter_length
pos = section.length2D() - meter_length
type = model.getType("GKMetering")
cmd = model.createNewCmd(model.getType("GKSectionObject"))
# TODO double check the zeros
Expand Down Expand Up @@ -825,7 +825,7 @@ def set_sim_step(experiment, sim_step):
for s in types.itervalues():
s_id = s.getId()
num_lanes = s.getNbFullLanes()
length = s.getLanesLength2D()
length = s.length2D()
speed = s.getSpeed()
edge_osm[s_id] = {"speed": speed,
"length": length,
Expand Down
7 changes: 2 additions & 5 deletions flow/utils/aimsun/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,8 @@ def get_dict_from_objects(sections, nodes, turnings, cen_connections):
scenario_data['sections'][s.id] = {
'name': s.name,
'numLanes': s.nb_full_lanes,
# FIXME this is a mean of the lanes lengths
# (bc they don't have to be all of the same size)
# it may not be 100% accurate
'length': s.lanes_length_2D / s.nb_full_lanes,
'max_speed': s.speed
'length': s.length2D(),
'speed': s.speed
}

# load nodes
Expand Down

0 comments on commit 054d393

Please sign in to comment.