Hello,

I model a stylized electrcity market. My aim is to know the optimal investment decisions each year, by using Vensim optimization.

To this end, I define the invesment variable as following, with a specific variable to use each year:

IF THEN ELSE( Time=2020 ,g0 , IF THEN ELSE( Time=2021 ,g1 , IF THEN ELSE

( Time=2022 ,g2 , IF THEN ELSE( Time=2023 ,g3 , IF THEN ELSE( Time=2024 ,g4 , IF THEN ELSE( Time=2025 ,g5 , IF THEN ELSE

( Time=2026 ,g6 , IF THEN ELSE( Time=2027 ,g7 , IF THEN ELSE( Time=2028 ,g8 , IF THEN ELSE( Time=2029 ,g9 , IF THEN ELSE

( Time=2030 ,g10 , IF THEN ELSE( Time=2031 ,g11 , IF THEN ELSE( Time=2032 ,g12 , IF THEN ELSE( Time=2033 ,g13 , IF THEN ELSE

( Time=2034 ,g14 , IF THEN ELSE( Time=2035 ,g15 , IF THEN ELSE( Time=2036 ,g16 , IF THEN ELSE( Time=2037 ,g17 , IF THEN ELSE

( Time=2038 ,g18 , IF THEN ELSE( Time=2039 ,g19 , IF THEN ELSE( Time=2040 ,g20 , IF THEN ELSE( Time=2041 ,g21 , IF THEN ELSE

( Time=2042 ,g22 , IF THEN ELSE( Time=2043 ,g23 , IF THEN ELSE( Time=2044 ,g24 , IF THEN ELSE( Time=2045 ,g25 , IF THEN ELSE

( Time=2046 ,g26 , IF THEN ELSE( Time=2047 ,g27 , IF THEN ELSE( Time=2048 ,g28 , IF THEN ELSE( Time=2049 ,g29 , IF THEN ELSE

( Time=2050 ,g30 , IF THEN ELSE( Time=2051 ,g31 , IF THEN ELSE( Time=2052 ,g32 , IF THEN ELSE( Time=2053 ,g33 , IF THEN ELSE

( Time=2044 ,g34 , IF THEN ELSE( Time=2055 ,g35 , IF THEN ELSE( Time=2056 ,g36 , IF THEN ELSE( Time=2057 ,g37 , IF THEN ELSE

( Time=2058 ,g38 , IF THEN ELSE( Time=2059 ,g39 , g40) ) ) ) ) ) ) ) ) ) ) ) )) )) ) ) ))) ) ) ) ) ) ) ) ) ) ) ) )) ))))))

My quesiton is: is there a more elegant way to do it?

Thank you

## Improving the modelling of annual decisions used for optimization

### Re: Improving the modelling of annual decisions used for optimization

There are two options:

1. Replace the IF THEN ELSE structure with a VECTOR LOOKUP over time (I think the sample model for VECTOR LOOKUP illustrates this). Then you will have an array of time points, like

decisionTime : (t1-t10)

with

gValue[decisionTime] = 3.5, 2.4, 1.9, 4.2 ...

You can then specify gValue[decisionTime] in your optimization control file.

2. Similar to the above, make the decision a function of time with something like Legendre polynomials:

https://metasd.com/2018/02/polynomials- ... ion-rules/

3. Replace the ballistic decisions above with a real feedback decision rule. I don't know what this is about, but an example might be:

ordering = expected losses + a*(desired inventory-inventory) + b*(desired pipeline-pipeline)

where a and b are parameters to be optimized and the rest are dynamic variables.

#3 is generally preferable, because (a) it gives you insight into the structure of the problem, and (b) it's robust to uncertainty and different states of the model. The decisions produced by 1 & 2 are fragile - they only work for a single realization of the model. Also, they assume knowledge of the future, which is impossible.

1. Replace the IF THEN ELSE structure with a VECTOR LOOKUP over time (I think the sample model for VECTOR LOOKUP illustrates this). Then you will have an array of time points, like

decisionTime : (t1-t10)

with

gValue[decisionTime] = 3.5, 2.4, 1.9, 4.2 ...

You can then specify gValue[decisionTime] in your optimization control file.

2. Similar to the above, make the decision a function of time with something like Legendre polynomials:

https://metasd.com/2018/02/polynomials- ... ion-rules/

3. Replace the ballistic decisions above with a real feedback decision rule. I don't know what this is about, but an example might be:

ordering = expected losses + a*(desired inventory-inventory) + b*(desired pipeline-pipeline)

where a and b are parameters to be optimized and the rest are dynamic variables.

#3 is generally preferable, because (a) it gives you insight into the structure of the problem, and (b) it's robust to uncertainty and different states of the model. The decisions produced by 1 & 2 are fragile - they only work for a single realization of the model. Also, they assume knowledge of the future, which is impossible.

/*

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: Improving the modelling of annual decisions used for optimization

A similar discussion is here:

viewtopic.php?f=2&t=6873

viewtopic.php?f=2&t=6873

/*

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: Improving the modelling of annual decisions used for optimization

Hello,

I try to model it with a vector lookup but I have this warning when I run the optimization. "timevalues" is a constant with a normal sub-type.

No usable constant name.

0<=timevalues<=150.

^.

Line 32 of file Opti_Control file_vector.VOC.

Previous errors prevent continuing

What should I do?

Thank you

I try to model it with a vector lookup but I have this warning when I run the optimization. "timevalues" is a constant with a normal sub-type.

No usable constant name.

0<=timevalues<=150.

^.

Line 32 of file Opti_Control file_vector.VOC.

Previous errors prevent continuing

What should I do?

Thank you

### Re: Improving the modelling of annual decisions used for optimization

You need to specify the subscript dimension:

0<=timevalues[timerange]<=150

0<=timevalues[timerange]<=150

/*

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: Improving the modelling of annual decisions used for optimization

Thank you, it works now!

I assume that if I use the same payoff definition file, replace the equation in my first message with an equivalent vector lookup function and update the optimization control file accordingly, I would have the same decisions for a policy optimization. Is it true as an assumption?

I assume that if I use the same payoff definition file, replace the equation in my first message with an equivalent vector lookup function and update the optimization control file accordingly, I would have the same decisions for a policy optimization. Is it true as an assumption?

### Re: Improving the modelling of annual decisions used for optimization

Generally, yes. VECTOR LOOKUP is potentially better because it interpolates, so you could have fewer points than there are time steps in the model.

A feedback-based decision rule is still superior.

A feedback-based decision rule is still superior.

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

*/