Added an optional parameter to SFO, update_func, that is a function handle that gets called on each iteration and is passed the current iteration index, objective value, and model parameters (theta) as arguments. Useful for storing / visualizing parameters as the optimizer is running. Defaults to None, in which case nothing is done on each iteration.
Changed name of argument in theta_flat_to_original from theta_original to theta_flat (avoids confusion)
convert theta from flat to original before calling update_func