Skip to content

A collection of objective functions and black box optimization algorithms related to proteins and small molecules

License

Notifications You must be signed in to change notification settings

MachineLearningLifeScience/poli-baselines

Repository files navigation

poli-baselines, a library of optimizers of black-box functions

Test (conda, python 3.9)

Warning

This package is a work in progress. Some solvers have not been properly tested. For an authoritative list of the stable solvers, check below or our documentation.

poli-baselines is a collection of black box optimization algorithms, aimed mostly at optimizing discrete sequences. These optimization algorithms are meant to optimize objective functions defined using poli, a tool for instantiating complex, difficult-to-query functions.

If the dependencies get too specific, we provide replicable conda environments for each solver.

Installation

Create a fresh conda environment by running

conda create -n poli-baselines python=3.10
conda activate poli-baselines

After which, you can install this package by running

pip install "poli-baselines @ git+https://github.com/MachineLearningLifeScience/poli-baselines.git@main"

After this, you could test you installation by running (inside your poli-baselines environment):

python -c "import poli_baselines ; print('Everything went well!')"

Solvers available

Some solvers run on specific conda environments. We provide the environment.yml files for each, so you can replicate the environment in your computer.

These can be found in the folder of each solver.

Name Status Reference
Random Mutations Test (conda, python 3.9) N/A
Random hill-climbing Test (conda, python 3.9) N/A
CMA-ES Test (conda, python 3.9) pycma
(Fixed-length) Genetic Algorithm Test (conda, python 3.9) pymoo's implementation
Hvarfner's Vanilla BO Ax (py3.10 in conda) Hvarfner et al. 2024
Bounce Bounce (py3.10 in conda) Papenmeier et al. 2023
BAxUS BAxUS (py3.10 in conda) Papenmeier et al. 2022
Probabilistic Reparametrization Prob. Rep. (py3.10 in conda) Daulton et al. 2022
SAASBO Ax (py3.10 in conda) Eriksson and Jankowiak 2021
ALEBO ALEBO (py3.10 in conda) Lentham et al. 2020
LaMBO2 LaMBO2 (py3.10 in conda) Gruver and Stanton et al. 2020

Your first optimization using poli-baselines

As mentioned above, this library interoperates well with the discrete objective functions defined in poli. One such objective function is the ALOHA problem, in which we search the space of 5-letter sequences of the word "ALOHA". The following is a simple example of how one could use the RandomMutation solver inside poli-baselines to solve this problem:

from poli.objective_repository import AlohaProblemFactory
from poli_baselines.solvers import RandomMutation

# Creating an instance of the problem
problem = AlohaProblemFactory().create()
f, x0 = problem.black_box, problem.x0
y0 = f(x0)

# Creating an instance of the solver
solver = RandomMutation(
    black_box=f,
    x0=x0,
    y0=y0,
)

# Running the optimization for 1000 steps,
# breaking if we find a performance above 5.0.
solver.solve(max_iter=1000, break_at_performance=5.0)

# Checking if we got the solution we were waiting for
print(solver.get_best_solution())  # Should be [["A", "L", "O", "H", "A"]]

More examples

The examples folder includes the optimization of more complex objective functions such as foldx stability (if you have foldx installed in your computer), and the use of advanced black box optimizers like (Line) Bayesian Optimization.

Our ongoing benchmark

We have an ongoing benchmark! We are using poli and poli-baselines to test several high-dimensional Bayesian optimization methods.

If you want to contribute a new solver for the benchmark, follow these instructions. We expect new optimizers to be contributed as pull requests to this project.

Want to contribute?

Take a look at our open issues, and check our guide to contributing.

About

A collection of objective functions and black box optimization algorithms related to proteins and small molecules

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages