Thanks again, and you read my mind, because my next question was
going to be how to encapsulate the info into something called "data".
I am now using unordered facts with named slots.
Now, I've got to move on to something a little more complicated.
I need to represent the following Java code in a Jess rule:
private boolean isStoreAffectedOverTen(DataBean currWeek,DataBean lastWeek) throws
Exception
{
// get stores affected if more than 10%
float storesAffected = (currWeek.store_count_small -
lastWeek.store_count_small)
+ (currWeek.store_count_zero -
lastWeek.store_count_zero);
float storesSelling = (currWeek.store_count_is_zero +
currWeek.store_count_selling);
float equation = ((storesAffected / storesSelling));
if( equation > .10)
return true;
else
return false;
}
Now I suppose I could come up with a predicate function that might
represent all this, but I'm afraid it might be somewhat ugly. My
basic problem is envisioning a pattern that would simultaneously
do all the math. Is there an elegant way to implement this rule
using a predicate function, or am I totally off track?
Thanks again.
On Wed, Jan 21, 2004 at 03:30:43PM -0800, [EMAIL PROTECTED] wrote:
> I think Udo Dieckmann wrote:
> > Ok, thanks, there's my decoder ring. It got activated. Can I try and
> > explan what's going on with the rule in order to make sure I've got it
> > right?
>
> [ explanation deleted ]
>
> >
> > Is that about right?
>
> Yes except that each line is a pattern itself; there are four patterns
> on the LHS.
>
> >
> > Definitely my error was in not understanding the patternization in
> > (last-week-inventory ?lwi) etc. I THINK I've got it now....
> > It's almost like saying "LET any fact asserted as a last-week-inventory
> > be known as ?lwi" ....
>
>
> Yes, pretty much.
>
> Note that since all of the facts are intended to be unique -- i.e,
> there's only ever going to be one last-week-sales fact -- then you
> could write things using unordered facts with named slots. The
> rules would be both more efficient and easier to read. You can
> comment, too.
>
> (deftemplate data (slot type) (slot last-week) (slot this-week))
>
> (assert (data (type sales) (last-week 10) (this-week 20)))
> (assert (data (type inventory) (last-week 23) (this-week 22)))
>
> (defrule my-rule
> ;; Sales are increasing
> (data (type sales)
> (last-week ?slw) (this-week ?stw&:(< ?slw ?stw)))
>
> ;; Inventory decreasing
> (data (type inventory)
> (last-week ?ilw) (this-week ?itw&:(> ?ilw ?itw)))
>
> =>
> (evaluate-orders))
>
>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Science and Engineering PSEs Phone: (925) 294-2154
> Sandia National Labs FAX: (925) 294-2234
> PO Box 969, MS 9012 [EMAIL PROTECTED]
> Livermore, CA 94550 http://herzberg.ca.sandia.gov
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the list
> (use your own address!) List problems? Notify [EMAIL PROTECTED]
> --------------------------------------------------------------------
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------