diff --git a/src/py2dmat/algorithm/exchange.py b/src/py2dmat/algorithm/exchange.py index 8f71a35..c61ba48 100644 --- a/src/py2dmat/algorithm/exchange.py +++ b/src/py2dmat/algorithm/exchange.py @@ -83,17 +83,8 @@ def __init__(self, info: py2dmat.Info, runner: py2dmat.Runner = None) -> None: super().__init__(info=info, runner=runner, nwalkers=nwalkers) - # if self.mpicomm is None: - # msg = "ERROR: algorithm.exchange requires mpi4py, but mpi4py cannot be imported" - # raise ImportError(msg) - self.nreplica = self.mpisize * self.nwalkers self.input_as_beta, self.betas = read_Ts(info_exchange, numT=self.nreplica) - # self.Tindex = np.arange( - # self.mpirank * self.nwalkers, (self.mpirank + 1) * self.nwalkers - # ) - # self.rep2T = np.arange(self.nreplica) - # self.T2rep = np.arange(self.nreplica) self.numsteps = info_exchange["numsteps"] self.numsteps_exchange = info_exchange["numsteps_exchange"] @@ -137,12 +128,6 @@ def _run(self) -> None: raise RuntimeError("unknown mode {}".format(self.mode)) beta = self.betas[self.Tindex] - # self.exchange_direction = True - - # self.istep = 0 - - # # first step - # self._evaluate() if self.mode.startswith("init"): # first step @@ -169,15 +154,6 @@ def _run(self) -> None: next_checkpoint_step = self.istep + self.checkpoint_steps next_checkpoint_time = time.time() + self.checkpoint_interval - # print(">>> checkpoint={}".format(self.checkpoint)) - # print(">>> checkpoint_file={}".format(self.checkpoint_file)) - # print(">>> checkpoint_steps={}".format(self.checkpoint_steps)) - # print(">>> checkpoint_interval={}".format(self.checkpoint_interval)) - # print(">>> istep= {}".format(self.istep)) - # print(">>> next_checkpoint_step={}".format(next_checkpoint_step)) - # print(">>> current_time= {}".format(time.time())) - # print(">>> next_checkpoint_time={}".format(next_checkpoint_time)) - while self.istep < self.numsteps: # print(">>> istep={}".format(self.istep)) diff --git a/src/py2dmat/algorithm/mapper_mpi.py b/src/py2dmat/algorithm/mapper_mpi.py index 944486c..0a1d2cb 100644 --- a/src/py2dmat/algorithm/mapper_mpi.py +++ b/src/py2dmat/algorithm/mapper_mpi.py @@ -26,7 +26,6 @@ import py2dmat.domain class Algorithm(py2dmat.algorithm.AlgorithmBase): - #mesh_list: np.ndarray mesh_list: List[Union[int, float]] def __init__(self, info: py2dmat.Info, @@ -52,12 +51,6 @@ def _initialize(self) -> None: def _run(self) -> None: # Make ColorMap - # label_list = self.label_list - # dimension = self.dimension - - # fx_list = [] - # self.timer["run"]["submit"] = 0.0 - if self.mode is None: raise RuntimeError("mode unset") diff --git a/src/py2dmat/algorithm/montecarlo.py b/src/py2dmat/algorithm/montecarlo.py index 569aee9..4c67b9a 100644 --- a/src/py2dmat/algorithm/montecarlo.py +++ b/src/py2dmat/algorithm/montecarlo.py @@ -120,8 +120,6 @@ def __init__(self, info: py2dmat.Info, self.domain = py2dmat.domain.Region(info) if self.iscontinuous: - # self.domain.initialize(rng=self.rng, limitation=self.runner.limitation, num_walkers=nwalkers) - # self.x = self.domain.initial_list self.xmin = self.domain.min_list self.xmax = self.domain.max_list self.xunit = self.domain.unit_list @@ -129,20 +127,12 @@ def __init__(self, info: py2dmat.Info, else: self.node_coordinates = np.array(self.domain.grid)[:, 1:] self.nnodes = self.node_coordinates.shape[0] - # self.inode = self.rng.randint(self.nnodes, size=self.nwalkers) - # self.x = self.node_coordinates[self.inode, :] self._setup_neighbour(info_param) - # self.fx = np.zeros(self.nwalkers) - # self.best_fx = 0.0 - # self.best_istep = 0 - # self.best_iwalker = 0 time_end = time.perf_counter() self.timer["init"]["total"] = time_end - time_sta self.Tindex = 0 self.input_as_beta = False - # self.naccepted = 0 - # self.ntrial = 0 def _initialize(self): if self.iscontinuous: diff --git a/src/py2dmat/algorithm/pamc.py b/src/py2dmat/algorithm/pamc.py index d18e0a5..137b587 100644 --- a/src/py2dmat/algorithm/pamc.py +++ b/src/py2dmat/algorithm/pamc.py @@ -106,35 +106,13 @@ def __init__(self, info: py2dmat.Info, runner: py2dmat.Runner = None) -> None: numT = self._find_scheduling(info_pamc) - # super()._initialize() - - #self.betas = self.read_Ts(info_pamc, numT=numT) self.input_as_beta, self.betas = read_Ts(info_pamc, numT=numT) self.betas.sort() - # self.Tindex = 0 - - # self.logZ = 0.0 - # self.logZs = np.zeros(numT) - # self.logweights = np.zeros(self.nwalkers) - - # self.Fmeans = np.zeros(numT) - # self.Ferrs = np.zeros(numT) - # nreplicas = self.mpisize * self.nwalkers - # self.nreplicas = np.full(numT, nreplicas) - # self.populations = np.zeros((numT, self.nwalkers), dtype=int) - # self.family_lo = self.nwalkers * self.mpirank - # self.family_hi = self.nwalkers * (self.mpirank + 1) - # self.walker_ancestors = np.arange(self.family_lo, self.family_hi) self.fix_nwalkers = info_pamc.get("fix_num_replicas", True) self.resampling_interval = info_pamc.get("resampling_interval", 1) if self.resampling_interval < 1: self.resampling_interval = numT + 1 - # self.fx_from_reset = np.zeros((self.resampling_interval, self.nwalkers)) - # self.naccepted_from_reset = np.zeros((self.resampling_interval, 2), dtype=int) - # self.acceptance_ratio = np.zeros(numT) - - #self._initialize() time_end = time.perf_counter() self.timer["init"]["total"] = time_end - time_sta @@ -142,11 +120,6 @@ def __init__(self, info: py2dmat.Info, runner: py2dmat.Runner = None) -> None: def _initialize(self) -> None: super()._initialize() - # #self.betas = self.read_Ts(info_pamc, numT=numT) - # self.input_as_beta, self.betas = read_Ts(info_pamc, numT=numT) - # self.betas.sort() - # self.Tindex = 0 - numT = len(self.betas) self.logZ = 0.0 @@ -162,15 +135,10 @@ def _initialize(self) -> None: self.family_lo = self.nwalkers * self.mpirank self.family_hi = self.nwalkers * (self.mpirank + 1) self.walker_ancestors = np.arange(self.family_lo, self.family_hi) - # self.fix_nwalkers = info_pamc.get("fix_num_replicas", True) - # self.resampling_interval = info_pamc.get("resampling_interval", 1) - # if self.resampling_interval < 1: - # self.resampling_interval = numT + 1 self.fx_from_reset = np.zeros((self.resampling_interval, self.nwalkers)) self.naccepted_from_reset = np.zeros((self.resampling_interval, 2), dtype=int) self.acceptance_ratio = np.zeros(numT) - def _find_scheduling(self, info_pamc) -> int: numsteps = info_pamc.get("numsteps", 0) numsteps_annealing = info_pamc.get("numsteps_annealing", 0) @@ -675,8 +643,6 @@ def _load_state(self, filename, mode="resume", restore_rng=True): self.nreplicas = data["nreplicas"] self.populations = data["populations"] - #assert self.mpirank * self.nwalkers == data["family_lo"] - #assert (self.mpirank+1) * self.nwalkers == data["family_hi"] self.family_lo = data["family_lo"] self.family_hi = data["family_hi"]