This discussion is archived
6 Replies Latest reply: Jan 1, 2013 2:02 PM by frank.hampshire RSS

Default value for infered attribute

Kunal Sharma Newbie
Currently Being Moderated
Hi All,

Whenever an inferred attribute is to be calculated it sometimes remains unknown for the chance the rules below are not able to define its value. Can we set the value of this inferred attribute to true or false or 0 in case of numeric stating OPA engine that it should never set this attribute to unknown it will be either default value or the value calculated from the rules.

Thanks
Kunal Sharma
  • 1. Re: Default value for infered attribute
    Ben Rogers Journeyer
    Currently Being Moderated
    Hi Kunal,
    The quickest way of doing this is to create another intermediate attribute and use te operator "currently known". You can then create a rule table in word to achieve the functionality you would like.


    For example:
    the person's income = the person's employment income + the person's capital income

    Lets say you wanted to default this to 0 if it was unknown.
    Create an intermediate :

    the person's income before default check = the person's employment income + the person's capital income

    Then create a rule table

    the person's income
    ---------------------
    the person's income before default check | the person's income before default check is currently known
    Otherwise | 0

    This will initially set the person's income to 0 in the debugger and should set it to the proper value according to the rule once it becomes known.

    However this generally isn't the best thing to do in these situations as it could lead to dangerous assumptions further on in the rulebase and actually hide the fact that errors have occurred or that the rulebase is missing data.

    Unknown can only be introduced from missing base attributes; we have a set of rules that check to make sure all of them have been populated, and then use uncertain in the rules to highlight when data is missing. As long as you have accounted for this somehow in your rulebase then the solution above should answer your question.
    Check the OPA help files and search for "currently known" for full information about this operator.

    Feel free to post back with any more questions on this.
    Cheers,
    Ben
  • 2. Re: Default value for infered attribute
    Kunal Sharma Newbie
    Currently Being Moderated
    Hi Ben,

    Thanks for the update I know this is one way of doing this but personally I feel this is bad code writing as the rule reader it becomes difficult to understand such rules. This I can say for sure as I have been developing and working on OPA projects for one of the software company and it takes me myself a lot of time the problems occurring due to unknown. most of the things I debug is just due to unknown. and writing such a rule in several places makes it hard for me to understand rules I don't know How someone else will be able to understand it.

    Thanks,
    Kunal Sharma
  • 3. Re: Default value for infered attribute
    Kunal Sharma Newbie
    Currently Being Moderated
    Hi Ben,

    I understand the fact stating the

    the person's income = the person's employment income + the person's capital income

    the person's income to be 0 when unknown is incorrect but the fact is when I am doing this I might also want the person's employment income and the person's capital income to be set to 0 instead of unknown to do this I need to write a similar rule twice as you have shown however this could have been better achived If i would have some keyword or may be if I could have stated this in properties file that these three should all be kept to 0. But not giving such a capability creates a larger problem than stating that it's not recommended as developer knows best or what is good for him keeping a choice whether he wants to use this featue or not is the best policy. as stated you maay not know what an developer requires

    Regards
    Kunal Sharma
  • 4. Re: Default value for infered attribute
    ChaseVoid Newbie
    Currently Being Moderated
    Can we not use Rule Fragment to set priority to rules?

    eg:
    +rule_property[fragment:1]+
    the person's income = 0
    the person's employment income is currently unknown or
    the person's capital income is currently unknown

    +rule_property[fragment:2]+
    the person's income = the person's employment income + the person's capital income
  • 5. Re: Default value for infered attribute
    Kunal Sharma Newbie
    Currently Being Moderated
    Hi Chase,

    Thanks for the reply Which version of OPM supports defining rule property?

    Thanks,
    Kunal Sharma
    < telephone number removed by moderator >
    (that's bad form - you'll get spam calls for all Eternity)
  • 6. Re: Default value for infered attribute
    frank.hampshire Expert
    Currently Being Moderated
    Rule fragments have been in OPA since at least version 10.2. I'm not sure what version they were first introduced in.

Legend

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