in

The ORM Foundation

Get the facts!

Modeling that the newest bid is higher than any existing bid

Last post Fri, May 22 2015 15:57 by Terry Halpin. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • Tue, May 5 2015 13:37

    • jacobvos
    • Top 25 Contributor
      Male
    • Joined on Mon, Jan 21 2013
    • The Netherlands
    • Posts 32

    Modeling that the newest bid is higher than any existing bid

    The situation

    On an online marketplace consumers can place advertisements to offer products. Other consumers can make bids. A bid is related to an advertisemen, it has an offer price and a date on which the bid is made. Rule is that the offer price of a bid is higher than any bid that was already made at that advertisement.

    Question

    How should I express this rule in ORM?

  • Tue, May 5 2015 18:34 In reply to

    Re: Modeling that the newest bid is higher than any existing bid

     Hi Jacob

      Assume the ORM schema contains the following fact types, each of which is mandatory and many-to-one.

    Bid(.Nr) is for Advertisement(.Nr).

    Bid is by Consumer(.Nr).

    Bid offers Price(USD:).

    Bid is made on Date(ymd).

     Now you may define the derived fact type "Bid is highest for Advertisement" (optional, 1:1).

    The professional version of NORMA under development provides formal support for entering derivation rules, but is not yet available to the general public. I assume you are using the public domain version of NORMA, in which case you can only enter the derivation rule informally as a DerivationNote. Here is one way to specify the derivation rule in FORML syntax (Please downshift the appended numbers to make them subscripts. I'm entering the text directly in the forum so have no convenient way to show subscripts).

    * Bid1 is  highest for Advertisement if and only if

          that Bid1 offers some Price1

          and no Bid2 <> Bid1 and is for that Advertisement and offers some Price2 >= Price1.

    Cheers

    Terry 

     

     

  • Fri, May 8 2015 13:13 In reply to

    • jacobvos
    • Top 25 Contributor
      Male
    • Joined on Mon, Jan 21 2013
    • The Netherlands
    • Posts 32

    Re: Modeling that the newest bid is higher than any existing bid

    Hello Terry,

    Thank you for answering. The fact types you suppose are correct, except that we pay in euros ;-). See the image below for the fact types I consider as relevant for my question.

    I think I didn't explain the situation well enough. Consumers can make bids and see each others bids. It is forbidden to make a bid that is lower than the latest one made. Let me give a sample for a random advertisement.

    2015-05-08 15:20 | € 15,00
    2015-05-08 15:22 | € 17,50
    2015-05-08 16:11 | € 20,50

    Now someone wants to make this bid:

    2015-05-08 17:20 | € 19,00

    This is forbidden.

    I would say it's something like this (sorry for the informal syntax): For any bid Bid1 holds: if Datetime1 >= any Datetime2 then Price1 > Price2.

    Please let me know.

    Kind regards,
    Jacob


  • Fri, May 8 2015 17:45 In reply to

    Re: Modeling that the newest bid is higher than any existing bid

     Hi Jacob

      First let me correct an obvious omission from my previous rule, which should have read as follows:

    * Bid1 is highest for Advertisement if and only if

          that Bid1 is for that Advertisement and offers some Price1

          and no Bid2 <> Bid1 and is for that Advertisement and offers some Price2 >= Price1.

    This rule implies that the fact type is 1:1. Alternatively, you could use the following simpler rule and then add an asserted uniqueness constraint to the derived fact type to ensure there is only one highest bid for each advertisement.

     * Bid1 is highest for Advertisement if and only if

          that Bid1 is for that Advertisement and offers some Price1

          and no Bid2 is for that Advertisement and offers some Price2 > Price1.

     

    I now usually use “rule” to mean “derivation rule” rather than a constraint. I now see that you are after a constraint. It is usual to treat “It is forbidden that ” as a deontic modal operator, and “It is impossible that” as an alethic modal operator. I assume by “This is forbidden” you actually mean “This must be rejected” (an alethic constraint) rather than accepting the update and marking it as forbidden (a deontic constraint).

     

    There are many ways to specify the constraint you are after. A dynamic rule approach is most efficient, but here is one simple way to specify the constraint statically.

     

    (1)    Add the derived fact type “Bid is highest for Advertisement” as indicated above.

    (2)    Add the derived fact type “Bid is latest for Advertisement” using the following derivation rule (this enforces 1:1, but you also could use the alternative approach for the previous rule):

     

       * Bid1 is latest for Advertisement if and only if

          that Bid1 is for that Advertisement and is made on some Datetime1

          and no Bid2 <> Bid1 is for that Advertisement and is made on some Datetime2 >= Datetime1.

     

    (3)    Assert the following pair-equality constraint between these two derived fact types:

    Bid is latest for Advertisement if and only if that Bid is highest for that Advertisement.

     

    Cheers

    Terry 

  • Wed, May 20 2015 12:53 In reply to

    • jacobvos
    • Top 25 Contributor
      Male
    • Joined on Mon, Jan 21 2013
    • The Netherlands
    • Posts 32

    Re: Modeling that the newest bid is higher than any existing bid

    Hi Terry,

    I hoped there was a shorter way to define this - alethic - constraint, without derived fact types...

    I was wondering why you defined a binary for the derived fact types. A bid can be for only one advertisement. So I would say unaries are OK. See the picture. I defined the derivation rules as follows:

    Bid1 is highest if and only if

          that Bid1 is for Advertisement1 and offers some Price1

          and no Bid2 is for Advertisement1 and offers some Price2 > Price1

    and:

    Bid1 is latest if and only if

          that Bid1 is for Advertisement1 and is made on some Datetime1

          and no Bid2 <> Bid1 is for Advertisement1 and is made on some Datetime2 >= Datetime1.

    The equality constraint reads:

    For each Bid,
          that Bid is latest if and only if that Bid is highest.

    Please let me know your opinion.

    Regards,
    Jacob


  • Wed, May 20 2015 15:33 In reply to

    Re: Modeling that the newest bid is higher than any existing bid

     Hi Jacob

      As I indicated earlier, your problem can be handled more efficiently using a dynamic rule. We have specified extensions to ORM’s rule syntax to support such rules, which can refer directly to states immediately previous to a transaction (e.g. the previous bid), but have not yet implemented this rule syntax in NORMA, so I have ignored this approach here.

     To make sense of your latest proposal, which adapts my proposal by replacing the binary fact types “Bid is highest for Advertisement” and “Bid is latest for Advertisement” with the unary fact types “Bid is highest” and “Bid is latest”, one needs to interpret “is highest” and “is latest” as “is highest for its advertisement” and “is latest for its advertisement”. Most people would instead interpret “Bid is highest” to mean the bid is the highest bid ever made (regardless of the advertisement). To avoid confusion with your approach, I suggest you use the longer readings suggested above, and also explicitly include “some” for object variables introduced in the body of a rule. With this rephrasing, the derivation rules and equality constraint for the unary fact types may be stated as follows:

     * Bid1 is highest for its advertisement if and only if

          that Bid1 is for some Advertisement and offers some Price1

          and no Bid2 is for that Advertisement and offers some Price2 > Price1.

     

       * Bid1 is latest for its advertisement if and only if

          that Bid1 is for some Advertisement and is made on some Datetime1

          and no Bid2 <> Bid1 is for that Advertisement and is made on some Datetime2 >= Datetime1.

    For each Bid,
          that Bid is latest for its advertisement if and only if that Bid is highest for its advertisement. 

    Cheers

    Terry 

  • Wed, May 20 2015 22:40 In reply to

    • jacobvos
    • Top 25 Contributor
      Male
    • Joined on Mon, Jan 21 2013
    • The Netherlands
    • Posts 32

    Re: Modeling that the newest bid is higher than any existing bid

    Hi Terry,

    I agree with you that a dynamic rule is better here. Thank you for your comments and rephrasing.

    Question: Is the syntax you use for derivation rules and for dynamic constraints published anywhere? I guess it's not - completely - in the 'big brown book'.

    Regards,
    Jacob

  • Wed, May 20 2015 23:11 In reply to

    Re: Modeling that the newest bid is higher than any existing bid

    Hi Jacob

    The FBM metamodel contains numerous examples of verbalizations of derivation rules, but we have not yet published the dynamic rule syntax.

    Cheers

    Terry.

  • Fri, May 22 2015 15:04 In reply to

    Re: Modeling that the newest bid is higher than any existing bid

    Hi Terry,

    By "FBM metamodel", are you referring to the work discussed here: http://www.factbasedmodeling.org/objectives.aspx?  Has the core of the metamodel (excluding dynamic rules) been published somewhere?   

    Thanks,

    Matt 

  • Fri, May 22 2015 15:57 In reply to

    Re: Modeling that the newest bid is higher than any existing bid

     Hi Matt

    Yes, www.factbasedmodeling.org is the website for the FBM Working Group. To get access to the metamodel, I suggest you join the working group, which is chaired by Serge Valera (see the membership page).

     Cheers

    Terry 

Page 1 of 1 (10 items)
© 2008-2015 The ORM Foundation: A UK not-for-profit organisation -------------- Terms of Service