Skip to main content

PATATUNE

A Framework for Metaheuristic Multi-Objective Optimization for High Energy Physics

PyPI - Version Documentation


Documentation: https://cms-patatrack.github.io/patatune

Source code: https://github.com/cms-patatrack/patatune

Dashboard for visualization (CERN instance for testing): https://patatune-dash.app.cern.ch/


PATATUNE is a Python package that provides a framework for multi-objective optimization algorithms, including the Multi-Objective Particle Swarm Optimization (MOPSO) method. Its primary purpose is to automate the optimization of the parameters of user-defined functions. The package has been developed with the needs of CMS and Patatrack in mind.

The key features are:

  • Easy to use and learn.
  • Pluggable Multi-objective optimization model with Multi-Objective Particle Swarm Optimization implemented via the MOPSO class.
  • Multiple objective definition supported, for any user-defined objective function.
  • Support for different parameter types (int, float, bool).
  • Built-in metrics for convergence/quality assessment: Generational Distance, Inverted GD, Hypervolume.
  • Persistence and checkpointing via FileManager (save/load pickle, CSV, Zarr); supports resuming runs and per-iteration history export.

Installation

PATATUNE is available on PyPi.

To install it you can simply run:

pip install patatune

If you want to use the latest development version on the main branch:

  1. Clone this repository

  2. Navigate into the project directory

  3. Install the package and its dependencies using pip:

    pip install .
    

You can install a project in “editable” or “develop” mode while you’re working on it. When installed as editable, a project can be edited in-place without reinstallation:

pip install -e .

Requirements

PATATUNE is written for Python 3.9+ and depends on a small set of scientific Python packages. The following are required to run the library:

Optional functionality is provided by extras:

  • numba (optional — JIT acceleration)
  • zarr==2.* (optional — save/load history in Zarr format)

These dependencies are declared in pyproject.toml and can be installed with pip (see Installation below). If you need the optional extras, install with extra:

pip install patatune[extra]

The additional example require additional libraries (matplotlib, pandas). If you want to run them, install with tests:

pip install patatune[tests]

or, to include every optional dependecy:

pip install patatune[all]

Example

Currently the package provides the patatune module that defines an optimization algorithm: MOPSO. PATATUNE relies on a few helper classes to handle configuration and the objective functions. To use this module in your Python projects:

  1. Import the required modules:

    import patatune
    
  2. Define the objective function to be optimized. i.e.:

    def f1(x):
        return 4 * x[0]**2 + 4 * x[1]**2
    
    
    def f2(x):
        return (x[0] - 5)**2 + (x[1] - 5)**2
    
    objectives = patatune.ElementWiseObjective([f1, f2])
    
  3. Define the boundaries of the parameters:

    lb = [0.0, 0.0]
    ub = [5.0, 3.0]
    
  4. Create the MOPSO object with the configuration of the algorithm

    mopso = patatune.MOPSO( objectives,
                            lower_bounds=lb, upper_bounds=ub,
                            num_particles=50,
                            inertia_weight=0.4, cognitive_coefficient=1.5, social_coefficient=2)
    
  5. Run the optimization algorithm

    pareto = mopso.optimize(num_iterations = 100)
    

The output will be the archive of optimal solutions found by the algorithm after 100 iterations.

The output is a Python list containing Particle objects (instances of patatune.mopso.particle.Particle). You can easily extract a compact representation from the returned list. For example:

for p in pareto:
    print("position:", p.position, "fitness:", p.fitness)

Example printed output:

id: 0  position: [1.8 1.6] fitness: [ 23.5 21.6]
id: 49 position: [0.0 0.0] fitness: [ 0.   50. ]
id: 18 position: [1.0 1.0] fitness: [ 8.3  31.7]
id: 29 position: [5.0 3.0] fitness: [ 136. 4.  ]
id: 16 position: [0.0 0.0] fitness: [ 0.   50. ]
...

Contributing

Contributions are welcome. If you want to contribute, please follow the Contribution guidelines.

License

PATATUNE is distributed under the MPL 2.0 License. Feel free to use, modify, and distribute the code following the terms of the license.

Download files

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

Source Distribution

patatune-1.0.4.tar.gz (51.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

patatune-1.0.4-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file patatune-1.0.4.tar.gz.

File metadata

  • Download URL: patatune-1.0.4.tar.gz
  • Upload date:
  • Size: 51.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for patatune-1.0.4.tar.gz
Algorithm Hash digest
SHA256 68e8f7c7d8ff073b27e2a01c073fa027eba3cafadf1c487da45c62b14068ac97
MD5 824afbd49d9649e13eb955b8fde260d9
BLAKE2b-256 67b79d0be465d736fe38966c96dcbc1a252f44eae940c258d24735aa563677f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for patatune-1.0.4.tar.gz:

Publisher: release.yml on cms-patatrack/patatune

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file patatune-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: patatune-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 26.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for patatune-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 34ac80cedabce4ccd6878bba9e14a7ba81cc5f47b2cbf386724ffef6e8608d4c
MD5 f7f744a9e46c8fed036f0d2815d77b9a
BLAKE2b-256 902676398c17b4fa2fe6d4c385b7b1dc7b5196a1470ea25999474ad86f005ee7

See more details on using hashes here.

Provenance

The following attestation bundles were made for patatune-1.0.4-py3-none-any.whl:

Publisher: release.yml on cms-patatrack/patatune

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page