Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smoothing crashing due to indexing error #303

Open
hjabbot opened this issue Oct 14, 2024 · 3 comments
Open

Smoothing crashing due to indexing error #303

hjabbot opened this issue Oct 14, 2024 · 3 comments
Assignees
Labels
Bug It might be considered a bug...

Comments

@hjabbot
Copy link
Collaborator

hjabbot commented Oct 14, 2024

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
@Ulvetanna Ulvetanna self-assigned this Oct 16, 2024
@Ulvetanna Ulvetanna added the Bug It might be considered a bug... label Oct 16, 2024
@davidwilby
Copy link

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

@Ulvetanna
Copy link
Collaborator

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

@davidwilby
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It might be considered a bug...
Projects
None yet
Development

No branches or pull requests

3 participants