PULSE triggers a circular reference even through it delays its third argument?

Several SimLang functions delay their arguments, and so allow what would otherwise be circular references. For example I can use STOCK as follows:

Foo = STOCK(Bar, 0)
Bar = Foo / TimePeriod

But I cannot use PULSE in a similar way, even though it delays its third argument. I would like to write

V Baz = PULSE(1, 1, Qux)
V Qux = IF(Baz, 1 + RAND * 10, PREVIOUS(Baz, 1))

intending the time interval of PULSE to be updated only when a unit is actually pulsed.
Otherwise no update happens. But when I do so, I get a complaint about circularity.
(Strictly speaking I see that circularity in Forio Simulate, not Epicenter, but I assume it
happens in both platforms.)

As I misunderstanding how PULSE works?

Dave

The third parameter-- the interval – is dynamic (not a delayed argument). This allows the interval to be changed over the course of the sim.

In your model there’s a loop from the first parameter of the IF and the third parameter of the PULSE.

V Baz = PULSE(1, 1, Qux) 
V Qux = IF(Baz, 1 + RAND * 10, PREVIOUS(Baz, 1))

My first change was to do this

V Baz = PULSE(1, 1, INITIAL(Qux)) 
V Qux = IF(Baz, 1 + RAND * 10, PREVIOUS(Baz, 1))

but that still didn’t work as it has a circular reference during the initialization. However, this removed the circular feedback:

V Baz = PULSE(1, 1, INITIAL(Qux)) 
V Qux = IF(step=0 || baz, 1 + RAND * 10, PREVIOUS(Baz, 1))

Yes, I want the interval to be changed over the course of the sim. In particular, I want some randomness in the interval, so the duration from the first pulse to the second is different from the second to the third.

I might could do this:

V Baz = PULSE(1, 1, Qux)
V Qux = 1+ RAND * 10

But then Qux is recalculated every step. Occasionally that recalculation would lead to a short interval, and that short intervals is more likely to result in an immediate pulse. That creates a bias in the randomness. So I attempted to only recalculate Qux only when I need it, when a pulse happens. But that attempt fails due to circularity.

I think you want to hold the interval steady until the next pulse.

(I changed the model to use self-documenting variable names)

V Pulsed Output = PULSE(1, 1, Interval)
V Update Interval = PREVIOUS(Pulsed Output, 0) = 1
V Interval = REMEMBER(Update Interval, 1 + RAND*10)

Now it changes the interval the next step after the pulse (PREVIOUS) and holds the interval until the next pulse (REMEMBER). Note this example assumes the TIMESTEP is 1.

I wasn’t quite sure from your note but you may want something similar, to have a minimum interval. In this case just change the interval function. But I think it’d be better to hold the interval constant with REMEMBER until the next pulse.

That is what I need. Thanks.