Skip to content

Commit 6da25fe

Browse files
committed
[fix] changed leftover np.random to global rng. Added global rng logic to test_mutation.py
1 parent 140fd89 commit 6da25fe

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

WeatherRoutingTool/algorithms/genetic/mutation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ def variable_plateau_size(self, route_length) -> bool:
247247
if route_length < 9:
248248
return False
249249

250-
plateau_length = np.random.randint(7, np.floor(0.9 * route_length))
250+
plateau_length = int(self.rng.integers(7, np.floor(0.9 * route_length)))
251251
if plateau_length % 2 != 1:
252252
plateau_length = plateau_length - 1
253-
self.plateau_size = np.random.randint(2, plateau_length - 4)
253+
self.plateau_size = int(self.rng.integers(2, plateau_length - 4))
254254
if self.plateau_size % 2 != 1:
255255
self.plateau_size += 1
256256
self.plateau_slope = (plateau_length + 2 - self.plateau_size) / 2

tests/test_mutation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ def test_variable_plateau_size(route_length):
2323
dirname = os.path.dirname(__file__)
2424
configpath = os.path.join(dirname, 'config.isofuel_single_route.json')
2525
config = Config.assign_config(Path(configpath))
26+
config.GENETIC_RANDOM_SEED = 1
2627
constraint_list = basic_test_func.generate_dummy_constraint_list()
2728

2829
mt = RandomPlateauMutation(config=config, constraints_list=constraint_list)
2930

30-
np.random.seed(1)
3131
for _ in range(100):
3232
mt.variable_plateau_size(route_length)
3333

0 commit comments

Comments
 (0)