Error in a counter variable

Use this forum to post Vensim related questions.
Post Reply
Nub_User
Member
Posts: 39
Joined: Mon Aug 16, 2021 11:55 pm
Vensim version: PLE+

Error in a counter variable

Post by Nub_User »

I made this module with a counter variable wich resets it when it reaches the value 10.

The problem is when I running the simulation. In periods 57, 76, and 92 the counter restarts at 1 when it should be 0. :shock:

Why is that? Can you help me correct it? Thanks!
Attachments
test_counter.mdl
(2.22 KiB) Downloaded 44 times
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Error in a counter variable

Post by Administrator »

If you want it to go to zero in these time steps, you also need to take account of any rates flowing into the level (event log is flowing in while you reset it).
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Nub_User
Member
Posts: 39
Joined: Mon Aug 16, 2021 11:55 pm
Vensim version: PLE+

Re: Error in a counter variable

Post by Nub_User »

Thank you very much, I understand what you're saying. What I'm struggling to figure out is how to implement a solution to prevent it from happening.
Please, can you help me to implement a solution?
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Error in a counter variable

Post by Administrator »

It might be better if you explain what you are trying to do.

The model does not pass the units check ("event log" is measured in 'events" when it should be events/mes). The time step should be smaller than 1/3 of the shortest delay in the model, I cannot identify where any delays are.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Nub_User
Member
Posts: 39
Joined: Mon Aug 16, 2021 11:55 pm
Vensim version: PLE+

Re: Error in a counter variable

Post by Nub_User »

Thank you very much for your response!

I'll explain what I'm trying to do:
I'm attempting to model a stock variable whose value becomes zero when a specific condition is met. In other words, I want to reset its value and use it as a counter.
This way, I could compute the amount of time it takes for the condition to be met or make that condition depend on a specific time value.
In the model, and for simplicity I follow this strategy: the "events" variable tracks the occurrence of a random event, which is "simulated" using a Dmnl-type variable named "occurrence of random events". This variable is then input into a flow variable "event log" to be added to the stock variable "event counter". Later, this stock variable is related to the auxiliary variable "flag to restart the counter", which simulates the condition I want to meet in order to reset the stock variable.

Upon rethinking this, I now better understand your initial response, and I realize that the model is indeed functioning correctly. The stock variable continues to be influenced by the flow variable in the t+1 time step when the reset condition is met. Sometimes, the value of the flow variable will be 1 because events occurred, and at other times, it will be zero because they didn't.

Regarding units:
I've corrected the units of the flow variable (to "events/month"). Furthermore, I understand that the stock variable shouldn't have units of time, so its units would be "events". However, when I perform the units check, the software indicates there's a Right Hand Side (RHS) error. I pragmatically tried changing the units, but I haven't been able to overcome the error. Am I on the right track?

Thank you very much for your time and help.
Attachments
test_counter_1.mdl
(2.24 KiB) Downloaded 47 times
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Error in a counter variable

Post by tomfid »

Here are some options.
test_counter_2.mdl
(7 KiB) Downloaded 116 times
I think one unit error might have been a typo in "dmnl".
Nub_User
Member
Posts: 39
Joined: Mon Aug 16, 2021 11:55 pm
Vensim version: PLE+

Re: Error in a counter variable

Post by Nub_User »

thank you very much @tomfid!!
I found the options very useful :D :D
Post Reply