mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 01:00:15 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
c9c9639803
commit
d62f39f647
|
@ -54,7 +54,7 @@ class GeneticAlgorithm:
|
||||||
... )
|
... )
|
||||||
>>> len(ga.initialize_population())
|
>>> len(ga.initialize_population())
|
||||||
5 # The population size should be equal to 5.
|
5 # The population size should be equal to 5.
|
||||||
>>> all(len(ind) == 2 for ind in ga.initialize_population())
|
>>> all(len(ind) == 2 for ind in ga.initialize_population())
|
||||||
# Each individual should have 2 variables
|
# Each individual should have 2 variables
|
||||||
True
|
True
|
||||||
"""
|
"""
|
||||||
|
@ -134,7 +134,7 @@ class GeneticAlgorithm:
|
||||||
parent2 (np.ndarray): The second parent.
|
parent2 (np.ndarray): The second parent.
|
||||||
Returns:
|
Returns:
|
||||||
tuple[np.ndarray, np.ndarray]: The two offspring generated by crossover.
|
tuple[np.ndarray, np.ndarray]: The two offspring generated by crossover.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
>>> ga = GeneticAlgorithm(
|
>>> ga = GeneticAlgorithm(
|
||||||
... lambda x, y: -(x**2 + y**2),
|
... lambda x, y: -(x**2 + y**2),
|
||||||
|
@ -276,7 +276,7 @@ def target_function(var_x: float, var_y: float) -> float:
|
||||||
var_y (float): The y-coordinate.
|
var_y (float): The y-coordinate.
|
||||||
Returns:
|
Returns:
|
||||||
float: The value of the function at (var_x, var_y).
|
float: The value of the function at (var_x, var_y).
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
>>> target_function(0, 0)
|
>>> target_function(0, 0)
|
||||||
0
|
0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user