Category: Functions

Whats New in Oracle Policy Automation November 2017 #2

Whats New in Oracle Policy Automation November 2017 #2

As in the previous post in this series, the OPA Hub Website is concentrating on the new features, or “Whats New in Oracle Policy Automation November 2017” to be more precise. This is the second in the series. In this post we will explore two different functionalities that have been improved. Firstly, we have all probably at some point found ourselves creating attributes, and thinking about default values : setting them on the different screens of our Interview and so on. We probably also have then spent time creating Rule Tables to handle what happens when we have to default values based on the certainty of other information.

Default Values in Web Service inbound attributes

These days, managing default values in a Web Service environment just got easier. Consider the following simple example. The insurance premium is inbound in a data Connection. It is copied into an attribute called the baseline annual premium. If the inbound value is uncertain, then the default value (in this case £500) will be used. If the inbound value is different to £500, then that value will be used instead. If the inbound value is unknown, then the value of the baseline annual premium will be unknown.

Whats New in Oracle Policy Automation November 2017

Set True and False values in one shot

Another feature from the Whats New in Oracle Policy Automation November 2017 collection : in the same vein, you can now use the If function to set values for a true or false result of a condition, like you would for example in Microsoft Excel formulae. Think of it as “If(expression, value if true, value if false)”.

Whats New in Oracle Policy Automation November 2017

If the baseline annual premium is greater than 500, then the percentage of legal fees will be 100. Otherwise it will be 50. The documentation refers to “condition” but in different places it refers to Boolean attributes or conditions. In any case, it seems to work with both.

Both of these will provide decent shortcuts to existing workflow for developers looking to create cleaner rules. You can find the details in the online documentation here. Catch up with more “Whats New in Oracle Policy Automation November 2017” in the upcoming third post, where we will look at cool new features in the Interview.

PS : Note that my example assumes a Project using the English United Kingdom regional settings.

OPA – Entities Adventures #10 Temporal Reasoning

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.

[vc_single_image image=”” img_size=”full” alignment=”center”]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

OPA – Entities Adventures #8 IsMemberOf()

[vc_row][vc_column][vc_column_text]

More Functions

Policy Automation has a vast array of Functions that can be called into service at one time or another. Many of them are very specific and we will try and discover a few more of them before the end of this series.

But we can take this opportunity to share with you a couple of “cheatsheets” that we give out sometimes in the Policy Automation training courses. These are PDF files with examples of lots of useful Functions from Oracle Policy Automation.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_text_separator title=”If you get Error 500 just click the Back button and try again”][/vc_column][/vc_row][vc_row][vc_column width=”1/2″][vc_column_text]

[stamper_download_button_for_wp_user file_url=”http://www.theopahub.com/mainfiles/OPAL/STRING/TextFunctions.pdf” button_text=”Download Text Functions Now”]

[/vc_column_text][/vc_column][vc_column width=”1/2″][vc_column_text]

[stamper_download_button_for_wp_user file_url=”http://www.theopahub.com/mainfiles/OPAL/DATETIME/DateAndTime.pdf” button_text=”Download Date Time Functions Now”]

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_separator][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

The Workshop

In this episode we will consider another key function

1) The IsMemberOf Function

This function can be useful in determining membership of a Reference Relationship. It is called “inferred membership”

To begin let us examine the scenario for the IsMemberOf function.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

IsMemberOf

The IsMemberOf function (or “is a member of”) can be used in two different ways. Firstly as a conclusion, but also as a condition. Let us take a look at them both in a practical example.

Back at our Workshop we want to find out which cars are Italian, since they may require expert care and attention. We might be tempted to write something like this almost straight away, so simple this function sounds.

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_single_image image=”9090″ img_size=”large” alignment=”center”][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

Hopefully you can see there is a problem. The New Attribute dialog box which appears when you click Compile is showing two boolean Attributes. That does not sound like what we need to make this work. In fact we need firstly to create our “Italian cars” – specifically we need a Relationship to hold the cars we are looking for.

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_single_image image=”9091″ img_size=”large” alignment=”center”][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

When we compile our simple rule after this, there is a difference:-

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_single_image image=”9092″ img_size=”large” alignment=”center”][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

And likewise, our Word document shows that the IsMemberOf function is now correctly included in our conclusion.

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_single_image image=”9093″ img_size=”large” alignment=”center”][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

If we build and debug our rulebase, and populate the new Boolean Attribute “The car is serviced weekly” for each car in the workshop, we will be able to see the results as shown below.

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_single_image image=”9094″ img_size=”large” alignment=”center”][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

Notice the yellow icon and the nature of the relationship – it is inferred and cannot be directly changed. Only by editing the Boolean Attribute can we change the members of the “Italian Cars”.

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

IsMemberOf as a Condition

The same function can also be used as a Condition. For example :

The syntax is straightforward as you can see.

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_single_image image=”9101″ img_size=”large” alignment=”center”][/vc_column][/vc_row][vc_row][vc_column][vc_column_text]

