Steffen:
I do not know what your semantics are since my German
is more than a little rusty.
Try the following modification -- you can aslo see what happens
if you remove the no-loop declaration and use your no-loops fact instead.
Regards.
David Scuse
(deftemplate Werkstueck
(slot Einspannungsart)
(slot Hauptprozess)
(slot Name)
)
(deftemplate Verzug (declare (slot-specific TRUE))
(slot v1)
(slot v2)
)
(deftemplate noloops
(slot einspannennl)
)
(deffacts initialFacts
(Werkstueck (Einspannungsart "Segmentbackenabdruck"))
(Verzug (v1 1) (v2 2))
(Verzug (v1 5) (v2 10))
(noloops (einspannennl 0))
)
(defrule einspannen
(declare (no-loop TRUE))
(Werkstueck (Einspannungsart "Segmentbackenabdruck"))
;;?r1 <- (noloops (einspannennl 0))
?r2 <- (Verzug (v1 ?v1) (v2 ?v2))
=>
;;(retract ?r1)
;;(assert (noloops (einspannennl 1)))
(assert (Verzug (v1 (* ?v1 2)) (v2 ?v2)))
(retract ?r2)
)
(reset)
(facts)
(run)
(facts)
----- Original Message -----
From: Steffen Niermann
To: [email protected]
Sent: Monday, July 13, 2009 12:59 PM
Subject: JESS: Avoiding an infinite loop
Hello,
I have a problem with defining a rule without getting into an infinite loop.
This is my code:
(deftemplate Werkstueck
(slot Einspannungsart)
(slot Hauptprozess)
(slot Name))
(deftemplate Verzug (declare (slot-specific TRUE))
(slot v1)
(slot v2))
(deftemplate noloops
(slot einspannennl) )
(defrule einspannen
(Werkstueck (Einspannungsart "Segmentbackenabdruck"))
(noloops (einspannennl 0))
?v1 <- (Verzug (v1))
=>
(assert (noloops (einspannennl 1)))
(assert (Verzug (v1 (+ ?v1 2)))))
I want to add more rules like "einspannen". When I use (declare (no-loop
TRUE)) the other rules won´t be fired.
So I added the SLOT "einspannennl" which should be "0" on the LHS. If the
rule is fired the slot will be set "1".
I thought that I could avoid an infinite loop with this slot.
Still it runs into an infinite loop, if fired.
Can you help me with avoiding an infinite loop?
Thank you very much.
Best Regards
Steffen N.
------------------------------------------------------------------------------
BIBA - Bremer Institut fuer Produktion und Logistik GmbH
Postanschrift: Postfach P.O.B. 33 05 60, D-28335 Bremen / Germany
Geschaeftssitz: Hochschulring 20, D-28359 Bremen / Germany
USt-ID: DE814890109, Amtsgericht Bremen HRB 24505 HB
Tel: +49(0)421/218-5576, Fax: +49(0)421/218-5640
E-Mail: [email protected], Internet: www.biba.uni-bremen.de
Geschaeftsfuehrer: Prof. Dr.-Ing. Bernd Scholz-Reiter