Skip to content

Commit

Permalink
Exposes unfeasible value on Ehrlich
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgondu committed Aug 14, 2024
1 parent e9cf11a commit b5e3c05
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/poli/objective_repository/ehrlich/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def __init__(
n_motifs: int,
quantization: int | None = None,
seed: int = None,
return_value_on_unfeasible: float = -np.inf,
alphabet: list[str] = AMINO_ACIDS,
batch_size: int = None,
parallelize: bool = False,
Expand All @@ -105,6 +106,7 @@ def __init__(
super().__init__(batch_size, parallelize, num_workers, evaluation_budget)
self.alphabet = alphabet
self.sequence_length = sequence_length
self.return_value_on_unfeasible = return_value_on_unfeasible

if seed is not None:
seed_python_numpy_and_torch(seed)
Expand Down Expand Up @@ -332,7 +334,7 @@ def _black_box(self, x: np.ndarray, context=None) -> np.ndarray:
values = []
for sequence in x:
if not self._is_feasible(sequence):
values.append(-np.inf)
values.append(self.return_value_on_unfeasible)
continue

value = 1.0
Expand All @@ -352,7 +354,7 @@ def get_black_box_info(self) -> BlackBoxInformation:
max_sequence_length=self.sequence_length,
aligned=True,
fixed_length=True,
deterministic=True, # ?
deterministic=True,
alphabet=self.alphabet,
log_transform_recommended=False,
discrete=True,
Expand Down

0 comments on commit b5e3c05

Please sign in to comment.