simpeg.objective_function.ComboObjectiveFunction#
- class simpeg.objective_function.ComboObjectiveFunction(objfcts=None, multipliers=None, unpack_on_add=True)[source]#
Bases:
BaseObjectiveFunction
Composite for multiple objective functions.
This class allows the creation of an objective function \(\phi\) which is the sum of a list of other objective functions \(\phi_i\). Each objective function has associated with it a multiplier \(c_i\) such that
\[\phi = \sum_{i = 1}^N c_i \phi_i\]- Parameters:
- objfcts
None
orlist
of
simpeg.objective_function.BaseObjectiveFunction
,optional
List containing the objective functions that will live inside the composite class. If
None
, an empty list will be created.- multipliers
None
orlist
of
int
,optional
List containing the multipliers for each objective function in
objfcts
. IfNone
, a list full of ones with the same length asobjfcts
will be created.- unpack_on_addbool
Whether to unpack the multiple objective functions when adding them to another objective function, or to add them as a whole.
- objfcts
Attributes
Full weighting matrix for the combo objective function.
Mapping from the model to the quantity evaluated in the object function.
Multipliers for the objective functions.
Number of model parameters.
Methods
__call__
(m[, f])Evaluate the objective functions for a given model.
deriv
(m[, f])Gradient of the objective function evaluated for the model provided.
deriv2
(m[, v, f])Hessian of the objective function evaluated for the model provided.
get_functions_of_type
(fun_class)Return objective functions of a given type(s).
map_class
alias of
IdentityMap
test
([x, num, random_seed])Run a convergence test on both the first and second derivatives.
Examples
Build a simple combo objective function:
>>> objective_fun_a = L2ObjectiveFunction(nP=3) >>> objective_fun_b = L2ObjectiveFunction(nP=3) >>> combo = ComboObjectiveFunction([objective_fun_a, objective_fun_b], [1, 0.5]) >>> print(len(combo)) 2 >>> print(combo.multipliers) [1, 0.5]
Combo objective functions are also created after adding two objective functions:
>>> combo = 2 * objective_fun_a + 3.5 * objective_fun_b >>> print(len(combo)) 2 >>> print(combo.multipliers) [2, 3.5]
We could add two combo objective functions as well:
>>> objective_fun_c = L2ObjectiveFunction(nP=3) >>> objective_fun_d = L2ObjectiveFunction(nP=3) >>> combo_1 = 4.3 * objective_fun_a + 3 * objective_fun_b >>> combo_2 = 1.5 * objective_fun_c + 0.5 * objective_fun_d >>> combo = combo_1 + combo_2 >>> print(len(combo)) 4 >>> print(combo.multipliers) [4.3, 3, 1.5, 0.5]
We can choose to not unpack the objective functions when creating the combo. For example:
>>> objective_fun_a = L2ObjectiveFunction(nP=3) >>> objective_fun_b = L2ObjectiveFunction(nP=3) >>> objective_fun_c = L2ObjectiveFunction(nP=3) >>> >>> # Create a ComboObjectiveFunction that won't unpack >>> combo_1 = ComboObjectiveFunction( ... objfcts=[objective_fun_a, objective_fun_b], ... multipliers=[0.1, 1.2], ... unpack_on_add=False, ... ) >>> combo_2 = combo_1 + objective_fun_c >>> print(len(combo_2)) 2
Galleries and Tutorials using simpeg.objective_function.ComboObjectiveFunction
#

Petrophysically guided inversion (PGI): Linear example

Petrophysically guided inversion: Joint linear example with nonlinear relationships

Heagy et al., 2017 1D RESOLVE and SkyTEM Bookpurnong Inversions

Heagy et al., 2017 1D RESOLVE Bookpurnong Inversion

1D Inversion of Time-Domain Data for a Single Sounding

2.5D DC Resistivity and IP Least-Squares Inversion

Compare weighting strategy with Inversion of surface Gravity Anomaly Data

Sparse Norm Inversion for Total Magnetic Intensity Data on a Tensor Mesh

Sparse Inversion with Iteratively Re-Weighted Least-Squares

Sparse Norm Inversion of 2D Seismic Tomography Data

Joint PGI of Gravity + Magnetic on an Octree mesh using full petrophysical information

Joint PGI of Gravity + Magnetic on an Octree mesh without petrophysical information

Cross-gradient Joint Inversion of Gravity and Magnetic Anomaly Data