File tree Expand file tree Collapse file tree 3 files changed +7
-10
lines changed
Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -110,8 +110,11 @@ def __init__(
110110 given
111111 fitness_transformation:
112112 A function mapping a score to a (non-negative) float
113+ mutation_method:
114+ A string indicating if the mutation method should be between original types ("transition")
115+ or based on the player's mutation method, if present ("atomic").
113116 stop_on_fixation:
114- A bool indicating if the process should stop on fixation.
117+ A bool indicating if the process should stop on fixation
115118 """
116119 self .turns = turns
117120 self .prob_end = prob_end
Original file line number Diff line number Diff line change @@ -73,14 +73,8 @@ def randrange(a: int, b: int) -> int:
7373
7474def random_vector (size ):
7575 """Create a random vector of values in [0, 1] that sums to 1."""
76- vector = []
77- s = 1
78- for _ in range (size - 1 ):
79- r = s * random .random ()
80- vector .append (r )
81- s -= r
82- vector .append (s )
83- return vector
76+ vector = np .random .random (size )
77+ return vector / np .sum (vector )
8478
8579
8680class Pdf (object ):
Original file line number Diff line number Diff line change @@ -232,7 +232,7 @@ def test_vector_to_instance(self):
232232 num_states = 4
233233 vector = []
234234 for _ in range (2 * num_states ):
235- vector += random_vector (num_states )
235+ vector . extend ( list ( random_vector (num_states )) )
236236 for _ in range (num_states + 1 ):
237237 vector .append (random .random ())
238238 player = self .player_class (num_states = num_states )
You can’t perform that action at this time.
0 commit comments