Interface SolutionManager

All Known Implementing Classes:
SimpleSolutionManager

public interface SolutionManager

SolutionManager

Abstraction that stores the partial substitutions produced by a back‑tracking evaluation engine. For each depth of the search tree (level) it keeps:

  • the Spliterator enumerating the candidate substitutions of that sub‑query,
  • the set of variables that will be newly bound when a candidate wins.

The interface lets the engine:

Concurrency and mutability: the object returned by getCurrentSolution() is a live view; it changes as soon as next(int) succeeds. Never cache or publish it outside the evaluation loop. Use copyCurrentSolution() when you need an immutable snapshot.

Author:
Guillaume Perution-Kihli
  • Method Details

    • getCurrentSolution

      Substitution getCurrentSolution()
      Returns the substitution that is currently valid at all explored levels.

      Live view: subsequent calls to next(int) may mutate and/or invalidate the content. Clone it with copyCurrentSolution() if you need to keep a stable version.

      Returns:
      the current live substitution
    • copyCurrentSolution

      Substitution copyCurrentSolution()
      Returns a stable snapshot of the current solution.
      Returns:
      a defensive copy of the current solution (safe to keep).
    • next

      boolean next(int level)
      Advance the iterator at level so the next candidate substitution (if any) is merged into the global solution.
      Parameters:
      level - depth in the search tree (0‑based)
      Returns:
      true if a compatible substitution exists, false otherwise.
    • add

      void add(int level, Spliterator<Substitution> substitutions, Collection<Variable> newVariables)
      Register the spliterator that will supply substitutions for level together with the
      list of variables that those substitutions can bind for the first time.
      Parameters:
      level - depth in the search tree (0-based)
      substitutions - the substitutions available at that level
      newVariables - the variables that may become bound at that level
    • getSpliterator

      Spliterator<Substitution> getSpliterator(int level)
      Returns the spliterator registered for a level.
      Parameters:
      level - depth in the search tree (0-based)
      Returns:
      the spliterator associated with level, or null.
    • replaceSpliterator

      void replaceSpliterator(int level, Spliterator<Substitution> newSpliterator)
      Replaces the spliterator registered for a level. Replace the spliterator stored for level.
      Parameters:
      level - depth in the search tree (0-based)
      newSpliterator - the replacement spliterator
    • pruneOtherIterators

      void pruneOtherIterators(int level)
      Prunes every stored iterator except the selected level. Remove (or empty) every level that is not equal to level.
      Parameters:
      level - the level to keep
    • deepCopy

      SolutionManager deepCopy()
      Creates an independent copy of this solution manager.
      Returns:
      an independent copy of this manager so that another branch can evolve in parallel without interference.