This discussion is archived
5 Replies Latest reply: Feb 7, 2013 6:49 AM by Ben Rogers RSS

Temporal reasoning with multiple instances for same period

969510 Newbie
Currently Being Moderated
We are trying to use temporal rules to determine the country a person is living in. We have the entity 'Person' with a one-to-many relation with 'Address'. In the target entity there can be residential addresses and postal addresses. We only want to use the residential addresses and not the postal addresses.

We want to use the 'TemporalFromRange' operator, but with that operator we can't make a distinction between residential and postal addresses.

Example situation:

Person 1

Address 1
Country: UK
Type: residential
Start date: 2001-01-01
End date: 2002-01-01

Address 2
Country: NL
Type: postal
Start date: 2001-06-01
End date: 2002-01-01

Address 3
Country: BE
Type: residential
Start date: 2002-01-01
End date: Unknown


What we want to see:
Initial Uncertain
UK from 2001-01-01
BE from 2002-01-01

What is the best solution for this issue?
  • 1. Re: Temporal reasoning with multiple instances for same period
    Ben Rogers Journeyer
    Currently Being Moderated
    Hi,
    I personally don't use TemporalFromRange. Every time I look back on the rules I forget what it does, and other users do too. Here is a suggested solution:

    Firstly, create an inferred relationship "the person's residential addresses" and set this up so that only residentital instances are members:

    IsMemberOf(the address, the person’s residential addresses)
    ...the address is residential

    Next, I find it useful to declare a generic "... is applicable (temporal)" intermediate attribute:

    the address is applicable (temporal) if
    .the address is for a range (temporal)
    ....TemporalOnOrAfter(the address start date) and
    ....TemporalOnOrBefore(the address end date)
    .or
    .the address is indefinite (temporal)
    ....TemporalOnOrAfter(the address start date) and
    ....the address end date is uncertain


    Note that this has you covered for the two scenarios. Either you have a start date and an end date for an address, or you just have a start date. Uncertain is easier to use here (i.e. set the base attribute of the address end date to uncertain) as the "unknown" becomes difficult to handle... you can't tell if the unknown was introduced on purpose, or if an error had occured. At least with uncertain, you can be sure that the missing end date was meant.

    Then, once you have this useful intermediate, you can declare a temporal attribute on address level that you can use to display to the customer etc:

    This is a rule table in Word:

    the address name (temporal)
    ......................................................
    the address name | the address is applicable (temporal)
    uncertain | otherwise


    Note that it is always a good idea to label temporal attributes in some way. It makes the rules much easier to debug and maintain in the future!

    The address name can be anything you want. Maybe firstline + postcode...

    Now you can create a text attribute at person level that will always pick their most recent residential address:

    the person’s current residential address (temporal) = InstanceValueIf(the person’s residential addresses, the address name (temporal), the address name (temporal) is certain)


    Note that if the person has an overlapping residential address, then their current residential address will be uncertain. I'm not too sure on your requirements or input data, so for now I'm assuming that you can't have one "applicable" residential address at the same time.

    If you can, then you would need some other criteria to decide what to pick (most recent start date is always chosen if InstanceCount > 1 for example)...

    Hope this helps.

    If you are having trouble just contact me and I can send you the rulebase.
    ben.rogers@monadsolutions.com.

    Cheers,
    Ben
  • 2. Re: Temporal reasoning with multiple instances for same period
    969510 Newbie
    Currently Being Moderated
    Hi Ben,

    Thanks for your explaination. This is indeed a good solution for the issue, but I hoped there was another way to solve the temporal reasoning with multiple entities for the same period.

    Some additional information: In our situation we have two persons. When we use an inferred relationship (which has a many-to-many relation) for addresses all addresses are put together and we can't distinct between the addresses for person 1 and person 2.
  • 3. Re: Temporal reasoning with multiple instances for same period
    Ben Rogers Journeyer
    Currently Being Moderated
    Hi,

    I tested this solution and it works, and is efficient and also easy to understand and maintain.

    The only thing (as I mentioned) is that if you have overlapping addresses, (you do on 2002-01-01 when one address ends and the other one starts) you should either end the first address on 2011-12-31 or put some logic in to handle it (i.e. in this situation, pick the address with the latest end date).

    What other way were you thinking of? You could try and use TemporalFromRange() but use "the residential addresses" inferred relationship I mentioned in the previous post. As I said, in my experience this function is tricky for other users to understand but you could try doing your rules now based on that. I also recommend getting rid of the "unknown" in your input data and using "uncertain" instead.

    "all addresses are put together and we can't distinct between the addresses for person 1 and person 2"

    OK, so what you are saying is that person 1 and person 2 are assumed to have the same addresses? In that case, just create the inferred relationship "the residential addresses" to be from global to the address rather than person to the address.

    Hope this helps.
    Ben
  • 4. Re: Temporal reasoning with multiple instances for same period
    969510 Newbie
    Currently Being Moderated
    Hi Ben,

    I didn't describe the situation clear enough in my first entry, anothery try:

    With rules for an inferred relation I created the following inferred relation:
    An adress is member of the person's postal adresses if it has the indication 'Postal'.

    Now I want to create a temporal rule to derive the country of the address from the inferred relation.

    The result is that I see the same address for the same period for both Person 1 and Person 2, while Person 2 has no postal address.


    person's country of the address for person 1 = NL from 2001-01-01

    person's country of the address for person 2 = NL from 2001-01-01



    Person 1

    Address 1
    Country: UK
    Type: residential
    Start date: 2001-01-01
    End date: 2002-01-01

    Address 2
    Country: NL
    Type: postal
    Start date: 2001-06-01
    End date: Unknown


    Person 2

    Address 3
    Country: BE
    Type: residential
    Start date: 2002-01-01
    End date: Unknown

    Edited by: EKroon_NL on 7-feb-2013 5:57
  • 5. Re: Temporal reasoning with multiple instances for same period
    Ben Rogers Journeyer
    Currently Being Moderated
    Hi!
    No problem, it is tricky to explain everything over the forum.

    I think I get what the problem is now - I am assuming this is your data model:

    person --> address (one to many.. "manual" relationship)
    global --> addresss (one to many)

    Then you want
    person --> address "the person's residential addresses" (many to many inferred)
    and
    person --> address "the person's postal addresses" (many to many inferred)

    If person 1 and person 2 could have different addresses, then you can refine the inferred relationship:

    IsMemberOf(the address, the person’s postal addresses)
    ...the address is postal and
    ...IsMemberOf(the address, the person's addresses)


    This second line makes sure that only members of the person's addresses will be included in the inferred relationship (so long as they are postal).

    You should then be able to use this address in TemporalFromRange or using the solution I originally described.
    Cheers,
    Ben

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points