tBuLi / symfit

Symbolic Fitting; fitting as it should be.
http://symfit.readthedocs.org
MIT License
233 stars 17 forks source link

Fixed #271 by lazily creating Hessian and Jacobian models #273

Closed tBuLi closed 4 years ago

tBuLi commented 4 years ago

Hessian and Jacobian models are only created when they are needed. For most use cases, this means the Hessian will no longer be calculated. This is a huge speedup gain, comparing to the code provided in #271, we get the following timings:

identical components, time (s)
1 0.005013465881347656
2 0.0010039806365966797
3 0.0010023117065429688
4 0.0010018348693847656
5 0.0010030269622802734
6 0.0010023117065429688
7 0.002006053924560547
8 0.0010023117065429688
9 0.002004861831665039
10 0.0020058155059814453

whereas in 0.5.1 it was

identical components, time (s)
1 0.0671529769897461
2 0.20554876327514648
3 0.8522927761077881
4 2.4235997200012207
5 5.880227088928223
6 13.202399969100952
7 25.026122331619263
8 42.70384192466736
...

The penalty will still occur if you actually use a Hessian minimizer, so don't.