Re: Matching multislots with JessTab/ Protege [was: JESS: Help on Jess Rules ..plz]

2006-07-11 Thread John
Hi,Thank you Ernest for your help, it worked. (MAIN::object (is-a A) (OBJECT ?ab) (ID $?b 111 $?a))However, when I use the variable $?a in the RHS, it gives me a error message stating that, no such variable a. 
I was stuck up with one more bug. Why does a slot-set in RHS of a rule creates an infinite loop? (defrule match (MAIN::object (is-a A) (OBJECT ?ab) (ID $?b 111 $?a)) (MAIN::object (is-a B) (OBJECT ?bb)(listofA $? ?ab $?))
 (MAIN::object (is-a C) (OBJECT ?cc)(listofB $? ?bb $?)) =(slot-set ?cc Name John))The above rule updates the slot Name infinitely. Does the update fires the rule again? If so how do i update a slot value inside the rule?
Thanx for any help in adv.JFCOn 7/9/06, friedman_hill ernest j [EMAIL PROTECTED]
 wrote:I think John wrote: However, (defrule match
 (MAIN::object (is-a A) (OBJECT ?ab) (ID $?b 111 $?a)) (MAIN::object (is-a B) (OBJECT ?bb)(listofA $?before ?ab $?after)) (MAIN::object (is-a C) (OBJECT ?cc)(listofB $?before ?bb $?after))
 =) the above rule never activates. The rule on Class C never returns true.My guess is that this is because you've used the same named variablesbefore and after in both patterns; this is telling Jess that the
before and after parts of the multislots should be the same in bothfacts, which I don't think is what you intend.Instead of using named variables, use blank variables -- i.e., (MAIN::object (is-a B) (OBJECT ?bb)(listofA $? ?ab $?))
 (MAIN::object (is-a C) (OBJECT ?cc)(listofB $? ?bb $?))The alternative, of course, is to use different names for bothpatterns, which seems inelegant to me, given that the values of thevariables aren't going to be used.
-Ernest Friedman-HillAdvanced Software ResearchPhone: (925) 294-2154Sandia National LabsFAX: (925) 294-2234PO 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].



Re: Matching multislots with JessTab/ Protege [was: JESS: Help on Jess Rules ..plz]

2006-07-11 Thread friedman_hill ernest j
I think John wrote:
 
  (MAIN::object (is-a A) (OBJECT ?ab) (ID $?b 111 $?a))
 
 However, when I use the variable $?a in the RHS, it gives me a error message
 stating that, no such variable a.

You should be able to use it just fine; check your work, or show us
the rule that's having the problem.
 
 I was stuck up with one more bug. Why does a slot-set in RHS of a rule
 creates an infinite loop?

This is a classic problem in rule-based systems. There are a number
of solutions, although the better ones are specific to Jess 7. In Jess
6, the only thing you can do is modify the left-hand-side of the rule
so that after you modify the fact, it won't match anymore. For
example, if the right-hand-side modifies the name slot to be John,
then add to the pattern on the left-hand-side so it only matched is
the name slot is not John.

In Jess 7, there is the no-loop declaration, which can be applied to
rules to explicitly break this kind of loop; and there's the
slot-specific declaration for templates, which breaks loops in which
slots not matched on the left-hand-side are being modified on the
right-hand-side. 



-
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]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]




Re: Matching multislots with JessTab/ Protege [was: JESS: Help on Jess Rules ..plz]

2006-07-09 Thread friedman_hill ernest j
I think John wrote:
 
 However,
 
 (defrule match
 (MAIN::object (is-a A) (OBJECT ?ab) (ID $?b 111 $?a))
 (MAIN::object (is-a B) (OBJECT ?bb)  (listofA $?before ?ab $?after))
 (MAIN::object (is-a C) (OBJECT ?cc)  (listofB $?before ?bb $?after))
 =)
 
 the above rule never activates. The rule on Class C never returns true.


