piglot

_images/logo.svg

GitHub Unit and integration testing PyPI - Version GitHub License CodeFactor Grade CodeCov ReadTheDocs

Welcome to piglot, a Python tool taylored for the automated optimisation of responses from numerical solvers. We aim at providing a simple and user-friendly interface which is also easily extendable, allowing intergration with other solvers within the community. Whether you’re working on structural analysis, material modelling, fluid dynamics, control systems or astrophysics (to name a few) using, for instance, finite element analysis, spectral methods or Monte Carlo methods, piglot provides a versatile solution for solving inverse problems. The primary emphasis is on derivative-free optimisation, ensuring compatibility with black-box solvers in scenarios where gradient information is not available, and cases where the function evaluations may be noisy. We highlight:

  • Integration with solvers: We provide an extensible interface for coupling with physics solvers. As long as your solver can return a time-response for the fields you are interested, you can optimise it with piglot.

  • Optimisation algorithms: Off the shelf, there are several optimisers included in the package. Among them, we highlight our fully-fledged Bayesian optimisation (based on BoTorch) that supports optimising stochastic and composite objectives and is highly customisable. Additional methods can also be easily implemented within piglot.

  • Visualisation tools: You can use the builtin tool piglot-plot to visualise the results of the optimisation. There are native plotting utilities for the optimised responses, the parameter history, objective history and, for supported solvers, live plotting of the currently running case. Also, an animation of the optimisation process can be exported.

Feel free to explore, contribute, and optimise with piglot! We recommend starting by reading the Getting started section, and then checking the latest documentation for additional details. You can use our discussions page for help and our issue tracker for reporting problems and suggestions. If you use this tool in your work, we encourage to open a PR to add it to our list of papers.

Installation

You can install piglot by only installing the main scripts or as a standard Python package. If you only intend to use the piglot and piglot-plot binaries, we strongly recommend the first option, as it avoids having to manage the dependencies in your Python environment. However, if you wish to use the tools in the piglot package, you may have to resort to the second option. Currently, we require Python 3.9 onwards.

Option 1: Install binaries

This option is recommended for end-users that only need to interact with the provided piglot and piglot-plot scripts. We use pipx to install the package in an isolated environment with the required dependencies (we recommend reading the pipx documentation to check the advantages of using this approach).

  1. Install pipx in your system using the instructions here;

  2. In your favourite terminal, run: pipx install piglot;

  3. Confirm the package is correctly installed by calling the piglot and piglot-plot executables.

Option 2: Install package

We recommend this option for users aiming to use the piglot package directly. Note that this option also provides the piglot and piglot-plot scripts, but requires manual handling of the installation environment.

  1. In your favourite terminal, run: pip install piglot;

  2. Confirm the package is correctly installed by calling the piglot and piglot-plot executables.

Installing additional optimisers

We also support some optional external optimisers, which are not automatically installed along with piglot to reduce the number of dependencies and the installation cost. You can either install them along with piglot, or manually using your package manager. Their detection is done at runtime and, if not installed, an error will be raised. Currently, the following optional optimisers are supported: - lipo - LIPO optimiser - geneticalgorithm - Genetic algorithm - pyswarms - Particle swarm optimiser

These can be installed directly from PyPI (with the package names above). If you wish to install piglot with one of these optimisers (which may be required when using a pipx install), you can run the following commands: - pip install piglot[lipo] for the LIPO optimiser - pip install piglot[genetic] for the Genetic algorithm - pip install piglot[pso] for the Particle swarm optimiser optimiser

To simultaneously install more than one optimiser, for instance, the LIPO and the Particle swarm optimisers, run pip install piglot[lipo,pso]. If you wish to install all optimisers at once, you can run pip install piglot[full].