- Optson is python toolbox for nonlinear unconstrained optimization.
- It offers Adam, Trust-Region L-BGFS and Steepest Descent methods and more can be added easily.
- It supports both "batch" and "mini-batch" approaches via specific implementations of the
BatchManagerclass. - A user can define a sublass of the
Problemclass and provide implementations off()(misfit) andg()(gradient). - An instance of this class as well as an initial model are then passed to Optson, after which Optson will perform optimization according to the specified settings.
Full documentation: https://swp_ethz.gitlab.io/optson
Note that the main repository resides on GitLab: https://gitlab.com/swp_ethz/optson. This is where we run our CI.
- Make sure you have an environment with Python version 3.9 or higher.
However, you can use our Conda environment files for that, as mentioned below. - Clone this repository and change to the resulting directory.
- To install just minimal dependencies run:
# skip if you don't use Conda conda env create -f conda-env-basic.yml conda activate optsonpip install -e "." - To install also dependencies needed for tutorials, use the
tutorialsdependencies:# skip if you don't use Conda conda env create -f conda-env-tutorials.yml conda activate optsonpip install -e ".[tutorials]"
If you would like to use JAX Arrays, or PyTorch Tensors, you can install Optson with JAX and/or PyTorch support.
- To install Optson with JAX support, add the
jaxdependency group, e.g.:# skip if you don't use Conda conda env create -f conda-env-tutorials.yml conda activate optson conda install jaxpip install -e ".[tutorials,jax]" - To install Optson with PyTorch support, add the
torchdependency group, e.g.:# skip if you don't use Conda conda env create -f conda-env-tutorials.yml conda activate optson conda install torchpip install -e ".[tutorials,torch]"
If you want to run the tests, ensure you have the required dependencies. To do so, run:
pip install -v -e ".[test]"
To run the tests, cd into the toplevel optson directory and execute:
py.test
This should ensure that your installation is working and optson is working as intended.
Please have a look at tutorials/ for example usage.
To update Optson, change into the top-level optson directory and type
git pull
pip install -v -e .
If you would like to contribute, feel free to make a merge request with your suggested feature.
Before incorporation, the merge request has to pass the CI testing routines and be reviewed by one of the maintainers, Vaclav or Dirk-Philip.
To install everything we use in our CI, including tools for docs build, do:
# skip if you don't use Conda
conda env create -f ci/conda-env.yml
conda activate optson
pip install -e ".[test,docs]"
You can then execute the test script optson/ci/test.sh locally.
We encourage you to do this before creating your MR.