Skip to content

Commit

Permalink
Merge pull request #280 from jakobj/enh/check-length-of-hurdles-perce…
Browse files Browse the repository at this point in the history
…ntile

Check number of objectives matches number of specified hurdle percentiles
  • Loading branch information
HenrikMettler committed Jan 8, 2021
2 parents a5f3435 + e5e0c96 commit 897393f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cgp/ea/mu_plus_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(
local_search: Callable[[IndividualBase], None] = lambda combined: None,
k_local_search: Union[int, None] = None,
reorder_genome: bool = False,
hurdle_percentile: List = [0.0]
hurdle_percentile: List = [0.0],
):
"""Init function
Expand Down Expand Up @@ -207,6 +207,12 @@ def compute_fitness_hurdle(ind_evaluating: List[IndividualBase]) -> float:

if callable(objective):
objective = [objective]
else:
if len(objective) != len(self.hurdle_percentile):
raise ValueError(
f"{len(objective)} objectives found, but hurdle percentile"
" defined for {len(self.hurdle_percentile)} objectives."
)

ind_evaluating = list(combined)
ind_done_evaluating = []
Expand Down

0 comments on commit 897393f

Please sign in to comment.