I think Sajindra Jayasena wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi All,
> I am new to Jess .
> I am trying out to develop a customizable rule engine as a university degree
> project that could be used by java applications. I have done the
> customizing interfaces for facts etc but facing problrm with working with
> the Rule.
> I found that (defrule ... ) is the command to create a rule . But facing
> problen in defining the RHS of the rule
> for e.g. If I create a rule where the LHS is
> ((customer ?name ?age new )
> and the RHS would be
>
> => (discount = 35 ) - this syntax is incorrect i think .
Yes, it is not valid syntax.
> If I explain the scenarion , what would happen is for any customer fact if
> his status is new , the discount that is applied to him is 35 ) .
> the problems I am facing are :
> 1. How to define the RHS ?
This depends on what you want to do, and the answer is tied up with
the answer to the next two questions. First, you have to figure out
what you want to do with the value "discount." Are you going to apply
more rules to it? If so, then you should make another fact out of it
and assert it -- i.e., (assert (discount 35)) . If you're -not- going
to apply more rules to it, but instead just want to send it back to
the user or the main Java program, then you can do that by calling a
Java function, or using the (store) and (fetch) Jess functions
(described in the manual) -- i.e., (this rule doesn't make any sense,
but hopefully you'll get the idea)
(defrule my-rule
(customer ?name ?age new )
=>
(store DISCOUNT 35))
and then in Java, if your Rete object is in a variable named "engine",
you can write
engine.run();
int discount = engine.fetch("DISCOUNT").intValue(null);
> 2. how can I get the out put of this rule ?
First you have to write a rule which produces some kind of "output."
The (store) function is a very handy and easy way to send results
back to a Java program.
> 3. do i have to write jess functions?
Deffunctions, you mean? Only if you want to.
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research 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]
--------------------------------------------------------------------