worlddynamics / Vensim2MTK.jl

A Julia package to import Vensim .xmile files as ModelingToolkit.jl models.
MIT License
2 stars 1 forks source link

Smooth initialisation #7

Closed meyde closed 1 year ago

meyde commented 1 year ago

when initialising variables during a smooth, the initial values are symbol, and not all are calculated. (meaning that some are). the order of definition doesn't matter. e.g : @variables TEMPVARSMOOTHED_Smoothed_Return(t) = ((Marg_Return_Capital)-((Initial_Return_Trend)*(smoothing_time)))

give the error: ArgumentError: Any[Marg_Return_Capital(t) - 20.0Initial_Return_Trend] are either missing from the variable map or missing from the system's states/parameters list.

here, smoothing_time was computed but Initial_Return_Trend and Marg_Return_Capital were not. I've tried replacing them by smoothing_time and it works. i don't know why smoothing time gets computed but not the other, they are defined similarly:

@parameters Initial_Return_Trend = -0.00054 [description = "Initial_Return_Trend"]

@parameters smoothing_time = 20.0 [description = "smoothing_time"]

meyde commented 1 year ago

i've tried Something, and i've replaced all variables used in initalisation by parameters; and there is still a problem. some parameters are not recognized. I've replaced all variables by the parameter "Initial_return_trend", and it failed. i've then replaced them by "smoothing_time", a parameter defined exactly the same, and it works (until there is a domain error in the modelisation, but the wrong values are probably to blame).