plz help

Use this forum to post Vensim related questions.
Post Reply
japrap
Member
Posts: 20
Joined: Wed Jan 14, 2015 1:54 pm
Vensim version: PLE

plz help

Post by japrap »

hi
is there any function which operate in the opposite way that DELAY FIXED( {in} , {1} , {init} ) operate?
ex)I mean a function that gets variable1(var1) and returns variable2 (var2)
time 0 -----1------2-----3-----4
var1 0 -----2----- 5------7-----16
var2 2-----5-----7-------16 --...
Last edited by japrap on Sat May 09, 2015 3:59 pm, edited 1 time in total.
Administrator
Super Administrator
Posts: 4621
Joined: Wed Mar 05, 2003 3:10 am

Re: plz help

Post by Administrator »

No, becauase that would mean looking into the future.

But if var1 is data (external to Vensim, or a lookup table), then yes, you can get the value.

It might help if you explain in a little more detail what you are trying to do.
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
japrap
Member
Posts: 20
Joined: Wed Jan 14, 2015 1:54 pm
Vensim version: PLE

Re: plz help

Post by japrap »

Many thanks for the prompt reply
suppose that variable1 and variable2 both are box variables.
consider variable2 equation = IF THEN ELSE(arrival-discharge+8+variable1<=capacity,0, arrival-discharge+8+ variable1-capacity)
suppose that we are at time 5 now. we know that for computing the present value of variable2 ,vensim uses the variable1 value at time 4 ,but I want that vensim first computes the present value of variable1 and then uses this value to compute the present value of variable2
in fact ,i want that in each time step vensim first computes the variable1 value (priority one) and then use this value to compute the variable2 value(priority two).
can anyone help me plz ?
Attachments
1.mdl
(2.51 KiB) Downloaded 216 times
tomfid
Administrator
Posts: 3816
Joined: Wed May 24, 2006 4:54 am

Re: plz help

Post by tomfid »

I'm sure there's a way to do what you're after, but it's hard to tell without some more information.
- var1 and var2 need real names - what do they represent?
- all variables should have units of measure
- it's unconventional to have causal arrows directly influencing levels; arrival-discharge+8+ variable1-capacity needs to be reformulated as an explicit (net) flow
- embedded dimensioned constants, like +8+, should be converted to variables with names and units
japrap
Member
Posts: 20
Joined: Wed Jan 14, 2015 1:54 pm
Vensim version: PLE

Re: plz help

Post by japrap »

i'm very thankful for your reply.

1-suppose that we have 2 categories of patients who want to be admitted in a General Ward(GW) 1- Trauma patients 2-other patients .normally , if GW isn't at full capacity ,at first Trauma patients are admitted and then according to the remain beds, other patients are admitted .so , in each time step if GW isn't at full capacity we should first admit Trauma patients (priority one) and then other patients(priroty two) .in fact for evaluating

2-I attach the model with real name and correct units .
Attachments
1.mdl
(3.13 KiB) Downloaded 203 times
tomfid
Administrator
Posts: 3816
Joined: Wed May 24, 2006 4:54 am

Re: plz help

Post by tomfid »

I think you want something more like this:
patientsWaiting1.mdl
(4.21 KiB) Downloaded 233 times
japrap
Member
Posts: 20
Joined: Wed Jan 14, 2015 1:54 pm
Vensim version: PLE

Re: plz help

Post by japrap »

Dear Tom
Many many thanks for helping me, that was just what I need.
there are still some little problems that i cannot fix them :
1- after simulating, the values of "trauma patients waiting" and "other patients waiting" are incorrect only at day 1.
2- the value of the "GW patients" should gets up-to-date 1 day earlier
the attached image shows the incorrect values .

with best regards
Attachments
Untitled.rar
(25.67 KiB) Downloaded 239 times
tomfid
Administrator
Posts: 3816
Joined: Wed May 24, 2006 4:54 am

Re: plz help

Post by tomfid »

Without the corresponding model, I'm not really sure what I'm seeing here.

If you're running the model with a 1-day time step, it's likely that the issue is that the integration through a stock imposes a 1-day lag (at minimum). You might be able to resolve this by changing the integration method to Diff instead of Euler (which really only changes the display - the math is the same).

Another possibility might be to permit the admitting flows to consider the arriving patients in addition to the stock of patients waiting. That would eliminate the lag through the waiting stocks. In standard SD, such rate-to-rate connections are normally verboten, but in this case you'd essentially be building a discrete event simulation, so it might be OK.
japrap
Member
Posts: 20
Joined: Wed Jan 14, 2015 1:54 pm
Vensim version: PLE

Re: plz help

Post by japrap »

Dear Tom

