Skip to main content

Bayesian optimization structure search

Project description

Bayesian Optimization Structure Search (BOSS) is an active machine learning technique for accelerated global exploration of energy and property phase space. It is designed to facilitate machine learning in computational and experimental natural sciences.

For a more detailed description of the code and tutorials, please consult the user guide.

Installation

BOSS is distributed as a PyPI package and can be installed using pip:

python3 -m pip install --user aalto-boss

Basic usage

As an easy example, consider the optimization of a bounded 1D function. BOSS can be run either directly from Python or via a CLI interface, both these approaches are illustrated briefly below. Note that BOSS always minimizes a given function.

Python iterface

To run BOSS from Python we first define our objective function, by default BOSS expects this function to take a single 2D numpy array as argument (this behaviour can be modified) and return a scalar value. Next, we import the BOMain object and feed it the function plus any number of BOSS keywords, after which the optimization can be started. Once finished, the optimziation results are returned in a BOResults object.

""" Using BOSS to solve the minimization problem
f(x) = sin(x) + 1.5*exp(-(x-4.3)**2) , 0 < x < 7
"""
import numpy as np
from boss.bo.bo_main import BOMain

def func(X):
    """ BOSS-compatible definition of the function. """
    x = X[0, 0]
    return np.sin(x) + 1.5*np.exp(-(x - 4.3)**2)

if __name__ == '__main__':
    bo = BOMain(
        func,
        np.array([[0., 7.]]),  # bounds
        yrange=[-1, 1],
        kernel='rbf',
        initpts=5,
        iterpts=15,
        verbosity=2
    )
    res = bo.run()
    print(res.xmin, res.fmin)

Command-line iterface

The CLI is provided by an executable called boss. The user must provide an input file containing a list of BOSS keywords and a separate Python script that defines a function to be optimized. By default, BOSS expects this function to take a single 2D numpy array as argument (this behaviour can be modified) and return a scalar value. Below we define such a function in a Python script, arbitrarily named user_function.py:

""" user_function.py
This script contains the function definition for the minimization problem
f(x) = sin(x) + 1.5*exp(-(x-4.3)**2) ,  0 < x < 7
Note that the bounds are specified in the BOSS input file.
"""
import numpy as np

def func(X):
    """ BOSS-compatible definition of the function. """
    x = X[0, 0]
    return np.sin(x) + 1.5*np.exp(-(x - 4.3)**2)

To minimize this function subject to the constraint 0 < x < 7, we define a BOSS input file boss.in:

# boss.in
userfn        user_function.py func
bounds        0 7
yrange        -1 1
kernel        rbf
initpts       5
iterpts       15
verbosity     2

The optimization can now be started from the command line:

$ boss o boss.in

Credits

BOSS is under active development in the Computational Electronic Structure Theory (CEST) group at Aalto University. Past and current members of development team include

  • Ville Parkkinen

  • Henri Paulamäki

  • Arttu Tolvanen

  • Ulpu Remes

  • Nuutti Sten

  • Joakim Löfgren (maintainer)

  • Milica Todorović (team lead)

If you wish to use BOSS in your research, please cite

Milica Todorovic, Micheal U. Gutmann, Jukka Corander, and Patrick Rinke
Bayesian inference of atomistic structure in functional materials
npj Comput Mater 5, 35 (2019)

Issues and feature requests

It is strongly encouraged to submit bug reports and feature requests via the gitlab issue tracker. The BOSS development team can be contacted by email at milica.todorovic@utu.fi

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

aalto-boss-1.5.tar.gz (51.4 kB view details)

Uploaded Source

Built Distribution

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

aalto_boss-1.5-py3-none-any.whl (66.8 kB view details)

Uploaded Python 3

File details

Details for the file aalto-boss-1.5.tar.gz.

File metadata

  • Download URL: aalto-boss-1.5.tar.gz
  • Upload date:
  • Size: 51.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for aalto-boss-1.5.tar.gz
Algorithm Hash digest
SHA256 1e18b23aad86c521d63746d6013c293a1a9c15268be1786cfee2b9a42b63b69b
MD5 af8a40db4f2ed1f51e5b417a8ba8a300
BLAKE2b-256 ab6fb7c33d88a95376a8b3537e09e8f42c8f8b5a1c4305403d2818b84a2ca6a0

See more details on using hashes here.

File details

Details for the file aalto_boss-1.5-py3-none-any.whl.

File metadata

  • Download URL: aalto_boss-1.5-py3-none-any.whl
  • Upload date:
  • Size: 66.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for aalto_boss-1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d91fad73fae184091856a9858ca3dfe4ef85452a98ca5debabb5122e3f2e6101
MD5 9b0caea95f56b271ffe88ddeac4350ec
BLAKE2b-256 29eee80dfd92da5e8ca75d25a58e2b41d914d0cd13e2c3f7a6c87b4db1c7df1e

See more details on using hashes here.

Supported by

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