My guess is that this is because you've used the same named variables
before and after in both patterns; this is telling Jess that the
before and after parts of the multislots should be the same in both
facts, which I don't think is what you intend.

Instead of using named variables, use blank variables -- i.e., 

 (MAIN::object (is-a B) (OBJECT ?bb)  (listofA $? ?ab $?))
 (MAIN::object (is-a C) (OBJECT ?cc)  (listofB $? ?bb $?))

The alternative, of course, is to use different names for both
patterns, which seems inelegant to me, given that the values of the
variables aren't going to be used.

-
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]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]




Re: Matching multislots with JessTab/ Protege [was: JESS: Help on Jess Rules ..plz]

2006-07-03 Thread Samson Tu


Like Ernest, I was confused by the terminology being used to describe 
the problem, until I loaded the Protege project and saw what you are 
trying to do. I think the JESS rule you want is (minus the back-slashes 
and spaces):


(defrule simple-multi-multi-match
   (object (is-a Hello)(OBJECT ?hello) (ResourceID $?b 111 $?a))
   ?behavior - (object (is-a NodeSpoof) (Resourcesequence $?before 
?hello $?after))

 =
(printout t Behavior ID:  (slot-get ?behavior BehaviorID)  crlf))

In JessTab translation of Protege instances to Jess facts, you have the 
Jess template slot OBJECT that references the object corresponding to 
the translated fact. That's what you can use in your subsequent matches 
for objects.



John wrote:


Q1. what is the logical difference between

