Setting value in lookup of Auxiliary variable

Use this forum to post Vensim related questions.
Post Reply
roel_v
Junior Member
Posts: 6
Joined: Thu Jun 02, 2016 2:17 pm
Vensim version: DSS

Setting value in lookup of Auxiliary variable

Post by roel_v »

I have one problem which breaks down into several questions.

Essentially, I'm calling the vensim dll from C++, and I have a bunch of Vensim variables for which I want to set (change) the value before calling ::vensim_continue_simulation(1); . This works fine for most variables (as far as I can tell for now) when I use the form ::vensim_command("SIMULATE>SETVAL|VarName[DimVal]=0.1"), for example.

But now I have a variable of type "Auxiliary" of subtype "with Lookup". The above method doesn't work, at least, ::vensim_command() returns 0 when doing this for this variable. So I found in the documentation that I need to use the brace syntax for lookups (and I assumed that an "Auxiliary" of type "Lookup" is the same?). So, I thought I could do "SIMULATE>GETVAL|time" to get the 'x' value for the lookup, and then do "SIMULATE>SETVAL|VarName((1=0.1)) (where '1' would be the value I get back as 'time', and 0.1 the new value to set).

I've wrapped all of my code into a C++ abstraction layer, for which I don't want the client to be concerned about the type of variable. So I thought I'd check the variable type and subtype, and call syntax 1 or syntax 2, depending on the type. However I can't find a way to get the subtype (vensim_get_varattrib only returns the type, not the subtype).

So my questions:

- Am I going about this in the right way at all?

But more specifically:

- Is the way I described above the right way to set the lookup values for an Auxiliary variable of subtype 'with Lookup'?
- Is it possible to set the value of only a single element in a lookup in the way described above?
- When using subscripts, do I need to put in any quotes anywhere, and if so, where?
- How do I find out the subtype of a variable?
- Is the way I get the 'time' variable correct? What is the unit of 'time', in the first place? The Vensim model I got to interface with does daily timesteps (model->Settings has 'TIME STEP' set to 0.0025) but the 'Look up' data in the variable has keys 0, 1, 2, ... etc for each year. So I'm confused as to what 'time' means in a simulation.

Sorry about the long list of questions but I figured it'd be easier if I'd just describe the context and treat it all as different ways of viewing the same underlying issue. Thanks.
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: Setting value in lookup of Auxiliary variable

Post by Administrator »

You cannot change the values of auxiliaries.

The best thing to do is split the parameter into it's parts. For example,

some value = WITH LOOKUP ( time , ((0,1),(1,1),(2,2)))
would become
some lookup ((0,1),(1,1),(2,2))
some value = some lookup ( time )

To be honest, I don't even know why the "with lookup" function is even in Vensim.

Other questions.
>> is it possible to set the value of only a single element in a lookup in the way described above?
No, you need to set the whole lookup.

>> When using subscripts, do I need to put in any quotes anywhere, and if so, where?
Only if the subscript has quotes around it.

>> How do I find out the subtype of a variable?
You can't unless you look at the equation in the model.

>> the way I get the 'time' variable correct?
You can get time via vensim_get_val.

>> What is the unit of 'time', in the first place?
Depends on the model.
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
roel_v
Junior Member
Posts: 6
Joined: Thu Jun 02, 2016 2:17 pm
Vensim version: DSS

Re: Setting value in lookup of Auxiliary variable

Post by roel_v »

Thank you, even if this is very bad news for me :)

So to double check that I understand, can I rephrase what you said as - an Auxiliary variable with sub-type 'with Lookup' is the same as two variables, a 'normal' one (i.e. of type Auxiliary and sub-type 'Normal) and a Lookup variable; and where the formula of that normal variable is "some lookup ( time )" ? And by splitting it up, I can modify the Lookup variable at runtime, and thus it will 'seem' (to the rest of the model) as if the normal variable is the one that changes over time ?
Administrator
Super Administrator
Posts: 4589
Joined: Wed Mar 05, 2003 3:10 am

Re: Setting value in lookup of Auxiliary variable

Post by Administrator »

Correct.
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: 3808
Joined: Wed May 24, 2006 4:54 am

Re: Setting value in lookup of Auxiliary variable

Post by tomfid »

>> is it possible to set the value of only a single element in a lookup in the way described above?
You can't do this with a lookup, but you can do it with an array of constants and VECTOR LOOKUP.
Post Reply