Combining Lookup Variables

Use this forum to post Vensim related questions.
Post Reply
bil
Junior Member
Posts: 3
Joined: Sat Mar 02, 2019 1:36 am
Vensim version: PLE

Combining Lookup Variables

Post by bil »

Hi,

I have two lookup variables I would like to combine into one. For example, given two lookup variables that represent an activity of a single individual in time as either engaged (1) or not (0): how can I combine "Work" and "Sleep" to have a third lookup variable "Busy". The input to the lookup variables is "Time".

Please find below some ideas I am exploring, but they are not straight forward. Ignore what is below if you have a straight forward suggestion.

I am able to combine (addition operator) the two lookup variables to have "Busy output" as an auxiliary variable that shows the expected output after simulation. However I am interested in a lookup variable so that I can find out what times are busy without running the entire simulation.

Another option I considered is to have two Vensim files. The first Vensim file creates the combined lookups for the duration of the simulation as an auxiliary variable "Busy output", then exports "Busy output" as an Excel file "Busy.xlsx". The second Vensim file then reads in "Busy.xlsx" as a lookup variable "Busy lookup" and proceeds. As you can imagine, this approach will be cumbersome, as well as error prone when scaling to multiple individuals. Also, this approach might require some mouse-clicking because I do not know how to export data automatically during, or after, a simulation without using mouse as illustrated in the help pages (http://www.vensim.com/documentation/data_export.htm).

Looking forward to your responses.

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

Re: Combining Lookup Variables

Post by tomfid »

How about something like:

working = work_lookup(time)
sleeping = sleep_lookup(time)
busy = IF THEN ELSE( working :OR: sleeping, 0, 1 )

?
bil
Junior Member
Posts: 3
Joined: Sat Mar 02, 2019 1:36 am
Vensim version: PLE

Re: Combining Lookup Variables

Post by bil »

Thanks for the prompt reply.

Whilst this may be a neater solution, it don't think it will work well with all the cases I plan to use it for. There are 2 cases, which should be checked in the same equation (IF ELSE THEN equation).

The first case is to check if the individual is busy in the current simulation time. In this case, your suggestion works well by using current simulation time "Time" in the equations.

The second case is to check if the individual is busy in a future, or even past, time. For this scenario, I would want something like:

busy_at_future_time = busy_lookup(future_time)

Having a single combined lookup would allow for an equation like:

future_time1 = Time + duration_of_new_activity1
start_new_activity1 = IF THEN ELSE( busy_lookup(Time) = 0 :AND: busy_lookup(future_time1) = 0,
1, 0 )

However, using your suggestion, perhaps we could have something for each activity like:

future_time1 = Time + duration_of_new_activity1
busy_now = IF THEN ELSE( work_lookup(Time) :OR: sleep_lookup(Time), 1, 0 )
busy_at_end_activity1 = IF THEN ELSE( work_lookup(future_time1) :OR: sleep_lookup(future_time1), 1, 0 )
start_new_activity1 = IF THEN ELSE( busy_now = 0 :AND: busy_at_end_activity1 = 0,
1, 0 )

Using this last suggestion would lead to a messy stock and flow diagram because each activity (which there will be many of) will have to be linked to the all the lookup variables (which may be many as well). However, when using a single combined lookup like busy_lookup(), there should be much less links and variables as the model scales up.

Any further suggestions?
Thanks
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Combining Lookup Variables

Post by Administrator »

The only thing I can think of is VECTOR LOOKUP which is not available in PLE. You can use VECTOR LOOKUP to define a lookup based on an array of values. So it would be easy to add two arrays to give a 3rd array which would be your lookup.
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
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Combining Lookup Variables

Post by tomfid »

If the point is to combine a bunch of conflicting schedule elements in a static way, which is what lookups would do, you could pre-combine the lookup tables in a spreadsheet and plug the result into the model.

If it's something else, I'd have to understand more about the dynamics to be represented in order to comment.
bil
Junior Member
Posts: 3
Joined: Sat Mar 02, 2019 1:36 am
Vensim version: PLE

Re: Combining Lookup Variables

Post by bil »

tomfid wrote: Sat Nov 23, 2019 12:47 pm If the point is to combine a bunch of conflicting schedule elements in a static way, which is what lookups would do, you could pre-combine the lookup tables in a spreadsheet and plug the result into the model.

If it's something else, I'd have to understand more about the dynamics to be represented in order to comment.
I have implemented this already because it is the option that provides me the combined schedule as a lookup variable which makes the diagram easier to read.
Administrator wrote: Sat Nov 23, 2019 8:17 am The only thing I can think of is VECTOR LOOKUP which is not available in PLE. You can use VECTOR LOOKUP to define a lookup based on an array of values. So it would be easy to add two arrays to give a 3rd array which would be your lookup.
I am running PLE+ and it also doesn't have VECTOR LOOKUP, but I am currently using a spreadsheet for the combination (explained above).


Thank you both
Post Reply