Skip to content

Rjf/dispatcher req sort#206

Merged
robfitzgerald merged 3 commits intomainfrom
rjf/dispatcher-req-sort
Jun 16, 2023
Merged

Rjf/dispatcher req sort#206
robfitzgerald merged 3 commits intomainfrom
rjf/dispatcher-req-sort

Conversation

@robfitzgerald
Copy link
Copy Markdown
Collaborator

@nreinicke i think i found it. i was writing an email response to dylan and was jotting down some potential leads, like looking into whether scipy guarantees the linear_sum_assignment is deterministic. then i was like OH YA i should quadruple-check that we build the matrix deterministically. we do not.

in the dispatcher logic, we were creating the assignment matrix of available vehicles by current unassigned requests. the unassigned_requests collection was being sorted by value descending, which is to say, "put the highest-valued customers at the top of this list". but there was no tie-breaker:

            unassigned_requests = simulation_state.get_requests(
                sort_key=lambda r: -r.value,
                filter_function=_valid_request,
            )

I fixed this by making the sort key lambda r: (-r.value, r.id). I ran manhattan.yaml twice in a row and observed the top-level stats were the same:

Screen Shot 2023-06-16 at 9 23 06 AM

as you'll see in the changed files for this PR, i've also updated the newly-added design.md section of the HIVE documentation to clearly highlight the sort issue.

@robfitzgerald robfitzgerald requested a review from nreinicke June 16, 2023 15:25
@robfitzgerald
Copy link
Copy Markdown
Collaborator Author

read the docs failed with the following error (below). link to build. it looks like we need to pin our sphinx version to "<7.0.0" as readthedocs doesn't support sphinx 7 yet.

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/sphinx/builders/html/__init__.py", line 1093, in handle_page
    output = self.templates.render(templatename, ctx)
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/readthedocs_ext/readthedocs.py", line 181, in rtd_render
    content = old_render(template, render_context)
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/sphinx/jinja2glue.py", line 196, in render
    return self.environment.get_template(template).render(context)
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/sphinx/themes/basic/page.html", line 10, in top-level template code
    {%- extends "layout.html" %}
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/sphinx_rtd_theme/layout.html", line 23, in top-level template code
    <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
jinja2.exceptions.UndefinedError: 'style' is undefined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/sphinx/cmd/build.py", line 285, in build_main
    app.build(args.force_all, args.filenames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/sphinx/application.py", line 351, in build
    self.builder.build_update()
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 294, in build_update
    self.build(to_build,
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 361, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 569, in write
    self._write_serial(sorted(docnames))
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 579, in _write_serial
    self.write_doc(docname, doctree)
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/sphinx/builders/html/__init__.py", line 667, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/home/docs/checkouts/readthedocs.org/user_builds/nrelhive/envs/206/lib/python3.8/site-packages/sphinx/builders/html/__init__.py", line 1100, in handle_page
    raise ThemeError(__("An error happened in rendering the page %s.\nReason: %r") %
sphinx.errors.ThemeError: An error happened in rendering the page autoapi/index.
Reason: UndefinedError("'style' is undefined")

Theme error:
An error happened in rendering the page autoapi/index.
Reason: UndefinedError("'style' is undefined")

Copy link
Copy Markdown
Collaborator

@nreinicke nreinicke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dude! Great find! It would have taken me forever to track that down. So happy you had the lighting bolt moment ⚡

@robfitzgerald robfitzgerald merged commit 2db64c1 into main Jun 16, 2023
@robfitzgerald robfitzgerald deleted the rjf/dispatcher-req-sort branch June 16, 2023 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants