zward / Amua

An open source modeling framework
GNU General Public License v3.0
37 stars 11 forks source link

Termination rule for Markov Models / ArrayIndexOutOfBounds for t #65

Open geweh opened 9 months ago

geweh commented 9 months ago

Hi!

Thanks for the great project - I really like the interface. Unfortunately, I've got some issues with the termination rules in markov cycles: When constructing a "mini-markov" simulation with 5 cycle runs, I wanted to stop the model after the 5th cycle automatically. Different logic operators (t==6 / t >5,...) did all cause errors (ArrayIndexOutOfBounds), except for the first run.

And - sorry for this question - I need to derive cycle-dependend probabilities from different tables (empirical probabilities). To look up the cycle, I thought to reference like "table"[t,column] - but, unfortunately, when the model starts with t = 0, "probability errors" where put out (probably due to the linked table index, which contains strings?) A workaround [t+1, column] and additional row (0, probabilities: 0) seemed to interfer with the termination condition / number of run cycles and did not work...

Could you maybe supply some solutions to (a) appropriate termination conditions and (b) a way of applying cycle-dependend transition probabilities to the markov cycles from an empirical table (deterministic probabilities).

Thanks a lot! Georg

zward commented 9 months ago

Hi Georg, Thanks for your message. I think there may be an issue with t not resetting to 0 when there is a runtime error with the termination condition - that would explain why the first run behaves differently than subsequent runs. Let me update the code: can you send me a message (zward@hsph.harvard.edu) with your e-mail so I can send you a test version of Amua to see if that solves your issue before making a public release?

You should be able to use a lookup table indexed by t to get time-dependent probabilities - if they do not sum to 1.0 you will get a probability error though, so make sure you are using 'C' as the other complementary probability. I think the termination condition issue is interfering with your ability to test this though...

Best, Zach