2 Replies Latest reply: May 31, 2012 9:27 AM by 853871 RSS

    Problem with inferred relationship

    853871
      the entity’s result = InstanceValueIf(the entity’s inferred siblings, the entity’s target value, the entity’s identity number = InstanceMinimum(the entity’s inferred siblings, the entity’s identity number))


      Can anyone help me out with this?
      “the entity’s inferred siblings” is an inferred many to many relationship between entities of the same type.
      And I have to use OPA 10.3

      I can infer InstanceMinimum(the entity’s inferred siblings, the entity’s identity number) correctly every time, and if I test by hard coding that value in place of the InstanceMinimum function it works fine.

      However, when I derive the value into its own property separately and substitute that property above the entity’s result is still wrong.

      I think I need a scope function or an alias somewhere but I haven’t seen anywhere where a scope or an alias can be used to derive a value, only where it can be used to prove true or false.

      Any help greatly appreciated.
        • 1. Re: Problem with inferred relationship
          Ben Rogers
          Hi there
          I think the problem is with:
          InstanceValueIf(the entity’s inferred siblings, the entity’s target value, the entity’s identity number = InstanceMinimum(the entity’s inferred siblings, the entity’s identity number))
          I think when it is doing the InstanceMinimum, it is looking at the other entity's siblings, and not the original one.
          The best way of solving this would be to create another inferred relationship, "the entity's minimum sibling". This will avoid this scope problem and generally make life much easier to debug.

          The rules would look something like this:

          IsMemberOf(the entity, the other entity, the entity's minimum sibling)
          -->the other entity’s id = the entity’s minimum sibling id

          the entity’s minimum sibling id = InstanceMinimum(the entity’s inferred siblings, the entity’s id)

          the entity’s result = InstanceValueIf(the entity's minimum sibling, the entity’s target value, the entity’s target value is certain)

          Word of warning though: if you have high numbers of entity instances, the rulebase performance will suffer because of the (now 2) self-referential inferred relationships. In our experience, over high volumes, the performance becomes an issue. Over low numbers of instances (say, under 50) it shouldn't be too much of an issue.

          Hope this helps - please let me know if this solves the problem!
          Cheers,
          Ben
          • 2. Re: Problem with inferred relationship
            853871
            Thanks Ben.

            Yes I did establish that the entity’s identity number = InstanceMinimum(the entity’s inferred siblings, the entity’s identity number) was referencing itself, resulting in the InstanceValueIf producing more than one result and crashing.

            The solution I've produced is almost identical to what you've suggested.

            Thanks for the performance info though. We should be OK with the volumes we've got.

            Cheers.