Skip to content

Commit

Permalink
improved parallel distribution of tasks based on discussion with Rob …
Browse files Browse the repository at this point in the history
…Boer
  • Loading branch information
minaskar committed May 11, 2020
1 parent de0bdc5 commit ed81ed4
Show file tree
Hide file tree
Showing 22 changed files with 67 additions and 41 deletions.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/index.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/_build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 3ed64e5c0523c57284ad7d6da93281b4
config: 98cbb77c72c006cb43bcbbf181b412bc
tags: 645f666f9bcd5a90fca523b33c5a78b7
7 changes: 7 additions & 0 deletions docs/_build/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ Copyright 2019-2020 Minas Karamanis and contributors.
zeus is free software made available under the GPL-3.0 License.


Changelog
=========

**1.0.7 (11/05/20)**

- Improved parallel distribution of tasks


.. toctree::
:maxdepth: 2
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '1.0.6',
VERSION: '1.0.7',
LANGUAGE: 'None',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>API &#8212; zeus 1.0.6 documentation</title>
<title>API &#8212; zeus 1.0.7 documentation</title>
<link rel="stylesheet" href="_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/_static/default.css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/cookbook.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Cookbook &#8212; zeus 1.0.6 documentation</title>
<title>Cookbook &#8212; zeus 1.0.7 documentation</title>
<link rel="stylesheet" href="_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/_static/default.css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Frequently Asked Questions &#8212; zeus 1.0.6 documentation</title>
<title>Frequently Asked Questions &#8212; zeus 1.0.7 documentation</title>
<link rel="stylesheet" href="_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/_static/default.css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Index &#8212; zeus 1.0.6 documentation</title>
<title>Index &#8212; zeus 1.0.7 documentation</title>
<link rel="stylesheet" href="_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/_static/default.css" />
Expand Down
10 changes: 9 additions & 1 deletion docs/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>zeus documentation &#8212; zeus 1.0.6 documentation</title>
<title>zeus documentation &#8212; zeus 1.0.7 documentation</title>
<link rel="stylesheet" href="_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/_static/default.css" />
Expand Down Expand Up @@ -109,6 +109,7 @@
<li><a class="reference internal" href="#getting-started">Getting Started</a></li>
<li><a class="reference internal" href="#attribution">Attribution</a></li>
<li><a class="reference internal" href="#licence">Licence</a></li>
<li><a class="reference internal" href="#changelog">Changelog</a></li>
</ul>
</ul>
</li>
Expand Down Expand Up @@ -208,6 +209,13 @@ <h1>Attribution<a class="headerlink" href="#attribution" title="Permalink to thi
<h1>Licence<a class="headerlink" href="#licence" title="Permalink to this headline"></a></h1>
<p>Copyright 2019-2020 Minas Karamanis and contributors.</p>
<p>zeus is free software made available under the GPL-3.0 License.</p>
</div>
<div class="section" id="changelog">
<h1>Changelog<a class="headerlink" href="#changelog" title="Permalink to this headline"></a></h1>
<p><strong>1.0.7 (11/05/20)</strong></p>
<ul class="simple">
<li><p>Improved parallel distribution of tasks</p></li>
</ul>
<div class="toctree-wrapper compound">
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/notebooks/MPI.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Parallelizing sampling using MPI &#8212; zeus 1.0.6 documentation</title>
<title>Parallelizing sampling using MPI &#8212; zeus 1.0.7 documentation</title>
<link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/_static/default.css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/notebooks/datafit.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Fitting a model to data &#8212; zeus 1.0.6 documentation</title>
<title>Fitting a model to data &#8212; zeus 1.0.7 documentation</title>
<link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/_static/default.css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/notebooks/multiprocessing.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Parallelizing sampling using multiprocessing &#8212; zeus 1.0.6 documentation</title>
<title>Parallelizing sampling using multiprocessing &#8212; zeus 1.0.7 documentation</title>
<link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/_static/default.css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/notebooks/normal_distribution.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Sampling from a multivariate Normal distribution &#8212; zeus 1.0.6 documentation</title>
<title>Sampling from a multivariate Normal distribution &#8212; zeus 1.0.7 documentation</title>
<link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/_static/default.css" />
Expand Down
Binary file modified docs/_build/html/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/_build/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Search &#8212; zeus 1.0.6 documentation</title>
<title>Search &#8212; zeus 1.0.7 documentation</title>
<link rel="stylesheet" href="_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/_static/default.css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
author = 'Minas Karamanis'

# The full version, including alpha/beta/rc tags
release = '1.0.6'
release = '1.0.7'

