Describe the bug
When the search space contains a boolean variable in addition to another categorical variable which is non-boolean, the search will fail.
To Reproduce
The following is a slight modification of an existing test to show the problem
`dim_r = 2 # dimension of the real values
def obj_fun(x):
x_r = np.array([x['continuous_%d'%i] for i in range(dim_r)])
x_i = x['ordinal']
x_d = x['nominal']
_ = 0 if x_d == 'OK' else 1
return np.sum(x_r ** 2) + abs(x_i - 10) / 123. + _ * 2
search_space = ContinuousSpace([-5, 5], var_name='continuous') * dim_r +
OrdinalSpace([5, 15], var_name='ordinal') +
NominalSpace(['OK', 'A', None], var_name='nominal') +
NominalSpace([True, False], var_name='boolvar')
model = RandomForest(levels=search_space.levels)
opt = ParallelBO(
search_space=search_space,
obj_fun=obj_fun,
model=model,
max_FEs=6,
DoE_size=3, # the initial DoE size
eval_type='dict',
acquisition_fun='MGFI',
acquisition_par={'t' : 2},
n_job=3, # number of processes
n_point=3, # number of the candidate solution proposed in each iteration
verbose=False # turn this off, if you prefer no output
)
xopt, fopt, stop_dict = opt.run()`
Expected behavior
This should perform exactly the same as the case without boolean variable
Additional context
It seems to be related to the checking of input in the random forest
Describe the bug
When the search space contains a boolean variable in addition to another categorical variable which is non-boolean, the search will fail.
To Reproduce
The following is a slight modification of an existing test to show the problem
`dim_r = 2 # dimension of the real values
def obj_fun(x):
x_r = np.array([x['continuous_%d'%i] for i in range(dim_r)])
x_i = x['ordinal']
x_d = x['nominal']
_ = 0 if x_d == 'OK' else 1
return np.sum(x_r ** 2) + abs(x_i - 10) / 123. + _ * 2
search_space = ContinuousSpace([-5, 5], var_name='continuous') * dim_r +
OrdinalSpace([5, 15], var_name='ordinal') +
NominalSpace(['OK', 'A', None], var_name='nominal') +
NominalSpace([True, False], var_name='boolvar')
model = RandomForest(levels=search_space.levels)
opt = ParallelBO(
search_space=search_space,
obj_fun=obj_fun,
model=model,
max_FEs=6,
DoE_size=3, # the initial DoE size
eval_type='dict',
acquisition_fun='MGFI',
acquisition_par={'t' : 2},
n_job=3, # number of processes
n_point=3, # number of the candidate solution proposed in each iteration
verbose=False # turn this off, if you prefer no output
)
xopt, fopt, stop_dict = opt.run()`
Expected behavior
This should perform exactly the same as the case without boolean variable
Additional context
It seems to be related to the checking of input in the random forest