Class SimpleSolutionManager

java.lang.Object
fr.inria.rules.integraal.query_evaluation.conjunction.backtrack.legacy.SimpleSolutionManager
All Implemented Interfaces:
SolutionManager

public class SimpleSolutionManager extends Object implements SolutionManager
First simple implementation of the SolutionManager using maps to index results.
  • Field Details

    • substitutionsByLevel

      protected final Map<Integer, Iterator<Substitution>> substitutionsByLevel
      Index solutions by level
    • initialSubstitution

      protected final Substitution initialSubstitution
      Initial substitution that must always be preserved in current solutions.
    • variableByLevel

      protected final Map<Integer, Collection<Variable>> variableByLevel
      Index assigned variables by level
    • currentSubstitution

      protected Substitution currentSubstitution
      Store the current solution
    • filterSubstitution

      protected Predicate<Substitution> filterSubstitution
      Predicate used to discard substitutions that should not be explored.
  • Constructor Details

    • SimpleSolutionManager

      public SimpleSolutionManager()
      Creates a new solution manager with default objects
    • SimpleSolutionManager

      public SimpleSolutionManager(Substitution initialSubstitution)
      Creates a new solution manager with default objects
      Parameters:
      initialSubstitution - the substitution to merge into every current solution
  • Method Details

    • getCurrentSolution

      public Substitution getCurrentSolution()
      //////////////////////////////////////////////
      Specified by:
      getCurrentSolution in interface SolutionManager
      Returns:
      the current solution.
    • next

      public boolean next(int level)
      Try to use the next solution for the given level. Recursively iterate over the solutions for the given level if needed.
      Specified by:
      next in interface SolutionManager
      Parameters:
      level - the current level
      Returns:
      true iff there is a next solution for this level
    • add

      public void add(int level, Iterator<Substitution> results)
      Adds new results for the given level.
      Specified by:
      add in interface SolutionManager
      Parameters:
      level - The level to add results to
      results - An iterator of substitutions to add
    • variablesBeforeLevel

      protected Collection<Variable> variablesBeforeLevel(int level)
      Returns the variables assigned before the supplied level.
      Parameters:
      level - the backtrack level
      Returns:
      a collection of variables assigned before the given level