Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f98f0c9

Browse files
committed
Fix a typo in example_custom_operators
In the crossover function, the split point is chosen in the range of the offspring size, instead of the solution size. An out-of-range split point is silently ignored by the range selection: it selects all genes from parent1, and none from parent2. However, the error can be demonstrated by throwing an exception if the split point is out of range.
1 parent 8024132 commit f98f0c9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎examples/example_custom_operators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def crossover_func(parents, offspring_size, ga_instance):
4141
parent1 = parents[idx % parents.shape[0], :].copy()
4242
parent2 = parents[(idx + 1) % parents.shape[0], :].copy()
4343

44-
random_split_point = numpy.random.choice(range(offspring_size[0]))
44+
random_split_point = numpy.random.choice(range(offspring_size[1]))
4545

4646
parent1[random_split_point:] = parent2[random_split_point:]
4747

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /