Class GRDImpl

java.lang.Object
org.jgrapht.graph.AbstractGraph<FORule,GRDEdge>
org.jgrapht.graph.AbstractBaseGraph<FORule,GRDEdge>
org.jgrapht.graph.DirectedPseudograph<FORule,GRDEdge>
fr.inria.rules.integraal.grd.impl.GRDImpl
All Implemented Interfaces:
GraphOfFORuleDependencies, Serializable, Cloneable, org.jgrapht.Graph<FORule,GRDEdge>

public class GRDImpl extends org.jgrapht.graph.DirectedPseudograph<FORule,GRDEdge> implements GraphOfFORuleDependencies
GRD implementation using unification

Rules of this GRD can have negation as long as the negation is safe

See Also:
  • Field Summary

    Fields inherited from interface org.jgrapht.Graph

    DEFAULT_EDGE_WEIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
    GRDImpl(RuleBase ruleBase)
    Constructor initialized with the rules from the rulebase no compilation and a productivity checker
    GRDImpl(RuleBase ruleBase, RuleCompilation compilation)
    Constructor initialized with the rules from the rulebase and a productivity checker
    GRDImpl(RuleBase rulebase, RuleCompilation compilation, Collection<DependencyChecker> checkers)
    Constructor initialized with the rules from the rulebase
    Constructor initialized with the rules from the rulebase and no compilation
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns all rules that can trigger the specified one.
    Collection<? extends FORule>
    getAncestorRules(FORule target, Set<FORule> rulesToIgnore)
    Retrieves the ancestor rules by ignoring some rules
    The computed order of the stratification must guaranty a correct rule application but no additional assumption is done at this level on the computed stratum
    Returns the compressed ancestor rules of the specified rule.
    double
     
    The computed order of the stratification must guaranty a correct rule application.
    Returns all rules that can be prevented by the specified one.
    Return all the rules in the GRD
    Computes a stratification of the rules for single evaluation.
    Returns all rules that can be triggered by the specified one.
    boolean
    Check if this GRD is stratifiable

    Methods inherited from class org.jgrapht.graph.DirectedPseudograph

    createBuilder, createBuilder

    Methods inherited from class org.jgrapht.graph.AbstractBaseGraph

    addEdge, addEdge, addVertex, addVertex, clone, containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeSource, getEdgeSupplier, getEdgeTarget, getType, getVertexSupplier, incomingEdgesOf, inDegreeOf, iterables, outDegreeOf, outgoingEdgesOf, removeEdge, removeEdge, removeVertex, setEdgeSupplier, setEdgeWeight, setVertexSupplier, vertexSet

    Methods inherited from class org.jgrapht.graph.AbstractGraph

    assertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSets

    Methods inherited from class Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.jgrapht.Graph

    containsEdge, removeAllEdges, removeAllEdges, removeAllVertices, setEdgeWeight
  • Constructor Details

    • GRDImpl

      public GRDImpl(RuleBase rulebase, RuleCompilation compilation, Collection<DependencyChecker> checkers)
      Constructor initialized with the rules from the rulebase
      Parameters:
      rulebase - the ruleset to compute dependencies over
      compilation - compilation used on the ruleset
      checkers - checkers of the dependencies
    • GRDImpl

      public GRDImpl(RuleBase ruleBase)
      Constructor initialized with the rules from the rulebase no compilation and a productivity checker
      Parameters:
      ruleBase - the ruleset to compute dependencies over
    • GRDImpl

      public GRDImpl(RuleBase ruleBase, RuleCompilation compilation)
      Constructor initialized with the rules from the rulebase and a productivity checker
      Parameters:
      ruleBase - the ruleset to compute dependencies over
      compilation - compilation used on the ruleset
    • GRDImpl

      public GRDImpl(RuleBase ruleBase, Collection<DependencyChecker> checkers)
      Constructor initialized with the rules from the rulebase and no compilation
      Parameters:
      ruleBase - the ruleset to compute dependencies over
      checkers - checkers of the dependencies
  • Method Details

    • getRules

      public Collection<FORule> getRules()
      Description copied from interface: GraphOfFORuleDependencies
      Return all the rules in the GRD
      Specified by:
      getRules in interface GraphOfFORuleDependencies
      Returns:
      all the rules in the GRD
    • getTriggeredRules

      public Set<FORule> getTriggeredRules(FORule src)
      Description copied from interface: GraphOfFORuleDependencies
      Returns all rules that can be triggered by the specified one.
      Specified by:
      getTriggeredRules in interface GraphOfFORuleDependencies
      Parameters:
      src - a Rule.
      Returns:
      all rules that can be triggered by the specified one.
    • getAncestorRules

      public Set<FORule> getAncestorRules(FORule target)
      Description copied from interface: GraphOfFORuleDependencies
      Returns all rules that can trigger the specified one.
      Specified by:
      getAncestorRules in interface GraphOfFORuleDependencies
      Parameters:
      target - a Rule.
      Returns:
      all rules that can trigger the specified one.
    • getAncestorRules

      public Collection<? extends FORule> getAncestorRules(FORule target, Set<FORule> rulesToIgnore)
      Description copied from interface: GraphOfFORuleDependencies
      Retrieves the ancestor rules by ignoring some rules
      Specified by:
      getAncestorRules in interface GraphOfFORuleDependencies
      Parameters:
      target - the rule whose ancestors are requested
      rulesToIgnore - these rules will be ignored in the recursive search of ancestors
      Returns:
      the ancestor rules found while ignoring the supplied rules
    • getCompressedAncestorRules

      public Set<FORule> getCompressedAncestorRules(FORule target)
      Description copied from interface: GraphOfFORuleDependencies
      Returns the compressed ancestor rules of the specified rule.
      Specified by:
      getCompressedAncestorRules in interface GraphOfFORuleDependencies
      Parameters:
      target - the rule whose compressed ancestors are requested
      Returns:
      the compressed ancestor rules of the specified rule
    • getPreventedRules

      public Set<FORule> getPreventedRules(FORule src)
      Description copied from interface: GraphOfFORuleDependencies
      Returns all rules that can be prevented by the specified one.
      Specified by:
      getPreventedRules in interface GraphOfFORuleDependencies
      Parameters:
      src - a Rule.
      Returns:
      all rules that can be prevented by the specified one.
    • isStratifiable

      public boolean isStratifiable()
      Description copied from interface: GraphOfFORuleDependencies
      Check if this GRD is stratifiable
      Specified by:
      isStratifiable in interface GraphOfFORuleDependencies
      Returns:
      true iff the ruleset represented by this GRD is stratifiable
    • getBySccStratification

      public List<RuleBase> getBySccStratification()
      Description copied from interface: GraphOfFORuleDependencies
      The computed order of the stratification must guaranty a correct rule application but no additional assumption is done at this level on the computed stratum
      Specified by:
      getBySccStratification in interface GraphOfFORuleDependencies
      Returns:
      the stratification as an ordered list of rulebases
    • getSingleEvaluationStratification

      public Optional<List<RuleBase>> getSingleEvaluationStratification()
      Description copied from interface: GraphOfFORuleDependencies
      Computes a stratification of the rules for single evaluation. This method ensures that each rule is evaluated exactly once and attempts to minimize the number of strata. This is only possible for an acyclic graph; if the graph contains a cycle, an empty Optional is returned.
      Specified by:
      getSingleEvaluationStratification in interface GraphOfFORuleDependencies
      Returns:
      an Optional containing the stratification as an ordered list of rule bases if the graph is acyclic, otherwise an empty Optional.
    • getMinimalStratification

      public Optional<List<RuleBase>> getMinimalStratification()
      Description copied from interface: GraphOfFORuleDependencies
      The computed order of the stratification must guaranty a correct rule application. This method should try to minimize the number of stratum while keeping a correct order but no guaranty is given on the minimality of the result. An empty optional should be returned if the rules are not stratifiable
      Specified by:
      getMinimalStratification in interface GraphOfFORuleDependencies
      Returns:
      the stratification as an ordered list of rulebases
    • getEdgeWeight

      public double getEdgeWeight(GRDEdge e)
      Specified by:
      getEdgeWeight in interface org.jgrapht.Graph<FORule,GRDEdge>
      Overrides:
      getEdgeWeight in class org.jgrapht.graph.AbstractBaseGraph<FORule,GRDEdge>