# -- General configuration ---------------------------------------------------

Expand Down
7 changes: 7 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ Copyright 2019-2020 Minas Karamanis and contributors.
zeus is free software made available under the GPL-3.0 License.


Changelog
=========

**1.0.7 (11/05/20)**

- Improved parallel distribution of tasks


.. toctree::
:maxdepth: 2
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="zeus-mcmc",
version="1.0.6",
version="1.0.7",
author="Minas Karamanis",
author_email="[email protected]",
description="zeus: Lightning Fast MCMC",
Expand Down
2 changes: 1 addition & 1 deletion zeus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "zeus-mcmc"
__version__ = "1.0.6"
__version__ = "1.0.7"
__url__ = "https://zeus-mcmc.readthedocs.io"
__author__ = "Minas Karamanis"
__email__ = "[email protected]"
Expand Down
54 changes: 29 additions & 25 deletions zeus/zeus.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,43 @@ def run(self,
# Initialise number of Log prob calls
ncall = 0

# Left stepping-out
# Left stepping-out initialisation
mask_J = np.full(int(self.nwalkers/2),True)
Z_L = np.empty(int(self.nwalkers/2))
X_L = np.empty((int(self.nwalkers/2),self.ndim))

# Right stepping-out initialisation
mask_K = np.full(int(self.nwalkers/2),True)
Z_R = np.empty(int(self.nwalkers/2))
X_R = np.empty((int(self.nwalkers/2),self.ndim))

cnt = 0
while len(mask_J[mask_J])>0:
# Stepping-Out procedure
while len(mask_J[mask_J])>0 or len(mask_K[mask_K])>0:
if len(mask_J[mask_J])>0:
cnt += 1
if len(mask_K[mask_K])>0:
cnt += 1
if cnt > self.maxiter:
raise RuntimeError('Number of expansions exceeded maximum limit! \n' +
'Make sure that the pdf is well-defined. \n' +
'Otherwise increase the maximum limit (maxiter=10^4 by default).')

for j in indeces[mask_J]:
if J[j] < 1:
mask_J[j] = False

for j in indeces[mask_K]:
if K[j] < 1:
mask_K[j] = False

X_L[mask_J] = directions[mask_J] * L[mask_J][:,np.newaxis] + X[active][mask_J]
Z_L[mask_J] = np.asarray(list(distribute(self.logprob_fn,X_L[mask_J])))
X_R[mask_K] = directions[mask_K] * R[mask_K][:,np.newaxis] + X[active][mask_K]

Z_LR_masked = np.asarray(list(distribute(self.logprob_fn, np.concatenate([X_L[mask_J],X_R[mask_K]]))))
Z_L[mask_J] = Z_LR_masked[:X_L[mask_J].shape[0]]
Z_R[mask_K] = Z_LR_masked[X_L[mask_J].shape[0]:]

for j in indeces[mask_J]:
ncall += 1
if Z0[j] < Z_L[j]:
Expand All @@ -234,24 +259,7 @@ def run(self,
nexp += 1
else:
mask_J[j] = False
cnt += 1
if cnt > self.maxiter:
raise RuntimeError('Number of expansions exceeded maximum limit! \n' +
'Make sure that the pdf is well-defined. \n' +
'Otherwise increase the maximum limit (maxiter=10^4 by default).')

# Right stepping-out
mask_K = np.full(int(self.nwalkers/2),True)
Z_R = np.empty(int(self.nwalkers/2))
X_R = np.empty((int(self.nwalkers/2),self.ndim))

cnt = 0
while len(mask_K[mask_K])>0:
for j in indeces[mask_K]:
if K[j] < 1:
mask_K[j] = False
X_R[mask_K] = directions[mask_K] * R[mask_K][:,np.newaxis] + X[active][mask_K]
Z_R[mask_K] = np.asarray(list(distribute(self.logprob_fn,X_R[mask_K])))
for j in indeces[mask_K]:
ncall += 1
if Z0[j] < Z_R[j]:
Expand All @@ -260,11 +268,7 @@ def run(self,
nexp += 1
else:
mask_K[j] = False
cnt += 1
if cnt > self.maxiter:
raise RuntimeError('Number of expansions exceeded maximum limit! \n' +
'Make sure that the pdf is well-defined. \n' +
'Otherwise increase the maximum limit (maxiter=10^4 by default).')


# Shrinking procedure
Widths = np.empty(int(self.nwalkers/2))
Expand Down

0 comments on commit ed81ed4

Please sign in to comment.