//in a file hello.clp
(defrule startup =>
(assert (num1 (fetch A)))
(assert (num2 (fetch B)))
(assert (num3 (fetch C))) )
(defrule sum_rule (cmp ?numb) => (if(> ?numb 10) then (bind ?sum (+ ?sum
?numb))))
(assert (cmp num1))
(assert (cmp num2))
(assert (cmp num3))
(store result ?sum)
/////////java program
public static void testAddition() {
Rete rete = new Rete();
try {
rete.reset();
rete.watchAll();
rete.store("A",new Value(11, RU.INTEGER));
rete.store("B",new Value(15, RU.INTEGER));
rete.store("C",new Value(13, RU.INTEGER));
rete.executeCommand("(batch hello.clp)");
System.out.println("rule name"+rete.getThisRuleName());
rete.run();
Value v = rete.fetch("result");
System.out.println("value " + v);
} catch (JessException e) {
e.printStackTrace();
}
}
//exception
Jess reported an error in routine Value.numericValue
while executing (> ?numb 10)
while executing (if (> ?numb 10) then (bind ?sum (+ ?sum ?numb)))
while executing defrule MAIN::sum_rule.
Message: Not a number: "num3" (type = ATOM).
at jess.Value.a(Unknown Source)
at jess.Value.a(Unknown Source)
at jess.Value.numericValue(Unknown Source)
at jess.Variable.numericValue(Unknown Source)
at jess.ek.call(Unknown Source)
at jess.ep.a(Unknown Source)
at jess.Funcall.execute(Unknown Source)
at jess.FuncallValue.resolveValue(Unknown Source)
at jess.dw.call(Unknown Source)
at jess.ep.a(Unknown Source)
at jess.Funcall.execute(Unknown Source)
at jess.Defrule.a(Unknown Source)
at jess.Activation.if(Unknown Source)
at jess.a8.a(Unknown Source)
at jess.a8.int(Unknown Source)
at jess.Rete.run(Unknown Source)
Any ideas?
[EMAIL PROTECTED]
.gov To: [EMAIL PROTECTED]
Sent by: cc:
owner-jess-users@ Subject: Re: JESS: running rules from
java program
sandia.gov
06/18/04 02:22 PM
Please respond to
jess-users
I think [EMAIL PROTECTED] wrote:
>
> Is there any example of setting the variables in java program for the
rules
> in a file and getting the results in java program.
>
> I am getting varibales not initialized problem!
>
You generally don't communicate with Jess by setting variables, but
rather by asserting facts, or else by putting things in the global
storage area (see section 4.4.4 of the manual.)
---------------------------------------------------------
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]
--------------------------------------------------------------------