Closed ashuein closed 1 year ago
Thanks dhadka for the response. The python random.seed function, I know, but I am asking how to use it in the Platypus function? NSGAII or NSGAIII doesn't seem to have a seed argument in the function call ?
Hi @ashuein , you can try to monkey patch the initialization of the algorithm you are using to init a random seed. For example:
from platypus.algorithms import NSGAII
old_init = NSGAII.__init__
def new_init(self, problem,
population_size = 100,
generator = RandomGenerator(),
selector = TournamentSelector(2),
variator = None,
archive = None,
seed = None
**kwargs):
old_init(self, problem,
population_size = 100,
generator = RandomGenerator(),
selector = TournamentSelector(2),
variator = None,
archive = None,
**kwargs)
if self.seed is None:
self.seed = random.randint(0,1000)
random.seed(self.seed)
else:
random.seed(self.seed)
NSGAII.__init__ = new_init
You can save that into a file and import before you begin calling Platypus stuff.
This issue is stale and will be closed soon. If you feel this issue is still relevant, please comment to keep it active. Please also consider working on a fix and submitting a PR.
Is there a "seed" option in the Platypus which can be defined to keep the results reproducible?