Movatterモバイル変換


[0]ホーム

URL:


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

Commitf98f0c9

Browse files
committed
Fix a typo in example_custom_operators
In the crossover function, the split point is chosen in the range of theoffspring 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 thesplit point is out of range.
1 parent8024132 commitf98f0c9

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)

[8]ページ先頭

©2009-2025 Movatter.jp