Extended to allow selection probabilities of 0 or 1
This commit is contained in:
@ -2,12 +2,12 @@ import random
|
|||||||
|
|
||||||
def _check_selection_probability(selection_method):
|
def _check_selection_probability(selection_method):
|
||||||
"""Raises an exception if the selection_probability
|
"""Raises an exception if the selection_probability
|
||||||
is not between 0 and 1. Otherwise runs the selection
|
is not between 0 and 1 inclusively. Otherwise runs
|
||||||
method.
|
the selection method.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def new_method(ga):
|
def new_method(ga):
|
||||||
if 0 < ga.selection_probability < 1:
|
if 0 <= ga.selection_probability <= 1:
|
||||||
selection_method(ga)
|
selection_method(ga)
|
||||||
else:
|
else:
|
||||||
raise Exception("Selection probability must be between 0 and 1 to select parents.")
|
raise Exception("Selection probability must be between 0 and 1 to select parents.")
|
||||||
|
|||||||
Reference in New Issue
Block a user