New user with newbie problems..please help

Use this forum to post Vensim related questions.
Post Reply
YahyaRafique
Junior Member
Posts: 13
Joined: Mon Mar 29, 2010 4:28 am

New user with newbie problems..please help

Post by YahyaRafique »

Hi all,

I am using for the first time for a masters level Computer Science project. I was simulating the traditional waterfall software development model and had to create an iterative loop to model the life cycle. On reading the reference manuals and looking at the samples I figured it involved the use of the SIMULTANEOUS function. The understanding that I got was that in the beginning of the INITIAL time step the base value provided as the second argument to the SIMULTANEOUS function is substituted and used to calculate values for all the simultaneous equations i.e.

given simultaneous equations for two variables a,b where we would otherwise get an error of simultaneous equations for var a:

1. Set base value for a.
2. Get value for b.
3. Use b's value to get a.

.... continue where future values from simultaneous equations are determined from previous values. My problem is I don't know which of the values from the previous time step are substituted in the previous equations are substituted and how the actual convergence happens. I was initially getting the following error:

Simultaneous Equations involving: Rework Error Detection Rate
:Rework Rate
:Rework Error Generation Rate
:Rework Error Reduction Rate



Heres the simultaneous part:

Levels: Detected Errors, New errors generated from rework
Rates: Rework Rate, Rework Error Detection Rate,
Rework Error Generation rate

Equations:


Rework Rate=
IF THEN ELSE( Detected Errors>0 :AND:
Rework Error Detection Rate =0,
Detected Errors
, 0 )

Rework Error Detection Rate=
IF THEN ELSE(
Rework Error Generation rate = 0 :
AND:New errors generated from rework>0 ,

0.95*New errors generated from rework

, 0 )

Rework Error Generation rate= Rework Rate*0.01


I think my understanding is wrong but I cant seem to find any clear materials to improve it. Anywaz I have developed a model which is pretty straight foward which I am attaching to this post. I am getting incorrect values at particular time steps..

problem : 1 I should get a non-zero outflow rate when I dont.
problem : 2 WHen there is no inflow into a model at a previous time step then how is the level value incremented in the next time step.




Please help me......

[Edited on 29-3-10 by YahyaRafique]

[Edited on 30-3-10 by YahyaRafique]
YahyaRafique
Junior Member
Posts: 13
Joined: Mon Mar 29, 2010 4:28 am

Add-ons

Post by YahyaRafique »

To make it easier to look at I am attaching a spreadsheet of values taken as export from Vensim...I have highlighted wrong values in red.....again please help me
Attachments
Simultaneous.xls
(22.5 KiB) Downloaded 229 times
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

Chapter 3 of the Modeling Guide covers Project Dynamics, there is also discussion of this in Business Dynamics by Sterman, a great description albeit done in Dynamo in the book "Introduction to System Dynamics with Dynamo" by George Richardson and Alexander Pugh and Tarek Abdel Hamid has a book on software project dynamics (though I have forgotten the title).

Using the SIMULTANEOUS function is almost certainly not the best solution.
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

Another good reference is Tarek Abdel-Hamid's dissertation.

It's in a book, with Stu Madnick:
http://www.amazon.com/Software-Project- ... 961&sr=8-1
(cheap if you buy a used copy)

The original thesis is free here:
http://hdl.handle.net/1721.1/38235

Tom
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

One more reference on project models: David Ford's thesis: http://dspace.mit.edu/handle/1721.1/11105

Tom
YahyaRafique
Junior Member
Posts: 13
Joined: Mon Mar 29, 2010 4:28 am

Post by YahyaRafique »

Thank you for your help with providing references to models but I really cannot use any other model. I have been working with my professor for two weeks on this and changing it is not a feasible option....Can somebody please look at my model and tell me what's wrong...or maybe even a detailed description on how simultaneous works....Any info will help...Desperately needs help..Thank you..
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

new user

Post by LAUJJL »

Hi

I have looked at your model.

There is a simultaneous error, and you have not assigned units to your equations, which is the first thing to correct.
A model with plenty of unit errors is simply not correct.
After you have corrected them, read the reference manual the chapter named the Vensim modelling language and then the computational sequence sub chapter. You will then understand why Vensim cannot compute values in the model you have built, and understand that you must construct your model differently or eventually add a simultaneous or find zero equation which are to use with care at the condition you are absolutely sure you need them.
Regards.
JJ
YahyaRafique
Junior Member
Posts: 13
Joined: Mon Mar 29, 2010 4:28 am

Post by YahyaRafique »

Hey JJ,

Thanks for the reply.

