mjcortejo / csc931m-complex-systems

This repository contains the projects done for the CSC931M class
0 stars 0 forks source link

Add more entry points as parking locations. Complete with parking capacity #29

Closed mjcortejo closed 1 year ago

mjcortejo commented 1 year ago

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

mjcortejo commented 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

mjcortejo commented 1 year ago

This area in particular

image
mjcortejo commented 1 year ago

Solution 1:

  1. Compute initial path

    paths = nx.dijkstra_path(G, 'P3', 'P2')
    print("First path", paths)
  2. Create temporary graph temp_G = G

  3. Create collection of sequences to be disallowed sample_sequence = ['C3', 22, 17]

  4. 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
  5. Check if sequence is executing a u-turn path check_subsequence(paths)

  6. Using temporary graph, remove the node temp_g = temp_G.remove_node(17)

  7. Now recompute path again paths = nx.dijkstra_path(temp_G, 'P3', 'P2')

mjcortejo commented 1 year ago

This solution worked

mjcortejo commented 1 year ago

Will close, the solution will be merged to the 22-implement-weighting-mechanism branch