diff --git a/litebo/__main__.py b/litebo/__main__.py new file mode 100644 index 00000000..f692bf9d --- /dev/null +++ b/litebo/__main__.py @@ -0,0 +1,50 @@ +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +import sys +import numpy as np +from litebo.utils.start_smbo import create_smbo + + +def branin(x): + xs = x.get_dictionary() + x1 = xs['x1'] + x2 = xs['x2'] + a = 1. + b = 5.1 / (4. * np.pi ** 2) + c = 5. / np.pi + r = 6. + s = 10. + t = 1. / (8. * np.pi) + ret = a * (x2 - b * x1 ** 2 + c * x1 - r) ** 2 + s * (1 - t) * np.cos(x1) + s + return {'objs': (ret,)} + + +config_dict = { + "optimizer": "SMBO", + "parameters": { + "x1": { + "type": "float", + "bound": [-5, 10], + "default": 0 + }, + "x2": { + "type": "float", + "bound": [0, 15] + }, + }, + "advisor_type": 'default', + "max_runs": 50, + "surrogate_type": 'gp', + "time_limit_per_trial": 5, + "logging_dir": 'logs', + "task_id": 'hp1' +} + + +def main(): + bo = create_smbo(branin, **config_dict) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/setup.py b/setup.py index 2c131ecf..9337ce25 100644 --- a/setup.py +++ b/setup.py @@ -9,13 +9,11 @@ import importlib.util from pathlib import Path from typing import Dict, List -from setuptools import setup, find_packages - -import setuptools from distutils.core import setup +from setuptools import find_packages -requirements: Dict[str, List[str]] = {} +requirements = dict() for extra in ["dev", "main"]: # Skip `package @ git+[repo_url]` because not supported by pypi requirements[extra] = [r @@ -44,9 +42,15 @@ def readme() -> str: url='https://github.com/thomas-young-2013/lite-bo', author="Thomas (Yang) Li from DAIM@PKU", packages=find_packages(), + license="MIT", install_requires=requirements["main"], extras_require={"dev": requirements["dev"]}, package_data={"lite-bo": ["py.typed"]}, include_package_data=True, - python_requires='>=3.5.2' + python_requires='>=3.5.2', + entry_points={ + "console_scripts": [ + "litebo = litebo.__main__:main", + ] + } )