Welcome to the OPA Hub!


Category Archives: Temporal Reasoning

Guest Post : Time Based Reasoning Worked Example

Hi There!


This content is accessible only to logged in users of the OPA Hub Website.

To Register takes only 10 seconds and uses LinkedIn for authentication.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.

Temporal Reasoning #5 : Temporal Attributes in Interviews

Hi There!


This content is accessible only to logged in users of the OPA Hub Website.

To Register takes only 10 seconds and uses LinkedIn for authentication.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.

Temporal Reasoning in Oracle Policy Automation #4 : Time Travel

Temporal Reasoning in Oracle Policy Automation #4 : Time Travel

In this, the fourth part of our little series about Temporal Reasoning, we are going to look at the business of entering data. Specifically how users can enter the information they need during an interview. Thinking back to the scenario we have been discussing in the previous posts (part one, two and three) we need to enter information about our bank balance.

In a non-temporal world, entering the data would be as simple as entering a value in an input box. But we cannot have that, since there is no built-in capability to enter different values on different dates. Unlike some CRM systems like my old friend Oracle Siebel, there is no user interface element designed to facilitate the entry of temporal data.

So what options do we have. We can ask our users to enter data in row format, with each row representing a specific amount on a specific date. Put simply we can create an Entity and each instance can be converted into a temporal value. Let’s see how that works. Consider the following new Project with a simple data model:

Temporal Reasoning in Oracle Policy Automation 3

As you can do doubt see, a single entity has been added and a few attributes. In addition I have changed the default text provided for the Containment Relationship to make it more natural. For our purposes we are interested in the date and the currency attributes which will form the basis of our conversion. To make this easier, we are going to use an Excel table to infer instances of the bank balance entry using the following table:

Temporal Reasoning in Oracle Policy Automation 4

With this data we can now use one or other of the Temporal Reasoning functions that allow us to build temporal values from entity instances. As a first example, enter the following in a Word document in the project.

Temporal Reasoning in Oracle Policy Automation 5

The expression targets a new attribute, the temporal bank balance, which will be populated with the output of the TemporalFromStartDate function. The function takes the relationship as the initial argument, followed by the date attribute and our currency attribute. The result in the Debugger is this (note I have superimposed the Temporal Visualization from the Debugger on the Interview output) :

Temporal Reasoning in Oracle Policy Automation 6

Awesome. Our instances have become temporal values for our temporal attribute. But beware what this function is giving you. The implication of From Start Date is that any date prior to the first date in your Excel will show a temporal value of uncertain. Change the function to the following:

Temporal Reasoning Oracle Policy Automation 7

In this case, you are indicating that From the End Date of your instances, the temporal attribute will be uncertain.

Temporal Reasoning Oracle Policy Automation 8

If you have instances where there is both an end and a start date for each instance (which is not the case in our bank balance Excel table), you could also use this function to calculate when something was (for example) valid or invalid:

Temporal Reasoning Oracle Policy Automation 9

This of course assumes you have an entity, relationship and attributes that match the example above. It produces output like this:

Temporal Reasoning Oracle Policy Automation 10

In case you were wondering, you can reverse this process (go from temporal to instances) using a different method. In the final part of this series we will look at displaying the temporal data in cool ways.

Temporal Reasoning in Oracle Policy Automation #3 : Time Travel

Hi There!


This content is accessible only to logged in users of the OPA Hub Website.

To Register takes only 10 seconds and uses LinkedIn for authentication.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.

Temporal Reasoning in Oracle Policy Automation #2 : Time Travel

Temporal Reasoning in Oracle Policy Automation #2 : Time Travel

Following on from the previous post, this short series is looking at temporal reasoning. In the initial post we investigated the basic principle of entering temporal data in the debugger and using a function such as ValueAt() to get the value of a temporal attribute on a given date.

