cgarling / StarFormationHistories.jl

Fitting astrophysical star formation histories via CMD modelling.
MIT License
3 stars 0 forks source link

Optimization in `fixed_amr` #21

Closed cgarling closed 7 months ago

cgarling commented 8 months ago

With dense isochrone grids (> 1000 isochrones) the primary compute time for SFH optimization is spent in the composite! function doing the linear algebra to build the composite model. In fixed_amr, relative weights due to age-metallicity relations and metallicity distribution functions are fixed at runtime and the only optimization parameters are effectively star formation rates. As such, we could exclude isochrones with very low relative weights from the computation at runtime with (hopefully) minimal impact on convergence / quality of the fits. I'm thinking of adding a keyword argument, something like relweightcut, such that when considering the set of all relative weights aweights for isochrones of age a, isochrones with aweights[i] <= relweightcut * maximum(aweights) would be excluded from the composite model. With grids that are quite wide in metallicity-space this could lead to speedups ~2-5x. Thinking default should be for this behavior to be disabled, but it's a nice feature for applications where you might run fixed_amr many times in a loop (i.e., Monte Carlo applications) as long as it doesn't impact accuracy significantly.

In principle this could additionally be implemented into methods that fit the age-metallicity relation but you would have to redefine the selection in every loop iteration, and since the metallicity parameters are now being fit I worry that truncating the isochrone list could lead to instability or inaccuracy, so this application is low-priority.

cgarling commented 7 months ago

This is now implemented in the fixed_amr method of fitting/hierarchical/fixed_amr.jl via the keyword argument relweightsmin.