Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
bc0f026
Start populating the User Guide
santisoler Sep 24, 2026
5efbab0
Merge branch 'main' into user-guide-jupyter
santisoler Sep 24, 2026
54e457c
Add more content to objective functions
santisoler Sep 24, 2026
8e50cf7
Modify the low and high bounds in LinearRegressor
santisoler Sep 24, 2026
bd97ae9
Merge branch 'user-guide-jupyter' of github.com:simpeg/inversion-desi…
santisoler Sep 24, 2026
4c64c61
Merge branch 'main' into user-guide-jupyter
santisoler Sep 24, 2026
d4ee99a
Add content to minimizer.rst
santisoler Sep 24, 2026
af0a794
Add entry for non-linear minimizers
santisoler Sep 24, 2026
f8c677f
Reorganize docs
santisoler Sep 24, 2026
b9cba99
Add guide on debugging and logging
santisoler Sep 24, 2026
78cb01b
Use emph in heading
santisoler Sep 28, 2026
6a09b7e
Merge branch 'main' into user-guide-jupyter
santisoler Sep 29, 2026
5df3b8e
Replace `TikhonovZero` for `SimpleSmallness`
santisoler Sep 29, 2026
c406085
Merge branch 'main' into user-guide-jupyter
santisoler Oct 5, 2026
4624405
Merge branch 'main' into user-guide-jupyter
santisoler Oct 6, 2026
2adc49c
Merge branch 'main' into user-guide-jupyter
santisoler Oct 7, 2026
54617f7
Restructure the user guide into folders
santisoler Oct 7, 2026
79d349c
Improve wording when defining objective function
santisoler Oct 7, 2026
b50f85a
Add page for Inversions
santisoler Oct 8, 2026
5b8de51
Introduce directives
santisoler Oct 8, 2026
5ec2c41
Add more content to the Inversion page
santisoler Oct 8, 2026
03e21e0
Add placeholders for upcoming pages
santisoler Oct 9, 2026
a1cb3df
Add more placeholders
santisoler Oct 9, 2026
71cc999
Add pandas to `requirements-dev.txt`
santisoler Oct 14, 2026
6190f5f
Merge branch 'main' into user-guide-jupyter
santisoler Oct 14, 2026
c1a851a
Merge branch 'main' into user-guide-jupyter
santisoler Oct 19, 2026
41031d0
Update import of `minimize.conjugate_gradient` in User Guide
santisoler Oct 19, 2026
d549e57
Update import of GaussNewtonConjugateGradient
santisoler Oct 19, 2026
de4e4c8
Add custom CSS style for the jupyter-execute cells
santisoler Oct 19, 2026
da4656b
Make use of SimpleFlatness
santisoler Oct 19, 2026
6547edd
Add link to Hyperparameters page
santisoler Oct 19, 2026
5b23d58
Removed unneeded caption in toc
santisoler Oct 20, 2026
f8ee1b9
Add user guide pages for simulations
santisoler Oct 20, 2026
ace9de3
Minor improvements to the simulations page
santisoler Oct 20, 2026
9f3340e
Add content to page about conditions
santisoler Oct 20, 2026
ff38744
Fix a few style issues in the conditions page
santisoler Oct 20, 2026
e17b343
Add content to the hyperparameters page
santisoler Oct 20, 2026
b2e71ab
Add bordado to requirements-dev.txt
santisoler Oct 20, 2026
5122b2b
Add content to the What section
santisoler Oct 20, 2026
245778e
Add page on preconditioners
santisoler Oct 21, 2026
053ab51
Add gravity inversion example to User Guide
santisoler Oct 21, 2026
adb3e9d
Minor tweaks to the gravity inversion
santisoler Oct 21, 2026
e97c131
Merge branch 'main' into user-guide-jupyter
santisoler Oct 21, 2026
6c3345c
Add Harmonica to requirements-dev.txt
santisoler Oct 21, 2026
2faf58a
Add content on the base submodule to the How To guide
santisoler Oct 21, 2026
f278fb3
Add content to Writing your objective function
santisoler Oct 21, 2026
9a70439
Start filling the simulation How To section
santisoler Oct 21, 2026
0c988a0
Remove empty DC inversion in Getting Started
santisoler Oct 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* Try to make the jupyter-sphinx style match sphinx-gallery for consistency */
div.jupyter_container {
border: none;
box-shadow: none;
}

