Skip to content

Smoothing crashing due to indexing error #303

Description

@hjabbot

Smoothing is crashing in a mesh with only land masses (no SIC, no currents, just a GRF elevation dataloader). I've plotted the mesh and I can't see anything obvious causing it.

image

Attached are the vessel mesh file, route config, waypoints used to create the crash, along with the dijkstra route saved out before the crash.
index_issue.zip

Traceback (most recent call last):
  File "/tmp/ipykernel_57641/66007170.py", line 47, in optimise_routes
    build_route_mesh_if_missing(route_config_file, vessel_mesh_json_file, waypoints_file, output_filename)
  File "/tmp/ipykernel_57641/66007170.py", line 23, in build_route_mesh_if_missing
    smoothed_routes = rp.compute_smoothed_routes()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/habbot/Documents/Work/BAS/repos/sdadt/PolarRoute/polar_route/utils.py", line 238, in wrapper
    res = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/habbot/Documents/Work/BAS/repos/sdadt/PolarRoute/polar_route/route_planner/route_planner.py", line 700, in compute_smoothed_routes
    sf.forward()
  File "/home/habbot/Documents/Work/BAS/repos/sdadt/PolarRoute/polar_route/route_planner/crossing_smoothing.py", line 1371, in forward
    if self.previous_vs(edge_a, edge_b, midpoint_prime):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/habbot/Documents/Work/BAS/repos/sdadt/PolarRoute/polar_route/route_planner/crossing_smoothing.py", line 1087, in previous_vs
    edge_b_start_index = edge_b.start['id']
                         ~~~~~~~~~~~~^^^^^^
TypeError: 'NoneType' object is not subscriptable

Activity

  1. self-assigned this
    on Oct 16, 2024
  2. davidwyld commented on Oct 24, 2024

    @davidwyld
    Contributor

    Also getting this error, with polar-route 1.0.0 (both python interface and CLI) when waypoint splitting is on, using an 'empty' open water mesh from the basic example (https://colab.research.google.com/drive/1N1mxOy2oX7bEGtPy7Ztshrs4Fs_7lBpV?usp=sharing#scrollTo=i-PJy6KMiLk9)

    Route config

    {
        "objective_function": "traveltime",
        "path_variables": [
            "fuel",
            "traveltime"
        ],
        "vector_names": [
            "uC",
            "vC"
        ],
        "zero_currents": false,
        "variable_speed": true,
        "time_unit": "days",
        "early_stopping_criterion": true,
        "save_dijkstra_graphs": true,
        "waypoint_splitting": true,
        "smoothing_merge_separation": 1e-3,
        "smoothing_converged_sep": 1e-3,
        "smooth_path": {
            "max_iteration_number": 1000,
            "minimum_difference": 0.0005
        }
    }

    The new bits of the config that result in this behaviour are:

        "waypoint_splitting": true,
        "smoothing_merge_separation": 1e-3,
        "smoothing_converged_sep": 1e-3,

    Output and stack trace:

    ❯ optimise_routes traveltime.config.json open_water.vessel.json waypoints_example.csv -o open_water.route.json
    [24-10-24 12:26:07 :INFO    ] - optimise_routes 1.0.0
    [24-10-24 12:26:07 :INFO    ] - Initialising Route Planner
    [24-10-24 12:26:07 :INFO    ] - Calculating Dijkstra routes
    [24-10-24 12:26:07 :INFO    ] -  Splitting around waypoints !
    [24-10-24 12:26:07 :INFO    ] - ============= Dijkstra Route Creation ============
    [24-10-24 12:26:07 :INFO    ] -  - Objective = traveltime
    [24-10-24 12:26:07 :INFO    ] - --- Processing Source Waypoint = Start
    [24-10-24 12:26:07 :INFO    ] - Destination waypoint: End
    [24-10-24 12:26:08 :INFO    ] - Dijkstra routing complete...
    [24-10-24 12:26:08 :INFO    ] - Timed call to compute_routes took 0.813959 seconds
    [24-10-24 12:26:08 :INFO    ] - Calculating smoothed routes
    [24-10-24 12:26:08 :INFO    ] - ========= Determining Smoothed Routes ===========
    [24-10-24 12:26:08 :INFO    ] - --- Smoothing Route - Start to End
    Traceback (most recent call last):
      File ".../bin/optimise_routes", line 8, in <module>
        sys.exit(optimise_routes_cli())
                 ^^^^^^^^^^^^^^^^^^^^^
      File ".../polar_route/utils.py", line 238, in wrapper
        res = func(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^
      File ".../polar_route/cli.py", line 202, in optimise_routes_cli
        smoothed_routes = rp.compute_smoothed_routes()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File ".../polar_route/utils.py", line 238, in wrapper
        res = func(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^
      File ".../polar_route/route_planner/route_planner.py", line 700, in compute_smoothed_routes
        sf.forward()
      File ".../polar_route/route_planner/crossing_smoothing.py", line 1327, in forward
        if self.previous_diagonals(edge_a, edge_b, firstpoint, lastpoint):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File ".../polar_route/route_planner/crossing_smoothing.py", line 1176, in previous_diagonals
        edge_b_start_index = edge_b.start['id']
                             ~~~~~~~~~~~~^^^^^^
    TypeError: 'NoneType' object is not subscriptable
  3. Ulvetanna commented on Oct 24, 2024

    @Ulvetanna
    Member

    Thanks @davidwilby for the info. Will look into the issue first thing tomorrow !

  4. davidwyld commented on Oct 24, 2024

    @davidwyld
    Contributor

    To add to this, if it's helpful, I've run this with the 'real data example' from the docs and get the same bug with waypoint_splitting switched on, and not when it's off.

  5. Ulvetanna commented on Oct 30, 2024

    @Ulvetanna
    Member

    Thanks David this has been really useful. As you say I think it's in the splitting around waypoints, currently correcting this in the work, will keep you updated when fixed

  6. linked a pull request that will close this issueBug Fixing - Path Smoothing failures #308on Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugIt might be considered a bug...

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions