Commit 5a4eb2f3 authored by Mario Teixeira Parente's avatar Mario Teixeira Parente
Browse files

use 'RandomState' instead of 'default_rng' for earlier numpy versions

parent df49c2aa
......@@ -249,7 +249,7 @@ class TASAutonomousApproach():
def __init__(self, name: str, random_seed: int) -> None:
self.name = name
self.id = random_seed
self.rng = np.random.default_rng(seed=random_seed)
self.random_state = np.random.RandomState(seed=random_seed)
@abstractmethod
def initialize(self, cost_measures: list[CostMeasure], test_case: TASTestCase,
......
......@@ -26,7 +26,7 @@ class RandomnessApproach(TASAutonomousApproach):
def next(self) -> Tuple[list[float], float]:
while True:
location = self.rng.uniform(low=self.limits[:, 0], high=self.limits[:, 1])
location = self.random_state.uniform(low=self.limits[:, 0], high=self.limits[:, 1])
# Check if location is valid
if len(filter_valid_locations([location], test_case=self.test_case)) > 0:
......
......@@ -72,8 +72,7 @@ class PANDAIApproach(TASAutonomousApproach):
self.client.finalize()
def _run_pandai_server(self):
run_server(rng=self.rng,
num_kernel_optim_restarts=self.num_kernel_optim_restarts,
run_server(num_kernel_optim_restarts=self.num_kernel_optim_restarts,
kernel_bounds_variance=self.kernel_bounds_variance,
kernel_bounds_length_scales=self.kernel_bounds_length_scales,
num_kernel_optims_min=self.num_kernel_optims_min,
......@@ -90,4 +89,5 @@ class PANDAIApproach(TASAutonomousApproach):
thresh_intens_diffs_rel_diffs_abs_max=self.thresh_intens_diffs_rel_diffs_abs_max,
thresh_intens_fact_min=self.thresh_intens_fact_min,
thresh_intens_fact_max=self.thresh_intens_fact_max,
random_state=self.random_state,
port=self.port)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment