Dear Steffen,
although I do not know what your program do, and probably the following is not the more elegant solution, you can try the following code:

; your deftemplates

(deffacts initial_facts
   (noloops (einspannennl 0))
   (Verzug (v1 0))
   (Werkstueck (Einspannungsart "Segmentbackenabdruck"))
)

(defrule einspannen
   (Werkstueck (Einspannungsart "Segmentbackenabdruck"))
   ?noloops <- (noloops (einspannennl ?e&0))
   ?verzug <- (Verzug (v1 ?v1))
   =>
   (modify ?noloops (einspannennl 1))
   (assert (Verzug (v1 (+ ?v1 2))))
)

(reset)
(run)
(facts)

Regards
 Joaquín

-------- Original Message  --------
Subject: JESS: Avoiding an infinite loop
From: Steffen Niermann <[email protected]>
To: [email protected]
Date: 13/07/2009 19:59

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



Reply via email to