Subscripts and random distribution

Use this forum to post Vensim related questions.
Post Reply
Hani
Member
Posts: 46
Joined: Wed Feb 23, 2011 12:40 am

Subscripts and random distribution

Post by Hani »

Hi,


I'm trying to adapt this standard model in developing my model. The attached file involves three tasks, each task starts as soon the earlier finished. Now,

1- How to start task 2 as soon as 50% of task 1 is finished?

2- " Max work accomplishment" is having values 188, 304, 326. Instead of using deterministic values, i would like to use probability distribution such as RANDOM NORMAL( {min} , {max} , {mean} , {stdev} , {seed} ), RANDOM NORMAL( {min} , {max} , {mean} , {stdev} , {seed} ), RANDOM NORMAL( {min} , {max} , {mean} , {stdev} , {seed} ), each one corresponds to task. When i entered the probability in the equation editor, i get error.



Thank you
Last edited by Hani on Mon Jan 07, 2013 8:38 pm, edited 1 time in total.
Administrator
Super Administrator
Posts: 4592
Joined: Wed Mar 05, 2003 3:10 am

Re: Subscripts and random distribution

Post by Administrator »

See the attached model, this does what you need.

Tony.
Attachments
PROJ3.MDL
(3.65 KiB) Downloaded 230 times
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
Hani
Member
Posts: 46
Joined: Wed Feb 23, 2011 12:40 am

Re: Subscripts and random distribution

Post by Hani »

Administrator wrote:See the attached model, this does what you need.

Tony.
That's awesome Tony. Thank you so much.

What about the distribution entry (the second part of the question)?
Administrator
Super Administrator
Posts: 4592
Joined: Wed Mar 05, 2003 3:10 am

Re: Subscripts and random distribution

Post by Administrator »

What was the error you got?
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
Hani
Member
Posts: 46
Joined: Wed Feb 23, 2011 12:40 am

Re: Subscripts and random distribution

Post by Hani »

Administrator wrote:What was the error you got?
I replaced the deterministic values of the " max work accomplishment" by probability distribution for all nine task as shown in the attached model, i used the add Eq.
Attachments
PROJ3_2.mdl
(4.98 KiB) Downloaded 218 times
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Subscripts and random distribution

Post by tomfid »

Somehow you have multiple identical instances of the equation for max work accomplishment. If you hit the "Remove" button until there's only one (the remove button will disappear), the model runs.

A few other observations:
- you might want to make max work accomplishment an Initial, if it's meant to represent a fixed rate for each scope element, rather than varying at each time step
- the expression 100 + 25*RANDOM NORMAL(-1,1,0,1,0) will give you a fairly strongly truncated normal distribution, because the min (-1) and max (1) are only one standard deviation away from the mean (0). It would be more typical to truncate 2-3 standard deviations out, or 6 if you want an effectively unconstrained distribution (though in this case that could lead to rare negative values)
- you probably should take the 100 and 25 and pull them out as separate named variables, so that you can assign units to everything

Tom
Hani
Member
Posts: 46
Joined: Wed Feb 23, 2011 12:40 am

Re: Subscripts and random distribution

Post by Hani »

Thank so mcuh for your respond
tomfid wrote:Somehow you have multiple identical instances of the equation for max work accomplishment. If you hit the "Remove" button until there's only one (the remove button will disappear), the model runs.

You mean the "Del" button as there is no "Remove" button. The values in the identical equations are going to be changes, i'm using same equation coz i'm testing the model, but those values will be changed and might have different prob dist for every scope. As i understood, that i have to delete 8 equations out of 9?. I need to represent each scope with probability distribution that changes the rate at every hour. This intended to model randomness. So, how to do that in vensim is not clear to me.


A few other observations:
- you might want to make max work accomplishment an Initial, if it's meant to represent a fixed rate for each scope element, rather than varying at each time step

