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.9
conda activate poli-baselines

After which, you can download this repository and install it locally

git clone git@github.com:MachineLearningLifeScience/poli-baselines.git
cd ./poli-baselines

Now install the requirements, as well as the library:

pip install -r requirements.txt
pip install -e .

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 Ax (py3.10 in conda) Lentham et al. 2020

In the case of Probabilistic Reparametrization, we rely on a slightly modified version of the run_one_replication.py script from the original repository.

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.

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