Re: [Lisa-users] how to change clos slots
Brought to you by:
youngde
From: Johan L. <joh...@gm...> - 2008-03-14 16:46:20
|
Hi again Pedro, > but what I want to do is to change the slots of each instance. I tried > the following code but I get a infinite loop: > > (defrule rule-1 () > (?sonority (sonority (notes ?notes))) > => > (modify ?sonority (tertian-p t))) The reason for the infinite loop is because LISA handles refraction and modifications just like CLIPS. While it won't place an Activation (a Rule + a set of Facts) on the Agenda if it has been executed before (aka Refraction). The problem is that the modify statement changes the Fact-index (of the ?sonority fact) and that also means that LISA will treat it as a "new" Fact. It won't show up on the list of previous Activations so Refraction won't work. Some engines (Jess) handle this type of situation a little better. Jess won't assign a new Fact-index unless the modify statement actually modifies a slot-value. It makes it easier to avoid this problem or it encourages you to write sloppy code, depends on how you look at it ;-) The easiest way to solve your problem is to modify the LHS so that it also matches (tertian-p nil). Try: (defrule rule-1 () (?sonority (sonority (notes ?notes) (tertian-p nil))) => (modify ?sonority (tertian-p t))) In general (using CLIPS, and LISA) you should include a match against the slot your modifying to make sure that it's not already been processed to avoid this sort of trouble. HTH Johan Lindberg jo...@pu... |