I know my model was missing units. I figured that I will enter them in the end after the whole diagram was complete. As for your suggestion of using the Simultaneous function, I did use it in fact and got some wrong values which I have attached to one of my earlier posts on this thread...I blame it on my knowledge of the computational sequence....

After reading the section on computational sequence I still cannot seem to understand the order in which the levels and rates will be computed in my model.


It says in the reference manual that levels are determined before rates which are a special type of auxiliary but it also says that when computing levels any auxiliaries in the equation of levels are computed first.....and also in simultaneous equations the variable posing the issue has its value substituted from the previous timestamp....I so far cant understand this?...I am trying to do the computation myself but it seems like I am not doing it the right way..... the levels and rates involved are mentioned in my first post...


This is the computation sequence I am thinking it is at timestamp t:

1. The levels 'Detected Errors', 'New Errors Generated from Rework' are computed from the rates at t-1.

2. The value for rate 'Rework Error Detection Rate' for t-1 is used to compute 'Rework Rate' and in turn 'Rework Error Generation Rate'.

3. The values computed in 2 are used to get the new value for
'Rework Error Detection Rate'.
4. Steps 2,3 are repeated with using new value computed in 3 in 2. Recursive behaviour continues until values no longer change.

I have attached a snapshot of the values where the error takes place .




any help will be greatly appreciated ..

Thank you

[Edited on 29-3-10 by YahyaRafique]
Attachments
simultaneous_error.JPG
simultaneous_error.JPG (35.67 KiB) Viewed 11199 times
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

I took a look at the model. The basic conceptual problem is the rate-to-rate connections from Rework Error Generation Rate to Rework Error Detection Rate to Rework Rate (and back). Making a rate to rate connection amounts to saying that the relationship is instantaneous, which would imply that errors are created, then detected and fixed instantly. That's unlikely to be physically possible. A simple solution would be to make the error detection/escape rates a function of the New Errors stock only, e.g. Error Detection Rate = New Errors/Time to Process Errors*Fraction Errors Detected, Error Escape Rate = New Errors/Time to Process Errors*(1-Fraction Errors Detected).

Notice that I incorporated another good practice, by taking your constants (.05, .95) out of the equation and making them parameters (Fraction Errors Detected).

Generally, defining units at the end is bad practice, for the same reason that saving all debugging for the end of a programming project is not productive.

Hope this helps.

Tom
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

A few other observations:

Generally it's easier to think of systems like this in continuous time (the limit as TIME STEP gets small) rather than discrete x(t) = f( x(t-1) ) notation. For most purposes, a test of a good model with an appropriate time step is to simply halve the time step and see if the behavior changes significantly; if it does, there are problems.

You may find the discussion in Forrester's Industrial Dynamics helpful, especially chapters 6 & 7 and section 7.4.

As much as possible, you should aspire to remove the IF THEN ELSE logic from your rate equations. The equations aren't very transparent, and the behavior will probably suffer from unrealistic bang-bang nonlinearities.

Tom
YahyaRafique
Junior Member
Posts: 13
Joined: Mon Mar 29, 2010 4:28 am

Post by YahyaRafique »

Thanks Tom for looking at the model.

Thank you for incorporating the good practice as well.

The fundamental question as you noticed is the rate to rate connection. Incorrect to your assuption the rate cycle does not happen instantaneously although the value are so small that this is being done in one time step for these particular values. I plan to increase the flow once I get everything working.

This is the behavior I am trying to simulate:

1. Detected Errors are reworked using the 'Rework Rate'.
Since the 'Rework Error Generation Rate' is a percentage of the 'Rework Rate' it is non-zero only when 'Rework Rate' is non-zero.

2. Once the errors have been reworked .i.e. 'Detected errors' is zero then we start testing again which is simulated by 'Rework Error Detection Rate' and then 'Rework Error Escape Rate'. HENCE these two rates are 0 as long the rework development is being done and only let flow go through when rework development has been completed.

3. Since rework has the possibility to give rise to new errors I wish to pass 'Detected Rework Errors' into 'Detected Errors' for the next round of rework processing.........once I get this working I will set a limit to how large the errors must be for another round of rework to take place.


So basically the flow is

1 -rework gives rise to new errors
2- The reworked code is tested to detected errors.
3- the detected errors are reworked in the next iteration of the rework cycle.



The reason why I have so many arrows is to simulate behaviour where level is completely filled before being drained....i.e. simulating a process model where nothing is programmed until everything hass been designed. To achieve this sequential progression I had to use so many arrows

I used the Simultaneous function when I got the simultaneous error earlier......I get correct values until a particular timestamp which I have attached a spreadsheet image of.....I am soo confused.....I just dont know how computation is working in this loop....please help me..

