Thanks everyone, this works.
Charles
On 11/1/06, Steven Williams <[EMAIL PROTECTED]> wrote:
I am guessing price and simpleMovingAverage are both properties of
StockOffer? If so the easiest way to compare is
when
offer : StockOffer( p : price, sma : simpleMovingAverage )
eval(p >= sma)
multiple columns cannot currently be used in comparisons against each other
or in predicates.
For the BigDecimal you could use
when
offer : StockOffer( p : price -> ( p.floatValue() >= 90 ))
cheers
Steve
On 11/1/06, Ramesh Bhaskar <[EMAIL PROTECTED] > wrote:
> Well, Hopefully my answers are right, since I'm new to drools as well...
But I'll give it my best shot.
>
>
> On 10/31/06, Charles Chan < [EMAIL PROTECTED]> wrote:
> > HI, I am new to Drools (and rule engine in general). I was trying to
> > write a very simple rule but was stuck. I hope someone here can help
> > me with my questions:
> >
> > 1. How do I write a condition such that it is a comparison between two
> > (or more) columns of a fact? For example,
> >
> > rule "BuyWhenMarketPriceAndVolumeMatchesRule"
> > when
> > offer : StockOffer( price >= simpleMovingAverage )
> > then
> > offer.setAction(StockOffer.Action.ACTION_BUY );
> > end
> >
> > where price and simpleMovingAverage are both attributes of the
> > StockOffer object.
>
>
> I'd say what you've written above is fine, as a comparison. If you need
to make multiple comparisons then use a ',' in between them.
>
> offer: StockOffer(price >= simpleMovingAverage,
price<=someMaxValue)
>
> Assuming that is what you asked in the first place. If its not, then I
guess I'm not clear on what you need.
>
>
>
> > 2. How do I compare between a BigDecimal and a literal numeral? For
example,
> >
> > rule "BuyWhenMarketPriceAndVolumeMatchesRule"
> > when
> > offer : StockOffer( price >= 90 )
> > then
> > offer.setAction(StockOffer.Action.ACTION_BUY);
> > end
>
>
>
> Not too sure about this one.
>
>
> > where price is a java.math.BigDecimal.
> >
> > 3. How do I "pass" variables into the working memory so that it can be
> > used for rule conditions? For example:
> >
> > rule "BuyWhenMarketPriceAndVolumeMatchesRule"
> > when
> > offer : StockOffer( price >=
$someVariableSetInWorkingMemory )
> > then
> > offer.setAction(StockOffer.Action.ACTION_BUY);
> > end
> >
> > where $someVariableSetInWorkingMemory is a variable passed into the
> > working memory.
>
>
>
> You can use the workingmemory.setGlobal () function to pass values from
the main program into your working memory.
>
>
>
> > Please let me know if some of my questions doesn't make sense in a
> > rule engine...
> >
> > Thanks
> > Charles
> >
> >
> >
> >
> > --
> > http://del.icio.us/chancharles
> >
> >
---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> > http://xircles.codehaus.org/manage_email
> >
> >
>
> Ramesh
>
> --
> http://www.rameshbhaskar.com
--
Steven Williams
Supervising Consultant
Object Consulting
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
[EMAIL PROTECTED]
www.objectconsulting.com.au
consulting | development | training | support
our experience makes the difference
--
http://del.icio.us/chancharles
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email