Pulse train

Use this forum to post Vensim related questions.
Post Reply
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Pulse train

Post by nikvyas »

Good morning all!

I have another simple question for you experts. I have a series of irregular pulses (of time step 1). What I want is to convert the pulses of time step 1 into pulses of time step 3. Obviously, simply multiplying by 3 will multiply the magnitude by 3, which is not what I want. I have tried to use an IF THEN ELSE, combined with either another PULSE function or a STEP function, but without much luck.

Any help would be greatly appreciated.

Thanks
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

The PULSE_TRAIN function does not need to be called with constants. I don't know what pattern you are looking for but it seems like it should work.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Post by nikvyas »

Thanks Bob - what I mean is that if you multiply a pulse train, it simply magnifies the amplitude. i.e, say you had a pulse train of height 1 that lasts for 2 hours - if you multiply this by 2 (i.e the multiplier constant was 2), you get a height of 2 that lasts for two hours. What I actually need is a height of 1 that lasts for FOUR hours - i.e., I want to multiply the duration, not the height.

Any help greatly appreciated.

Thanks
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

The second argument to the PULSE_TRAIN function is the duration, also called width. This can be an expression. See Chapter 4 of the Reference manual for details of the PULSE_TRAIN function.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Post by nikvyas »

Thanks Bob - however I don't think I've described the problem well enough. The pulse train has already been defined and manipulated elsewhere. It was defined as follows:

DS Failure Pulses=
(IF THEN ELSE( DS CUMULATIVE=0 , 0 , IF THEN ELSE(MODULO(DS CUMULATIVE,(DS MTBF*"A/C 'stoppage' factor"))=0 , 1, 0)))+(IF THEN ELSE
( DS CUMULATIVE=0 , 0 , IF THEN ELSE(MODULO(DS CUMULATIVE,(25*Thales 'stoppage' factor))=0 , 1, 0)))

