# SimPEG.objective_function.ComboObjectiveFunction#

Composite for multiple objective functions

A composite class for multiple objective functions. Each objective function is accompanied by a multiplier. Both objective functions and multipliers are stored in a list.

Parameters:
objfcts`list` or `None`, `optional`

List containing the objective functions that will live inside the composite class. If `None`, an empty list will be created.

multipliers`list` or `None`, `optional`

List containing the multipliers for its respective objective function in `objfcts`. If `None`, a list full of ones with the same length as `objfcts` will be created.

unpack_on_addbool, `optional`

Weather to unpack the multiple objective functions when adding them to another objective function, or to add them as a whole.

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],
... )
>>> combo_2 = combo_1 + objective_fun_c
>>> print(len(combo_2))
2
```

Attributes

 `W` W matrix for the full objective function. `multipliers` Multipliers for each objective function

Methods

 `__call__`(m[, f]) Evaluate the objective functions for a given model `deriv`(m[, f]) First derivative of the composite objective function is the sum of the derivatives of each objective function in the list, weighted by their respective multplier. `deriv2`(m[, v, f]) Second derivative of the composite objective function is the sum of the second derivatives of each objective function in the list, weighted by their respective multplier. `get_functions_of_type`(fun_class) Find an objective function type from a ComboObjectiveFunction class.

## Galleries and Tutorials using `SimPEG.objective_function.ComboObjectiveFunction`#

Maps: ComboMaps

Maps: ComboMaps

PF: Gravity: Tiled Inversion Linear

PF: Gravity: Tiled Inversion Linear

Magnetic inversion on a TreeMesh

Magnetic inversion on a TreeMesh

Magnetic inversion on a TreeMesh

Magnetic inversion on a TreeMesh

Magnetic Amplitude inversion on a TreeMesh

Magnetic Amplitude inversion on a TreeMesh

3D DC inversion of Dipole Dipole array

3D DC inversion of Dipole Dipole array

Parametric DC inversion with Dipole Dipole array

Parametric DC inversion with Dipole Dipole array

2D inversion of Loop-Loop EM Data

2D inversion of Loop-Loop EM Data

EM: TDEM: 1D: Inversion

EM: TDEM: 1D: Inversion

EM: TDEM: 1D: Inversion with VTEM waveform

EM: TDEM: 1D: Inversion with VTEM waveform

FLOW: Richards: 1D: Inversion

FLOW: Richards: 1D: Inversion

Petrophysically guided inversion (PGI): Linear example

Petrophysically guided inversion (PGI): Linear example

Petrophysically guided inversion: Joint linear example with nonlinear relationships

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 and SkyTEM Bookpurnong Inversions

Heagy et al., 2017 1D RESOLVE Bookpurnong Inversion

Heagy et al., 2017 1D RESOLVE Bookpurnong Inversion

Heagy et al., 2017 1D FDEM and TDEM inversions

Heagy et al., 2017 1D FDEM and TDEM inversions

PF: Gravity: Laguna del Maule Bouguer Gravity

PF: Gravity: Laguna del Maule Bouguer Gravity

Straight Ray with Volume Data Misfit Term

Straight Ray with Volume Data Misfit Term

1D Inversion of for a Single Sounding

1D Inversion of for a Single Sounding

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

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

Linear Least-Squares Inversion

Linear Least-Squares Inversion

Sparse Inversion with Iteratively Re-Weighted Least-Squares

Sparse Inversion with Iteratively Re-Weighted Least-Squares

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

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

Least-Squares Inversion of Gravity Anomaly Data

Least-Squares Inversion of Gravity Anomaly Data

Sparse Norm Inversion of Gravity Anomaly Data

Sparse Norm Inversion of Gravity Anomaly Data

2.5D DC Resistivity and IP Least-Squares Inversion

2.5D DC Resistivity and IP Least-Squares Inversion

3D Least-Squares Inversion of DC and IP Data

3D Least-Squares Inversion of DC and IP Data

Least-Squares 1D Inversion of Sounding Data

Least-Squares 1D Inversion of Sounding Data

Sparse 1D Inversion of Sounding Data

Sparse 1D Inversion of Sounding Data

Parametric 1D Inversion of Sounding Data

Parametric 1D Inversion of Sounding Data

2.5D DC Resistivity Least-Squares Inversion

2.5D DC Resistivity Least-Squares Inversion

2.5D DC Resistivity Inversion with Sparse Norms

2.5D DC Resistivity Inversion with Sparse Norms

3D Least-Squares Inversion of DC Resistivity Data

3D Least-Squares Inversion of DC Resistivity Data

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

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

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

Sparse Norm Inversion of 2D Seismic Tomography Data

Sparse Norm Inversion of 2D Seismic Tomography Data

Cross-gradient Joint Inversion of Gravity and Magnetic Anomaly Data

Cross-gradient Joint Inversion of Gravity and Magnetic Anomaly Data