RE: JESS: retract doesn't work like I want it to do
I've tried to run your example, but I received: java.lang.ClassNotFoundException: Fehlerauslesen I think that it is missing -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de H|bner Envoyi : vendredi 27 janvier 2006 09:32 @ : jess-users@sandia.gov Objet : JESS: retract doesn't work like I want it to do Hello everybody, I need a hint from you. When I try to retract a fact, all other facts are reactivated. To understand what I mean, I'm sending the anlageneu.clp and fehlertabelle.dat with this mail. It has a small GUI and it's asking some questions to the user. Answer the first question with expertensystem, the second with ja and the third with nein. This procedure will insert the following facts to the working memory: (fehlermeldung) (Zylinder IO) (Funktion Probleme) (fehlermeldung2) (fehlermeldung3) (Notausschalter unbetaetigt) (Geschlossen) (repair Jeder Notaus- Knopf muss unbetaetigt sein. Loesen Sie alle, die noch gedrueckt sind!) In the next step I have to retract the last fact to fire the rule reparatur_Schutztuere_Stufe1, but it restarts questioning the user with the first three questions. Can somebody tell me what's wrong with the code? Best regards, Lars 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]
JESS: Relation between a Java Bean and Jess - retrieving results
Hi everybody, As I am developing using JESS, I have some doubts. Here is more one... Consider that I have one fact and the two rules below. They are automatically created using Java and Rete. Actually, I used the STORE and a bean because I want to retrieve (FETCH) a list of results. For example, I know that when running this algorithm if I used printout I will receive as response: fournitureBeton creationEscalierBeton. Actually I want to retrieve these values. Probably my use of STORE is not correct and you have another simple solution. The problem here is that even if I declared my bean as global, this means, it will be instanciated only one time, as I saw the answers I received, it is passing two times when I call it. Thus I can conclude that it is creating two instances of my bean, one for creationEscalierBeton and another for fournitureBeton. Thus this is the reason that my StringBuffer inside the bean only have one result. Actually I want to retrieve an order list telling which rule is fired firstly, and so on. I want to retrieve as System.out.println(Order List: + rete.fetch(RESULT)); Do you know another way to FETCH the RESULT value since this RESULT should be a list of the name of my rules or the name that I am saying? If in the place of the set and store I used printout, everything works as I need. However the problem is that I need to retrieve these results. Best regards, Daniela (assert (existPlancher)) (defglobal ?*obj* = (new MarchePublicBeanPlan)) (defrule creationEscalierBeton (existPlancher) (betonFournit) = (assert (existEscalierBeton)) (set ?*obj* action creationEscalierBeton) (store RESULT (get ?*obj* action)) ) (defrule fournitureBeton (not(betonFournit)) = (assert (betonFournit)) (set ?*obj* action fournitureBeton) (store RESULT (get ?*obj* action)) ) I have this bean: import java.io.Serializable; public class MarchePublicBeanPlan implements Serializable{ private String action; public StringBuffer plan; public MarchePublicBeanPlan() { System.out.println(* Inside BEAN**); action = null; plan = new StringBuffer(); } public void setAction(String action) { System.out.println(ACTION:+action); plan.append(action); } public String getAction() { System.out.println(PLAN:+plan.toString()); return plan.toString(); } } And this is the answer I get when I rete.run it. STARTING RETE * Inside BEAN** * Inside BEAN** ACTION:fournitureBeton PLAN:fournitureBeton Order List: fournitureBeton 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]
RE: JESS: Goal in each action
Hi James, Thank you very much for your deeply answer. I have some comments to add... Actually, I completely agree with you that rule-based systems are a kind of data-driven and forward chaining also. In my example, the planner that I am devellopping, I can have an explicitly goal, but actually I dynamically create my plan and my goal depends on which rules are decided by the user to be included. Each rule corresponds to a web service in real world and the goal of my planner is to order the rules, saying which one should be before the other. For example, if I am constructing a stairs, first I need the concrete and then I can construct a stairs. Thus based on preconditions the actions will be organized in the order of its execution. In this case my goal was construct a stair, but if I had put also action floor, probably my goal would be construct a new floor, and stair will only be an intermediate step. More or less, I hope you have understood what I am doing... About the book, I can buy it, but is it different from the Docs in Jess, or they are similar? Do you really encourage me to buy it? Thank you very much, I will probably post another message about some other problems I am having when implementing Jess with Java beans. Daniela -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de James C. Owen Envoyi : mercredi 25 janvier 2006 20:36 @ : jess-users@sandia.gov Objet : Re: JESS: Goal in each action Deniela: As stated before, which you might not have seen, most of the problems with newbies and rulebased systems is that the process is declarative rather than procedural as with most other languages. When a rule is refracted (removed from the agenda permanently because it has already) the rule that is deleted is the rule+data, meaning that the same rule logic may appear several times but with a different set of data. If the data are changed, then the rule logic might appear again. Now, to goal-oriented rules. Normally, in most rulebased systems, recency is one of the first items to consider. So, if a new goal is asserted it will take precedence over any other goals. That's why the goal usually appears as the first condition in the rule. The manner in which the rules are processed is not like other languages; it is determined as an abstract problem and is solved by the conflict resolution strategy. And, yes, under the covers, each OR is broken down into two rules complete with data associated with that rule. Here is a fairly easy way to think of the rules: All of the rules and all of the data are put into a big pot. Each rule associates itself with a set of data and becomes an object. When we use goal- oriented rules, we restrict each set of rules to only those with the current goal - which can change if any of the rules assert another goal. During the first cycle, all of the rules+data are examined (1) to associated each datum with a specific rule, (2) to associate a rule with specific data and (3) to see if any of the rules evaluate to TRUE. All of the rules that evaluate to TRUE are put on the Agenda Table as well as being put into a truth maintenance table. Then the rules are evaluated according to conflict resolution. If any datum is changed then any rule that used that datum is RE-evaluated to see if (1) it was false and is now true and it will be put on the Agenda table or (2) if it was true and on the Agenda table and is now false it will be removed. ONLY those rules where the data are changed are evaluated. And numerous tests over the years have determined that even with thousands of rules, only two or three rules are changed during one cycle of rules. Meaning that not all of the rules need to be checked - only those who data have changed. I know that all of this might seem a bit low-level and simplistic, but sometimes we tend to forget that rules are kind of data driven - it's also sometimes called forward chaining which may or may not be a misnomer. Above all, read the book on Jess, Jess in Action, and go through the examples and tutorials before attempting to design your own system. If I sound condescending, I apologize but it's most difficult to answer questions over the internet without sounding like a professor talking to a student. If this has been of any help, good. If not, then just toss it. :-) SDG jco James C. Owen Senior Consultant [EMAIL PROTECTED] http://www.kbsc.com Never give up. Never give up. Never, never, never give up. From a speech by former Prime Minister, Winston Churchill, during the most trying times of the British Empire; a great leader too soon forgotten by his country after keeping it from being swallowed up by the Nazi Empire during the second world war. On Jan 25, 2006, at 2:51 AM, Daniela CLARO wrote: Thank you Ernest, I have more questions about it...The first one is that I'd read that Jess memorizes each rule that it passes and so Jess doesn't pass two times in the same rule
RE: JESS: Relation between a Java Bean and Jess - retrieving results
I am myself answering me because I found the first mistake and it works. But if anybody knows a way more simple to do the same thing, I will be glad to learn it. Here is the right code, it is automatically generate : rete.executeCommand((set-reset-globals nil)); rete.executeCommand((reset)); rete.executeCommand((defglobal ?*obj* = (new MarchePublicBeanPlan))); rete.executeCommand((assert (existPlancher))); rete.executeCommand((defrule creationEscalierBeton + (existPlancher) + (betonFournit) + = + (assert (existEscalierBeton)) + (call ?*obj* setAction \creationEscalierBeton\) + (store RESULT (call ?*obj* getAction)) + ) ); rete.executeCommand((defrule fournitureBeton + (not(betonFournit)) + = + (assert (betonFournit)) + (call ?*obj* setAction \fournitureBeton\) + (store RESULT (call ?*obj* getAction)) + ) ); And right now, it is passing only one time in the bean. I didn't change anything, but it works correctly. Thank you. Daniela -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Daniela CLARO Envoyi : jeudi 26 janvier 2006 15:43 @ : jess-users@sandia.gov Objet : JESS: Relation between a Java Bean and Jess - retrieving results Hi everybody, As I am developing using JESS, I have some doubts. Here is more one... Consider that I have one fact and the two rules below. They are automatically created using Java and Rete. Actually, I used the STORE and a bean because I want to retrieve (FETCH) a list of results. For example, I know that when running this algorithm if I used printout I will receive as response: fournitureBeton creationEscalierBeton. Actually I want to retrieve these values. Probably my use of STORE is not correct and you have another simple solution. The problem here is that even if I declared my bean as global, this means, it will be instanciated only one time, as I saw the answers I received, it is passing two times when I call it. Thus I can conclude that it is creating two instances of my bean, one for creationEscalierBeton and another for fournitureBeton. Thus this is the reason that my StringBuffer inside the bean only have one result. Actually I want to retrieve an order list telling which rule is fired firstly, and so on. I want to retrieve as System.out.println(Order List: + rete.fetch(RESULT)); Do you know another way to FETCH the RESULT value since this RESULT should be a list of the name of my rules or the name that I am saying? If in the place of the set and store I used printout, everything works as I need. However the problem is that I need to retrieve these results. Best regards, Daniela (assert (existPlancher)) (defglobal ?*obj* = (new MarchePublicBeanPlan)) (defrule creationEscalierBeton (existPlancher) (betonFournit) = (assert (existEscalierBeton)) (set ?*obj* action creationEscalierBeton) (store RESULT (get ?*obj* action)) ) (defrule fournitureBeton (not(betonFournit)) = (assert (betonFournit)) (set ?*obj* action fournitureBeton) (store RESULT (get ?*obj* action)) ) I have this bean: import java.io.Serializable; public class MarchePublicBeanPlan implements Serializable{ private String action; public StringBuffer plan; public MarchePublicBeanPlan() { System.out.println(* Inside BEAN**); action = null; plan = new StringBuffer(); } public void setAction(String action) { System.out.println(ACTION:+action); plan.append(action); } public String getAction() { System.out.println(PLAN:+plan.toString()); return plan.toString(); } } And this is the answer I get when I rete.run it. STARTING RETE * Inside BEAN** * Inside BEAN** ACTION:fournitureBeton PLAN:fournitureBeton Order List: fournitureBeton
JESS: ExecuteCommand(variable) versus ExecuteCommand(string)
Hi folks, I am having some problems running my rules in Java using executeCommand. When I run using a variable 'knowledgeBaseRule' that is a StringBuffer rete.executeCommand(knowledgeBaseRule.toString()); I don't receive any answer and it does not call either my bean. When I catch the string given by 'knowledgeBaseRule' and I paste as shown above, everything works fine. rete.executeCommand((set-reset-globals nil)+ (reset)+ (defglobal ?*obj* = (new MarchePublicBeanPlan))+ (assert (existPlancher))+ (defrule creationEscalierBeton+ (existPlancher)+ (betonFournit)+ =+ (assert (existEscalierBeton))+ (call ?*obj* setAction 'fournitureBeton')+ (store RESULT (call ?*obj* getAction))+ )+ (defrule fournitureBeton+ (not(betonFournit))+ =+ (assert (betonFournit))+ (call ?*obj* setAction 'fournitureBeton')+ (store RESULT (call ?*obj* getAction))+ )); Am I missing something? Thanks in advance, Daniela 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]
JESS: Goal in each action
Thank you Ernest, I have more questions about it...The first one is that I'd read that Jess memorizes each rule that it passes and so Jess doesn't pass two times in the same rule. Am I right? If yes, in Monkey and Bananas example, I do not understand why it changes the goal in some actions, because for me the goal in a planner should be allways the same, for example eat bananas and as the planner is running and passing to into rules, it will not fire that rule again. If a rule has the OR operator, then as you said it creates another rule, and see below what it does. Actually, I thought that changing the goal in each action is the only way to make sure Jess will fire this rule only one time, but...how about the others solutions, how can I get them? Imagine that we have these rules: (clear) (deffacts start (fermetureFenetre pose) (fermeturePorte pose) (fauxPlafond pose) (exist cloison) ) (reset) (defrule peindre-murs-et-plafonds (fermetureFenetre pose) (fermeturePorte pose) (fauxPlafond pose) (exist cloison) = (assert (murPlafond peint)) (printout t Peint murs et plafonds crlf) ) (defrule fournir-poser-papier-peint (murPlafond peint) = (assert (papierPeint pose)) (printout t Fourniture et pose des Papiers Peint crlf) ) (defrule peindre-sol (or (murPlafond peint) (papierPeint pose)) = (assert (sol peint)) (printout t Peint le sol crlf) ) (defrule fournir-poser-moquette (sol peint) (or (murPlafond peint) (papierPeint pose)) = (assert (moquette pose)) (printout t Fourniture et pose de moquette crlf) ) (run) My answers are: Peint murs et plafonds Fourniture et pose des Papiers Peint Peint le sol Fourniture et pose de moquette Fourniture et pose de moquette Peint le sol 6 And then as Jess consider 1 as another rule, it did not stop at the first Fourniture et pose de moquette but it tries to execute the OR operator and fire the rule Fourniture et pose de moquete and Peint le sol two times. Thus is it the reason that I should change the goals in each rule to assure that Jess will fire only one time each rule even if I have an OR operator? Thus my answer in the first planner would be like that: Peint murs et plafonds Fourniture et pose des Papiers Peint Peint le sol Fourniture et pose de moquette This order is fixed based on the preconditions, but imagine that X can be executed before Y or before Z. Thus how can I force that the first plan shows me X before Y and than another plan shows me X before Z. How can I get the other plan? Here is the watch all from Jess (batch peinture.clp) == Focus MAIN == f-0 (MAIN::initial-fact) == f-1 (MAIN::fermetureFenetre pose) == f-2 (MAIN::fermeturePorte pose) == f-3 (MAIN::fauxPlafond pose) == f-4 (MAIN::exist cloison) == Activation: MAIN::peindre-murs-et-plafonds : f-1, f-2, f-3, f-4 MAIN::peindre-murs-et-plafonds: +1+1+1+1+1+1+1+2+1+1+1+2+1+1+1+2+t MAIN::fournir-poser-papier-peint: +1+1+1+1+t MAIN::peindre-sol: =1=1=1=1+t MAIN::peindre-sol1: +1+1+1+1+t MAIN::fournir-poser-moquette: +1+1+1+1=1=1=1+2+t MAIN::fournir-poser-moquette1: =1=1=1=1=1=1=1+2+t FIRE 1 MAIN::peindre-murs-et-plafonds f-1, f-2, f-3, f-4 == f-5 (MAIN::murPlafond peint) == Activation: MAIN::fournir-poser-papier-peint : f-5 == Activation: MAIN::peindre-sol : f-5 Peint murs et plafonds FIRE 2 MAIN::fournir-poser-papier-peint f-5 == f-6 (MAIN::papierPeint pose) == Activation: MAIN::peindre-sol : f-6 Fourniture et pose des Papiers Peint FIRE 3 MAIN::peindre-sol f-6 == f-7 (MAIN::sol peint) == Activation: MAIN::fournir-poser-moquette : f-7, f-5 == Activation: MAIN::fournir-poser-moquette : f-7, f-6 Peint le sol FIRE 4 MAIN::fournir-poser-moquette f-7, f-6 == f-8 (MAIN::moquette pose) Fourniture et pose de moquette FIRE 5 MAIN::fournir-poser-moquette f-7, f-5 Fourniture et pose de moquette FIRE 6 MAIN::peindre-sol f-5 Peint le sol == Focus MAIN 6 Jess Thank you!!! Daniela 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]
JESS: Capturing another solution
Hi everybody, I developed a simple plan using Jess, and I know that it can propose me another solution, how can I run Jess in order that it proposes me another plan? Actually, I want to know the ; in Prolog, what I do it in Jess? Thank you, Daniela 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]
JESS: Watch all - '1 ' inside defrule
Hi, I have one more question, I did an (watch all) to my batch program, and actually I found the in some rules that I defined it put this character 1 and it duplicate my rule. MAIN::installer-barreaux-metallique: =1=1=1=1+t MAIN::installer-barreaux-metallique1: =1=1=1=1+t What actually this means for Jess? Thank you DAniela 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]
JESS: RE: Understanding JESS
Thank you so much for your help. In fact running (watch all) I found my error. I had run a first example using this rules, I had put a rule called host, and then I changed this rule into hotel. The problem was that my rule host executed in the correct moment, putting as effects hotel ok, and at the end my rule hotel also executed and then printed hotel services. The rule host didn't print anything. Thus it was because we could only see hotel service at the end. However I have more two questions, the first one I thought that (reset) clear my knowledge base, I mean, my facts, rules, all things and actually it doesn't. What is the command I can use to clear my knowledge base? More one thing, is there any command that lists all facts before execution, for example, I only want to know which facts I have put in my knowledge base before execution. Thank you again. Daniela -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de [EMAIL PROTECTED] Envoyi : jeudi 3 novembre 2005 20:23 @ : jess-users@sandia.gov Objet : Re: JESS: Understanding JESS As you'd expect, this is impossible. It's always fun when impossible things happen, though, isn't it? One thing I notice is that number 5 at the end. That's how many rules fired. But I only would expect four (presumably the same four, in the same order, that you expect: travel, hotel, rentalcar, and goal. And indeed, the facts that are asserted seem to be exactly those that you'd expect. In any case, I ran your problem under Jess 6.1p8 and 7.0b4 and in both cases I got the expected result; four rules fired, in the order you'd expect, and the hotel output shows up in the right place. This has been run with (watch facts). Can you run it again with (watch all), and show us the output? Maybe that will give us a clue as to what's happening. I think Daniela CLARO wrote: Hi everybody, I am a new user of JESS and I am coming from Prolog's world, so I have some misunderstanding using Jess. First of all, I am trying to create a plan that I will have 3 actions: travel, hotel and rentalCar. As I have some preconditions that must be valid in order to execute an action, I want to estabilish a first order. I have only 3 actions because I am trying to understand Jess, so I need to know what exactly they are doing. How can I do the prolog's trace in Jess? Because he shows me only the steps and the result, but if I want to do step by step. I tried to create a batch file, here it is: (reset) (assert (in paris) (passportValid paris salvador)) (defrule travel Travel (in paris) (passportValid paris salvador) = (printout t Travel service crlf) (assert (in salvador) (travel ok) (airportArea salvador laurofreitas)) ) (defrule hotel Hotel (in salvador) (travel ok) = (printout t Hotel service crlf) (assert (hotel ok)) ) (defrule rentalcar Rental a car (in salvador) (travel ok) (hotel ok) (airportArea salvador laurofreitas) = (printout t Rental Car service crlf) (assert (car ok)) ) (defrule goal Aim the goal (travel ok) (hotel ok) (car ok) = (printout t End of the plan crlf) ) (run) When I run it, I receive this answer: Jess (batch Z:/Implementacao/planning/travel.clp) == f-0 (MAIN::initial-fact) == f-1 (MAIN::in paris) == f-2 (MAIN::passportValid paris salvador) Travel service == f-3 (MAIN::in salvador) == f-4 (MAIN::travel ok) == f-5 (MAIN::airportArea salvador laurofreitas) == f-6 (MAIN::hotel ok) Rental Car service == f-7 (MAIN::car ok) End of the plan Hotel service 5 The first thing that I do not understand was why it writes Hotel service at the end if it was executed in the middle as we can see f-6 The next question, I have read about Jess but actually I do not understand what is exactly the best use for deftemplates? I know it is like classes/objects in Java, but in an inference motor where should I use it? In my example here, I thought that I could use, but actually I did not find where I can put it. Thanks in advance for all your help. Daniela 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] - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (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
JESS: Understanding JESS
Hi everybody, I am a new user of JESS and I am coming from Prolog's world, so I have some misunderstanding using Jess. First of all, I am trying to create a plan that I will have 3 actions: travel, hotel and rentalCar. As I have some preconditions that must be valid in order to execute an action, I want to estabilish a first order. I have only 3 actions because I am trying to understand Jess, so I need to know what exactly they are doing. How can I do the prolog's trace in Jess? Because he shows me only the steps and the result, but if I want to do step by step. I tried to create a batch file, here it is: (reset) (assert (in paris) (passportValid paris salvador)) (defrule travel Travel (in paris) (passportValid paris salvador) = (printout t Travel service crlf) (assert (in salvador) (travel ok) (airportArea salvador laurofreitas)) ) (defrule hotel Hotel (in salvador) (travel ok) = (printout t Hotel service crlf) (assert (hotel ok)) ) (defrule rentalcar Rental a car (in salvador) (travel ok) (hotel ok) (airportArea salvador laurofreitas) = (printout t Rental Car service crlf) (assert (car ok)) ) (defrule goal Aim the goal (travel ok) (hotel ok) (car ok) = (printout t End of the plan crlf) ) (run) When I run it, I receive this answer: Jess (batch Z:/Implementacao/planning/travel.clp) == f-0 (MAIN::initial-fact) == f-1 (MAIN::in paris) == f-2 (MAIN::passportValid paris salvador) Travel service == f-3 (MAIN::in salvador) == f-4 (MAIN::travel ok) == f-5 (MAIN::airportArea salvador laurofreitas) == f-6 (MAIN::hotel ok) Rental Car service == f-7 (MAIN::car ok) End of the plan Hotel service 5 The first thing that I do not understand was why it writes Hotel service at the end if it was executed in the middle as we can see f-6 The next question, I have read about Jess but actually I do not understand what is exactly the best use for deftemplates? I know it is like classes/objects in Java, but in an inference motor where should I use it? In my example here, I thought that I could use, but actually I did not find where I can put it. Thanks in advance for all your help. Daniela 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]