It would be more efficient to use pattern matching rather than test.

(defrule locality-street
    (agreement (of-type "locality") (of-value ?ov)
               (with-type "street") (with-value ?wv))
    (potential-element (type "locality") (value ?locality&?ov))
    (potential-element (type "street") (value ?street&?wv))
    =>
    (assert (locality-street-match (locality-value ?locality)
                                   (street-value ?street))))

Bob Kirby

At 12:12 PM 7/30/2007, Robert Kirby wrote:
>I would help to pretty-print your rules.  If you had, you could see that you 
>have (eq ?ov ?locality) (eq ?wv ?street) as patterns within an "and" to be 
>matched rather than (test (and (eq ?ov ?locality) (eq ?wv ?street))).  By the 
>way, the outer "and" on the LHS of locality-stree is unnecessary.
>
>Bob Kirby
At 12:07 PM 7/30/2007, Orchard, Bob wrote:
>The tests require using a test construct ...
> 
>(defrule locality-street 
>  (and (agreement (of-type "locality")(of-value ?ov)(with-type 
> "street")(with-value ?wv))
>       (potential-element (type "locality")(value ?locality)) 
>       (potential-element (type "street")(value ?street)) 
>       (test (eq ?ov ?locality)) 
>       (test (eq ?wv ?street))
>   ) 
>  => 
>   (assert (locality-street-match (locality-value ?locality)(street-value 
> ?street) ) )  
> ) 
>You can also get rid of the (and ... ).
> 
>Results with the changed code and using (watch all) and executing a (run) are:
> 
> 
>Jess> (batch "..//..//t1.clp")
> ==> Focus MAIN
> ==> f-0 (MAIN::initial-fact)
>MAIN::locality-street: +1+1+1+1+1+1+2+1+2+2+2+t
> ==> f-1 (MAIN::potential-element (type "locality") (value "south perth"))
> ==> f-2 (MAIN::potential-element (type "locality") (value "wembley"))
> ==> f-3 (MAIN::potential-element (type "locality") (value "bentley"))
> ==> f-4 (MAIN::potential-element (type "locality") (value "floreat"))
> ==> f-5 (MAIN::potential-element (type "locality") (value "osborne park"))
> ==> f-6 (MAIN::potential-element (type "street") (value "marlow"))
> ==> f-7 (MAIN::potential-element (type "street") (value "coode"))
> ==> f-8 (MAIN::potential-element (type "street") (value "jutland"))
> ==> f-9 (MAIN::potential-element (type "street") (value "grantham"))
> ==> f-10 (MAIN::potential-element (type "street") (value "giles"))
> ==> f-11 (MAIN::agreement (of-type "locality") (of-value "south perth") 
> (with-type "street") (with-value "coode"))
>==> Activation: MAIN::locality-street :  f-11, f-1, f-7,,
> ==> f-12 (MAIN::agreement (of-type "locality") (of-value "wembley") 
> (with-type "street") (with-value "marlow"))
>==> Activation: MAIN::locality-street :  f-12, f-2, f-6,,
> ==> f-13 (MAIN::agreement (of-type "locality") (of-value "dalkeith") 
> (with-type "street") (with-value "jutland"))
> ==> f-14 (MAIN::agreement (of-type "locality") (of-value "wembley") 
> (with-type "street") (with-value "grantham"))
>==> Activation: MAIN::locality-street :  f-14, f-2, f-9,,
> ==> f-15 (MAIN::agreement (of-type "locality") (of-value "floreat") 
> (with-type "street") (with-value "marlow"))
>==> Activation: MAIN::locality-street :  f-15, f-4, f-6,,
><Fact-15>
>Jess> (run)
>FIRE 1 MAIN::locality-street f-15, f-4, f-6,,
> ==> f-16 (MAIN::locality-street-match (locality-value "floreat") 
> (street-value "marlow"))
>FIRE 2 MAIN::locality-street f-14, f-2, f-9,,
> ==> f-17 (MAIN::locality-street-match (locality-value "wembley") 
> (street-value "grantham"))
>FIRE 3 MAIN::locality-street f-12, f-2, f-6,,
> ==> f-18 (MAIN::locality-street-match (locality-value "wembley") 
> (street-value "marlow"))
>FIRE 4 MAIN::locality-street f-11, f-1, f-7,,
> ==> f-19 (MAIN::locality-street-match (locality-value "south perth") 
> (street-value "coode"))
> <== Focus MAIN
>4
> 
>
>Bob Orchard 
>National Research Council Canada      Conseil national de recherches Canada 
>Institute for Information Technology  Institut de technologie de l'information 
>1200 Montreal Road, Building M-50     M50, 1200 chemin Montréal 
>Ottawa, ON, Canada K1A 0R6            Ottawa (Ontario) Canada K1A 0R6 
>(613) 993-8557 
>(613) 952-0215 Fax / télécopieur 
>[EMAIL PROTECTED] 
>Government of Canada | Gouvernement du Canada 
>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Matthew J 
>Hutchinson
>Sent: Monday, July 30, 2007 2:48 PM
>To: jess-users@sandia.gov
>Subject: JESS: No rules firing
>
>Hi,
>
>I have tried loading the following code with the batch command, then (run)ing 
>the whole lot, unfortunately my rule is not firing. I was expecting the rule 
>to fire, and as a result there should be several new locality-street-match 
>facts. 
>
>The code includes:
>-----------------------------------------------
>
>(reset)
>(watch activations)
>
>(deftemplate potential-element (slot type)(slot value) )
>(deftemplate agreement (slot of-type)(slot of-value)(slot with-type)(slot 
>with-value) ) 
>(deftemplate locality-street-match (slot locality-value)(slot street-value) )
>
>(defrule locality-street (and (agreement (of-type "locality")(of-value 
>?ov)(with-type "street")(with-value ?wv)) (potential-element (type 
>"locality")(value ?locality)) (potential-element (type "street")(value 
>?street)) (eq ?ov ?locality) (eq ?wv ?street) ) => (assert 
>(locality-street-match (locality-value ?locality)(street-value ?street) ) )  ) 
>
>(assert (potential-element (type "locality")(value "south perth") ) )
>(assert (potential-element (type "locality")(value "wembley") ) )
>(assert (potential-element (type "locality")(value "bentley") ) ) 
>(assert (potential-element (type "locality")(value "floreat") ) )
>(assert (potential-element (type "locality")(value "osborne park") ) )
>
>(assert (potential-element (type "street")(value "marlow") ) ) 
>(assert (potential-element (type "street")(value "coode") ) )
>(assert (potential-element (type "street")(value "jutland") ) )
>(assert (potential-element (type "street")(value "grantham") ) ) 
>(assert (potential-element (type "street")(value "giles") ) )
>
>
>(assert (agreement (of-type "locality")(of-value "south perth")(with-type 
>"street")(with-value "coode") ) ) 
>(assert (agreement (of-type "locality")(of-value "wembley")(with-type 
>"street")(with-value "marlow") ) )
>(assert (agreement (of-type "locality")(of-value "dalkeith")(with-type 
>"street")(with-value "jutland") ) ) 
>(assert (agreement (of-type "locality")(of-value "wembley")(with-type 
>"street")(with-value "grantham") ) )
>(assert (agreement (of-type "locality")(of-value "floreat")(with-type 
>"street")(with-value "marlow") ) ) 
>
>-----------------------------------------------
>
>then I (run) it.
>
>Any ideas? - thank you so much.
>
>Cheers,
>Matt
>
>
>
>
>-- 
>Matthew Hutchinson 
>Ph.D. Candidate
>Department of Spatial Sciences
>Curtin University of Technology
>GPO Box U1987
>Perth, Western Australia 6845
>
>Visiting Scholar
>Department of Geography and Planning
>University of Akron
>Akron, Ohio USA 

Reply via email to