div.jupyter_container .cell_input {
margin-bottom: 1.15rem;
border-radius: 0.4em;
box-shadow: 1px 1px 1px #d8d8d8;
}

div.jupyter_container .cell_output {
margin-bottom: 1.15rem;
}

.jupyter_container div.code_cell pre {
padding: 10px;
}
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"sphinx.ext.intersphinx",
"sphinx_design",
"numpydoc",
"jupyter_sphinx",
]

intersphinx_mapping = {
Expand All @@ -27,6 +28,7 @@
"numba": ("https://numba.readthedocs.io/en/stable/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
"simpeg": ("https://docs.simpeg.xyz/latest/", None),
"pandas": ("https://pandas.pydata.org/docs/", None),
}

templates_path = ["_templates"]
Expand Down Expand Up @@ -80,4 +82,5 @@
"github_version": "main",
"doc_path": "docs",
}
html_static_path = [] # avoid warning by overwriting the default ["_static"]
html_static_path = ["_static"]
html_css_files = ["custom.css"]
17 changes: 1 addition & 16 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,12 @@ The main goal of this repository is to build a working prototype of a new invers
:padding: 0 0 0 0
:gutter: 4

.. grid-item-card:: :fas:`book-open` Getting Started
:text-align: center
:class-title: sd-fs-5
:class-card: sd-p-3

Start using the framework.

.. button-ref:: getting-started
:ref-type: ref
:click-parent:
:color: primary
:shadow:
:expand:

.. grid-item-card:: :fas:`book-open` User Guide
:text-align: center
:class-title: sd-fs-5
:class-card: sd-p-3

Learn how to use the framework.
Get started and learn how to use the framework.

.. button-ref:: user-guide
:ref-type: ref
Expand Down Expand Up @@ -63,6 +49,5 @@ The main goal of this repository is to build a working prototype of a new invers
:caption: Contents:
:hidden:

getting-started/index.rst
user-guide/index.rst
reference/index.rst
7 changes: 4 additions & 3 deletions docs/reference/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
Base submodule
==============

The :mod:`inversion_ideas.base` submodule contains abstract classes and base classes that work as the foundation of the framework. Inherit from these classes when defining your own subclasses.
The :mod:`inversion_ideas.base` submodule contains mostly abstract classes and base classes that work as the foundation of the framework. Inherit from these classes when defining your own subclasses.

.. admonition:: important

These classes are not meant to be instantiated. They are abstract classes only intended to be inherited from, or containers (like :class:`inversion_ideas.base.Scaled` and :class:`inversion_ideas.base.Combo`) that should not be instantiated by end users either.
.. important::

Most of these classes are not meant to be instantiated. They are abstract classes only intended to be inherited from, or containers (like :class:`inversion_ideas.base.Scaled` and :class:`inversion_ideas.base.Combo`) that should not be instantiated by end users.

.. autosummary::
:toctree: api/
Expand Down
211 changes: 211 additions & 0 deletions docs/user-guide/fundamentals/beta-cooling.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
.. _beta-cooling:

Beta-cooling schedule
=====================

One common example is the *beta cooling schedule* that consists in defining an
objective function in the form of

.. math::

\phi(\mathbf{m}) = \phi_\text{d}(\mathbf{m}) + \beta_0 \phi_\text{m}(\mathbf{m}),

where :math:`\phi_\text{d}(\mathbf{m})` is the data misfit term,
:math:`\phi_\text{m}(\mathbf{m})` is the model norm, and :math:`\beta_0` is an
initial value for the trade-off parameter, which is usually chosen to be a high value.
We proceed to minimize the objective function to obtain an inverted model, and then
*cool down* the trade-off parameter by dividing it by a constant factor.
Then we carry another minimization step, and another cooling step, and so on until a certain condition is met, usually that the data is fitted up to their uncertainties.


Beta-cooling: simple
--------------------
We can achieve that in the new inversion framework with just a ``for`` loop.
For example, consider a :class:`~inversion_ideas.DataMisfit` object that uses a
:class:`~inversion_ideas.LinearRegressor` simulation, like the one we defined in
:ref:`objective-function`:

.. jupyter-execute::
:hide-code:

import numpy as np
import inversion_ideas as ii

# Define a linear regressor as a simulation
n_data, n_params = 3, 5
simulation = ii.simulations.LinearRegressor.create_random(n_data, n_params, seed=42)

# Create some synthetic data and uncertainties
true_model = np.array([-5., 2., -3., 4., 1.])
std = 1e-2
data = simulation(true_model) + np.random.default_rng(seed=42).normal(size=n_data, scale=std)
uncertainties = std * np.ones_like(data)