At first let me say that I'm indebted to you for your help and I really appreciate you for the time you spend for me .
I use the Vensim PLE and it seems that there are just two integration types 1-Euler 2-RK4 Auto and there is no Diff integration type in PLE version.In addition, when we consider Diff for the model integration type ,in fact , we consider it for all the model variables not just for a specific stock variable .
moreover , when I add the stock of patients waiting to the admitting flows it ruins all the admitting values .
normally patients wait in a department until a bed get available (for example they are boarded in ED until an ICU bed get available) ,so I eliminated "normal time to admit" from the model and attached the model . please run the model and look at the value of GW patients , trauma patients waiting and other patients waiting .

Best Regards
Attachments
patientsWaiting2.mdl
(3.89 KiB) Downloaded 208 times
LAUJJL
Senior Member
Posts: 1432
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: plz help

Post by LAUJJL »

Hi

The original model does not verify the mass balance check.

There is a mistake in the calculation of the 'potential GW admitting'. You must take into consideration the discharging. In fact one must first discharge, first priority, than admit trauma, second priority, than admit others pt third priority. Once the change is made the masses are balanced. I have too added the unit corrections that help understand how the model works and prevent bugs.
The GW residence time must be greate than an hour, otherwise there is a risk of the stock of GW patients coming negative.

Joined the model corrected.

There is a slight error in the model with the test as the difference in stock variation and flows cumulated is not strictly equal to 0 due to the continuous calculations. I have made a small change to the model named mod2.

Regards.

JJ
Attachments
patientsWaiting2[1]_mod2.mdl
(7.06 KiB) Downloaded 211 times
patientsWaiting2[1]_mod.mdl
(6.63 KiB) Downloaded 224 times
Last edited by LAUJJL on Sun May 10, 2015 8:29 pm, edited 1 time in total.
japrap
Member
Posts: 20
Joined: Wed Jan 14, 2015 1:54 pm
Vensim version: PLE

Re: plz help

Post by japrap »

LAUJJL wrote:Hi

The original model does not verify the mass balance check.

There is a mistake in the calculation of the 'potential GW admitting'. You must take into consideration the discharging. In fact one must first discharge, first priority, than admit trauma, second priority, than admit others pt third priority. Once the change is made the masses are balanced. I have too added the unit corrections that help understand how the model works and prevent bugs.
The GW residence time must be greate than an hour, otherwise there is a risk of the stock of GW patients coming negative.

Joined the model corrected.

Regards.

JJ
Dear JJ
Many many thanks for helping me . you are completely right, but the problems remain unresolved . please run the model and look at the "trauma patients waiting" and "other patients waiting" values at hour 1 (or set trauma pt arriving = 1 and then look at the incorrect values of the "trauma patients waiting" in the first 2 hours) .in addition , there is still a 1-hour lag in the "GW patients" values .

Best Regards
AM
LAUJJL
Senior Member
Posts: 1432
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: plz help

Post by LAUJJL »

Hi

I have rune the model I sent you with a 1 value for the 'trauma patients arriving' and did not find any error for the 'trauma patients waiting' nor elsewhere.

Joined the run in vdf format. Can you tell me where you see the problem?

Joined the run corrected from the second model that has now a control variable always equal to 1 or true.


Regards.

JJ
Attachments
patients waiting_2.vdf
(7.23 KiB) Downloaded 221 times
patients waiting.vdf
(7 KiB) Downloaded 211 times
Last edited by LAUJJL on Sun May 10, 2015 8:32 pm, edited 1 time in total.
japrap
Member
Posts: 20
Joined: Wed Jan 14, 2015 1:54 pm
Vensim version: PLE

Re: plz help

Post by japrap »

Dear JJ
Thank you very very much. you are completely right and I was wrong because I didn't consider the role of the "One hour" variable in the model .but as I mentioned above , normally patients are held in a department until a bed get available ( for example they are boarded in ED until an ICU bed get available and then , according to their high severity of illness , they get immediately admitted ) , so it seems that the variable "one hour" is just for justifying the model behavior .so is there anyway that we didn't consider this variable and everything just works correctly ?

Best Regards
AM
LAUJJL
Senior Member
Posts: 1432
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Re: plz help

Post by LAUJJL »

Hi

What do you mean by working properly?

Without a clear purpose and a minimum of understanding of your problem it is difficult to give an advice.

How close to the reality the model must be?

In the reality patients are integers and cannot be splitted like they are in the present model.

If you want that you must model the problem like a discreet event model.

It can be done in Vensim but if your model becomes really complex and has only queues, capacity and servicing like what you find in a factory, you might be better using discreet events packages like simul8 or witness or anylogic. But by experience it is often possible to build models with different packages using different paradigms like SD, DES or agent based solving the same problem.

The model I am working on presently has a large part of stricitly discreet data, but I still work well with Vensim.

Nothing is better than experimenting.

Regards.

JJ
japrap
Member
Posts: 20
Joined: Wed Jan 14, 2015 1:54 pm
Vensim version: PLE

Re: plz help

Post by japrap »

Dear JJ

I really thank you and I really appreciate you for the time you spend for me .
what you said is completely right .


Best Regards
A.M
Post Reply