Skip to content
Notifications
Clear all

Dynamic variable

3 Posts
4 Users
1 Reactions
1,385 Views
Avatar
Posts: 1
Customer
Topic starter
(@0ojhfmwqgjrglyp46x5qoeo0jgg2)
New Member
Joined: 2 years ago

Dear Analytical users,

I am newbe.

If I define inv_t as:

Dynamic[i_t](inv_0,Self[i_t-1]-dem_t[i_t]+lambda[i_t])

And i_t as:

1 .. 365

I will obtein in inv_t as

first value

inv_0

inv_0

second value

inv_0 - dem_t[1] + lambda[1]

or second value is

inv_0 - dem_t[2] + lambda[2]

Thanks in advance,

Sebastián.

2 Replies
Lonnie Chrisman
Posts: 42
Admin
(@lchrisman)
Member
Joined: 14 years ago

The second value will be

inv_0 - dem_t[1] + lambda[1] 

Let's take some example values:

Inv_0 := 100000
Dem_t := 10 * I_t
Lambda := 100 * I_t

The result sequence will be:

100000
100000 + 200 - 20 = 100180
100180 + 300 - 30 = 100450
100450 + 400 - 40 = 100810
...

By the way, if you prefer writing dem_t[I_t] then that is fine, but the [I_t] part is not doing anything since variable names in a Dynamic automatically use the current time slice.  So it is entirely equivalent to write

Dynamic[i_t](inv_0, Self[i_t-1] - dem_t + lambda)

 My own preference is to not include the extra subscript notation.

Reply
Avatar
Posts: 3
Customer
(@xlptf79tizl550gfep8lo6isp6t2)
Active Member
Joined: 3 years ago

In a Dynamic, the notation X[I_t - k] is by position, not by value. So this notation is an abbreviated for X[@I_t = @I_t - k].  In general, this is not the same as X[ I_t = I_t - k ] nor X[ @I_t = I_t - k ]. 

Since positions are numbered starting at 1, positional and associative subscripts are the same in your example where you have 

Index I_t := 1..365

But, if your change your example to instead use

Index I_t := 0..364

now you can see it makes a difference. When you are at the second position along I_t, the value of I_t is now 1, but the position is 2.

Changing the index in this way would not change the result of your Dynamic expression, because it is using positions and not the index values.

I point this out because your question about which one was the result sounded to me like you might have been wondering whether it was by position or by value, and maybe you were thinking that positions start at 0, as they do in C or Python languages.

 

Reply
Share:

Download the free edition of Analytica

The free version of Analytica lets you create and edit models with up to 101 variables, which is pretty substantial since each variable can be a multidimensional array. It also lets you run larger modes in ‘browse mode.’ Learn more about the free edition.

While Analytica doesn’t run on macOS, it does work with Parallels or VMWare through Windows.


    Analytica Cubes Pattern

    Download the free edition of Analytica

    The free version of Analytica lets you create and edit models with up to 101 variables, which is pretty substantial since each variable can be a multidimensional array. It also lets you run larger modes in ‘browse mode.’ Learn more about the free edition.

    While Analytica doesn’t run on macOS, it does work with Parallels or VMWare through Windows.


      Analytica Cubes Pattern