# Define a data misfit function
data_misfit = ii.DataMisfit(data, uncertainties, simulation)

.. jupyter-execute::

data_misfit

Let's define a :class:`~inversion_ideas.SimpleSmallness` regularization:

.. jupyter-execute::

smallness = ii.SimpleSmallness(data_misfit.n_params)
smallness

And create our objective function with a high value for our starting trade-off parameter ``beta``:

.. jupyter-execute::

beta_0 = 200.0
regularization = beta_0 * smallness
phi = data_misfit + regularization
phi

.. note::

A *high value* for the trade-off parameter depends on the type of problem we
are facing. For one problem a value of 200.0 might be high enough, but for other
it might need to be several order of magnitudes larger.

Since we can access the value of the trade-off parameter through ``regularization.multiplier``, we can also change it.
Let's use this capability to implement a simple beta-cooling schedule:

.. jupyter-execute::

# Define an initial model
model = np.zeros(data_misfit.n_params)

# Perform a beta cooling schedule
while True:

# Minimize the objective function using a conjugate gradient minimizer.
# Overwrite the model variable with the minimized model.
model = ii.minimize.conjugate_gradient(phi, model)

# Define a stopping criterion:
# finish the inversion if the chi factor is below 1.
if data_misfit.chi_factor(model) <= 1.0:
break

# Cool down beta using a factor of 2
regularization.multiplier /= 2.0

The final inverted model will be stored in the ``model`` variable:

.. jupyter-execute::

inverted_model = model.copy()
inverted_model

We can also see the final value of the trade-off parameter by displaying the objective function:

.. jupyter-execute::

phi


Beta-cooling: with custom objects
---------------------------------

The new framework ships some objects that would make writing this inversion in a slicker way.
First, instead of defining our tradeoff parameter as a ``float`` and manually cooling it down, we can use a :class:`inversion_ideas.hyperparams.CooledMultiplier`.
This object acts like a float, but it has an
:meth:`~inversion_ideas.hyperparams.CooledMultiplier.update` method that can automatically perform the cooling step.

Following the previous example, we can define our objective function as:

.. jupyter-execute::

# Define trade-off parameter as a hyperparameter object.
# Set its initial value to 200.0 and the factor that will be used to cool it down to 2.0.
beta = ii.hyperparams.CooledMultiplier(200.0, cooling_factor=2.0)

# Use this beta as any other number
phi = data_misfit + beta * smallness
phi

.. seealso::

Learn more about custom hyperparameter objects in :ref:`hyperparameters`.


We can also define a stopping criterion to define when our inversion should stop.
In this case we can make use of :class:`inversion_ideas.conditions.ChiTarget` to check if the :math:`\chi` factor for the ``data_misfit`` falls below a desired threshold:

.. jupyter-execute::

# Define a stopping criterion
chi_target = ii.conditions.ChiTarget(data_misfit, chi_target=1.0)


And finally re-write our inversion in a slicker way:

.. jupyter-execute::

# Define an initial model
model = np.zeros(data_misfit.n_params)

# Perform a beta cooling schedule
while True:

# Minimize the objective function
model = ii.minimize.conjugate_gradient(phi, model)

# Finish the inversion if the stopping criterion is met
if chi_target(model):
break

# Cool down beta
beta.update()

# Define inverted model as last model in the iterations
inverted_model = model.copy()
inverted_model


We can also explore the custom ``beta`` hyperparameter and see how its value changed:

.. jupyter-execute::

print(beta)


.. hint::

We can easily insert any custom code in between iterations.
For example we could print information about the inversion process:

.. jupyter-execute::

# Define objective function
beta = ii.hyperparams.CooledMultiplier(200.0, cooling_factor=2.0)
phi = data_misfit + beta * smallness

# Define an initial model
model = np.zeros(data_misfit.n_params)

# Perform a beta cooling schedule
iteration = 0
while True:

# Minimize the objective function
model = ii.minimize.conjugate_gradient(phi, model)

# Print information
iteration += 1
print(f"Iteration: {iteration:2d}")
print("-------------")
print(f"- model: {model}")
print(f"- beta: {beta}")
print(f"- chi factor: {data_misfit.chi_factor(model)}")
print("")

# Finish the inversion if the stopping criterion is met
if chi_target(model):
break

# Cool down beta
beta.update()
Loading
Loading