Which basically takes an accumulated value 'DS CUMULATIVE' and samples it every few hours (according to the three variables 'A/C 'stoppage' factor', 'DS MTBF' and 'Thales 'stoppage' factor'. However, we don't want to sample consecutive, identical values of DS CUMULATIVE - ie, say we want to sample every 10 hours of DS CUMULATIVE, there will be occasions when DS CUMALATIVE is 20 on more than one time step, but we just want to sample the first occurance, so the following equations are used:

DS FAILURE PULSES FILTERED=
IF THEN ELSE (DS FAILURE PULSES >0 :AND: "DS step-1" >0,0,DS FAILURE PULSES)

DS STEP-1=
(DS FAILURE PULSES - "DS step-1") [with an initial value of 0 - i.e. this is a level, all the other equations are auxilliaries]

Now, we want to multiply the pulse duration of DS FAILURE PULSES FILTERED by a variable - however, if I simply multiply it, I wiould multiply the height of the pulse and not the duration. So is there a way to multiply the duration instead?

Hope this is a bit clearer.

[Edited on 7-3-2006 by nikvyas]

[Edited on 7-3-2006 by nikvyas]

[Edited on 7-3-2006 by nikvyas]
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

I really can't follow any of this. I will point out that the equations you have do not appear to be very robust numerically.

From your written description it sounds to me like you want something like:

Sampled Failures = SAMPLE IF TRUE(new sampling required :OR: stop sampling,IF THEN ELSE(stop sampling,0,DS Cumulative),0)

where stop sampling probably looks something like

stop sampling = IF THEN ELSE(Sampled Failures > 0,
IF THEN ELSE(Time > last sample time + current sampling duration,1,0),
0)

last sampling time = SAMPLE IF TRUE(new sampling required,Time,0)

I hope that is helpful.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Post by nikvyas »

Hi Bob - I think the equations I have are robust enough - they have been tested fairly exhaustively - although I will certainly take your recommendations aboard. All I really wanted to know Bob, was with an already defined pulse train, is there any way to adjust the duration of the pulses, rather than the magnitude of the pulses themselves? ie, the pulse train enters a box variable and this box variable factors the pulse train - say this box variable has a constant of 6, it will increase the magnitude of the pulse train by 6. However, I actually want to increase the duration - is there a way to do this?

[Edited on 7-4-2006 by nikvyas]

[Edited on 7-4-2006 by nikvyas]
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

Back on PULSE TRAIN then just use

output pulse = pulse height * PULSE TRAIN(first pulse start time, pulse duration in time units, time between beginning of pulses in time units, last time to output a pulse which can simply be a large number)

Just incidentially if you are looking at failure processes then the normal approach to this is to use RANDOM POISSON as in

failures realized = RANDOM POISSON(0,1e9,expected failure rate in parts per time unit, 0,1,0)

Going to a deterministic formulation for this, while appealing since random things are hard to analyze, is probably not going to give good results.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Post by nikvyas »

I think we have a bit of serious miscommunication here Bob ;) Could we please try again, as it is vital to my model to get this right. :(

As opposed to your last post where you defined 'output pulse', my pulses are random pulses of height 1 and duration 1. So for instance, the output from 'output pulses' might look like:
100000000000010000100000000010000001000010000010

Now, what I actually want to know is the following:
'output pulses' now enters a box variable called 'pulse change'. Within pulse change, I want to modify the PULSE DURATIONS of 'ouput pulses'. So, I might want to increase all the pulse widths from 1 to 3, so that the pattern now looks like:
1110000000000111000111000000111000000000111 etc.

However, how do I do this? If 'pulse change'= 3 * 'output pulses', the output would like:
30000000000003000003000000003000000000003 etc.,
which is NOT what I want. So in short, what would the 'pulse change' equation look like if I wanted to increase the pulse duration of all the pulses (by a constant of, say, 3) within 'output pulses' and NOT the pulse height.

[Edited on 7-4-2006 by nikvyas]
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

Suppose that "input" is the amount of stuff that needs to be put through the system - it is some random variable that might look like

0010004000000000200000100000

If you want an output that is 1 as long as all the input has not been processed this looks like

output = IF THEN ELSE(todo > 0,1,0) ~ Widget/Day
todo = INTEG(input - output,0) ~ Widget

I am assuming TIME STEP = 1 (day) though it is still OK otherwise. This does cause a 1 day delay from input to output if that is bad you can have

output = IF THEN ELSE(input > 0 :OR: todo > 0,1,0) ~ Widget/Day

Perhaps that is helpful.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Post by nikvyas »

Almost there Bob :cool:

What I actually want is as follows:

Take your "input" above. If the TIME STEP=1(day), the "input" has a pulse of 1 at 3 days for 1 day, a pulse of 4 at 7 days for 1 day, a pulse of 2 at 17 days for 1 day etc. Now, what I want is to adjust the DURATION (length) of the pulses - ie, say I want to increase the duration of all the pulses by 2 days, so that the "output" looks like:

00111044400000002220000 etc.

In short, I want to take a random sequence of pulses (as in your "input" above) and increase the DURATION of each pulse.

Any help will, as usual, be greatly appreciated Bob.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

Depending on how things might bump into one another (that is overlapping pulses) there may be problems. If this won't happen the following will work:

quantity = SAMPLE IF TRUE(input > 0,input ,0) ~ Widget/day
todo = INTEG(input * duration / TIME STEP - output,0) ~ Widget
output = IF THEN ELSE(todo > 0,quantity,0)

Where duration is a time varying value that you set - the value at the time of the input determines how long the output continues.

If you might have overlap you should change output to something like

output = MIN(todo/TIME STEP,quantity)

so that you don't get something funny when quantity is changing.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Post by nikvyas »

That's fantastic - exactly what I wanted Bob!

Thanks again.

[Edited on 7-5-2006 by nikvyas]
Post Reply