(defglobal ?*re* = (nth$ 1 (find-all-instances ((?h Hello)) (member$ 111 
(slot-get ?h Resource\ ID)


and

(defglobal ?*re* = (nth$ 1 (find-all-instances ((?h Hello)) (eq 
(slot-get ?h Resource\ ID) 111


Because, the second statement points to the first instance, even if 
there is no field matching 111. Just try slot-get after the defglobal in 
Jess prompt to confirm.


The second statement should be empty, if your Resource\ ID slot has 
cardinality multiple. Thus (slot-get ?h Resource\ ID) is a list, and can 
never equal 111. So find-all-instances should return the empty list.


Samson
--
Samson Tuemail: [EMAIL PROTECTED]
Senior Research Scientistweb: www.stanford.edu/~swt/
Stanford Medical Informatics phone: 1-650-725-3391
Stanford University  fax: 1-650-725-7944

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: Matching multislots with JessTab/ Protege [was: JESS: Help on Jess Rules ..plz]

2006-07-01 Thread friedman_hill ernest j
I think John wrote:

 It is fascinating as well as frustrating as solving problem bring forth new
 ones.

Frustrating, indeed. There are two quite different sets of terminology
and concepts all smushed together in this thread (Jess and Protege)
and although I can guess at what's being discussed at times, I'm never
quite sure. One of these days I'm going to have to make a study of
Protege and JessTab so I can contribute to this kind of discussion. As
it is, there are but a few places where I can contribute something, so
I'll give it a try.

 
 Q2. What is the difference between defglobal and bind?
 
 I understand defglobal is global and reset doesnt affect it. But I see funny
 things. In the project I gave in my last mail, jus change
 (defglobal ?*res* = ...
 to 
 (bind ?res ...
 I get funny results. (change the variable in defrule also)


A defglobal is sort of like a Java static variable, whereas a variable
created by bind' at the command prompt is like a local variable,
available only at the command prompt. If you define a rule and
use a variable of the same name, the fact that the local variable at
the command prompt exists is completely irrelevant -- it will be
utterly ignored. So while using the name of a defglobal on the left
side of a rule means to match a slot to the value of a defglobal,
using the name of a local variable defined at the prompt is just like
using any other variable name -- the variable is bound to whatever
value is in that slot, and matching continues. To repeat: any value
bound to a local variable at the prompt is completely irrelevant in
the definition or behavior of any rules.

 Q3. Can rules can be nested?

No. Not sure what that would even mean.

 
 Finally, Dona, my problem of matching multifield to multifield instance slot
 is still unsolved.
 
 find-all-instances provides a list of matching fields. However, inside the
 rule, the matching occurs only to the head instance of the list.
 
 Why is the below code not firing any rules
 
 (defrule simple-multi-multi-match
 
 ?rem - (object(is-a Hello) (Resource\ ID $?before 111 $?after))
 ?behavior - (object(is-a Node\ Spoof) (Resource\ sequence $?before
 ?rem $?after))
  =
 (printout t Behavior ID\:  (slot-get ?behavior Behavior\ ID)  crlf))
 
 I understand ?rem is an object,

Specifically, it's a jess.Fact object. Perhaps the Java instance
you're interested in is held in a slot named OBJECT, which is how
normal Jess definstances work. Have you tried that?

 then how do I get the multi-slot value from
 it, to use in second statement.(without defglobals)

I think part of the difficulty here is that we're using different terms
to describe the same things, and as a result, we're not
communicating.

A FACT has slots. The thing that you're matching with a PATTERN like
(object... is a FACT. A FACT has SLOTS. The things that you're
matching like (is-a... and (Resource\ sequence are SLOTS. Some
SLOTs are single slots, which can hold only a single value. Other
slots are MULTISLOTS, which hold a list of zero or more values of any
kind. Every SLOT has a name.

One thing about Jess multislots (and Jess lists in general) is that
they are *flat*. If you try to construct a list which contains nested
lists, they all get flattened to a single one-dimensional list. A list
(or multislot) can, however, contain arbitrary Java objects, including
other jess.Fact objects (which themselves have slots of their own) or
Protege instances.

So *WHICH* multislot(s) is/are of interest? And what exactly are the
types of the values that they hold? I'm sure that the questions you're
asking have straightforward answers. But without clear answers to *my*
questions, I can't be of any help to you at all.

-
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]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]




Re: Matching multislots with JessTab/ Protege [was: JESS: Help on Jess Rules ..plz]

2006-06-30 Thread John
Hi Dona,It is fascinating as well as frustrating as solving problem bring forth new ones. Honestly, I dont know how the error vanished off my screen. I was trying something else and incidently the bug buggered off. 
However, I dont see any difference in your code and mine. I reckon the problem is with protege instances. Sorry that I didnt help much about it.I got interesting questions from the problems I faced.
Q1. what is the logical difference between(defglobal ?*re* = (nth$ 1 (find-all-instances ((?h Hello)) (member$ 111 (slot-get ?h Resource\ ID)and(defglobal ?*re* = (nth$ 1 (find-all-instances ((?h Hello)) (eq (slot-get ?h Resource\ ID) 111
Because, the second statement points to the first instance, even if there is no field matching 111. Just try slot-get after the defglobal in Jess prompt to confirm. Q2. What is the difference between defglobal and bind? 
I understand defglobal is global and reset doesnt affect it. But I see funny things. In the project I gave in my last mail, jus change(defglobal ?*res* = (nth$ 1 (find-instance ((?h Hello)) (slot-get ?h Resource\ ID ?n:(member$ 111 ?n)
to(bind ?res (nth$ 1 (find-instance ((?h Hello)) (slot-get ?h Resource\ ID ?n:(member$ 111 ?n)I get funny results. (change the variable in defrule also)Q3. Can rules can be nested?
Finally, Dona, my problem of matching multifield to multifield instance slot is still unsolved.find-all-instances provides a list of matching fields. However, inside the rule, the matching occurs only to the head instance of the list.
Why is the below code not firing any rules(defrule simple-multi-multi-match ?rem - (object(is-a Hello) (Resource\ ID $?before 111 $?after))  ?behavior - (object(is-a Node\ Spoof) (Resource\ sequence $?before ?rem $?after))
 = (printout t Behavior ID\:  (slot-get ?behavior Behavior\ ID) crlf))I understand ?rem is an object, then how do I get the multi-slot value from it, to use in second statement.(without defglobals)
In the project i gave in last mail:The expected rule firing and output:Jess (batch h:\\CLIPS\\simple.clp)Behavior ID: 5Behavior ID: 2Behavior ID: 13Observed:Jess (batch h:\\CLIPS\\simple.clp)
[Activation: MAIN::simple-multi-multi-match f-472 ; time=794 ; salience=0][Activation: MAIN::simple-multi-multi-match f-468 ; time=786 ; salience=0]For a total of 2 activations in module MAIN.Behavior ID: 5
Behavior ID: 12Thx indeed, for your time.JFCOn 6/30/06, Dona Mommsen [EMAIL PROTECTED]
 wrote:Hi John,On Jun 29, 2006, at 3:54 AM, John wrote: Hi, Im back with problems, but quite interesting ones.
 I solved the problem Dona have listed in her last mail. However, I found more problems while doing so.I apologize that I didn't have the time to look into it. But now I'mcurious: How did you get rid of the error message? 
 Jess reported an error in routine ValueVector.setwhile executing rule LHS (TECT).
 Message: Bad index 5 in call to set() on this vector: (MAIN::object (is-a Hello) (is-a-name Hello) (OBJECT Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance
) (Neighbor Address rst uvw xyz) (Resource ID 4)). Program text: ( defrule testnest3 ?r2 - ( MAIN::object ( is-a Node Spoof ) ( Resource sequence $?r  : ( member$ ?*a* $?r ) ) ) =  (
 printout t Node ( slot-get ?r2 Behavior ID ) crlf ) )at line 7. I tried to match multislot to multislot instances. The problem is that only first occurence of the instance is searched. I have attached the
 protege/Jess project files. This project is just a modified implementation of Dona's model. The Jess batch files contains the pattern matching rules ( simple.clp). From the scripts:
 (mapclass :THING)Well, I don't know if it is relevant, but I usually don't do(mapclass:THING), because it maps the entire Protege system classes (unnecessaryoverload in your fact base if you are not doing anyting with them). In
addition, this mapping includes also the JessTab classes, see under:SYSTEM-CLASS there are subclasses :JESS-ENGINGE, :JESS-DEFINITION,:RULE, :FUNCTION. It would confuse me if I had them in the fact base.On my system it apparentlyalso troubles Protege. When I tried
(mapclass :THING) everyting got asserted in the fact base, but calling(clear) instantly crashes Protege. Have you tried to (clear) your factbase? I wonder if this Is a version-specific issue on my machine, or a
general thing not to map :THING. Although I assume that you are usingprotege frames, note that the JessTab website explicitly warns of doingthat with owl projects: Avoid doing (mapclass owl:Thing) under OWL, because JessTab will map
 all the hidden RDF/OWL classes as well, which may result in a large amount of unwanted Jess facts and stability problems. For the same reason, avoid mapping metaclasses and metaproperties under OWL. Use an
 intermediate subclass of owl:Thing and map this class instead. ;matching the integer 111 in the multislot Resource ID(defglobal ?*res* = (nth$ 1 (find-instance ((?h Hello)) (slot-get ?h
 Resource\ ID ?n:(member$ 111 ?n)Putting just one 

Re: Matching multislots with JessTab/ Protege [was: JESS: Help on Jess Rules ..plz]

2006-06-27 Thread John
Hi Dona,thx for helping me out. But what if the slot Resource ID is itself a multislot? how do I match multislot to a multislot of instances?Thx for your time.John Felix C J
On 6/23/06, Dona Mommsen [EMAIL PROTECTED] wrote:
Hi John,I was trying to reproduce John's small example and I was convinced thatmatching multislots with Protege is possible.I used the model described by John (see below).I created 4 Instances of Hello with Resource\ ID 1 through 4
I created 3 Instances of Node\ Spoof:Behavior\ ID A Resource sequence (1 3 4)Behavior\ ID B Resource sequence (2 3)Behavior\ ID C Resource sequence (1 2 3 4)These are all mapped Protege instances, so the multislot resource
sequence is actually a list of Protege intstances.For example, the fact for the instance with Behavior\ ID A looks likethis:(MAIN::object (is-a Node Spoof) (is-a-name Node Spoof) (OBJECT
Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance)(Resource sequenceJava-Object:edu.stanford.smi.protege.model.DefaultSimpleInstanceJava-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance
Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance)(Behavior ID A))I simplified the rule just to match multislots with instances, and Itried 2 alternatives, one with return value constraint and one with the
multifield.For each test, I bind a Protege instance to a global variable that Iuse in the rules. ;; ;;Example with return value constraint cf. JiA p. 106 ;; Hello with Resource ID 1 is in Node Spoof A and C
 ;; (defglobal ?*a* = (nth$ 1 (find-instance ((?h Hello)) (eq (slot-get?h Resource\ ID) 1 (defrule testnest3?r2 - (MAIN::object (is-a Node\ Spoof) (Resource\ sequence
$?r:(member$ ?*a* $?r))) = (printout t Node (slot-get ?r2 Behavior\ ID)crlf)) ;; ;;Example with multifields JiA p. 103 ;; Hello with Resource ID 2 is in Node Spoof B and C
 ;; (defglobal ?*b* = (nth$ 1 (find-instance ((?h Hello)) (eq (slot-get?h Resource\ ID) 2 (defrule testnest4?r2 - (MAIN::object (is-a Node\ Spoof) (Resource\ sequence $?before
?*b* $?after)) = (printout t Node (slot-get ?r2 Behavior\ ID)crlf))The rules match properly and fire, but I do get error messages in bothcases: Jess (defrule testnest3?r2 - (MAIN::object (is-a Node\ Spoof)
 (Resource\ sequence $?r:(member$ ?*a* $?r))) = (printout t Node (slot-get ?r2 Behavior\ ID)crlf)) == Activation: MAIN::testnest3 :f-4 == Activation: MAIN::testnest3 :f-6
 Jess reported an error in routine ValueVector.set while executing rule LHS (TECT). Message: Bad index 5 in call to set() on this vector: (MAIN::object (is-a Hello) (is-a-name Hello) (OBJECT
 Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance) (Neighbor Address rst uvw xyz) (Resource ID 4)). Program text: ( defrule testnest3 ?r2 - ( MAIN::object ( is-a Node
 Spoof ) ( Resource sequence $?r  : ( member$ ?*a* $?r ) ) ) =  ( printout t Node ( slot-get ?r2 Behavior ID ) crlf ) )at line 7. Jess (run) FIRE 1 MAIN::testnest3 f-6
 NodeC FIRE 2 MAIN::testnest3 f-4 NodeA 2 Jess (defrule testnest4?r2 - (MAIN::object (is-a Node\ Spoof) (Resource\ sequence $?before ?*b* $?after)) = (printout t
 Node (slot-get ?r2 Behavior\ ID)crlf)) == Activation: MAIN::testnest4 :f-5 == Activation: MAIN::testnest4 :f-6 Jess reported an error in routine ValueVector.set
 while executing rule LHS (TECT). Message: Bad index 5 in call to set() on this vector: (MAIN::object (is-a Hello) (is-a-name Hello) (OBJECT Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance
) (Neighbor Address rst uvw xyz) (Resource ID 4)). Program text: ( defrule testnest4 ?r2 - ( MAIN::object ( is-a Node Spoof ) ( Resource sequence $?before ?*b* $?after ) ) =  ( printout t
 Node ( slot-get ?r2 Behavior ID ) crlf ) )at line 9. Jess (run) FIRE 1 MAIN::testnest4 f-6 NodeC FIRE 2 MAIN::testnest4 f-5 NodeB 2While Jess is still able to fire the rules correctly, it is about the
last thing it does before Protege hangs.Any idea what is going on here?I'm using Protege 3.1.1 Build 216, JessTab 1.4, Jess 7.0b4 on Mac OS X10.3.9Thanks in advance for any hintsDona
P.S.: I'll gladly send the Protege project to anyone interested.On Jun 21, 2006, at 9:01 PM, John wrote: first, thx for Dona  Jason for their valuable comments. Yes, Dona, your guess is right. I am using protege in combo with Jess. I see
 protege is more powerful if you combine the Jess features. As Dona have accurately guessed, I used JessTab to map instances and classes created in protege to Jess. Jason, Assert(ion) in Jess(with protoge) is done by a GUI interface
 (Form based). The problem is that the object variable (for the multislots) is a single instance address and doesnt contain the actual contents. As of the contents of the Hello and Node Spoof class;
 Hello class contain two slots: Resource ID and Neighbor Address(multislot type string) Node Spoof: Behavior ID (string) and Resouce sequence (multislot type Hello)
 

Re: Matching multislots with JessTab/ Protege [was: JESS: Help on Jess Rules ..plz]

2006-06-27 Thread John
Hi all,Dona, I figured a way to match multislots with multislot instance. However Im not able to solve the error you pointed out. Any help will be great.thx in advance.JFC
On 6/27/06, John [EMAIL PROTECTED] wrote:
Hi Dona,thx for helping me out. But what if the slot Resource ID is itself a multislot? how do I match multislot to a multislot of instances?Thx for your time.John Felix C J

On 6/23/06, Dona Mommsen [EMAIL PROTECTED] wrote:

Hi John,I was trying to reproduce John's small example and I was convinced thatmatching multislots with Protege is possible.I used the model described by John (see below).I created 4 Instances of Hello with Resource\ ID 1 through 4
I created 3 Instances of Node\ Spoof:Behavior\ ID A Resource sequence (1 3 4)Behavior\ ID B Resource sequence (2 3)Behavior\ ID C Resource sequence (1 2 3 4)These are all mapped Protege instances, so the multislot resource
sequence is actually a list of Protege intstances.For example, the fact for the instance with Behavior\ ID A looks likethis:(MAIN::object (is-a Node Spoof) (is-a-name Node Spoof) (OBJECT

Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance)(Resource sequenceJava-Object:edu.stanford.smi.protege.model.DefaultSimpleInstanceJava-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance

Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance)(Behavior ID A))I simplified the rule just to match multislots with instances, and Itried 2 alternatives, one with return value constraint and one with the
multifield.For each test, I bind a Protege instance to a global variable that Iuse in the rules. ;; ;;Example with return value constraint cf. JiA p. 106 ;; Hello with Resource ID 1 is in Node Spoof A and C
 ;; (defglobal ?*a* = (nth$ 1 (find-instance ((?h Hello)) (eq (slot-get?h Resource\ ID) 1 (defrule testnest3?r2 - (MAIN::object (is-a Node\ Spoof) (Resource\ sequence
$?r:(member$ ?*a* $?r))) = (printout t Node (slot-get ?r2 Behavior\ ID)crlf)) ;; ;;Example with multifields JiA p. 103 ;; Hello with Resource ID 2 is in Node Spoof B and C
 ;; (defglobal ?*b* = (nth$ 1 (find-instance ((?h Hello)) (eq (slot-get?h Resource\ ID) 2 (defrule testnest4?r2 - (MAIN::object (is-a Node\ Spoof) (Resource\ sequence $?before
?*b* $?after)) = (printout t Node (slot-get ?r2 Behavior\ ID)crlf))The rules match properly and fire, but I do get error messages in bothcases: Jess (defrule testnest3?r2 - (MAIN::object (is-a Node\ Spoof)
 (Resource\ sequence $?r:(member$ ?*a* $?r))) = (printout t Node (slot-get ?r2 Behavior\ ID)crlf)) == Activation: MAIN::testnest3 :f-4 == Activation: MAIN::testnest3 :f-6
 Jess reported an error in routine ValueVector.set while executing rule LHS (TECT). Message: Bad index 5 in call to set() on this vector: (MAIN::object (is-a Hello) (is-a-name Hello) (OBJECT
 Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance) (Neighbor Address rst uvw xyz) (Resource ID 4)). Program text: ( defrule testnest3 ?r2 - ( MAIN::object ( is-a Node
 Spoof ) ( Resource sequence $?r  : ( member$ ?*a* $?r ) ) ) =  ( printout t Node ( slot-get ?r2 Behavior ID ) crlf ) )at line 7. Jess (run) FIRE 1 MAIN::testnest3 f-6
 NodeC FIRE 2 MAIN::testnest3 f-4 NodeA 2 Jess (defrule testnest4?r2 - (MAIN::object (is-a Node\ Spoof) (Resource\ sequence $?before ?*b* $?after)) = (printout t
 Node (slot-get ?r2 Behavior\ ID)crlf)) == Activation: MAIN::testnest4 :f-5 == Activation: MAIN::testnest4 :f-6 Jess reported an error in routine ValueVector.set

 while executing rule LHS (TECT). Message: Bad index 5 in call to set() on this vector: (MAIN::object (is-a Hello) (is-a-name Hello) (OBJECT Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance

) (Neighbor Address rst uvw xyz) (Resource ID 4)). Program text: ( defrule testnest4 ?r2 - ( MAIN::object ( is-a Node Spoof ) ( Resource sequence $?before ?*b* $?after ) ) =  ( printout t
 Node ( slot-get ?r2 Behavior ID ) crlf ) )at line 9. Jess (run) FIRE 1 MAIN::testnest4 f-6 NodeC FIRE 2 MAIN::testnest4 f-5 NodeB 2While Jess is still able to fire the rules correctly, it is about the
last thing it does before Protege hangs.Any idea what is going on here?I'm using Protege 3.1.1 Build 216, JessTab 1.4, Jess 7.0b4 on Mac OS X10.3.9Thanks in advance for any hintsDona

P.S.: I'll gladly send the Protege project to anyone interested.On Jun 21, 2006, at 9:01 PM, John wrote: first, thx for Dona  Jason for their valuable comments. Yes, Dona, your guess is right. I am using protege in combo with Jess. I see
 protege is more powerful if you combine the Jess features. As Dona have accurately guessed, I used JessTab to map instances and classes created in protege to Jess. Jason, Assert(ion) in Jess(with protoge) is done by a GUI interface
 (Form based). The problem is that the object variable (for the multislots) is a single instance address and doesnt contain the actual 

Matching multislots with JessTab/ Protege [was: JESS: Help on Jess Rules ..plz]

2006-06-22 Thread Dona Mommsen

Hi John,

I was trying to reproduce John's small example and I was convinced that 
matching multislots with Protege is possible.


I used the model described by John (see below).
I created 4 Instances of Hello with Resource\ ID 1 through 4
I created 3 Instances of Node\ Spoof:
Behavior\ ID A Resource sequence (1 3 4)
Behavior\ ID B Resource sequence (2 3)
Behavior\ ID C Resource sequence (1 2 3 4)

These are all mapped Protege instances, so the multislot resource 
sequence is actually a list of Protege intstances.
For example, the fact for the instance with Behavior\ ID A looks like 
this:


(MAIN::object (is-a Node Spoof) (is-a-name Node Spoof) (OBJECT 
Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance) 
(Resource sequence 
Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance 
Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance 
Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance) 
(Behavior ID A))


I simplified the rule just to match multislots with instances, and I 
tried 2 alternatives, one with return value constraint and one with the 
multifield.
For each test, I bind a Protege instance to a global variable that I 
use in the rules.


  ;;
;;Example with return value constraint cf. JiA p. 106
;; Hello with Resource ID 1 is in Node Spoof A and C
;;
(defglobal ?*a* = (nth$ 1 (find-instance ((?h Hello)) (eq (slot-get 
?h Resource\ ID) 1


(defrule testnest3
 ?r2 - (MAIN::object (is-a Node\ Spoof) (Resource\ sequence 
$?r:(member$ ?*a* $?r)))

=
(printout t Node (slot-get ?r2 Behavior\ ID)  crlf))

;;
;;Example with multifields JiA p. 103
;; Hello with Resource ID 2 is in Node Spoof B and C
;;

(defglobal ?*b* = (nth$ 1 (find-instance ((?h Hello)) (eq (slot-get 
?h Resource\ ID) 2


  (defrule testnest4
 ?r2 - (MAIN::object (is-a Node\ Spoof) (Resource\ sequence $?before 
?*b* $?after))

=
(printout t Node (slot-get ?r2 Behavior\ ID)  crlf))

The rules match properly and fire, but I do get error messages in both 
cases:



Jess (defrule testnest3  ?r2 - (MAIN::object (is-a Node\ Spoof) 
(Resource\ sequence $?r:(member$ ?*a* $?r))) = (printout t 
Node (slot-get ?r2 Behavior\ ID)  crlf))

== Activation: MAIN::testnest3 :  f-4
== Activation: MAIN::testnest3 :  f-6
Jess reported an error in routine ValueVector.set
while executing rule LHS (TECT).
  Message: Bad index 5 in call to set() on this vector: (MAIN::object 
(is-a Hello) (is-a-name Hello) (OBJECT 
Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance) 
(Neighbor Address rst uvw xyz) (Resource ID 4)).
  Program text: ( defrule testnest3 ?r2 - ( MAIN::object ( is-a Node 
Spoof ) ( Resource sequence $?r  : ( member$ ?*a* $?r ) ) ) =  ( 
printout t Node ( slot-get ?r2 Behavior ID ) crlf ) )  at line 7.

Jess (run)
FIRE 1 MAIN::testnest3 f-6
NodeC
FIRE 2 MAIN::testnest3 f-4
NodeA
2


Jess (defrule testnest4  ?r2 - (MAIN::object (is-a Node\ Spoof) 
(Resource\ sequence $?before ?*b* $?after)) = (printout t 
Node (slot-get ?r2 Behavior\ ID)  crlf))

== Activation: MAIN::testnest4 :  f-5
== Activation: MAIN::testnest4 :  f-6
Jess reported an error in routine ValueVector.set
while executing rule LHS (TECT).
  Message: Bad index 5 in call to set() on this vector: (MAIN::object 
(is-a Hello) (is-a-name Hello) (OBJECT 
Java-Object:edu.stanford.smi.protege.model.DefaultSimpleInstance) 
(Neighbor Address rst uvw xyz) (Resource ID 4)).
  Program text: ( defrule testnest4 ?r2 - ( MAIN::object ( is-a Node 
Spoof ) ( Resource sequence $?before ?*b* $?after ) ) =  ( printout t 
Node ( slot-get ?r2 Behavior ID ) crlf ) )  at line 9.

Jess (run)
FIRE 1 MAIN::testnest4 f-6
NodeC
FIRE 2 MAIN::testnest4 f-5
NodeB
2


While Jess is still able to fire the rules correctly, it is about the 
last thing it does before Protege hangs.

Any idea what is going on here?
I'm using Protege 3.1.1 Build 216, JessTab 1.4, Jess 7.0b4 on Mac OS X 
10.3.9


Thanks in advance for any hints

Dona

P.S.: I'll gladly send the Protege project to anyone interested.



On Jun 21, 2006, at 9:01 PM, John wrote:

first, thx for Dona  Jason for their valuable comments. Yes, Dona, 
your guess is right. I am using protege in combo with Jess. I see 
protege is more powerful if you combine the Jess features. As Dona 
have accurately guessed, I used JessTab to map instances and classes 
created in protege to Jess.


Jason, Assert(ion) in Jess(with protoge) is done by a GUI interface 
(Form based).  The problem is that the object variable (for the 
multislots) is a single instance address and doesnt contain the actual 
contents.


As of the contents of the Hello and Node Spoof class;

Hello class contain two slots: Resource ID and Neighbor 
Address(multislot type string)


Node Spoof: Behavior ID (string) and Resouce sequence (multislot