Skip to content

Conversation

@robfitzgerald
Copy link
Collaborator

@robfitzgerald robfitzgerald commented Dec 23, 2025

this PR closes #445 by introducing a new compare method to LabelModel. it returns a std::cmp::Ordering designating whether a previous label is less than, greater than, or equal to some next label.

during A* directly before tree insert we prune the existing tree entries that share the same vertex. previous entries are removed if one dominates (edit) by minimizing cost and maximizing label state.

both LabelModel implementations were updated accordingly:

  • the default label model always chooses "Greater" - any label overwrites are accepted
  • the charging label model returns the result of comparing their SOC values (soc1.cmp(soc2))

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces label dominance checking to the RouteE Compass search algorithm by adding a compare method to the LabelModel trait. The goal is to prune dominated search tree entries during A* search to improve performance by reducing the label state space.

Key changes:

  • Added compare method to LabelModel trait for comparing label dominance
  • Implemented compare in VertexLabelModel (always returns Greater to allow any override) and SOCLabelModel (compares SOC values)
  • Added prune_tree function in A* algorithm to remove dominated labels before tree insertion
  • Added helper methods to SearchTree (get_labels_iter, get_labels_mut) and SearchTreeNode (traversal_cost)
  • Added new error types for label mismatches and missing nodes

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
rust/routee-compass-core/src/model/label/label_model.rs Adds compare method to LabelModel trait for dominance checking
rust/routee-compass-core/src/model/label/default/vertex_label_model.rs Implements compare for default vertex labels, always returning Greater
rust/routee-compass-powertrain/src/model/charging/soc_label_model.rs Implements compare for SOC labels by comparing SOC state values
rust/routee-compass-core/src/algorithm/search/a_star/a_star_algorithm.rs Adds prune_tree function to remove dominated labels during search
rust/routee-compass-core/src/algorithm/search/search_tree.rs Adds helper methods for label access and new error variant
rust/routee-compass-core/src/algorithm/search/search_tree_node.rs Adds traversal_cost method to access node costs
rust/routee-compass-core/src/model/label/label_model_error.rs Adds MismatchLabelTypes error variant for type mismatches
rust/routee-compass-core/src/model/label/mod.rs Re-exports additional types for cleaner imports

robfitzgerald and others added 24 commits January 7, 2026 13:24
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v5...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v6...v7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@robfitzgerald
Copy link
Collaborator Author

@nreinicke this PR is once again ready for a review.

latest changes:

  • moved pruning into the SearchTree::insert function
    • still effectively a no-op for VertexLabel types
  • moved pruning logic into a search_pruning.rs module
  • improved comments

Copy link
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.

This is looking good, thanks for adding this in. I think the logic is flipped for skipping the pruning but everything else looks good to me

/// if not, then its type has a greater cardinality than the vertex set and so
/// we will want to prune any dominated labels with matching VertexId.
pub fn does_not_require_pruning(&self) -> bool {
!matches!(self, Label::Vertex(_))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this logic is flipped right? We want to return True if self matches a Label::Vertex variant but this returns False for that variant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nice catch!

Copy link
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.

Dig it. Do you mind doing a squash merge on this one since the commit list is so big?

@robfitzgerald robfitzgerald merged commit 3ef48dc into main Feb 11, 2026
5 checks passed
@robfitzgerald robfitzgerald deleted the rjf/label-dominates branch February 11, 2026 22:46
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.

LabelModel::dominates method for label state pruning

2 participants