Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MLopez-Ibanez authored Jul 9, 2023
1 parent a4fc030 commit 344f769
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pymoo/util/reference_direction.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,17 @@ def do(self):
# Util
# =========================================================================================================

def get_rng(seed = None):
if seed is None or type(seed) == int:
rng = np.random.default_rng(seed)
return rng

def sample_on_unit_simplex(n_points, n_dim, unit_simplex_mapping="kraemer"):
def sample_on_unit_simplex(n_points, n_dim, unit_simplex_mapping="kraemer", seed = None):
if unit_simplex_mapping == "sum":
rnd = map_onto_unit_simplex(np.random.random((n_points, n_dim)), "sum")
rnd = map_onto_unit_simplex(get_rng(seed).random((n_points, n_dim)), "sum")

elif unit_simplex_mapping == "kraemer":
rnd = map_onto_unit_simplex(np.random.random((n_points, n_dim)), "kraemer")
rnd = map_onto_unit_simplex(get_rng(seed).random((n_points, n_dim)), "kraemer")

elif unit_simplex_mapping == "das-dennis":
n_partitions = get_partition_closest_to_points(n_points, n_dim)
Expand Down

0 comments on commit 344f769

Please sign in to comment.