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 type
Hello)
When I pattern - match the resource sequence, the matching returns
false always since LHS obtains just the instance address of resource
sequence and not the contents of the multislot.
One more silly question; is CLIPS more advanced than JESS? I see lot
of common syntax and features between them. Then why not use CLIPS?
Also from some sources, I heard CLIPS is more powerful and portable to
various other language.
Thx in advance.
On 6/22/06, Dona Mommsen <[EMAIL PROTECTED]> wrote:
I apologize for barging in. I'm just guessing that John might be using
Jess in combination with Protégé
>> (object (is-a Node\ Spoof) (resource\ sequence $? ?o $?)
(Behavior\
>> ID ?bid))
looks very much like a mapped instance with JessTab. Asserting facts
with mapclass or mapinstance creates facts that have
> this "object/is-a" thing
Usually this shouldn't interfere with the efficiency and possibilities
of using Jess.
Dona
On Jun 21, 2006, at 6:47 AM, friedman_hill ernest j wrote:
> This should work fine if the "resource sequence" multislot contains
> the actual fact object; if you showed us where you assert the
"Hello"
> fact, then I could probably tell you what's gone wrong.
>
> While we're here, I should ask why you're doing this "object/is-a"
> thing, rather than having a "hello" template and a "node spoof"
> template; you're doing a lot of extra work to make sure Jess can't
> work very efficiently. And I can tell you that the "and" is not
needed
> here; all the patterns on the LHS of a rule are implicitly "and"-ed
> together. And finally, my goodness, you're going to drive yourself
> nuts embedding spaces into symbols like this -- don't do that!
>
> I think John wrote:
> [Charset iso-8859-1 unsupported, filtering to ASCII...]
>> Hi all,
>>
>> I am a rookie to jess. I was stuck-up with this problem for the
past
>> 24-hrs.
>> So kindly advice.
>>
>> I created two classes with multislots. The second class has a
>> multislot of
>> type - instance of the previous class. I am not able to pattern
match
>> the
>> instance in the second class's object. Multislot pattern works well
>> for
>> strings. How can i do it for multislot of instances? I have
attached
>> the
>> snippet for your kind perusal. Please Help.
>>
>>
>> (defrule testnest
>> (and
>>
>> ?o<- (object (is-a Hello) (Neighbor\ Address $? "10.0.0.1" $?)
>> (Resource\ ID
>> ?rid))
>>
>> ?r2 <- (object (is-a Node\ Spoof) (resource\ sequence $? ?o $?)
>> (Behavior\
>> ID ?bid))
>> =>
>>
>> (printout t "Attack" crlf))
>>
>> The Two Classes: Hello and Node Spoof
>>
>> Multifield slots : Neighbor Address (type STRING) and resource
>> sequence
>> (is-a Hello)
>>
>> Thanx in Advance
>
>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Advanced Software 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]
> --------------------------------------------------------------------
>
--------------------------------------------------------------------
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]
--------------------------------------------------------------------