Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f6dd3ee
Showing
4 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# remove .DS_Store from the fucking planet | ||
.DS_Store | ||
|
||
# ignore PyCharm stuff | ||
.idea/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
.venv | ||
venv/ | ||
ENV/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2018, Sycorax | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# LIPO | ||
Global optimization of Lipschitz functions | ||
|
||
## References | ||
Cédric Malherbe and Nicolas Vayatis, "Global optimization of Lipschitz functions" | ||
https://arxiv.org/abs/1703.02628 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/python3 | ||
# -*- coding: utf-8 -*- | ||
# Author: David J. Elkind | ||
# Creation date: 2018-02-17 (YYYY-MM-DD) | ||
|
||
""" | ||
An implementation of | ||
Cédric Malherbe and Nicolas Vayatis, "Global optimization of Lipschitz functions" | ||
https://arxiv.org/abs/1703.02628 | ||
with some experimental modifications also implemented. | ||
""" | ||
|
||
from __future__ import division | ||
|
||
import numpy as np | ||
import os | ||
|
||
|
||
class LIPO(object): | ||
def __init__(self, objective_functon, bounding_box, acquisition_function, stan_surrogate_model_path): | ||
""" | ||
:param objective_functon: function object - the function under minimization; must return a float | ||
:param bounding_box: iterable containing the max and min for each dimension. Order of max and min is irrelevant, | ||
but all outputs depend on the order in which the dimensions are supplied. | ||
For example, suppose you want a bounding box on (Z x Y) = [2, -2] x [-5, 5]. You could supply | ||
[(2,-2),(-5,5)] or | ||
[[-2,2],[5,-5]] or | ||
np.array([[2,-2],[5,-5]) | ||
or similar as each of these will be iterated in the order of first [-2,2], and second [-5,5]. | ||
:param acquisition_function: string - string must be in {"PI", "EQI", "EI", "UCB"} | ||
PI - probability of improvement | ||
EQI - expected quantile improvement | ||
EI - expected improvement | ||
UCB - upper confidence bound | ||
:param stan_surrogate_model_path: | ||
""" | ||
self._obj_fn = objective_functon | ||
self.bounding_box = bounding_box | ||
self.acquisition_function = acquisition_function | ||
|
||
try: | ||
with open(stan_surrogate_model_path) as f: | ||
self._model_str = f.read() | ||
except FileNotFoundError: | ||
load_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), stan_surrogate_model_path) | ||
with open(load_path) as f: | ||
self._model_str = f.read() | ||
|
||
@property | ||
def obj_fn(self): | ||
return self._obj_fn | ||
|
||
@property | ||
def model_str(self): | ||
return self._model_str | ||
|
||
def fit(self): | ||
return | ||
|
||
|
||
if __name__ == "__main__": | ||
def gramacy_lee_2012(x): | ||
if not (0.5 < x < 2.5): | ||
raise ValueError("provided value of x not in [0.5, 2.5].") | ||
y = np.sin(10.0 * np.pi * x) | ||
y /= 2 * x | ||
y += np.power(x - 1.0, 4.0) | ||
return y | ||
|
||
|
||
pass |