PKU-DAIR / open-box

Generalized and Efficient Blackbox Optimization System
https://open-box.readthedocs.io
Other
376 stars 52 forks source link

Example code does not work #70

Closed mathstream closed 11 months ago

mathstream commented 11 months ago

Describe the bug The sample code on the website does not work. I am using openbox 0.8.1, Python 3.11.6, on MacOS 13.0 (ARM / M1 architecture)

To Reproduce from openbox import space as sp x1 = sp.Real("x1", -5, 10, default_value=0)

or

from openbox import space as sp x1 = sp.Real("x1", -5.0, 10.0, default_value=0.0)

Expected behavior The sample code should not throw an exception

Outputs and Logs If we call sp.Real and supply int values (like the example on the website):

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/alanw/projects/pxsim-clean/.env/HANGAR/lib/python3.11/site-packages/openbox/utils/space.py", line 99, in __init__ super().__init__(name=name, lower=lower, upper=upper, File "ConfigSpace/hyperparameters.pyx", line 669, in ConfigSpace.hyperparameters.UniformFloatHyperparameter.__init__ TypeError: Argument 'default_value' has incorrect type (expected float, got int)

If we fix it and pass floats, somewhere it's getting converted to numpy values:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/alanw/projects/pxsim-clean/.env/HANGAR/lib/python3.11/site-packages/openbox/utils/space.py", line 99, in __init__ super().__init__(name=name, lower=lower, upper=upper, File "ConfigSpace/hyperparameters.pyx", line 669, in ConfigSpace.hyperparameters.UniformFloatHyperparameter.__init__ File "ConfigSpace/hyperparameters.pyx", line 731, in ConfigSpace.hyperparameters.UniformFloatHyperparameter.check_default TypeError: Expected float, got numpy.float64

Additional context Just trying it for the first time

jhj0411jhj commented 11 months ago

Thanks for the issue. It seems to be an incompatibility bug between the ConfigSpace package and python3.11 (or cython). (See https://github.com/automl/ConfigSpace/issues/336) Upgrade Configspace to 0.7.1 will fix it (via pip install ConfigSpace==0.7.1), or use python 3.10 instead. We are doing more test to find a better solution.

jhj0411jhj commented 11 months ago

This issue is the same as #69 and will be closed. We will continue to track this bug in #69. Please feel free to reopen the issue if you have further questions.