[rules-users] Rule using accumulate

Greg Barton greg_barton at yahoo.com
Tue Apr 27 11:01:33 EDT 2010


Use an existence check:

rule "Match Offer" 
    when 
        $b :PartiallyCoveredBid(uncoveredSize>0, $p:price) 
        $o :Offer(price<$p, alreadyUsed==false, $ct:creationTimestamp)
        not Offer(creationTimestamp < $ct)
    then 
        [ add Offer $o to Bid $b] 
end 

i.e. pick an Offer o such that there does not exist another Offer with a creationTimestamp less than o.creationTimestamp.

--- On Tue, 4/27/10, Andres Corvetto <acorvetto at gmail.com> wrote:

> From: Andres Corvetto <acorvetto at gmail.com>
> Subject: Re: [rules-users] Rule using accumulate
> To: rules-users at lists.jboss.org
> Date: Tuesday, April 27, 2010, 8:56 AM
> 
> Offers already have a creationTimestamp, that could be used
> for this.
> However, it's not clear to me how to write a rule that
> matches only the
> Offer with the minimum creationTimestamp.
> 
> Something like:
> 
> rule "Match Offer" 
>     when 
>         $b :
> PartiallyCoveredBid(uncoveredSize>0, $p:price) 
>         $o :
> Offer(price<$p, alreadyUsed==false,
> creationTimestamp<[all other
> matching Offer creationTimestamps ]) 
>     then 
>         [ add Offer $o to Bid
> $b] 
> end 
> 
> is that possible?
> 
> - Andres
> 
> Wolfgang Laun-2 wrote:
> > 
> > If the age of Offers is so important it ought to be
> represented as
> > fact data. If it cannot be added to the Offer itself,
> a proxy fact
> > could be created, combining a counter with an Offer
> reference. A high
> > salience rule for an Offer without OfferProxy would
> create this.
> > 
> > -W
> > 
> > On Mon, Apr 26, 2010 at 9:43 PM, Andres Corvetto
> <acorvetto at gmail.com>
> > wrote:
> >>
> >> Thank you for your reply!
> >> I understand your approach, and I think it could
> work if Offers were
> >> inserted into the working memory after the Bid.
> >> However, to implement your approach for already
> inserted Offers I think I
> >> would need some way of forcing the matching Offer
> to be the oldest in
> >> memory, is that possible?
> >> The rule would be something like:
> >>
> >> rule "Match Offer"
> >>        when
> >>                $b :
> PartiallyCoveredBid(uncoveredSize>0, $p:price)
> >>                $o : Offer(price<$p.
> alreadyUsed==false, [this is the
> >> oldest Offer in
> >> memory with these conditions])
> >>        then
> >>            [ add Offer $o to Bid $b]
> >> end
> >>
> >> Thanks again
> >>       Andrés
> >> --
> >> View this message in context:
> >> http://drools-java-rules-engine.46999.n3.nabble.com/Rule-using-accumulate-tp757311p757703.html
> >> Sent from the Drools - User mailing list archive
> at Nabble.com.
> >>
> >> _______________________________________________
> >> rules-users mailing list
> >> rules-users at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >>
> > 
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> > 
> > 
> 
> -- 
> View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rule-using-accumulate-tp757311p759323.html
> Sent from the Drools - User mailing list archive at
> Nabble.com.
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 


      




More information about the rules-users mailing list