PKU-DAIR / open-box

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

How to define the parameter space using Openbox when there are integers to the power of 2 in my parameters #77

Closed DimanChauncey closed 6 months ago

DimanChauncey commented 6 months ago

Some of my parameters are powers of 2, for example, the search range for x1 is [2,4,8,16,32,64]. In this case, how to use Openbox to define the parameter space.

我的参数中有一些是2的幂次方,比如x1的搜索范围是[2,4,8,16,32,64],这种情况,如何使用openbox去定义参数空间

thanks a lot.

jhj0411jhj commented 6 months ago

There are two ways:

  1. Define an Int parameter to represent the exponent number, e.g. 1 to 6, and restore the original x1 parameter (2^1 to 2^6) in your objective function.
  2. Define the parameter using Ordinal. However, some algorithms may not support Ordinal yet.
    from openbox import space as sp
    x1 = sp.Ordinal('x1', sequence=[2, 4, 8, 16, 32, 64], default_value=2)
DimanChauncey commented 6 months ago

Thank you! I took the first way. I wanna know a little bit about the difference of two ways. Does the choice of different methods have any impact on the results?

jhj0411jhj commented 6 months ago

When config.get_array() is called, the Int parameter is automatically scaled to [0, 1], while the Ordinal parameter is not scaled. It's a feature of ConfigSpace, and OpenBox does no extra work when fitting the surrogate model. Therefore, there might be a little difference in model fitting.