Commit 2b0a9da7 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

multicanonical_equilibrate(): small improvements

parent 2085f45a
......@@ -80,7 +80,7 @@ auto multicanonical_sweep(MulticanonicalState& state, RNG& rng)
}
else
{
double a = dens[i] - dens[j] + dS.second;
double a = (dens[i] - dens[j]) + dS.second;
if (a > 0)
{
accept = true;
......
......@@ -981,9 +981,9 @@ class BlockState(object):
return libinference.multicanonical_sweep(multicanonical_state,
self._state, _get_rng())
def multicanonical_sweep(self, m_state, c=1., niter=1, entropy_args={},
allow_empty=True, vertices=None, block_list=None,
verbose=False):
def multicanonical_sweep(self, m_state, c=numpy.inf, niter=1,
entropy_args={}, allow_empty=True, vertices=None,
block_list=None, verbose=False):
r"""Perform ``niter`` sweeps of a non-Markovian multicanonical sampling using
the Wang-Landau algorithm.
......@@ -992,7 +992,7 @@ class BlockState(object):
m_state : :class:`~graph_tool.inference.MulticanonicalState`
:class:`~graph_tool.inference.MulticanonicalState` instance
containing the current state of the Wang-Landau run.
c : ``float`` (optional, default: ``1.``)
c : ``float`` (optional, default: ``numpy.inf``)
Sampling parameter ``c`` for move proposals: For :math:`c\to 0` the
blocks are sampled according to the local neighbourhood of a given
node and their block connections; for :math:`c\to\infty` the blocks
......
......@@ -470,7 +470,8 @@ class MulticanonicalState(object):
if h.sum() == 0:
return 0
if allow_gaps:
h = array(h[h>0], dtype="float")
h_all = h + self._perm_hist
h = array(h[h_all>0], dtype="float")
else:
Ss = self.get_range()
S_min, S_max = self.get_allowed_energies()
......@@ -502,7 +503,7 @@ class MulticanonicalState(object):
self._hist.a = 0
def multicanonical_equilibrate(state, m_state, f_range=(1., 1e-6),
f_refine=1e-5, r=2, flatness=.99, use_ent=True,
f_refine=1e-5, r=2, flatness=.95, use_ent=False,
allow_gaps=False, callback=None,
multicanonical_args={}, verbose=False):
r"""Equilibrate a multicanonical Monte Carlo sampling using the Wang-Landau
......@@ -525,7 +526,7 @@ def multicanonical_equilibrate(state, m_state, f_range=(1., 1e-6),
be reduced by a factor ``r``.
flatness : ``float`` (optional, default: ``.99``)
Sufficient histogram flatness threshold used to continue the algorithm.
use_ent : ``bool`` (optional, default: ``True``)
use_ent : ``bool`` (optional, default: ``False``)
If ``True``, the histogram entropy will be used to determine flatness,
otherwise the smallest and largest counts relative to the mean will be
used.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment