longest run of zeros

Use this forum to post Vensim related questions.
Post Reply
danraymond53
Junior Member
Posts: 11
Joined: Sat Apr 21, 2018 5:14 am
Vensim version: PLE+

longest run of zeros

Post by danraymond53 »

I have a flow that can either 650 or zero depending on other conditions. I need to calculate the longest period where the flow remains zero.

e.g. 650,650,0,0,0,650,0,0,0,0,0,650,0,0 the answer would be 5 (days in my case).

I have PLE Plus is there a way to code this?

Thanks
danraymond53
Junior Member
Posts: 11
Joined: Sat Apr 21, 2018 5:14 am
Vensim version: PLE+

Re: longest run of zeros

Post by danraymond53 »

I realise how I can solve this.

But I need to reset a level to zero after the data stream changes back to 650 (having accumulated the count of zeros in another variable).
I can't find a way to do this, is there a reset variable command?
danraymond53
Junior Member
Posts: 11
Joined: Sat Apr 21, 2018 5:14 am
Vensim version: PLE+

Re: longest run of zeros

Post by danraymond53 »

Got it:

Used IF THEN ELSE to catch when zero stream started and count it. Used SAMPLE IF TRUE to find the maximum length of the counted stream.
Thanks
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: longest run of zeros

Post by LAUJJL »

joined a model to reset a level to 0. Does not use the sample if true, normally not available in PLE plus.
Attachments
resetting.vpm
(19.65 KiB) Downloaded 183 times
danraymond53
Junior Member
Posts: 11
Joined: Sat Apr 21, 2018 5:14 am
Vensim version: PLE+

Re: longest run of zeros

Post by danraymond53 »

Thanks LAUJJ

that cleaned it up!
Post Reply