Class InferenceEngine

java.lang.Object
com.aquima.interactions.rule.inference.InferenceEngine
All Implemented Interfaces:
IRuleGraph

public class InferenceEngine extends Object implements IRuleGraph
The inference engine contains the logic to determine a value for an attribute using the inference business rules defined.
Since:
5.0
Author:
O. Kerpershoek
  • Constructor Details

    • InferenceEngine

      public InferenceEngine(IRuleGraph graph)
      Constructs an inference engine using an initialized rule graph.
      Parameters:
      graph - The rule graph that should be used by the inference engine.
  • Method Details

    • sourceAttribute

      public InferenceResult[] sourceAttribute(IProfile profile, ValueReference valueReference, IRuleListener listener)
      This method does not check if the profile already contains a value for the given reference, but will always source a value for the attribute. This method will return an inference result object in the result array for each rule that has been evaluated. Also rules that did not yield a value for the target attribute will be present in this array. The reason to include all inference results is that the dependency information on the failed rules is needed to determine whether the target attribute may need to be inferenced again when one of the dependencies of the failed rules changes.
      Parameters:
      profile - The profile that should be used when evaluating the business rules.
      valueReference - The attribute whose value should be inferenced.
      listener - Optional listener that may be used to intercept events.
      Returns:
      Array containing the results of the inference actions that were triggered.
      Throws:
      AppException - This exception is raised when the source action failed due to an unexpected error.
    • getJustification

      protected JustificationTree getJustification(InferenceContext context, ValueReference valueReference, JustificationDepth depth, Map<ValueReference,JustificationTree> coveredJustifications)
      This method determines the justification tree for the specified value.
      Parameters:
      context - The profile containing the inferenced values.
      valueReference - The value for which the justification tree should be generated.
      depth - The depth of the justification tree that should be generated.
      coveredJustifications - the covered justifications
      Returns:
      The justification tree for the specified value.
      Throws:
      AppException - This exception is thrown when the justification tree could not be determined.
    • getJustification

      public JustificationTree getJustification(IProfile profile, ValueReference valueReference, JustificationDepth depth)
      This method determines the justification tree for the specified value.
      Parameters:
      profile - The profile containing the inferenced values.
      valueReference - The value for which the justification tree should be generated.
      depth - The depth of the justification tree that should be generated.
      Returns:
      The justification tree for the specified value.
      Throws:
      AppException - This exception is thrown when the justification tree could not be determined.
    • getDMNDecision

      protected DMNDecisionTree getDMNDecision(InferenceContext context, ValueReference valueReference)
      This method determines the DMN decision tree for the specified value.
      Parameters:
      context - The profile containing the inferenced values.
      valueReference - The value for which the DMN decision tree should be generated.
      Returns:
      The DMN decision tree for the specified value.
      Throws:
      AppException - This exception is thrown when the DMN decision tree could not be determined.
    • getDMNDecision

      public DMNDecisionTree getDMNDecision(IProfile profile, ValueReference valueReference)
      Determines the justification information for the DMN decision tree for the specified value.
      Parameters:
      profile - The profile containing the inferred values.
      valueReference - The value for which the DMN decision tree should be generated.
      Returns:
      DMN decision tree for the specified value.
    • getDMNDecision

      public DMNDecisionTree getDMNDecision(IProfile profile, IExpression expression, String description)
      Determines the justification information for the DMN decision tree for the specified expression
      Parameters:
      profile - The profile contained the inferred values
      expression - The expression for which the DMN decision tree should be generated
      description - the description
      Returns:
      DMN decision tree for the specified expression
    • getAllEntityNodes

      public IEntityNode[] getAllEntityNodes()
      Description copied from interface: IRuleGraph
      This method returns an array containing all the entity nodes present in the rule graph.
      Specified by:
      getAllEntityNodes in interface IRuleGraph
      Returns:
      Array containing all the entity nodes of the rule graph.
    • getAttributeNode

      public IAttributeNode getAttributeNode(String entity, String attribute)
      Description copied from interface: IRuleGraph
      This method returns the IAttributeNodeof the dependency graph for the given attribute. When the attribute is not used by a business rule, this method may return null.
      Specified by:
      getAttributeNode in interface IRuleGraph
      Parameters:
      entity - The name of the entity that contains the attribute (this does not need to be the name of the entity in which the attribute is defined, but may also be the entity that contains the attribute by inheritance.
      attribute - The name of the attribute.
      Returns:
      IAttributeNode The attribute node of the dependency graph for the given attribute name, or null when the attribute has no dependencies.
    • getEntityNode

      public IEntityNode getEntityNode(String entity)
      Description copied from interface: IRuleGraph
      This method returns the IEntityNode of the dependency graph for the given entity name.
      Specified by:
      getEntityNode in interface IRuleGraph
      Parameters:
      entity - The name of the entity.
      Returns:
      IEntityNode The entity node of the dependency graph for the given entity name.
    • getRuleGroup

      public IRuleGroup getRuleGroup(String name)
      Description copied from interface: IRuleGraph
      This method returns the rule group definition for the specified name.
      Specified by:
      getRuleGroup in interface IRuleGraph
      Parameters:
      name - The name of the requested rule group.
      Returns:
      The rule group definition for the specified name.