Inferred Relationship examples

Hi,
1. I want to understand the use of Inferred relation with a proper example. I want to understand how exactly to write rules using inferred relationship. Please provide with a simple as well as complex use of inferred relationship.. that will help me understand better.
2. Can we have inferred relationship between any two entities or it is necessary that both the entity be same...
3. If both entities are different then why use inferred relationship? What is the benefit?How the attributes can be accessed in such a case?
Please provide an example on this too..
thanks,
Rajan

There are numerous examples and explanations between the documentation, examples which install with the product and on OTN (http://www.oracle.com/technetwork/apps-tech/policy-automation/documentation/index.html). A couple of good starting points are the following topics in the OPM User's Guide (10.4.2): "Define a data model", "Define a relationship" and "Write rules that infer relationships and entities" - it is important to understand the different components of a policy model (also covered in the Oracle University courses on Oracle Policy Modeling).
To quickly answer a few of your questions:
- Attributes are associated with an entity not a relationship. Relationships are defined as being between two entities.
- Inferred relationships can be between any two entities - the entities do not need to be the same.
- Inferred relationships are used so that relationships can be "inferred" by rules - i.e. if rules dictate when two entities should be related then inferred relationships are necessary.
For example, determining if a person is considered a member of a household or if a product should be recommended to a person or determining the legal dependents of a person, or determining the preferred replacement products to offer under warranty replacement policies. In other words, there are countless uses and needs for inferred relationships.

Similar Messages

  • How to provide inferred relationship as an input in the SOAP UI request.

    In a single OPA project, I have two separate requests.
    Request 1: All the base INPUTS are provided and an inferred relation is an OUTPUT of the request. The outputs of this request (attributes as well as relationships) is stored in the database. So that it can be retrieved and be used as an Input in some other request.
    Request 2: The inferred relation from Request 1 is retrieved from the database and is provided as INPUT and then the respective OUTPUTS should be derived.
    But when I try hitting the Request 2 (which uses INFERRED RELATIONSHIP as input) it throws me an Error saying "Inferred relationship cannot be set by the user".
    Is there any possible way where we can use the inferred relationship as an input in the request?
    Thanks
    Snehal

    Hi SnehalS,
    Two approaches:
    1. If you keep your inferred relationship in Request 2 you should also provide the input data; which is what you apparently want to avoid.
    2. What I mean is probably best explained in the following example:
    Request 1:
    INPUT: 5 Persons (the person) with their age (the person's age), in global via the relationship "the person's"
    the rulebase identifies the children (age < 18) and adds them to the inferred relationship in global (the identified children)
    OUTPUT: the inferred relationship (the children), and all other output data
    Change the Request to use "the children" instead of "the identified children"
    Request 2: n Persons (the person) with their age (the person's age) in global via the relationship "the children"
    the rulebase does its determination
    OUTPUT: as defined for request 2
    Hope this Helps,
    Darko

  • Determinations Engine and inferred relationships

    I have a rulebase which is working fine through the determinations server.
    However, when I try to use the determinations engine directly, it doesn't seem to deal with inferred relationships.
    I'm using 10.2, so the relaionships seem to be all present and correct when i debug in Visual Studio.
    Can anyone suggest what I might need to do?
    I had a similar problem with Instance functions, which was fixed by setting MarkContainmentComplete, so i think i'm just missing some similar setting on the relationships.
    Thanks.

    The answer is:
    My data structure is
    global
    ----->child
    ---------->grandchild
    I was setting containment complete on each of the children, and since that fixed the instance count, and since I'm only using the inferred relationship to get a subset of grandchildren, I thought that would do the job.
    However, it seems that the inferred relationship is evaluated on all grandchildren, regardless of their parent, so once I set containment complete on the global entity as well, it worked fine.

  • Return value of inferred entity instance from relationship in SOAP Determinations

    Hey,
    I had an original thread open which indicates the problem I was trying to solve (Multiple Conclusion based on input values ). My rule base now behaves as expected and I can test it in the debugger as expected, only now I can't get the actual identifying values back I want using the determinations web service.
    I get a whole bunch of inferred entity instances back from an inferred relationship the same as the situation/screen shot at the bottom of the "Investigate an inferred relationship" page on the Oracle Policy Automation Cloud Service User Guide, but in my SOAP response I only get the instances with hashed IDs. I want the actual identifying value of the entity.
    e.g. Currently get this:
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i18n="http://www.w3.org/2005/09/ws-i18n" xmlns:typ="http://oracle.com/determinations/server/11.0/rulebase/assess/types">
       <SOAP-ENV:Header>
          <i18n:international>
             <i18n:locale>en_GB</i18n:locale>
             <i18n:tz>GMT-0500</i18n:tz>
          </i18n:international>
       </SOAP-ENV:Header>
       <SOAP-ENV:Body>
          <typ:assess-response>
             <typ:global-instance>
                <typ:attribute id="course_code" type="text">
                   <typ:text-val>AHPY</typ:text-val>
                </typ:attribute>
                <typ:entity id="the_supplementary_documents" inferred="true">
                   <typ:instance id="0x608c2dc220e15d8c"></typ:instance>
                   <typ:instance id="0x5b7e2d02e8780325"></typ:instance>
                </typ:entity>
                <typ:entity id="the_informational_documents" inferred="true">
                   <typ:instance id="0x19387621439a43c7"></typ:instance>
                </typ:entity>
             </typ:global-instance>
          </typ:assess-response>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    But I want something like below and I'm having a lot of trouble figuring out how to actually do this. Also is there anywhere that defines the meaning of errors you get from OPA? I have tried to modify my rulebase and I got a few OPA-EXXXXX errors but apart from the description you get in OPM, I can't find anywhere that gives more detail on these and explains what they mean/how to fix it.
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i18n="http://www.w3.org/2005/09/ws-i18n" xmlns:typ="http://oracle.com/determinations/server/11.0/rulebase/assess/types">
       <SOAP-ENV:Header>
          <i18n:international>
             <i18n:locale>en_GB</i18n:locale>
             <i18n:tz>GMT-0500</i18n:tz>
          </i18n:international>
       </SOAP-ENV:Header>
       <SOAP-ENV:Body>
          <typ:assess-response>
             <typ:global-instance>
                <typ:attribute id="course_code" type="text">
                   <typ:text-val>AHPY</typ:text-val>
                </typ:attribute>
                <typ:entity id="the_supplementary_documents" inferred="true">
                   <typ:instance id="http://mydomain.com/mydocument.pdf">
                   </typ:instance>
                   <typ:instance id="http://mydomain.com/mydocument.pdf"></typ:instance>
                </typ:entity>
                <typ:entity id="the_informational_documents" inferred="true">
                   <typ:instance id="http://mydomain.com/mydocument.pdf"></typ:instance>
                </typ:entity>
             </typ:global-instance>
          </typ:assess-response>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    I managed to get this working by referring to this thread: Inferred Entity Instances IDs in output response
    I had tried something similar but not quite the same. In the end my request looked something like this:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://oracle.com/determinations/server/11.0/rulebase/assess/types">
       <soapenv:Header/>
       <soapenv:Body>
          <typ:assess-request>
             <typ:config>
               <typ:outcome>
              <typ:entity id="the_supplementary_documents">
                <typ:attribute-outcome id="supplementary_documents" outcome-style="value-only"/>
              </typ:entity>
              <typ:entity id="the_informational_documents">
                <typ:attribute-outcome id="informational_documents" outcome-style="value-only"/>
              </typ:entity>
           </typ:outcome>
             </typ:config>
             <typ:global-instance>
                <typ:attribute id="course_code">
                <typ:text-val>AHPY</typ:text-val>
       </typ:attribute>
              </typ:global-instance>
          </typ:assess-request>
       </soapenv:Body>
    </soapenv:Envelope>

  • Clarify a Limitation for Inferred Entity Instances

    Hi,
    Under the section "Write rules that infer relationships and entities" in the User Guide there is the
    Notes /Limitations
    1) Combining manually created instances with inferred instances is not allowed.
    2) Combining inferred entity instances with temporal values is not supported.
    3) Only a single attribute of the entity instance can be inferred as a part of the entity rule. For example, the type of benefit ("unemployment benefit") can be set but the amount of the benefit would have to be set via a separate rule.
    4) Inferred entity instances may not contain base level attributes.
    5) A relationship that participates in an inferred entity instance rule is considered to be an inferred relationship. This means that an inferred relationship rule cannot be used to prove the same relationship used in an inferred entity instance rule.
    Can number 4 be explained in a little more detail?
    Thanks

    I'm not sure I understand the question so I'm going to guess what you're asking by suggesting a business scenario and talk about how that would work. It is always much easier to talk about a specific business requirement you have rather than product features in general - so if you have a specific requirement I strongly recommend sharing it as you'll get better quality help.
    Anyway, if we keep our existing example of an inferred entity "the product" (has attributes: the name of the product, the price of the product). Say we want to know want the price of the most expensive product you have selected (a concept which would be represented by an attribute at the global level).
    You can do that. The rules to do that are just the same as the rules you'd use if instead of inferring the products and prices you instead asked the user to provide them (ie instancemaximum across a relationship). I'd send an example showing these rules - but it's not possible to attach files to this forum. You use inferred entities in the rest of your rules as if they had been input by a user - there's no difference. The key difference between an inferred entity and a non-inferred entity is that you can't collect more information about it (ie it can't have any base level attributes).
    You can use any attribute in a rule so long as the usage of the attribute matches the entity level of the conclusion. ie You couldn't use "the price of the product" directly in a rule with a conclusion at the global level - because you revert to the problem of "the price of which product?".
    On the off chance that this is somehow a "programmer" question (ie you're trying to understand how OPA works by treating it the same as another method for creating programs, for example a programming language like Java) - attributes in OPA don't have a concept of "private" and "public". If I tried to put OPA In those terms (and it's a stretch because OPA is not Java) - in OPA: everything is public (declare once use everywhere). An entity model in OPA is different thing to a class hierarchy.

  • 1:1 Self Relationship is hard to model.  Need advice.

    Here is a quick example of the problem using boats...
    Create an entity "the boat".
    Create a 1:1 relationship of "the boat" to "the boat". Call both the forward and reverse text "the other boat"
    Here is the original text from the rules document: When boats are on opposite tacks, a port-tack boat shall keep clear of a starboard-tack boat.
    Here is the modeled rule:
    the boat is required to keep clear if
         the boat is on a port tack and
         for(the other boat, the boat is on a starboard tack)
    When you debug this and create 2 boats, you will see that each boat actually has 2 relationships. The rule doesn't actually work intuitively. Both relationships must be set.
    How do people solve this problem?

    From your description, I think what you're after is cross entity reasoning.
    As a start, have a look at the Entity and Relationship Functions, particularly the example rule about twins (search for the word "twin" on the page): http://download.oracle.com/docs/html/E24270_01/Content/Reference/Rule%20syntax%20reference/Entity_and_relationship_functions.htm
    In the twin example, there are multiple instances of 'the child', and for each instance of 'the child' the rule works out whether or not it is a twin by comparing one child's date of birth with another child's date of birth. Obviously this isn't exactly the logic you're after, but you should get some ideas to explore if you look into the cross entity reasoning functionality and inferred relationships logic.
    Cheers,
    Jasmine

  • Temporal Relationships

    I am a huge fan of the new advanced relationships and reasoning that are possible in 10.2. I am literally struggling to think up examples of things that cannot be modelled.
    But I can't see any place to enter a temporal element to a relationship. Am I right to assume that they are not supported?
    For example, if I have 2 entites, the person and the country, and a many-to-one relationship between them called the person's country of residence, then I would like to represent a person moving between countries as -
    - the death of one relationship instance at a point in time, and
    - the birth of another relationship instance at the same point in time,
    but there doesn't seem to be any place to add changepoints on the relationships.
    When I try to trick OPA into a temporal relationship by inferring the relationship from a temporal attribute, it has an error in the debugger saying "Relationship targets can only be true, false, uncertain or unknown." I agree these are the only sensible values for relationships, but I can think of many real life applications of temporal relationships, i.e. changes to them over time, like changes in family membership or employment status.
    Can someone confirm the status of temporal relationships?

    I can confirm that, at the moment, we don't support temporal relationships.
    * You cannot enter a temporal targets for standard static relationships.
    * You cannot infer relationships in such a way that the relationship would be temporal (change over time).

  • How to map CRM BP relationship and R/3 customer partner funnction

    Hello !
    Please, I need the following actions:
    1) during BP initial download from R/3 to CRM, a specific partner function should be mapped by a CRM relationship (Example: in R/3 master data, customer X is the Payer of customer Y. I'd like this partner function "Payer" should be mapped by BP relationship "Payer" in CRM);
    2) a particular relationship between BPs in CRM should be mapped by  the corresponding R/3 partner function during upload from CRM to R/3.
    Please, can anyone help me ?
    Thank you.
    Kind regards.
    Elena

    Hi, Venkat.
    Thank you for your answer, but the question is: is it possible to define the correspondece between R/3 partner function and CRM relationship ? I know transaction PIDE: it allows to map R/3 accont group and CRM roles.
    Thank you very much.
    Bye.
    Elena

  • Deploying CMP Relationships

    Hi I wonder if someone could help me please. Im trying to deploy an EJB CMP Relationship example. In fact the one from Enterprise JavaBeans by R. Monson-Haefel Example 6.3. Now I realise there was some code missing to do with throwing Exceptions, which I've added - so its not the pure example.
    Right so I'm using j2eesdk 1.3.1 along with Cloudscape as the DB and the standard J2ee deployment tool.
    My first problem is that when I try to setup the relationship between the Customer & the Address I only get the Customer Bean in the 'Edit Relationship' Dialogue Box - not the Address as well. Yep I've deployed the Address EJB.
    Then when I validate the EJB I get the following logged to the Resaults file
         Test Name : tests.ejb.entity.TransactionDemarcationHomeInterface
         Test Assertion : Entity bean container transaction demarcation for methods of home interface test
         Test Description : For [ CustomerBean ]
    Error: Transaction attributes must be specified for the methods defined in the home interface [ com.titan.customer.CustomerHomeRemote ]. Method [ create ] has no transaction attribute defined within this bean [ CustomerBean ].
    I've set the transaction attributes to 'Requires New' but it doesn't seem to be saving then to the Deployment file.
    Thanks & Regards
    Nick

    Oops, I've fixed the problem by re-reading the manuals yet again. I missed the line that said that both of the EJB needed to be in the SAME jar file not just the same package.
    Nick

  • One to many relationship leads to recursion?

    Hi,
    I've created a web services function which returns an object retrieved from a database using the persistence api (the class was generated by the Netbeans 5.5 "Entity Class from Database" feature.
    I can successfully return an object which has no foreign keys. However, when I try to retrieve an entity which is on either side of a 1:N relationship, I receive a stackOverflowError.
    Here's my sample schema (I'm using Derby bundled with SJAS 9 for testing)
    create table Address (
       Id int not null,
       StreetName varchar(255),
       City varchar(255),
       PostalCode varchar(255),
       Party int,
       primary key (Id)
    create table Party (
       Id int,
       Name varchar(255),
       primary key(Id)
    alter table Address add constraint foreign key (Party) references Party;So as you can see, one Party might have many addresses.
    I can retrieve either an Address or Party from the database using something like:
    em.createNamedQuery("Party.findById")
       .setParameter("id", 1)
       .getSingleResult();When I try to return it, I get a stackOverflowError in the server log. I'm using the default Toplink provider so enabling full logging on this, I can see the SQL.
    When retrieving an address, it selects all of the address fields and correctly binds the supplied Id value. It then performs a select on the Party table using the Address.Party value. This in turn causes it to attempt to retrieve an Address. After three queries, the error is thrown.
    I can't see why the above schema should cause this problem. Where an Address is requested, I would expect it to retrieve the address fields, including the value of the Party field but not the Party object itself. On the other hand. when a Party is retrieved, I would expect it to recurse through and return a collection of Address objects.
    Have I misunderstood this or am I missing some fundamental point about JAX-WS?
    Thanks for your help,
    -Phil

    You have to set both sides of the relations...
    for example to do this in a more seamless manner:
    public UserProfile
         public void addLog (UserActivityLog activity)
              logs.add (activity);
              if (!equals (activity.getUserProfile ()))
                   activity.setUserProfile (this);
    Now this is the most primitive of ways to maintain two sided relations.
    There are a lot of other patterns to get around this.
    If you want to set the UserActivityLog to a specific UserProfile without
    having a firm reference to ther UserProfile, you should get the object
    from the database/persistenceManager... as you are using application
    identity, you can do something like pm.getObjectById.
    JDO does not do magic references. If you set something to null, it will
    remain null until you set it.
    Srini wrote:
    Hi Guys
    I am trying to create a one to many relationship between 2 JDOs.
    UserProfile - User JDO having user info
    UserActivityLog - JDO having user log info
    UserProfile -- UserActivityLog
    1 many
    UserProfile - has a collection of UserActivityLog objects
    UserActivityLog - has a reference to UserProfile
    Qn 1:
    I created a UserProfile along with a collection of 2 UserActivityLog
    objects.
    Navigation:
    Now given a UserProfile object,i am able to get the UserActivityLog objects.
    But given a UserActivityLog object ,i get a NULL UserProfile object.
    Issues:
    Why this is happening???Do i need to set the reference for "UserProfile" in
    UserActivityLog before inserting???
    If so,then how do i add a UserActivityLog to an existing
    UserProfile???cos,if i create a UserActivityLog with reference to
    UserProfile ,then it will throw a Duplicate Key violation for UserProfile as
    it is already persisted in DB.
    It will be great if you can direct me to some one to many relationship
    examples already implemented.
    Thanks
    Srini
    Stephen Kim
    [email protected]
    SolarMetric, Inc.
    http://www.solarmetric.com

  • Need advise on how to model this rule

    Hi,
    I got stuck in modelling some rule. I will try to paint the picture using some example:
    Assume the following entities (and relations)
    the child (the children)
         the toy (the childs toys)
    the cupboard (the cupboards)
    I would like to construct a boolean saying that all children can store their most favorite toy in the best cupboard
    What I have tried so far:
    I have inferred a relation for the best cupboard.
    I also inferred a relation for the most favorite toy of a child.
    Now I get stuck. What should be the way to do this? Is it possible? I have the feeling I am missing something. It might be versy simple, but I am relative new to OPA.
    Any help is very much appreciated.
    Cheers,
    Han Joosten

    Hi Han,
    When I first had a go at this, I had several inferred relationships and it got complicated, so I tried to simplify it down to minimal inferred relationships. Here's what I did...
    Entities and Relationships
    Containment Relationships
    Global --> one-to-many --> the child (relationship text: the children)
    the child --> one-to-many --> the child's toy (relationship text: the child's toys; reverse text: the toy of the child)
    Global --> one-to-many --> the cupboard (relationship text: the cupboards)
    Inferred Relationships
    the cupboard --> many-to-many --> the child's toy (relationship text: the cupboard's toys)
    Note: Before you can write rules associating two different entities, you need to set up a relationship between them in the Properties file.
    Rules
    Determine the best cupboard...
    I made up a number attribute 'the cupboard's priority'. The best cupboard is the one with the lowest priority number, i.e. the cupboard with priority 1 beats the cupboard with priority 2.
    the cupboard is the best cupboard if
    the cupboard's priority = the priority number of the top cupboard
    the priority number of the top cupboard = InstanceMinimum(the cupboards, the cupboard's priority)
    If you wanted to reverse the priority logic so that the highest number is the 'best', use InstanceMaximum instead.
    Determine the favourite toy...
    Similar approach with the toys:
    the child's toy is the favourite toy if
    the child's toy's priority = the priority number of the child's top toy
    the priority number of the child's top toy = InstanceMinimum(the child's toys, the child's toy's priority)
    Put the favourite toy of each child in the best cupboard...
    Write a membership rule to associate the child's toys and the cupboards:
    the child's toy is a member of the cupboard's toys if
    the cupboard is the best cupboard and
    ForScope(the toy of the child)
    the child's toy is the favourite toy
    Procedural rules to tie it all together...
    The rules above do all the tricky logic work. If you want a Global level rule which ties it all together, you could add procedural rules, e.g.
    the appropriate cupboard has been determined for all the favourite toys if
    ForAll(the children, the child's favourite toy has been determined) and
    ForAll(the cupboards, it is known whether or not the cupboard is the best cupboard)
    the child's favourite toy has been determined if
    ForAll(the child's toys, it is known whether or not the child's toy is the favourite toy)
    Test case
    I tried the following test scenario, which worked as expected.
    Inputs
    Child: Bart
    Toys: Krusty Doll (priority 1), Television (priority 2)
    Child: Lisa
    Toys: Saxophone (priority 1), Malibu Stacy (priority 2)
    Cupboard: Cupboard A (priority 1)
    Cupboard: Cupboard B (priority 2)
    Results
    Cupboard A is the best cupboard
    Instances of 'the child's toy' associated with Cupboard A: Krusty Doll, Saxophone
    Cupboard B is not the best cupboard
    No instances of 'the child's toy' associated with Cupboard B.
    Further comments
    If each child can have multiple 'favourite' toys (all of which can go in the best cupboard), then make 'the child's toy is the favourite toy' a base level attribute. Any toy where 'the child's toy is the favourite toy'=true will be associated with the best cupboard, i.e. Cupboard A in the scenario above.
    Depending on what else you need to do, it may be worth creating an inferred relationship for 'the child's favourite toys', e.g.
    the child's toy is a member of the child's favourite toys if
    IsMemberOf(the child's toy, the child's toys) and
    the child's toy is the favourite toy
    Cheers,
    Jasmine

  • Can Entites be sorted

    Hi All,
    Just wondering if this can be done in Entities
    Assume I have Child as an Entity, with attribute:
    Name {string}
    DOB {number}
    Pocket Money Allowance {number} Also have a Global attribute Parents Budget
            Parent_Budget {number} Set to 100 Now i want the interview to ask Child Name, DOB. but then I want the entities to be sorted by DOB and then each of the Child Pocket Money Allowance incremented by 50 from my Parent_Budget.
    The idea of the sorting being if I had 3 children the youngest of the 3 wouldnt recieve any more pocket money.
    Is this achievable with OPA?
    Hope that made sense.

    Hi user9015745,
    I think you can do this with OPA. However, I think it gets quite messy if the ranking for each child is not unique. By this I mean if you rank the 3 kids by date of birth, and they are triplets, then how should the $100 get distributed?
    Leaving the twins, triplets, quadruplets, etc. issue aside, and imagining that for now each child has a 'priority ranking' which you are providing as a base input, then here's how you could tackle this...
    Entity setup*
    One-to-many containment relationship
    Global --> the child
    Relationship text: the children
    Inferred relationship
    the child --> the child
    Relationship text: the high priority children
    Rules*
    the child (the other child) is a member of the higher priority children if
    the other child's priority < the child's priority
    the money available to allocate to the child = the budget of the parents - InstanceSum(the higher priority children, the child's maximum amount of pocket money)
    the money to allocate to the child = Minimum(the child's maximum amount of pocket money, the money available to allocate to the child)
    At runtime, provide as an input 1, 2, 3 for "the child's priority', and you'll see the allocation of fund cascade down from the top priority child until the funds are exhausted. So if the parents have $100 to allocate, the child with priority 1 gets $50, as does the priority 2 child, but the priority 3 child gets nothing because there's no money left in the bucket.
    Note that "the child's maximum amount of pocket money" is at the child entity level in these rules. This means you can allocate a different maximum for each child. For example, you could say that priority 1 child's maximum is $60, priority 2 child's maximum is $50. So if the parent's budget is $100, then the priority 1 child gets $60, priority 2 child gets $40 as that's all that is left, and priority 3 child obviously gets nothing. If the cap for each child was identical, then you could make that attribute Global.
    I'm guessing this child pocket money example is just a hypothetical example of your real life customer scenario, but hopefully the example I've described above is helpful.
    Cheers,
    Jasmine

  • Determine the number of days in a False period in a Temporal Boolean

    Hi all,
    I need to determiine the number of days based on a condition that lies on the gaps between the periods.
    My input consists of multiple periods. The length of the gap is the condition to determine the start date for summation. However, there can be multimple gaps between my instances that satisfy this condition and I need the last one that satisfies it.
    For example:
    period 1: 1-1-1990 until 31-12-1992
    period 2: 1-1-1994 until 31-12-1996
    period 3: 1-1-1998 until 31-12-1999
    period 4: 1-6-2000 until 31-12-2009
    The condition for the start date is the last gap greater than 1 year. In this example, the start date should be the start date of period 3: 1-1-1998, because this is the period after the last gap >= 1 year. Period 2 also has a previous gap of >= 1 year, but this period should NOT be selected.
    My first idea was to use a TBR function: to determine relevant periods (based on the gaps before and after), calculate the amount of days per relevant period and add those up. However, if I want to do that I need to calculate the number of days in the gaps and I don't see how to do that, since I cannot determine a day difference across periods (end date period 1 until start date period 2).
    Any help/ other solution ideas?
    Kind regards, Els

    This was an interesting puzzle which you can solve from a couple of different angles.
    Firstly, you can use inferred relationships to infer a relationship "the following periods" (ie. the periods that follow the current one). My rules looked like this:
    the period (the other period) is a member of the following periods if
       the other period start date > the period start date
    the period’s next start date = InstanceMinimum(the following periods, the period start date)From here it should be easy to see if there was a gap of more than a year, and find the most recent period after a year-long gap. Of course you need to deal with the situation of the last period, when there is no 'next' period, presumably you would use the date of assessment in that case, but I'll leave that as an exercise for the reader.
    A completely different way of doing it is to use the TemporalConsecutiveDays function to find a date where a gap of 365 days exists, then select periods in which there is a gap immediately before the start of that period. Here are some rules that :
    there is a period that applies if
       ExistsScope(the periods)
          TemporalOnOrAfter(the period start date) and
          TemporalOnOrBefore(the period end date)
    there is a year-long gap if
       TemporalConsecutiveDays(365, 365, there is not a period that applies)
    the period starts after a year-long gap if
       ValueAt(the period start date, there is a year-long gap)
    the start date for calculation = InstanceMaximumIf(the periods, the period start date, the period starts after a year-long gap)Hopefully one of these is suitable for your needs.
    cheers,
    Steve.

  • Creating New Entity Instances within OPA

    This is another one that I think I know the answer to, but I think it is best to confirm.
    In prior versions, it was not possible to create entity instances within RuleBurst/Haley Office Rules. Is that still the case in OPA?
    For example, my rules are determining the status of a case and the reason(s) why that status was determined. The case status may be Denied and the reasons may be "invalid customer Id", "expenses to income ratio too high", "primary customer not employed long enough", etc. I want to return all the reasons for the status. While the list of reasons is pre-determined, the ones that apply to a particular case are dynamic, as any, but not all can apply.
    Given this situation using a database, I would create an instance of reason for each applicable one and link it to the case. In the past, with OPA's predecessor(s), it was not possible to create new instances from within. They either had to all be passed into the rulebase or a list of all allowable reasons attributes had to be created and then set to true for the ones that applied.
    My preference is to create the instances inside OPA. Is that functionality provided in the current version?
    Thanks,
    Terry

    Hi Terry,
    Michael is correct that you can't write rules at design time which will dynamically create new entity instances at runtime. However, perhaps the new inferred relationships functionality in v10 could address what you're trying to do.
    You can write rules which conclude membership of an inferred relationship. So you might always have, say, 10 instances of 'the reason' in every case, but as for which of those instances apply in any particular case, it depends on the details of the case. You could use an inferred relationship to collect up the entity instances which apply in the case.
    First you'd need to set up a regular one-to-many relationship to instantiate the 10 instances at runtime - this would be done in the usual way. Then you'd also need to set up an inferred relationship and write rules to conclude the members of the inferred relationship. The instances which are members of the inferred relationship are then effectively the list of entity instances you wanted to create in your example above.
    Have a look at this OPM Help article: http://www.oracle.com/technology/products/applications/policy-automation/help/opm10_1/Content/Rules%20using%20entity%20instances/Reason_about_relship_between_2_entities.htm
    Cheers,
    Jasmine

  • How to show logic of picking multiple stores to fulfill an order line item

    I'm still learning some basics with OPA.
    How do I represent the logic of picking multiple stores to fulfill an order line item when no one store has the requested quantity? A concrete example would be greatly appreciated as I'm still thinking procedurally for solutions.

    Hi!
    I believe this is following on from the thread:
    Calculating least cost of a product across stores using OPA
    So I'm assuming we're using a similar data model.
    If we want to involve quantity as well as cheapest price, then I'm assuming the requirement is:
    Find the cheapest price for the product from all the stores which still have quantity left of that product.
    This is where inferred relationships come in handy.
    Here is an example of what you can do with them to help solve this requirement.
    the store is a member of the product's stores if
    .ExistsScope(the store's prices)
    ..the price's product name = the product name
    the store is a member of the product's stores with remaining stock if
    .the store is a member of the product's stores and
    ..ExistsScope(the store's quantities)
    ...the quantity's product name = the product name and
    ...the quantity's amount > 0
    Then we basically want to pick the cheapest price for the product from the members of the relationship "the product's stores with remaining stock"
    Note that "the product's stores with remaining stock" could obviously be many instances, all with different prices. But for an order, a product needs to come from only one place! The deciding factor to "pinpoint" one place from this potential list of many could be based on anything, such as location, sales ranking, etc. But in this case Im going to assume lowest price is the decider.
    In the previous post we created a simple relationship between "the product" and "the prices" (which are contained by the store).
    We can make a more powerful relationship now:
    the price is a member of the product's available prices if
    ForScope(the price's store, the main store)
    .the main store is a member of the product's stores with remaining stock
    (I'm using an alias here to be 100% sure of which store is in scope)
    Now we can use the rules in the previous post, but change the relationship to the more advanced one we just created:
    the product's cheapest available price = InstanceMin(the product's available prices, the price's amount)
    Then
    the product's cheapest available store name = InstanceValueIf(the product's available prices, the price's store name, the price's amount = the product's cheapest available price)
    This is all psuedo code so many need some slight tweaks when you put it into OPM. Make sure you set up the relationships in a property file and declare all the attributes etc.
    Inferred relationships are really useful as "filters" sometimes. Here we first filtered all the stores which have prices for the product (i.e. have it in their catalogue). Then we filtered to get a list of all the stores which have stock remaining for the product. From that, we could find the cheapest available price.
    This is by no means the only way to do it! It's also by no means a simple problem but the great thing about OPA is that you can put all of the relationship config rules in the system rule folder / word doc, meaning that the source / business rules can still look relatively simple (in the end, it only took 2 lines of source rules to find the cheapest available price!). Once you've got the right set up and invested time in designing your data model, you will find it much easier to solve seemingly complex problems across entities.
    One word of warning though: if you have thousands of instances of prices, stores, products etc. then there is a performance impact of using many inferred relationships and alternatives should also be considered.
    Hope this helps!
    Feel free to contact me for more help on this. If you are relatively new to OPA and trying to tackle this you should consider investing in some training.
    Cheers,
    Ben

Maybe you are looking for