@@ -267,6 +267,7 @@ cpdef np.ndarray change_hp_value(
267267 cdef Hyperparameter current
268268 cdef str current_name
269269 cdef list disabled
270+ cdef set hps_to_be_activate
270271 cdef set visited
271272 cdef dict activated_values
272273 cdef int active
@@ -287,6 +288,12 @@ cpdef np.ndarray change_hp_value(
287288 # Hyperparameters which are going to be set to inactive
288289 disabled = []
289290
291+ # Hyperparameters which are going to be set activate, we introduce this to resolve the conflict that might be raised
292+ # by OrConjunction:
293+ # Suppose that we have a parent HP_p whose possible values are A, B, C; a child HP_d is activate if
294+ # HP_p is A or B. Then when HP_p switches from A to B, HP_d needs to remain activate.
295+ hps_to_be_activate = set ()
296+
290297 # Activate hyperparameters if their parent node got activated
291298 children = children_of[hp_name]
292299 if len (children) > 0 :
@@ -301,7 +308,7 @@ cpdef np.ndarray change_hp_value(
301308 if current_name in visited:
302309 continue
303310 visited.add(current_name)
304- if current_name in disabled :
311+ if current_name in hps_to_be_activate :
305312 continue
306313
307314 current_idx = configuration_space._hyperparameter_idx[current_name]
@@ -315,6 +322,16 @@ cpdef np.ndarray change_hp_value(
315322 active = False
316323 break
317324
325+ if active:
326+ hps_to_be_activate.add(current_idx)
327+ if current_value == current_value:
328+ children_ = children_of[current_name]
329+ if len (children_) > 0 :
330+ to_visit.extendleft(children_)
331+
332+ if current_name in disabled:
333+ continue
334+
318335 if active and not current_value == current_value:
319336 default_value = current.normalized_default_value
320337 configuration_array[current_idx] = default_value
@@ -343,6 +360,7 @@ cpdef np.ndarray change_hp_value(
343360 to_disable.add(ch.name)
344361
345362 for idx in disabled:
346- configuration_array[idx] = NaN
363+ if idx not in hps_to_be_activate:
364+ configuration_array[idx] = NaN
347365
348366 return configuration_array
0 commit comments