From b2dba52d024396bf10183a17c657ea07db333683 Mon Sep 17 00:00:00 2001 From: SevgiAkten Date: Mon, 4 Nov 2024 12:30:19 +0300 Subject: [PATCH] (#67) Added seed parameter for reproducibility --- README.md | 1 - paper/paper.md | 1 - pycellga/optimizer.py | 3 ++- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8556259..fef67d9 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,6 @@ print("Best solution:", result[1], "\nBest solution chromosome:", result[0]) # Best solution: 0.0 # Best solution chromosome: [0.0, 0.0, 0.0, 0.0, 0.0] -# Note that the result could be different because the algorithm includes randomness. ``` We have provided a basic example above. If you're interested in exploring more examples, you have two options: diff --git a/paper/paper.md b/paper/paper.md index f2de256..c3e6320 100644 --- a/paper/paper.md +++ b/paper/paper.md @@ -114,7 +114,6 @@ print("Best solution:", result[1], "\nBest solution chromosome:", result[0]) # Best solution: 0.0 # Best solution chromosome: [0.0, 0.0, 0.0, 0.0, 0.0] -# Note that the result could be different because the algorithm includes randomness. ``` diff --git a/pycellga/optimizer.py b/pycellga/optimizer.py index 1254aa0..48e29df 100644 --- a/pycellga/optimizer.py +++ b/pycellga/optimizer.py @@ -49,7 +49,8 @@ from typing import Callable, List, Tuple from collections.abc import Callable - +np.random.seed(100) +random.seed(100) def cga( n_cols: int,