Conclusion

The IsMemberOf function gives us flexibility to create inferred relationships.[/vc_column_text][/vc_column][/vc_row]

OPA – Entities Adventures #6 Cross Entity Reasoning

Cross-Entity Reasoning

Once again we return to the Cars and Mechanics in the mythical Workshop. The first part of this post will review the French version of the work done in the previous episode, and then we will undertake some cross-entity reasoning using the various functions at our disposal. Catch up with the rest of the series (12345)

The French version looks like this in the Web Determination window. First off, the basic structure is exactly the same and there are no challenges to report.

OPA - French Workshop

Eagle-eyed viewers will notice there is a problem (that we raised earlier in the context of Gender but now is as good a time as any) concerning the title of the page. In fact, despite the Project being French Language and French Region, all the labels are in English (“Data Review”, “Assessment Summary” etc.). You could be forgiven for thinking these came from the “Appearances Property File” in your Release folder:

OPA - Messages FR Properties

But no. The titles that I just mentioned are generated when you add a Screens File to your Project. So even though we have a French Project with French as the Rule Language, we get English titles!

OPA - Titles in English

Common Trap Number #10 – Screen Titles in the wrong language

Irritatingly enough the way to fix this (if it can really be called fixing) is to switch the Language of Policy Modelling to French before you start, in which case when you add a Screens File you will see valid Titles:

OPA - French Screens Titles

Then you can switch the editing language back to English and at least you have the right titles in your Screens File. (Tools > Options > UI Language). I know it sounds silly but there are many occasions when you want to create a Project in another language but you don’t want Policy Modelling User Interface to be in that Language.

Switching back to the English version of our Project, we can now get into some more Functions, specifically cross-Entity functions. These functions are designed to cope with the need to cross from Car to Mechanic in a rule. For example

Consider the fact that Mechanics exist in several types – Expert, Confirmed and Novice. We want to write rules that say

The Car will be ready on time if the Car’s Mechanic is an Expert.

The Workshop is running efficiently if at least 2 cars are being repaired by Experts

The Car, the Mechanic – these are our Entities. The Workshop, our “singleton parent Entity” is the standard Global parent Entiity proviided by Policy Automation.

Let’s look at the Function Reference for the For function that will be useful in our case. We are able to reason cross-Entity, as long as the Relationship type is correct (and between Car and Mechanic it is Many-to-One), and there is only one Condition (the Mechanic is an Expert.

Assuming you take a moment to create an Attribute “The Mechanic’s level” of type Text, then you could examine the following from the Function Reference and get writing.

OPA - For Function Reference

As is often the case, there are long and short versions. There is nothing stopping you using one, or other of these versions as you prefer, interchangeably. But look closely and you will see the definition of the Function has some differences. The short or “terse” version “For (relationship, expression)” looks like this when we write it out: The following should compile.

OPA - For Terse Version

 

Common Trap #11 Assuming All Versions of Functions have the same syntax

But suppose you decided to write using the Long form, “in the case of“. The Function Reference gives a slightly different explanation for that version, if you look closely. It says “in the case of relationship, attribute”. Which is not the same thing as the previous example, And indeed, the example below does not compile.

OPA - For Long Version Error

 

The following example does however, Notice how in this example we have changed the “level” to be a Boolean attribute rather than a Text attribute. It would appear from the Function Reference that the long version is only possible with a Boolean. And that may mean you end up creating an intermediate rule like this:

OPA - For Function Intermediate RuleAnd that may be something you do not need or wish to do, so you decide to use the terse version. But before you give up on the long version, you see there is a third option in the Function Reference “<val>, in the case of <relationship>”. Interestingy, the “<val>” acronym appears only once on the entire list of Functions. And it is far from clear what it actually means. So best to avoid that.

Next time, we will continue and use some other Functions!

 

Policy Automation – Beginner’s Traps Video

Policy Automation – Beginner Video

To accompany the previous post about errors and confusion during the first phases of writing rules and getting used to the unique properties of Policy Modelling, to provide a quick way to remember the biggest traps and the areas to consider we have created a small video for your viewing pleasure. The idea is simply to remind new users of the basics of writing rules, and the commonest traps they will encounter.  You can view it on YouTube here.

Getting more help

Of course there are lots of excellent resources on the Oracle Web Site, not least the following (please be aware that these links will probably not always be up to date, in which case you are better off just linking to the home page for OPA documentation.

Browsing the Content on this Site

For more help, we recommend reading through the various series of blog posts on this site to get started, and to help you get some starting ideas you will find a filterable list of articles below. In addition you can use the Search feature on this and every page to look for things that might help.

[vc_masonry_grid post_type=”post” max_items=”10″ show_filter=”yes” grid_id=”vc_gid:1440751293963-677f69ed-6e4f-9″ filter_source=”category” exclude_filter=”609, 305, 187, 602, 192, 196, 189, 606, 98, 107, 157, 251, 599, 252, 601″]

Worldwide
Logo by Southpaw Projects LLC