Now that we have laid the groundwork, we can extend our range a little. The first scenario to discover requires us to have the data in the debugger just like last time, with data for the first few days in July. If you are not sure of the scenario then jump right back to chapter one.

When did you last have lots of money in your account?

I’m sure I’m not the only one who sometimes looks at my bank account and feels a little depressed! The bank balance seems to go down and down, then spikes up on pay day and down and down again. I often ask myself, when looking at something nice in a shop or showroom  – a car for example – when did I last have that kind of money?

Thankfully, Oracle Policy Automation is here to help answer that question and many others in relation to temporal data. The following function will hopefully illustrate this example:

OPA 12 - Temporal Reasoning Part Two 2

You can probably guess the idea. Working backwards from the current date, when did I last have a value greater than 1500 in the temporal bank balance. Now, if you have been using the same example data as me, this function will currently return a value of uncertain. That’s because none of the data in the debugger at the moment is greater than 1500. But if you add a new Change Point to the temporal bank balance, for example :

OPA 12 - Temporal Reasoning Part Two 3

Then your debugger should provide you with a more definite answer. In my case, you can see that June 14 I had a change to my bank balance and it was 1550. The next available change point is July 1, when the value was 1000. So when did I last have more than 1500 in my temporal bank account? Following the change point data, the last date I had that amount of money was June 30. You might suspect that I spent my money faster than that 🙂 but we can only work with the facts, and the change points are those facts.

It won’t come to you as a surprise that there are many functions in the Function Reference for finding out values, and one of them is described below. It belongs to a series of functions prefixed with Interval.

OPA 12 - Temporal Reasoning Part Two 4

This one, as the goal suggests, helps me find my lowest bank balance in the period between the start of the year and today, based on the information in the change points. It will obviously depend on your data, but you will probably have something like this.

OPA 12 - Temporal Reasoning Part Two 5

In the next post we will continue investigating members of this family of temporal reasoning functions.

Temporal Reasoning in Oracle Policy Automation #1 : Time Travel

Hi There!


This content is accessible only to logged in users of the OPA Hub Website.

To Register takes only 10 seconds and uses LinkedIn for authentication.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.

OPA – Entities Adventures #10 Temporal Reasoning

Temporal Workshop

And so we come to the tenth, and final (for the time being) post in this hopefully useful and entertaining series for learners of Oracle Policy Automation. In this episode we will discuss the concept of Temporal Reasoning and apply it to the Workshop example we have been using since the beginning of the series.

What is this temporal stuff?

To give you a simple example, our Workshop has a variety of elements to it that change over time :-

  • Cars in the Workshop
  • Mechanics
  • Car Storage Cost

And of course, these pieces of data might need to be analysed and calculated over time. This is a common thing in business of course. Generally software tries to handle this by having “data points” – snapshots of data – but usually they are not very good at handling “periods of time” – where you don’t have data for each day or other time period  but you expect to have to calculate as if you did. Say for example you have a person who receives money from the state. They receive it on a weekly basis. We need to calculate from their date of first receipt, until today. So we need to be able to “span the time period” and calculate the figures. And that is pretty cool.

How does it work in Policy Automation? – an example

In Policy Automation, we need first to understand how the data is entered. Let’s focus on the storage costs – cars that are left in the Workshop are charged at a daily rate to the customer, for storage, once they are left more than 3 days. In addition, the storage charge is a percentage of the value of the vehicle. Finally, storage of more than 10 days gets a higher rate.

So let us work up an example. Assume two cars being worked on in the Workshop. One of the them arrives in the Workshop on September 11, the other on September 1. Today is September 17. So how much storage should we charge? To make matters more realistic, we can say that the first ten days are charged at 9% of the car’s residual value, the next ten days at 11%, and beyond that a punitive 15% since the car has really been here too long.

OPA - Daily Cost of Storage Temporal Example

In the above example we introduce some new Attributes (the cost of the car’s storage and the date of the car’s arrival) respectively currency and date types, and the function TemporalBefore().

