I'm implementing an iterative optimization routine, and as a diagnostic, I'd like to have the option to store and return the intermediary values (so that I can plot the convergence versus iteration). The set up is something like
def alg(args,diagnostic=False):
for i in range(n):
... optimize args ...
How can I provide an option to store the history without
- requiring an
if diagnostic == Truewithin my iteration loop - requiring an
if diagnostic == Trueoutside of the loop and having two nearly identical implementations below to call run normal mode or diagnostic mode
Aucun commentaire:
Enregistrer un commentaire