:(
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

new user

Post by LAUJJL »

Hi

Two remarks:

You write: It says in the reference manual that levels are determined before rates. I cannot see where you read that. It is wrong during the simulation, where the rates determine the values of the levels. The only time when it is true is at the start of the simulation, where the levels have to be initialised, and some times calculated from constants or initial values.
A second remark.
Before making a model that is already complex, at least for your level of SD practice and general level of understanding or belief of understanding of the problem, I would try first to simplify the specifications of your problem, even to a point that is is far away from the reality, and build a much simpler model which I master and understand fully, because I have used it quite a bit, and then progressively add new material step by step, repeating the understanding process at each step.
If you have the patience to do it, it will do miracles.
Regards.
JJ
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

JJ is correct on the level-rate sequence.

If you connect rate A to rate B directly, that's a formal statement that the causal effect of A on B is instantaneous.

If you connect rates circularly, A -> B -> C -> A as you've done in the draft model, then A, B, C represent a system of simultaneous equations that will either solve to equilibrium or explode unstably. Occasionally this is useful, when modeling a process that is extremely fast compared to the time scale of interest in a model. However, it's also generally difficult to implement and even harder to understand. For a model of this size, it's generally much better to include short delays where needed, and use a small time step.

The 1-2-3 flow of error generation and rework sounds like a reasonable description of the process, but the key is that it's not instantaneous. It takes time to rework known errors and to discover errors generated. The sequence that you describe unfolds across many time steps, mediated by the levels, rather than within a single time step. One implication of the current setup is that Detected Rework Errors will always be zero, because its inflow and outflow will be equal at every point in time.

Again, the solution here is for every rate equation to depend (ultimately) only on the state of the system - that is, the levels. For the Rework Rate, that means that it can only depend on Detected Errors (and perhaps other levels, if for example there are competing demands on a programmers' time). If programmers do work in anticipation of the inflows to detected errors, then you could create an "expected error generation rate" that is a level (e.g., a SMOOTH of the actual rates), reflecting the fact that perception is different from reality. However, there still has to be a first-order negative feedback relationship between Detected Errors and Rework Rate (i.e. 0 detected errors implies 0 rework).

I'd encourage you to work with a subset of this model - perhaps everything to the right of Unit Test Error Detection Rate - and get that working conceptually before tackling the whole.

Tom
YahyaRafique
Junior Member
Posts: 13
Joined: Mon Mar 29, 2010 4:28 am

Post by YahyaRafique »

Thanks Tom and JJ,

I now understand the instantaneous nature of the loop mentioned. Unfortunately I can't change the model as it exists. When I used the simultaneous function I was getting errors only when numbers were really small. When I set the overall flow to be higher and set a minimum threshold on the values required for the recursive loop to reiterate I seem to get all correct values...so I think I am gonna stick to that.

Thank you so much for the help :-)
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

I'd strongly urge you to reconsider. The basic stock-flow structure here seems quite well articulated. Revising the rates so that they rely only on information actually available ( e.g., stock/processingTime ) would be a quite simple change here.

A look at the sample project model in Vensim>Models>Mguide>3PROJ>PROJECT9.mdl might be helpful.

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

Post by bob@vensim.com »

Just one more comment on this. If you want to do something simultaneously just solve out the algebra for that plays out and and enter the solution directly into the equations. Using the SIMULTANEOUS functions for this is not, as you have noticed, a very good solution.
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

simultaneous

Post by LAUJJL »

Hi

If I want to build a loop within a time step, there is no built in solution right in Vensim, but the simultaneous and find zero function. The simultaneous and find zero function do not permit to follow the values that are taken within the loop. The simultaneous has no control at all on the looping process and works only if there is a convergence. The find zero works the same way but with more control on the convergence mechanism, but needs always the process to converge someway and without any information about any values during the looping process.

But there is a simple way to build a looping process within Vensim, even without a looping function in the language. The solution is to loop within an array. You can build a loop within a time step, at the condtion that at each loop you calculate a new value from the array. this way you have a complete control on the looping process and can even build special actions to be taken depending on the values. It works like a common procedural language. You can do the same using an external function working for instance with C, but it is less practical, and you cannot run reality checks inside the looping action and I do not know if it is possible to follow the calculus within the external function during a simulation.
Besides I am not sure if one can run reality checks with external fuctions at all. Having never used external functions, I cannot tell.
Regards.
JJ
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Post by tomfid »

Incidentally, the array trick works for other things that you might normally accomplish with a For...Next loop. For example, if you want to find the maximum of 20 draws from a random distribution, just define

i : (i1-i20)
draw = RANDOM SOMETHING(...)
max val = VMAX(draw[i!])

Tom
Post Reply