Closed mjcortejo closed 1 year ago
Unexpected behavior that cars do a u-turn on places they shouldn't. Might have to create aprior variable that looks 2 edges back and see allow an attribute if to allow a u-turn
This area in particular
Solution 1:
Compute initial path
paths = nx.dijkstra_path(G, 'P3', 'P2')
print("First path", paths)
Create temporary graph
temp_G = G
Create collection of sequences to be disallowed
sample_sequence = ['C3', 22, 17]
Define function for checking subsequence
def check_subsequence(paths):
n = len(sample_sequence)
for i in range(len(paths)):
if paths[i:i+n] == sample_sequence:
return True, i
return False
Check if sequence is executing a u-turn path
check_subsequence(paths)
Using temporary graph, remove the node
temp_g = temp_G.remove_node(17)
Now recompute path again
paths = nx.dijkstra_path(temp_G, 'P3', 'P2')
This solution worked
Will close, the solution will be merged to the 22-implement-weighting-mechanism branch
I have currently implemented multiple entry points and parking points.
Right now, cars coming out of parking points diverge both ways out of the connector nodes.
The possible culprit to check:
self.G.add_edge(edges[0], edges[1])
https://github.com/mjcortejo/csc931m-complex-systems/blob/df6f838a81edde3c6d028a9db0949dd903edcf6c/main.py#L306