Skip to main content

Fraunhofer IWES optimization tools in Python

Project description

iwopy

Fraunhofer IWES optimization tools in Python

IWOPY Logo

Overview

The iwopy package is in fact a meta package that provides interfaces to other open-source Python optimization packages out there. Currently this includes

iwopy can thus be understood as an attempt to provide the best of all worlds when it comes to solving optimization problems with Python. This has not yet been achieved, since above list of accessable optimization packages is obviously incomplete, but it's a start. All the credit for implementing the invoked optimizers goes to the original package providers.

The basic idea of iwopy is to provide abstract base classes, that can be concretized for any kind of problem by the users, and the corresponding solver interfaces. However, also some helpful problem wrappers and an original optimizer are provided in addition:

  • Problem wrapper LocalFD: Calculates derivatives by finite differences
  • Problem wrapper RegularDiscretizationGrid: Puts the problem on a Grid
  • Optimizer GG: Greedy Gradient optimization with constraints

All calculations support vectorized evaluation of a complete population of parameters. This is useful for heuristic approaches like genetic algorithms, but also for evaluating gradients. It can lead to a vast speed-up and should be invoked whenever possible. Check the examples (or the API) for details.

Documentation: https://fraunhoferiwes.github.io/iwopy.docs/index.html

Source code: https://github.com/FraunhoferIWES/iwopy

PyPi reference: https://pypi.org/project/iwopy/

Anaconda reference: https://anaconda.org/conda-forge/iwopy

Requirements

The supported Python versions are:

  • Python 3.7
  • Python 3.8
  • Python 3.9
  • Python 3.10
  • Python 3.11
  • Python 3.12

Installation via pip

Virtual Python environment

We recommend working in a Python virtual environment and install iwopy there. Such an environment can be created by

python -m venv /path/to/my_venv

and afterwards be activated by

source /path/to/my_venv/bin/activate

Note that in the above commands /path/to/my_venv is a placeholder that should be replaced by a path to a (non-existing) folder of your choice, for example ~/venv/iwopy.

All subsequent installation commands via pip can then be executed directly within the active environment without changes. After your work with iwopy is done you can leave the environment by the command deactivate.

Standard users

As a standard user, you can install the latest release via pip by

pip install iwopy

This in general corresponds to the main branch at github. Alternatively, you can decide to install the latest pre-release developments (non-stable) by

pip install git+https://github.com/FraunhoferIWES/iwopy@dev#egg=iwopy

Notice that the above default installation does not install the third-party optimization packages. iwopy will tell you in an error message that it is missing a package, with a hint of installation advice. You can avoid this step by installing all supported optimzer packages by installing those optoinal packages by addig [opt]:

pip install iwopy[opt]

or

pip install git+https://github.com/FraunhoferIWES/iwopy@dev#egg=iwopy[opt]

Developers

The first step as a developer is to clone the iwopy repository by

git clone https://github.com/FraunhoferIWES/iwopy.git

Enter the root directory by

cd iwopy

Then you can either install from this directory via

pip install -e .

Notice that the above default installation does not install the third-party optimization packages. iwopy will tell you in an error message that it is missing a package, with a hint of installation advice. You can avoid this step by installing all supported optimzer packages by installing those optoinal packages by addig [opt]:

pip install -e .[opt]

Installation via conda

Preparation (optional)

It is strongly recommend to use the libmamba dependency solver instead of the default solver. Install it once by

conda install conda-libmamba-solver -n base -c conda-forge

We recommend that you set this to be your default solver, by

conda config --set solver libmamba

Standard users

The iwopy package is available on the channel conda-forge. You can install the latest version by

conda install -c conda-forge iwopy

Developers

For developers using conda, we recommend first installing iwopy as described above, then removing only the iwopy package while keeping the dependencies, and then adding iwopy again from a git using conda develop:

conda install iwopy conda-build -c conda-forge
conda remove iwopy --force
git clone https://github.com/FraunhoferIWES/iwopy.git
cd iwopy
conda develop .

Concerning the git clone line, we actually recommend that you fork iwopy on GitHub and then replace that command by cloning your fork instead.

Testing

For testing, please clone the repository and install the required dependencies (flake8, pytest, pygmo, pymoo):

git clone https://github.com/FraunhoferIWES/iwopy.git
cd iwopy
pip install .[test]

If you are a developer you might want to replace the last line by

pip install -e .[test]

for dynamic installation from the local code base.

The tests are then run by

pytest tests

Contributing

Please feel invited to contribute to iwopy! Here is how:

  1. Fork iwopy on github.
  2. Create a branch (git checkout -b new_branch)
  3. Commit your changes (git commit -am "your awesome message")
  4. Push to the branch (git push origin new_branch)
  5. Create a pull request here

Support

For trouble shooting and support, please

  • raise an issue here,
  • or start a discussion here,
  • or contact the contributers.

Thanks for your help with improving iwopy!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iwopy-0.3.0.1.tar.gz (69.7 kB view details)

Uploaded Source

Built Distribution

iwopy-0.3.0.1-py3-none-any.whl (88.3 kB view details)

Uploaded Python 3

File details

Details for the file iwopy-0.3.0.1.tar.gz.

File metadata

  • Download URL: iwopy-0.3.0.1.tar.gz
  • Upload date:
  • Size: 69.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for iwopy-0.3.0.1.tar.gz
Algorithm Hash digest
SHA256 683eb59aa33e7392721309b1a727bb8a4be837ce7af9c656636daa4a6ab3edf5
MD5 31c610ed594c9234db5d24ad4570631f
BLAKE2b-256 029fbb3878e60886a1dfee3de6efd9c342182c69b0b1beb11a0fae445671916a

See more details on using hashes here.

File details

Details for the file iwopy-0.3.0.1-py3-none-any.whl.

File metadata

  • Download URL: iwopy-0.3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 88.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for iwopy-0.3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 11c77810cbaf850a014d431f0c673b48e1e3b167cc3302f2c1b18e0126f6c5b1
MD5 62bc4134cfa9c2250b168943fe7ea9da
BLAKE2b-256 d0b99764ffedbee7bf8b9fd10076e09ebc147d2f517d5c5ed37e94e55e8979fa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page