From the Function Reference we see that TemporalBefore (date) is explained thus:

Returns a Boolean attribute that varies over time and is true before a date and false on and afterwards.

So essentially our cost will be calculated using the car’s residual value * 0.09 for as long as TemporalBefore(AddDays(the date of the car’s arrival, 10)) is TRUE.

There are other versions of this function to handle things like “on or before” or similar calculations for “after” or “on or after” dates.

Visualising the data in the debugger makes it clearer how this is working. Don’t forget to right-click the cost of the car’s storage in the Debugger window and choose Show in Temporal Visualisation.

Now we can see the cost of storage incurred based on the car residual value and the arrival date of the car, according to the different values over time. But perhaps you didn’t see what you were expecting – the actual total cost as of today. So let us introduce this into the mix:-

In the following screenshot, note we have added new “total cost” and “current daily cost” Attributes.

As a demonstration we are using the ValueAt() function to get the current value charged today (according to our table of values).

We are also using the IntervalDailySum(start, end, value) to calculate the total amount payable to date.

OPA - Car Storage Cost Rates and Total Temporal Function Example

Now that we have the total cost of the storage, we can go ahead and work out if the car storage has exceeded the residual value of the car.

And so we come to the end of this 10 part series, designed to give you some more fun examples of working with Entities. For those of you who are reading this after taking the OPA Essentials Class with me, I hope you enjoyed them.

What Next?

For the next series of posts we will be looking at teasing questions that might help you prepare for the certification. After that, get ready for more function examples and fun with Oracle Policy Automation.

Rich@rd

Policy Automation – Jargon Busting – Temporal Reasoning

Temporal Reasoning

Temporal Reasoning in Policy Modelling is the capacity to deal with Change Points and data that varies over time. For those of you who are familiar with the Siebel CRM, a similar concept was introduced to Siebel Public Sector 8.2 called “Effective Dating” for certain components that needed to be configured in this way (for example, the case of a person who changes their name, effective 1/1/2014). They had a name before and they had a name after. So the attribute or field name is the same, the value changes however over time.

To illustrate the point and observe the capabilities of Policy Modelling briefly, create a new Project and call it “TimeTravel”.

In the project, add a New Word Document. As is often the case in these brief examples, for the sake of speed we are skipping over items that we do not need to mention here, specifically some best practices have been sacrificed in the name of speed.

Temporal1

Type the text above and make sure you select “the cash” and click the “Add Attribute” button and create an attribute of type Currency. Do the same for the “the last good day” attribute but make sure you have created it as type Date. The Attribute Editor button will let you review your work.

AttributeEditor

Now Compile the Word Document. So far it would appear that there is nothing very special about our project, save the use of a new Function called WhenLast(date, condition). Now let us complete the exercise. In the Policy Modeller, Build and Debug (without Screens) or just press F5. The usual screen will appear. We will enter some information into the debugger. Double-click “the cash” to enter the value. And proceed in the following fashion:

Temporal2

Click the Change Points button, and proceed to enter a series of Values for different dates. Make sure one of them is over 100, and make the most recent one less than 100. You are providing the raw data that the “WhenLast()” function requires. When did you last have 100 $ (or whatever your regional currency setting is) in your bank account? The last good day is designed to be inferred from the data you are entering.

CashSetup

So in the case above, there are various dates and figures. Now we can see in the debugger :

Temporal Result 1

If we right click “the cash” we can select the “Show in Temporal Visualisation” option, and click the “Temporal Visualisation” tab in the Debugger. Notice the display, and how the initial value entered (77 in the case above) is used to seed the attribute with its initial value, and the other numbers are entered according to their change points. If you remove the 77 from “the cash” Value field, you can choose “uncertain” or “unknown” instead.

Temporal Result 2

Clearly such a simple example cannot do justice to the different Temporal Reasoning functions but where data is presented for analysis with change points, now you know to consult the Temporal Reasoning section of the documentation.