acturtle / cashflower

An open-source Python framework for actuarial cash flow models
https://cashflower.acturtle.com
MIT License
38 stars 9 forks source link

how do I update "T_MAX_CALCULATION" and "T_MAX_OUTPUT" ? #367

Closed DanielBayo closed 4 months ago

DanielBayo commented 5 months ago

I am trying to build a model, however for each model point set, the T_MAX_CALCULATION" is calculated from the model point. Any idea on how to achieve this? e.g main = ModelPointSet(data=pd.DataFrame( { 'id': [1, 2, 3], 'x':[400,455,500], 'y':[4,5,7] } )) for id==1, T_MAX_CALCULATION,T_MAX_OUTPUT=x+y .Thank you

zchmielewska commented 5 months ago

Hi @DanielBayo ,

these two settings (T_MAX_CALCULATION and T_MAX_OUTPUT) are constant across all model points.

If you need shorter calculation for certain model points, you can incorporate this logic into the model.

For example:

model.py

@variable()
def foo(t):
    if t > main.get("x") + main.get("y"):
        return 0
    else:
        pass # your logic here

Hope this helps!

DanielBayo commented 4 months ago

@zchmielewska. Thank you, it does. Thanks for the help.

DanielBayo commented 4 months ago

.