Lookup over time with subscripts
-
- Junior Member
- Posts: 14
- Joined: Mon Apr 18, 2016 4:33 pm
- Vensim version: DSS
Lookup over time with subscripts
Hello,
I've searched the forum for this topic but couldn't find the answer to my problem.
I have 4 products, demand for each is exogenous over time. Thought it should be easy but Vensim keeps telling me there are more than 1 equations for each product.
Please have a look at the attached model. Thanks!
Ruby
I've searched the forum for this topic but couldn't find the answer to my problem.
I have 4 products, demand for each is exogenous over time. Thought it should be easy but Vensim keeps telling me there are more than 1 equations for each product.
Please have a look at the attached model. Thanks!
Ruby
- Attachments
-
- testing lookup.mdl
- (2.08 KiB) Downloaded 533 times
Re: Lookup over time with subscripts
You're on the right track; the only problem is that your lookup definition uses the subscript range name twice. If you want a different lookup for each element, you need to use the individual element names, like:
MyRange : a, b
MyLookup[a] [(2015,0)-(2020,4000)],(2015,1000),(2016,1500),(2017,2000),(2018,2500),(2019,3000),(2020,3500)
MyLookup [(2015,0)-(2020,4000)],(2015,1000),(2016,1500),(2017,2000),(2018,2500),(2019,3000),(2020,3500)
MyRange : a, b
MyLookup[a] [(2015,0)-(2020,4000)],(2015,1000),(2016,1500),(2017,2000),(2018,2500),(2019,3000),(2020,3500)
MyLookup [(2015,0)-(2020,4000)],(2015,1000),(2016,1500),(2017,2000),(2018,2500),(2019,3000),(2020,3500)
/*
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
*/
-
- Junior Member
- Posts: 14
- Joined: Mon Apr 18, 2016 4:33 pm
- Vensim version: DSS
Re: Lookup over time with subscripts
Got it! Many thanks, Tom!
-
- Junior Member
- Posts: 14
- Joined: Mon Apr 18, 2016 4:33 pm
- Vensim version: DSS
Re: Lookup over time with subscripts
Another problem I encounter is to index the array. There are a couple functions in Vensim but I don't know which one to use.
If I have a vector of Q=[30,50,70,90,110], after calculating the profit of all Qs, I have another vector P=[100,200,500,350,400]. I can easily find Pmax with Vmax function and find the index/location of Pmax (from previous threads). In this case, Pmax location is 3. The question is if I want to extract the value of Q3, what is the simplest way to go? Thanks!
Ruby
If I have a vector of Q=[30,50,70,90,110], after calculating the profit of all Qs, I have another vector P=[100,200,500,350,400]. I can easily find Pmax with Vmax function and find the index/location of Pmax (from previous threads). In this case, Pmax location is 3. The question is if I want to extract the value of Q3, what is the simplest way to go? Thanks!
Ruby
Re: Lookup over time with subscripts
You want VECTOR REORDER with SORT ORDER. See the example in https://www.vensim.com/documentation/fn ... eorder.htm
/*
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: Lookup over time with subscripts
Hi
Another solution that does not need the vector order function is joined.
Regards.
JJ
Another solution that does not need the vector order function is joined.
Regards.
JJ
- Attachments
-
- sub max.mdl
- (1.82 KiB) Downloaded 633 times
-
- Junior Member
- Posts: 14
- Joined: Mon Apr 18, 2016 4:33 pm
- Vensim version: DSS
Re: Lookup over time with subscripts
JJ,
Many thanks for the solution. This is very similar to Powersim, which I'm familiar with.
Ruby
Many thanks for the solution. This is very similar to Powersim, which I'm familiar with.
Ruby
Re: Lookup over time with subscripts
Good solution. The VECTOR operations are computationally expensive if you only need the min or max element.
/*
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: Lookup over time with subscripts
Hi
There are probably many other ways to solve that problem.
One is to first identify the subscript range corresponding to the maximum and then to find the value in q using a vector elm map function that is maybe quicker if there is a large number of subs. I have not tried. To use the vector elm map one is obliged to find first the subscript. Joined the model. It is maybe quicker but unfortunately more tricky and difficult to understand.
Regards.
JJ
There are probably many other ways to solve that problem.
One is to first identify the subscript range corresponding to the maximum and then to find the value in q using a vector elm map function that is maybe quicker if there is a large number of subs. I have not tried. To use the vector elm map one is obliged to find first the subscript. Joined the model. It is maybe quicker but unfortunately more tricky and difficult to understand.
Regards.
JJ
- Attachments
-
- sub max2.mdl
- (2.19 KiB) Downloaded 478 times
-
- Junior Member
- Posts: 14
- Joined: Mon Apr 18, 2016 4:33 pm
- Vensim version: DSS
Re: Lookup over time with subscripts
A little off track but still in the subscript topic.
If I have a subscript of 4 products, can I show 2 of them on a graph instead of 4? The reason why I want to show them separately is because of values. Say products A & B are calculated in millions while products C & D are counted in hundreds. Displaying on the same graph will make C & D look like zero.
Thanks!
Ruby
If I have a subscript of 4 products, can I show 2 of them on a graph instead of 4? The reason why I want to show them separately is because of values. Say products A & B are calculated in millions while products C & D are counted in hundreds. Displaying on the same graph will make C & D look like zero.
Thanks!
Ruby
Re: Lookup over time with subscripts
Sure - just vary what you select in the Subscript Control: https://www.vensim.com/documentation/in ... ?20165.htm
If you need to make it permanent, create subranges & custom graphs.
If you need to make it permanent, create subranges & custom graphs.
/*
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
*/
-
- Junior Member
- Posts: 14
- Joined: Mon Apr 18, 2016 4:33 pm
- Vensim version: DSS
Re: Lookup over time with subscripts
So when I select the active subscript, does it mean that I can't have both graphs (1 for A&B) and 1 for ( C&D) at the same time?
Thanks!
Thanks!
Re: Lookup over time with subscripts
You can have both if you define a custom graph, and you can display both on the screen at one time. There just isn't a way to generate two different graphs with one click.
If you have few elements, another option would be to use the strip graph tool with the causes & uses options turned off. Then you'd get a single window with one graph per subscript element in it.
If you have few elements, another option would be to use the strip graph tool with the causes & uses options turned off. Then you'd get a single window with one graph per subscript element in it.
/*
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
*/
-
- Junior Member
- Posts: 14
- Joined: Mon Apr 18, 2016 4:33 pm
- Vensim version: DSS
Re: Lookup over time with subscripts
Thanks for the suggestion, Tom!