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_function
Objective Objective function to minimize.
- initial_model(
n_params)array Starting model for the inversion.
- minimizer
Minimizerorcallable() Instance of
Minimizeror callable used to minimize the objective function during the inversion. It must take the objective function and a model as arguments.- directives
listofDirective List of
Directiveused to modify the objective function after each iteration.- stopping_criterion
Conditionorcallable() Boolean function that takes the model as argument. If this function returns
True, then the inversion will stop.- max_iterations
int, 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.
- log
Logor bool, optional Instance of
InversionLogto store information about the inversion, or any object that follows theinversion_ideas.typing.Logprotocol. IfTrue, a defaultInversionLogis going to be used. IfFalse, no log will be assigned to the inversion, andInversion.logwill beNone.- log_minimizersbool, optional
Whether to log the minimizers or not. Logging minimizers is only possible when the
minimizeris an instance ofinversion_ideas.base.Minimizer.- minimizer_kwargs
dict, optional Extra arguments that will be passed to the
minimizerwhen called.
- objective_function
Attributes
Iteration counter.
Whether minimizers will be logged or not.
Logs of minimizers.
Cached inverted models.
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.