[rules-users] Rule using accumulate

Wolfgang Laun wolfgang.laun at gmail.com
Tue Apr 27 10:38:19 EDT 2010


A typical case for the "not" CE:

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

-W

On Tue, Apr 27, 2010 at 3:56 PM, Andres Corvetto <acorvetto at gmail.com> wrote:
>
> 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