ddo icon indicating copy to clipboard operation
ddo copied to clipboard

Change some traits' associated types to type parameters

Open Bubbler-4 opened this issue 1 year ago • 0 comments

Guessing from the technical note for WidthHeuristic, all traits that don't directly define the problem are designed to be problem-agnostic, and should be written using type parameters instead of associated types.

This PR changes the traits DecisionDiagram, Fringe, Cache, DominanceChecker, and SubProblemRanking to use type parameters instead of associated types. The former three are obviously part of the "engine"; the other two act as wrappers for user-implemented traits Dominance and StateRanking respectively, and therefore can be considered problem-agnostic as well. All examples compiled and example tests passed without modification.

I'm working on generalizing Solution to allow types other than Vec<Decision>, including

  • a linked list of chunks of Decisions, to avoid duplication
  • a user-supplied type, e.g. a bitset if the problem involves binary variables and the variables are visited in a fixed order

and this PR is expected to make the change a bit cleaner.

Bubbler-4 avatar Dec 30 '24 15:12 Bubbler-4