diff --git a/doc/en/source/algorithm/bayes.rst b/doc/en/source/algorithm/bayes.rst index b7ba7ae..7f8e8a4 100644 --- a/doc/en/source/algorithm/bayes.rst +++ b/doc/en/source/algorithm/bayes.rst @@ -139,11 +139,11 @@ At each step of the optimization process, the values of the parameters and the c Restart ~~~~~~~~~~~~~~~~~~~~~~ -The execution mode is specified by the ``run_mode`` parameter to the ``Algorithm.main()`` method. +The execution mode is specified by the ``run_mode`` parameter to the constructor. The operation of each mode is described as follows. The parameter values correspond to ``--init``, ``--resume``, and ``--cont`` options of ``py2dmat`` command, respectively. -- ``"initialize"`` (default) +- ``"initial"`` (default) The program is started from the initial state. First, it performs the random sampling for the number of times specified by ``random_max_num_probes`` parameter. diff --git a/doc/en/source/algorithm/exchange.rst b/doc/en/source/algorithm/exchange.rst index c22e2c2..b282fd3 100644 --- a/doc/en/source/algorithm/exchange.rst +++ b/doc/en/source/algorithm/exchange.rst @@ -243,11 +243,11 @@ The remaining columns are the coordinates. Restart ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The execution mode is specified by the ``run_mode`` parameter to the ``Algorithm.main()`` method. +The execution mode is specified by the ``run_mode`` parameter to the constructor. The operation of each mode is described as follows. The parameter values correspond to ``--init``, ``--resume``, and ``--cont`` options of ``py2dmat`` command, respectively. -- ``"initialize"`` (default) +- ``"initial"`` (default) The program is started from the initialized state. If the checkpointing is enabled, the intermediate states will be stored at the folloing occasions: diff --git a/doc/en/source/algorithm/mapper_mpi.rst b/doc/en/source/algorithm/mapper_mpi.rst index e3d5f9f..3a3e76a 100644 --- a/doc/en/source/algorithm/mapper_mpi.rst +++ b/doc/en/source/algorithm/mapper_mpi.rst @@ -106,11 +106,11 @@ Below, output example is shown. Restart ~~~~~~~~~~~~~~~~~~~~~~ -The execution mode is specified by the ``run_mode`` parameter to the ``Algorithm.main()`` method. +The execution mode is specified by the ``run_mode`` parameter to the constructor. The operation of each mode is described as follows. The parameter values correspond to ``--init``, ``--resume``, and ``--cont`` options of ``py2dmat`` command, respectively. -- ``"initialize"`` (default) +- ``"initial"`` (default) The program is started from the initial state. If the checkpointing is enabled, the intermediate states will be stored at the folloing occasions: diff --git a/doc/en/source/algorithm/pamc.rst b/doc/en/source/algorithm/pamc.rst index e934fa9..967d3d1 100644 --- a/doc/en/source/algorithm/pamc.rst +++ b/doc/en/source/algorithm/pamc.rst @@ -296,11 +296,11 @@ The sixth column is the acceptance ratio of MC updates. Restart ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The execution mode is specified by the ``run_mode`` parameter to the ``Algorithm.main()`` method. +The execution mode is specified by the ``run_mode`` parameter to the constructor. The operation of each mode is described as follows. The parameter values correspond to ``--init``, ``--resume``, and ``--cont`` options of ``py2dmat`` command, respectively. -- ``"initialize"`` (default) +- ``"initial"`` (default) The program is started from the initialized state. If the checkpointing is enabled, the intermediate states will be stored at the folloing occasions: diff --git a/doc/ja/source/algorithm/bayes.rst b/doc/ja/source/algorithm/bayes.rst index 2e502d1..42638ce 100644 --- a/doc/ja/source/algorithm/bayes.rst +++ b/doc/ja/source/algorithm/bayes.rst @@ -140,11 +140,11 @@ リスタート ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -``Algorithm.main()`` メソッドの引数 ``run_mode`` に実行モードを指定します。 +コンストラクタの引数 ``run_mode`` に実行モードを指定します。 以下はそれぞれ ``py2dmat`` コマンドの引数の ``--init``, ``--resume``, ``--cont`` に対応します。 各モードの動作は次のとおりです。 -- ``"initialize"`` (デフォルト) +- ``"initial"`` (デフォルト) 初期化して実行します。 まず、ランダムサンプリングを ``random_max_num_probes`` に指定した回数だけ行います。 diff --git a/doc/ja/source/algorithm/exchange.rst b/doc/ja/source/algorithm/exchange.rst index 013134d..a8b4f4a 100644 --- a/doc/ja/source/algorithm/exchange.rst +++ b/doc/ja/source/algorithm/exchange.rst @@ -233,11 +233,11 @@ MPI並列を利用する場合は、あらかじめ `mpi4py None: self.mpicomm = mpi.comm() self.mpisize = mpi.size() @@ -73,7 +76,7 @@ def __init__( self.timer = {"init": {}, "prepare": {}, "run": {}, "post": {}} self.timer["init"]["total"] = 0.0 self.status = AlgorithmStatus.INIT - self.mode = None + self.mode = run_mode.lower() # keep copy of parameters self.info = copy.deepcopy(info.algorithm) @@ -168,9 +171,7 @@ def post(self) -> Dict: def _post(self) -> Dict: pass - def main(self, run_mode: str = "initialize"): - self.mode = run_mode.lower() - + def main(self): time_sta = time.perf_counter() self.prepare() time_end = time.perf_counter() diff --git a/src/py2dmat/algorithm/bayes.py b/src/py2dmat/algorithm/bayes.py index 545d47a..3c56dd5 100644 --- a/src/py2dmat/algorithm/bayes.py +++ b/src/py2dmat/algorithm/bayes.py @@ -48,8 +48,10 @@ class Algorithm(py2dmat.algorithm.AlgorithmBase): def __init__(self, info: py2dmat.Info, runner: py2dmat.Runner = None, - domain = None) -> None: - super().__init__(info=info, runner=runner) + domain = None, + run_mode: str = "initial" + ) -> None: + super().__init__(info=info, runner=runner, run_mode=run_mode) info_param = info.algorithm.get("param", {}) info_bayes = info.algorithm.get("bayes", {}) diff --git a/src/py2dmat/algorithm/exchange.py b/src/py2dmat/algorithm/exchange.py index 25376ed..e8714ab 100644 --- a/src/py2dmat/algorithm/exchange.py +++ b/src/py2dmat/algorithm/exchange.py @@ -75,13 +75,17 @@ class Algorithm(py2dmat.algorithm.montecarlo.AlgorithmBase): exchange_direction: bool - def __init__(self, info: py2dmat.Info, runner: py2dmat.Runner = None) -> None: + def __init__(self, + info: py2dmat.Info, + runner: py2dmat.Runner = None, + run_mode: str = "initial" + ) -> None: time_sta = time.perf_counter() info_exchange = info.algorithm["exchange"] nwalkers = info_exchange.get("nreplica_per_proc", 1) - super().__init__(info=info, runner=runner, nwalkers=nwalkers) + super().__init__(info=info, runner=runner, nwalkers=nwalkers, run_mode=run_mode) self.nreplica = self.mpisize * self.nwalkers self.input_as_beta, self.betas = read_Ts(info_exchange, numT=self.nreplica) diff --git a/src/py2dmat/algorithm/mapper_mpi.py b/src/py2dmat/algorithm/mapper_mpi.py index dbcec05..37f670a 100644 --- a/src/py2dmat/algorithm/mapper_mpi.py +++ b/src/py2dmat/algorithm/mapper_mpi.py @@ -30,8 +30,10 @@ class Algorithm(py2dmat.algorithm.AlgorithmBase): def __init__(self, info: py2dmat.Info, runner: py2dmat.Runner = None, - domain = None) -> None: - super().__init__(info=info, runner=runner) + domain = None, + run_mode: str = "initial" + ) -> None: + super().__init__(info=info, runner=runner, run_mode=run_mode) if domain and isinstance(domain, py2dmat.domain.MeshGrid): self.domain = domain diff --git a/src/py2dmat/algorithm/min_search.py b/src/py2dmat/algorithm/min_search.py index f881d9b..397c4b0 100644 --- a/src/py2dmat/algorithm/min_search.py +++ b/src/py2dmat/algorithm/min_search.py @@ -51,8 +51,10 @@ class Algorithm(py2dmat.algorithm.AlgorithmBase): def __init__(self, info: py2dmat.Info, runner: py2dmat.Runner = None, - domain = None) -> None: - super().__init__(info=info, runner=runner) + domain = None, + run_mode: str = "initial" + ) -> None: + super().__init__(info=info, runner=runner, run_mode=run_mode) if domain and isinstance(domain, py2dmat.domain.Region): self.domain = domain diff --git a/src/py2dmat/algorithm/montecarlo.py b/src/py2dmat/algorithm/montecarlo.py index 4c67b9a..776d1f5 100644 --- a/src/py2dmat/algorithm/montecarlo.py +++ b/src/py2dmat/algorithm/montecarlo.py @@ -95,10 +95,11 @@ class AlgorithmBase(py2dmat.algorithm.AlgorithmBase): def __init__(self, info: py2dmat.Info, runner: py2dmat.Runner = None, domain = None, - nwalkers: int = 1 + nwalkers: int = 1, + run_mode: str = "initial" ) -> None: time_sta = time.perf_counter() - super().__init__(info=info, runner=runner) + super().__init__(info=info, runner=runner, run_mode=run_mode) self.nwalkers = nwalkers if domain: diff --git a/src/py2dmat/algorithm/pamc.py b/src/py2dmat/algorithm/pamc.py index 175770d..2ddfc7e 100644 --- a/src/py2dmat/algorithm/pamc.py +++ b/src/py2dmat/algorithm/pamc.py @@ -94,13 +94,17 @@ class Algorithm(py2dmat.algorithm.montecarlo.AlgorithmBase): Fmeans: np.ndarray Ferrs: np.ndarray - def __init__(self, info: py2dmat.Info, runner: py2dmat.Runner = None) -> None: + def __init__(self, + info: py2dmat.Info, + runner: py2dmat.Runner = None, + run_mode: str = "initial" + ) -> None: time_sta = time.perf_counter() info_pamc = info.algorithm["pamc"] nwalkers = info_pamc.get("nreplica_per_proc", 1) - super().__init__(info=info, runner=runner, nwalkers=nwalkers) + super().__init__(info=info, runner=runner, nwalkers=nwalkers, run_mode=run_mode) self.verbose = True and self.mpirank == 0