Skip to main content

grAdapt: Gradient Adaption for Black-Box Optimization.

Project description

grAdapt: Gradient-Adaptation for Black-Box Optimization

License Python

grAdapt is a Python package for black-box optimization with fixed budget. It is running on top of scikit-learn, scipy and numpy.

It adapts first-order optimization methods to black-box functions by estimating the gradient with different approaches without the need of additional function evaluations. Further, it samples new starting points from multivariate probability distributions to escape local optima. It is a stochastic and sequential model-based optimization method (SMBO). Most SMBO techniques suffer from quadratic, cubic or even worse time complexities. This is caused by refitting the surrogate model without prior information. grAdapt establishes incremental learning and a sliding window technique to improve the complexity significantly. In stock settings, the runtime of grAdapt scales linearly with the number of function evaluations.

Instead of establishing one optimization method, grAdapt is a modular package where the sampling method, surrogate, optimizer, escape function, and the domain constraint can be changed. This makes grAdapt very adaptable to many optimization problems and not only specifically to black-box optimization.

Due to the fixed budget, it suits optimization problems with costly objectives. The most common application of grAdapt is hyperparameter optimization.

It was started in 2019 by Manh Khoi Duong as a project and was since then continually developed, maintained by the author himself under the supervision of Martha Tatusch.

Installation

Dependencies

grAdapt requires:

  • numpy ~= 1.18
  • scipy ~= 1.4
  • scikit-learn ~= 0.22
  • tqdm ~= 4.44
  • deprecated ~= 1.2.7

How-to install

The current stable release can be installed from the pip distribution by:

$ pip install grAdapt

The nightly release can be installed by pulling this repository, navigating to the source directory and then simply installing the setup.py file:

$ python setup.py install

or alternatively (with VCS Support):

$ pip install git+https://github.com/mkduong-ai/grAdapt.git

Testing

To verify that the installation went well without any complications, go to the source directory, then navigate to tests

$ cd tests

and run:

$ python run_all.py

All tests should end with an OK.

First start: Optimizing the sphere function

import numpy as np
import grAdapt
from grAdapt.models import Sequential
from grAdapt.space.datatype import Integer, Float, Categorical

# Black-Box Function
def sphereMin(x):
    return np.sum(x**2)

# create model to optimize
model = Sequential()

# defining search space
var1 = Float(low=-10, high=10)
var2 = Float(low=-10, high=10)
var3 = Float(low=-10, high=10)
bounds = [var1, var2, var3]

# minimize
n_evals = 100 # budget/number of function evaluations
res = model.minimize(sphereMin, bounds, n_evals)

# getting the history
x = res['x']
y = res['y']

# best solutions
x_sol = res['x_sol']
y_sol = res['y_sol']

Citation

When using grAdapt in your publication, we would appreciate if you cite us.

BibTeX entry:

@misc{grAdapt,
title={grAdapt: Gradient-Adaptation for Black-Box Optimization},
author={Manh Khoi Duong and Martha Tatusch and Stefan Conrad and Gunnar W. Klau}
howpublished={The Python Package Index: PyPi}
}

License

This project is distributed under the Apache License 2.0.

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

grAdapt-0.1.1b8.tar.gz (4.6 MB view details)

Uploaded Source

Built Distribution

grAdapt-0.1.1b8-py3-none-any.whl (66.3 kB view details)

Uploaded Python 3

File details

Details for the file grAdapt-0.1.1b8.tar.gz.

File metadata

  • Download URL: grAdapt-0.1.1b8.tar.gz
  • Upload date:
  • Size: 4.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/0.0.0 pkginfo/1.6.0 requests/2.24.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.2

File hashes

Hashes for grAdapt-0.1.1b8.tar.gz
Algorithm Hash digest
SHA256 2f92fbad18b917ffb77567548b962ec76492edd9c633a8d1fa0b39e25b4be8aa
MD5 1e92201c3173398573608430f52dc38d
BLAKE2b-256 9636d9c92795b02cf8bf0a36873d96d884305631d8230623298d19ce60cf8516

See more details on using hashes here.

File details

Details for the file grAdapt-0.1.1b8-py3-none-any.whl.

File metadata

  • Download URL: grAdapt-0.1.1b8-py3-none-any.whl
  • Upload date:
  • Size: 66.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/0.0.0 pkginfo/1.6.0 requests/2.24.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.2

File hashes

Hashes for grAdapt-0.1.1b8-py3-none-any.whl
Algorithm Hash digest
SHA256 ff8300eeae6b4ea6a6a1193f97a8b948b0609a3ee25c14311d74ddf8d8e69117
MD5 ebdb65dd2710c0ec25cb5bf5f716175f
BLAKE2b-256 364d028b3b9680913a73f050c96d2e178e8dae6895ffe7f280b41d5cb423c11a

See more details on using hashes here.

Supported by

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