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.
Why is that? Can you help me correct it? Thanks!
Error in a counter variable
Error in a counter variable
- Attachments
-
- test_counter.mdl
- (2.22 KiB) Downloaded 44 times
-
- Super Administrator
- Posts: 4592
- Joined: Wed Mar 05, 2003 3:10 am
Re: Error in a counter variable
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Error in a counter variable
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?
Please, can you help me to implement a solution?
-
- Super Administrator
- Posts: 4592
- Joined: Wed Mar 05, 2003 3:10 am
Re: Error in a counter variable
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.
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Error in a counter variable
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.
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
Re: Error in a counter variable
Here are some options.
I think one unit error might have been a typo in "dmnl".
I think one unit error might have been a typo in "dmnl".
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Error in a counter variable
thank you very much @tomfid!!
I found the options very useful
I found the options very useful