inversion_ideas.Inversion#

class inversion_ideas.Inversion(objective_function, initial_model, minimizer, *, directives, stopping_criterion, max_iterations=None, cache_models=True, log=True, log_minimizers=True, minimizer_kwargs=None)#

Inversion runner.

Parameters:
objective_functionObjective

Objective function to minimize.

initial_model(n_params) array

Starting model for the inversion.

minimizerMinimizer or callable

Instance of Minimizer or callable used to minimize the objective function during the inversion. It must take the objective function and a model as arguments.

directiveslist of Directive

List of ``Directive``s used to modify the objective function after each iteration.

stopping_criterionCondition or callable

Boolean function that takes the model as argument. If this function returns True, then the inversion will stop.

max_iterationsint, optional

Max amount of iterations that will be performed. If None, then there will be no limit on the total amount of iterations.

cache_modelsbool, optional

Whether to cache each model after each iteration.

logLog or bool, optional

Instance of InversionLog to store information about the inversion, or any object that follows the inversion_ideas.typing.Log protocol. If True, a default InversionLog is going to be used. If False, no log will be assigned to the inversion, and Inversion.log will be None.

log_minimizersbool, optional

Whether to log the minimizers or not. Logging minimizers is only possible when the minimizer is an instance of inversion_ideas.base.Minimizer.

minimizer_kwargsdict, optional

Extra arguments that will be passed to the minimizer when called.

Attributes

counter

Iteration counter.

log_minimizers

Whether minimizers will be logged or not.

minimizer_logs

Logs of minimizers.

models

Cached inverted models.

stop_code

Code obtained after inversion stopped.

Methods

run([show_log])

Run the inversion.

Attributes#

Inversion.counter#

Iteration counter.

Inversion.log_minimizers#

Whether minimizers will be logged or not.

Inversion.minimizer_logs#

Logs of minimizers.

Inversion.models#

Cached inverted models.

The first model in the list is the initial model, the one that corresponds to the zeroth iteration.

Inversion.stop_code#

Code obtained after inversion stopped.

Code 0: the stopping criterion was met. Code 1: the inversion stopped due to that the maximum number of iterations was encountered.. Code None: the inversion is still running or hasn’t started yet.

Methods#

Methods documentation

Inversion.run(show_log=True)#

Run the inversion.

Parameters:
show_logbool, optional

Whether to show the log (if it’s defined) during the inversion.