Commit 81815628 authored by Mario Teixeira Parente's avatar Mario Teixeira Parente
Browse files

move random state to concrete approach classes

parent 59d48d56
......@@ -246,10 +246,9 @@ class BenefitMeasureApproximationErrorByNorm(BenefitMeasure):
class TASAutonomousApproach():
def __init__(self, name: str, random_seed: int) -> None:
def __init__(self, name: str, id: int) -> None:
self.name = name
self.id = random_seed
self.random_state = np.random.default_rng(seed=random_seed)
self.id = id
@abstractmethod
def initialize(self, cost_measures: list[CostMeasure], test_case: TASTestCase,
......
......@@ -12,8 +12,10 @@ class RandomnessApproach(TASAutonomousApproach):
"""Class representing an autonomous approach that measures uniformly at random
within the `limits`"""
def __init__(self, random_seed: int) -> None:
super().__init__("approach_random", random_seed)
def __init__(self, id: int) -> None:
super().__init__("approach_random", id)
self.random_state = np.random.default_rng(seed=id)
def initialize(self, cost_measures: list[CostMeasure], test_case: TASTestCase,
cost_milestone_values: list[list[float]], metric: AngleMapInducedMetric) \
......@@ -37,8 +39,8 @@ class GridApproach(TASAutonomousApproach):
"""Class representing an autonomous approach that measures on a regular grid
within the `limits`"""
def __init__(self, random_seed: int) -> None:
super().__init__("approach_grid", random_seed)
def __init__(self, id: int) -> None:
super().__init__("approach_grid", id)
def initialize(self, cost_measures: list[CostMeasure], test_case: TASTestCase,
cost_milestone_values: list[list[float]], metric: AngleMapInducedMetric) \
......
......@@ -15,8 +15,8 @@ from tas.approaches.dummies import RandomnessApproach as Approach
## Approach ##
random_seed = 0 if len(sys.argv) < 2 else int(sys.argv[1])
approach = Approach(random_seed)
id = 0 if len(sys.argv) < 2 else int(sys.argv[1])
approach = Approach(id)
##
## Folders ##
......
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