Skip to content

Commit

Permalink
avoid evaluating forbidden relations on HPOs that were disabled/not s…
Browse files Browse the repository at this point in the history
…ampled because of conditions that were not met
  • Loading branch information
Bogdan Budescu committed Nov 19, 2024
1 parent d5b82ae commit 84899b7
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/ConfigSpace/forbidden.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,10 @@ def is_forbidden_vector(self, vector: Array[f64]) -> bool:
def is_forbidden_vector_array(self, arr: Array[f64]) -> Mask:
left = arr[self.vector_ids[0]]
right = arr[self.vector_ids[1]]
return self.left.to_value(left) < self.right.to_value(right)
mask = ~(np.isnan(left) | np.isnan(right))
out = np.zeros_like(mask)
out[mask] = self.left.to_value(left[mask]) < self.right.to_value(right[mask])
return out


class ForbiddenEqualsRelation(ForbiddenRelation):
Expand Down Expand Up @@ -686,7 +689,10 @@ def is_forbidden_vector(self, vector: Array[f64]) -> bool:
def is_forbidden_vector_array(self, arr: Array[f64]) -> Mask:
left = arr[self.vector_ids[0]]
right = arr[self.vector_ids[1]]
return self.left.to_value(left) == self.right.to_value(right) # type: ignore
mask = ~(np.isnan(left) | np.isnan(right))
out = np.zeros_like(mask)
out[mask] = self.left.to_value(left[mask]) == self.right.to_value(right[mask])
return out # type: ignore


class ForbiddenGreaterThanRelation(ForbiddenRelation):
Expand Down Expand Up @@ -751,7 +757,10 @@ def is_forbidden_vector(self, vector: Array[f64]) -> bool:
def is_forbidden_vector_array(self, arr: Array[f64]) -> Mask:
left = arr[self.vector_ids[0]]
right = arr[self.vector_ids[1]]
return self.left.to_value(left) > self.right.to_value(right)
mask = ~(np.isnan(left) | np.isnan(right))
out = np.zeros_like(mask)
out[mask] = self.left.to_value(left[mask]) > self.right.to_value(right[mask])
return out


ForbiddenLike = Union[
Expand Down

0 comments on commit 84899b7

Please sign in to comment.