From 6fc30c4bb99ca08dc738e63c99a6a0d4cfd4ceb8 Mon Sep 17 00:00:00 2001 From: Retief Lubbe Date: Mon, 15 Jan 2024 16:40:14 +0000 Subject: [PATCH] Remove class attributes and set_curr_step function -related to #55 --- grainlearning/bayesian_calibration.py | 41 ++++++++------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/grainlearning/bayesian_calibration.py b/grainlearning/bayesian_calibration.py index 0044caf..5d97274 100644 --- a/grainlearning/bayesian_calibration.py +++ b/grainlearning/bayesian_calibration.py @@ -67,40 +67,31 @@ class BayesianCalibration: :param curr_iter: Current iteration step :param save_fig: Flag for skipping (-1), showing (0), or saving (1) the figures """ - #: Dynamic system whose parameters or hidden states are being inferred - system: Type["DynamicSystem"] - - #: Calibration method (e.g, Iterative Bayesian Filter) - calibration: Type["IterativeBayesianFilter"] - - #: Number of iterations - num_iter: int - - #: Current calibration step - curr_iter: int = 0 - - #: Flag to save figures - save_fig: int = -1 - def __init__( self, system: Type["DynamicSystem"], calibration: Type["IterativeBayesianFilter"], - num_iter: int, - curr_iter: int, - save_fig: int + num_iter: int = 10, + curr_iter: int = 0, + save_fig: int = -1 ): """Initialize the Bayesian calibration class""" - self.system = system - self.calibration = calibration self.num_iter = num_iter - self.set_curr_iter(curr_iter) self.save_fig = save_fig + self.system = system + + self.system.curr_iter = curr_iter + + self.curr_iter = curr_iter + + self.calibration = calibration + + def run(self): """ This is the main calibration loop which does the following steps 1. First iteration of Bayesian calibration starts with a Halton sequence @@ -272,14 +263,6 @@ def get_most_prob_params(self): most_prob = argmax(self.calibration.posterior) return self.system.param_data[most_prob] - def set_curr_iter(self, curr_iter: int): - """Set the current iteration step - - param curr_iter: Current iteration step - """ - self.system.curr_iter = curr_iter - self.curr_iter = self.system.curr_iter - def increase_curr_iter(self): """Increase the current iteration step by one """