"Max work accomplishment' should be a probability distribution, and every scope must have its own prob dist. that change the rate for every scope at every time step.
- the expression 100 + 25*RANDOM NORMAL(-1,1,0,1,0) will give you a fairly strongly truncated normal distribution, because the min (-1) and max (1) are only one standard deviation away from the mean (0). It would be more typical to truncate 2-3 standard deviations out, or 6 if you want an effectively unconstrained distribution (though in this case that could lead to rare negative values).
ok.
- you probably should take the 100 and 25 and pull them out as separate named variables, so that you can assign units to everything
ok.
Tom
Summary,
How to represent every scope with probability distribution that makes every scope processed with rate that changes at every time step ?
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Subscripts and random distribution

Post by tomfid »

Right - it's "Remove" in vensim 6, "Del" in earlier versions.

I don't have the model in front of me, but as I recall you had something like:

Code: Select all

scope : (s1-s5)~~|
myvar[scope] = 100+25*RANDOM NORMAL(...)~~|
myvar[scope] = 100+25*RANDOM NORMAL(...)~~|
myvar[scope] = 100+25*RANDOM NORMAL(...)~~|
myvar[scope] = 100+25*RANDOM NORMAL(...)~~|
myvar[scope] = 100+25*RANDOM NORMAL(...)~~|
You can't do that, because your left hand side is repeatedly defining the same elements of scope.

You could write equations for individual elements, as in

Code: Select all

scope : (s1-s5)~~|
myvar[s1] = 100+25*RANDOM NORMAL(...)~~|
myvar[s2] = 100+25*RANDOM NORMAL(...)~~|
myvar[s3] = 100+25*RANDOM NORMAL(...)~~|
myvar[s4] = 100+25*RANDOM NORMAL(...)~~|
myvar[s5] = 100+25*RANDOM NORMAL(...)~~|
That works, but it's not necessary if you're just trying to get different random draws for each element. That will already happen if you simply write,

Code: Select all

scope : (s1-s5)~~|
myvar[scope] = 100+25*RANDOM NORMAL(...)~~|
Hani
Member
Posts: 46
Joined: Wed Feb 23, 2011 12:40 am

Re: Subscripts and random distribution

Post by Hani »

Thank you so much Tom, it worked.

In fact i need different distributions as i have 9 scopes each associated with different probability for rate production.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Subscripts and random distribution

Post by tomfid »

If the distributions differ only in parameters (i.e., they're all NORMAL), then you could do:

Code: Select all

scope: (s1-s3)~~|

mean[scope] = 1,2,3~~|
std dev[scope] = 3,4,5~~|

myvar[scope] = mean[scope]+std dev[scope]*RANDOM NORMAL(-6,6,0,1,seed)
If the distributions also differ (some NORMAL, some UNIFORM, etc.), they you'll need to write element-specific equations, e.g. myvar[s1] = ... myvar[s2] = ...
Hani
Member
Posts: 46
Joined: Wed Feb 23, 2011 12:40 am

Re: Subscripts and random distribution

Post by Hani »

Administrator wrote:See the attached model, this does what you need.

Tony.
Hi Tony and Administrator

Please refer to PROJ3 model in this thread.

Task size 14500, 29200, 192700... Total=236,400

After running the model and computing the final total work using function SUM( Work Done[task!] ) i get 235,000....why is that? Can you please put some light on that..

Thank you.
Administrator
Super Administrator
Posts: 4592
Joined: Wed Mar 05, 2003 3:10 am

Re: Subscripts and random distribution

Post by Administrator »

You will need to debug the model to figure out why the end values are incorrect. My guess is that it is something to do with
IF THEN ELSE( Work Done[task] >= 0.98 * TASK SIZE[task], 1, 0)
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
Hani
Member
Posts: 46
Joined: Wed Feb 23, 2011 12:40 am

Re: Subscripts and random distribution

Post by Hani »

Administrator wrote:You will need to debug the model to figure out why the end values are incorrect. My guess is that it is something to do with
IF THEN ELSE( Work Done[task] >= 0.98 * TASK SIZE[task], 1, 0)
Please accept my appreciation for the great and prompt support...You are right...the problem is with 0.98..
Post Reply