Skip to content

Commit

Permalink
parameter speed change
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikOrm committed Oct 19, 2023
1 parent bd8e04c commit 42fae5f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hypermapper/param/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,10 @@ def __init__(
i.item(): i for i in self.values
} # from internal to index (which are the same for permutations)

self._permutation_indices = {
tuple(p): i for i, p in enumerate(self.permutation_values)
}

def parametrize(self, data: List[int]) -> Tuple[List[str], List[List[float]]]:
"""
Provides a parametrization representation of the variable.
Expand Down Expand Up @@ -859,7 +863,7 @@ def get_permutation_values(self) -> List[Tuple[int]]:
return self.permutation_values

def get_int_value(self, permutation: Tuple[int]) -> int:
return self.permutation_values.index(permutation)
return self._permutation_indices[permutation]

def get_permutation_value(self, idx_value: int) -> Tuple[int]:
return self.permutation_values[int(idx_value)]
Expand Down

0 comments on commit 42fae5f

Please sign in to comment.