fumitoh / modelx

Use Python like a spreadsheet!
https://modelx.io
GNU Lesser General Public License v3.0
90 stars 20 forks source link

Recalculation upon input change #24

Closed alebaran closed 4 years ago

alebaran commented 4 years ago

Thank you for releasing new version and all the improvement. There is one item, which creates a problem for me:

Before version 0.1.0, when a new input value is assigned to a node of a Cells, the values of the nodes depending on the input cells are cleared. From version 0.1.0, those values are recalculated.

The model I built has hundreds of parameters. After performing a base run, I do a number of sensitivity runs, in which several parameters are changed together. It often doesn't make sense to change one parameter without changing the other. It isn't beneficial to have the model automatically recalculating after each parameter is changed. It slows down the execution a lot and in some cases may lead to breakage of the model (as the parameter should only be changed together with the other one).

This change goes against the basic design principle of modelx that it only calculates what has been asked for. For example, in the base run I may produce 100 results, but in the sensitivity run I only need 1 number. But I can't control it, if everything is always recalculated.

fumitoh commented 4 years ago

I'll consider adding an option to control whether you want to clear or recalculate dependent cells.

alebaran commented 4 years ago

What is the idea behind automatic recalculation?

alebaran commented 4 years ago

Btw. I have experience with another python library with dependency grid quantlib. It doesn't have automatic recalculation function.

fumitoh commented 4 years ago

When you use modelx interactively on IPython console, it's annoying when you change one part a model and the rest of it vanishes. You need to manually populate same cells again.

What's the other python library? Is it in QuantLib?

alebaran commented 4 years ago

How do they use it in console? Do you mean that they use .frame option to explore results?

QuantLib indeed

fumitoh commented 4 years ago

Yes. Just like the way you would normally use Excel.

alebaran commented 4 years ago

In this case I would trigger recalculation, when .frame is called

fumitoh commented 4 years ago

modelx v0.2.0 adds an option to activate/deactivate dependents recalculation. https://modelx.readthedocs.io/en/latest/releases/relnotes_v0_2_0.html

alebaran commented 4 years ago

Thank you very much