Reporting JESS's inference

I'm trying to report the inference steps in JESS. For example, I would like to know which rules/facts caused inference engine to fire a certain rule. In order words, I want to see the theorem proving capabilities of JESS.Here is an example from Wikipedia:(defrule A "" (and (X croaks) (X eats flies)) => (assert (X is a frog)))(defrule B "" (and (X chirps) (X sings)) => (assert (X is a canary)))(defrule C "" (X is a frog) => (assert (X is green)))(defrule D "" (X is a canary) => (assert (X is yellow)))If I have...Read more

i don´t know why this example of the jess rule manual doesn´t work

I am reading the jess manual, exactly in 6.12. The 'test' conditional element. I copied exactly the example for try running this code, but didn´t work at all. NOTE: I have run another examples and work fine.(deftemplate person (slot age))(defrule example-8 (test (eq 4 (+ 2 2))) => (printout t "2 + 2 is 4!" crlf))My result is nothing.. don´t show me any message, don´t return any error message. I really want to understand it. Please help me on this....Read more

jess - JessTab in Protege

I'm using Jess with Protege, I created a def template Person with the slots (name, age and adress), and I created another def template which extends the first one with the additional slot (sex), now I want to delete the first one and replace it by the new one, and I don't want to lose instances, I want the instances of the first one to be extended by the second, how can I do it ?thank you i tried first to modify the structure of the def template with the function "replace$", but it doesn't work, then I tried the function "modify" but it just m...Read more

jess - Compare value of a nested java bean

I am trying my hands with JESS wherein I want to write a rule as following.When order amount is greater than 1000 and customer is preferred and customer name matches to order name then do something.My has following propertiesint amount, Customer custAnd is a plain bean class holding following properties.string name, string addressI am not able to find a way wherein I can get the value of and compare with in JESS.Can anyone help me here please?I tried using following but not working out for ...Read more

How to debug this very simple Jess code?

(deftemplate bikelife (slot name) (slot type))(deffacts bike (bikelife (name Strida) (type low_lifestyle)) (bikelife (name Brompton) (type med_lifestyle)) (bikelife (name Molton) (type high_lifestyle)) (bikelife (name Specialized_AlleComp) (type low_sport)) (bikelife (name Specialized_Tarmac) (type medium_sport)) (bikelife (name Pinarello_DOGMA_F8) (type high_sport)))(defrule rule-1 (budget ?x) (test (< ?x 300)) (use_for lifestyle) => (assert (recommend low_lifestyle)))(defrule rule-2(budget ?x)(test...Read more

How to modify a Jess multislot fact in working memory

I have some rules in my Jess code which i want to modify two facts in the working memory. The facts which have been asserted are: (assert (analysis (reasons $?c) (total ?t))))reasons $?c is a multislot and I want to add to this multislot if needed in rules.For example: If a user drinks too much alcohol, I want the text "You are drinking to much alcohol which is unsafe." added as a field to the multislot (reasons $?c).How would I acheive this task. I have done a lot of research and tried several methods but they are not working correctly....Read more

removing a multislot variable in JESS

I have a deftemplate which contains a multislot in JESS and I want to delete a variable in the multilot if the rule is fired. for example:(deftemplate Person (slot name) (multislot friends))(assert (Person (name John)(friends Jimmy Joe Jessica)))now i want to delete Jimmy from the friends slot. Thank you very muchAli...Read more

Ordering the activation of modules in jess

I am using JESS to write a program which eliminates some elements in the deftemplate for each rule that is fired.I want to print out the results to a file after all rules have been fired.I have put all the rules which effect the deftemplate in a defmodule, and made two seperate modules for reporting the results. but the point is the reporting modules are executed in between and therefore there rules will be fired,I want to have the report modules executed at the end, Can I use the defadvice after halt?shall I add another rule saying that when a...Read more

jess - Stop rete activations

I have a rule that retracts thousands of facts when a certain condition is met. This rule sits in a module that contains two other rules that use "not" statements. My questions are:Does the rete network get recalculated every time the first rule retracts a fact?It is because of the "not" statements in the other two rules or would that happen anyway?Is there a way to stop recomputing activations until the first rule has no more facts to retract?Thanks!...Read more

Jess - Add Facts with Random Function

I am making a Tetris game and I want to know how can I add points to my facts. (deftemplate point (slot i(type INTEGER)) (slot j(type INTEGER))) (defglobal ?*LINES* = 24) (defglobal ?*COLUMNS* = 12) (deffacts initial (piece 0)) (defrule choosePiece => (bind ?y (mod (random) 7)) //there are 7 pieces in Tetris game (assert (piece ?y)))I have a Random rule choosePiece and if the result of that rule is 1 I want to add one square to my facts in coordinates (1,6) (1,7) (2,6) (2,7), if it is 2 I want to add a T. How can I make this and then crea...Read more

How to compare java object in jess

I have a problem when I compare java object as attribute inside the java class This is my clp file (import Model.*)(deftemplate PizzaBase (declare (from-class PizzaBase) (include-variables TRUE))) (deftemplate PizzaTopping (declare (from-class PizzaTopping) (include-variables TRUE))) (deftemplate Pizza (declare (from-class Pizza) (include-variables TRUE))) (defrule make-pizza ?pizzaBase1 <-(PizzaBase{size == 9}) (Pizza(pizzaBase ?pizzaBase1)) => ...Read more

In Jess, how would I add a slot to a template through a rule?

As an example, I have:(deftemplate Animal(slot has-feathers (default FALSE))(slot name (default "George")))and in a rule I have:(defrule bird-test?a <-(Animal (has-feathers ?))=>(printout t ? " is a bird" crlf)"Add slot 'bird' to ?a or Animal")How would I do this? and thank you in advanceEdit: Thanks guys! I think I understand what I need to do....Read more