Skip to content

Commit

Permalink
Merge pull request #389 from Happy-Algorithms-League/bug/permissible-…
Browse files Browse the repository at this point in the history
…values

Make sure `permissible_values` is a list of arrays
  • Loading branch information
jakobj authored Mar 29, 2024
2 parents 3351014 + 6ec03be commit dd6b262
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cgp/genome.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ def determine_permissible_values(self) -> List[np.ndarray]:
def _determine_permissible_values_input_region(self, gene_idx: int) -> np.ndarray:

if self._is_function_gene(gene_idx):
return np.array(self._id_input_node)
return np.array([self._id_input_node])
else:
return np.array(self._id_unused_gene)
return np.array([self._id_unused_gene])

def _determine_permissible_values_hidden_region(
self, gene_idx: int, region_idx: int
Expand All @@ -206,13 +206,13 @@ def _determine_permissible_values_hidden_region(
def _determine_permissible_values_output_region(self, gene_idx: int) -> np.ndarray:

if self._is_function_gene(gene_idx):
return np.array(self._id_output_node)
return np.array([self._id_output_node])
else:
address_idx = gene_idx % self._length_per_region - 1
if address_idx == 0:
return np.array(self._permissible_addresses_for_output_region())
else:
return np.array(self._id_unused_gene)
return np.array([self._id_unused_gene])

def _create_input_region(self) -> List[int]:

Expand Down

0 comments on commit dd6b262

Please sign in to comment.