transentis/bptk_py_tutorial

deathRate not connect to foodAvailablePerPerson in step-by-step-guides

Closed this issue · 6 comments

image
in this code, i think the deathRate not connect to foodAvailablePerPerson
image

i think may be add one line
`
model.points["deathRate"] = [
[0.0,1.0],
[0.1,0.670320046036],
[0.2,0.449328964117],
[0.3,0.301194211912],
[0.4,0.201896517995],
[0.5,0.135335283237],
[0.6,0.0907179532894],
[0.7,0.0608100626252],
[0.8,0.0407622039784],
[0.9,0.0273237224473],
[1.0,0.0183156388887]
]

deathRate.equation = model._lookup(foodAvailablePerPerson, model.points["deathRate"])

deaths.equation = deathRate * population
`
but this result not my want too
image

so i want to know how to connect deathRate to foodAvailablePerPerson, thanks.

mingR commented

Hi, I think it should be:

from BPTK_Py import sd_functions as sd
deathRate.equation = sd.lookup(foodAvailablePerPerson, "deathRate")

sorry for our late response - we will check this today and give you feedback

so - I've just checked the notebook and you are both completely right: the connection between deathRate and foodAvailablePerPerson is illustrated correctly in the diagram but missing in the code.

mingR's solution is correct, thank you!

I will get an update to the repo posted today and will then post a comment here.

but, when i use mingR's solution, i find deathRate not change, is right?
image

I've updated the notebook - I'll push it in a seconds. The deathRate can be constant or change, depending on the initial settings.

I've pushed the changes to github - I've set the base scenario to a stable state (so deathRate is also stable and equal to birthRate)

In the scenario07 the deathRate is higher then the birth rate and population decreases

I hope this answers your question and thank you for pointing this out. Let me know if you have further questions.