Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
aoymt committed Aug 17, 2024
1 parent 08613ff commit d1a4af4
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 75 deletions.
24 changes: 0 additions & 24 deletions src/py2dmat/algorithm/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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
Expand All @@ -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))

Expand Down
7 changes: 0 additions & 7 deletions src/py2dmat/algorithm/mapper_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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")

Expand Down
10 changes: 0 additions & 10 deletions src/py2dmat/algorithm/montecarlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,29 +120,19 @@ 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

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:
Expand Down
34 changes: 0 additions & 34 deletions src/py2dmat/algorithm/pamc.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,47 +106,20 @@ 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

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
Expand All @@ -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)
Expand Down Expand Up @@ -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"]

Expand Down

0 comments on commit d1a4af4

Please sign in to comment.