Page 1 of 1

Dynamic cohorts with stock change

Posted: Wed Dec 22, 2021 6:48 am
by cobleg
I've been developing an electric vehicle forecast model in Ventity using the dynamic cohort pattern. I have two entities defined: LGA; and VehicleCohort. LGA represents spatial areas, namely local government areas. VehicleCohort contains information about the age of each cohort, number of registered vehicles by cohort and vehicle range.

I managed to get this working the way I want it, but I have a feeling there is a better way to implement the logic. In particular, the way I increase the Range attribute (actually a stock) in the create cohort action. Is there a more elegant way to implement this? I intend to add more complex logic, but wanted to build on the best foundation possible.

I have attached the model CarsByLGA2.zip for your reference. Thanks.

Re: Dynamic cohorts with stock change

Posted: Mon Jan 17, 2022 6:10 pm
by tomfid
This looks fine to me. The only thing I might do differently is keep the range dynamics in the entity rather than the action. In otherwords, compute "create cohort.change" in the LGA entitytype, and then just reference the value in the action (via parent.change or invoker.change). No difference in the result, but it might be easier to debug.

Re: Dynamic cohorts with stock change

Posted: Tue Mar 01, 2022 1:26 am
by cobleg
Cheers, thanks for the advice!