Rules that infer relationships and entities can be useful for grouping entity instances in order to refer to the group as a whole in your rules and use the standard entity functions in a more powerful way. For example, you could:
Further examples are provided under Worked Examples below.
Infer membership of a relationship
Infer existence of entities to satisfy the relationship
The syntax to use to infer that existing entity instances are members of a relationship is:
Note that membership rules must be written in the positive form. That is, it is not possible to infer that an entity is not a member of a relationship.
All subsequent rule levels for this conclusion must have the source entity and the target entity in its reasoning scope. The relationship used must be defined as a many-to-many relationship type in the properties file for the project. (See Define a relationship for more information.)
In the example rule below, a membership statement is used to conclude membership of the inferred relationship 'the parent’s school-aged children'.
the child is a member of the parent’s school-aged children if
the child is of school age
A relationship must only be inferred in its primary direction.
You can also write a rule that creates entity instances to become members of a relationship.
The syntax to use to infer that entity instances should be created (or deleted) as members of a relationship is:
or in table form (where multiple instances are needed):
Relationship | |
---|---|
<identifying value> | Condition |
<identifying value> | Condition |
The identifying value can either be a fixed value ("spouse") or a variable (the tax year) which is then used as the identifying attribute for the entity instances created.
At runtime, the engine will evaluate each rule in the above form, evaluate the condition(s) and will create an instance for any condition that is true, and destroy any instance for which no condition returns true.
For example, assuming you have the following data model:
Writing the rule:
the locations ("Main office") exists
will create a single instance of the entity "the location" which is a member of the containment relationship "the locations". The instance will have "Main office" as the value of the identifying attribute.
Writing the rule:
the locations | |
---|---|
"Main office" | the assessment date >= 2009-10-01 |
"Warehouse" | the assessment date >= 2000-01-15 |
"Factory" | the assessment date >= 2000-01-15 |
will create instances of the entity "the location" (depending on the assessment date), which are members of the containment relationship "the locations". These instances will have "Main office", "Warehouse" and "Factory" as the value of their identifying attributes.
Writing the rule:
the location in which the employee works (the employee’s local office) exists
will create an instance of the location entity for each unique value of "the employee’s local office". These instances will be members of the relationship "the location in which the employee works" and have the value of the employee’s local office as the value of the identifying attribute.
The following example rulebases installed with Oracle Policy Modeling demonstrate the inferred entity instance functionality. For how to view these rulebases, see Open an example rulebase.
This rulebase models a generic purchase order scenario using inferred entity instances to group order items by brand and then apply a brand discount for purchases over $100 for any given brand.
This rulebase infers the existence of benefits and tallies the number of people eligible for each benefit. It also demonstrates inferred instances using rule tables.
This rulebase infers the existence of tax year entity instances so that further rules related to those tax years can be applied. This can be helpful if you want to ask further information about previous years (ie "did you submit a tax return for <tax year>") but only ask about tax years relevant to the interview, without pre-populating every possible tax year.
This rulebase infers the existence of service entity instances in order to identify which services should be started, stopped or retained when a customer changes phone plans. It also demonstrates inferred instances from global values.
See also: