Commit 2da36167 authored by Tiago Peixoto's avatar Tiago Peixoto

gibbs_sweep(): fix detailed balance

parent 70f6e1bd
......@@ -39,7 +39,6 @@ using namespace std;
((vlist,&, std::vector<size_t>&, 0)) \
((beta,, double, 0)) \
((entropy_args,, entropy_args_t, 0)) \
((allow_vacate,, bool, 0)) \
((allow_new_group,, bool, 0)) \
((sequential,, bool, 0)) \
((deterministic,, bool, 0)) \
......@@ -97,10 +96,13 @@ struct Gibbs
double virtual_move_dS(size_t v, size_t nr, rng_t& rng)
{
size_t r = _state._b[v];
if (!_allow_new_group && nr != r && _state.virtual_remove_size(v) == 0)
return numeric_limits<double>::infinity();
if (nr == null_group)
{
if (!_allow_new_group ||
_state._candidate_blocks.size() - 1 == num_vertices(_state._g))
_state._candidate_blocks.size() - 1 == num_vertices(_state._g) ||
_state.virtual_remove_size(v) == 0)
return numeric_limits<double>::infinity();
_state.get_empty_block(v);
_nr = nr = uniform_sample(_state._empty_blocks, rng);
......
......@@ -1614,7 +1614,7 @@ class BlockState(object):
[s._state for s in states],
_get_rng())
def gibbs_sweep(self, beta=1., niter=1, entropy_args={}, allow_vacate=True,
def gibbs_sweep(self, beta=1., niter=1, entropy_args={},
allow_new_group=True, sequential=True, deterministic=False,
vertices=None, verbose=False, **kwargs):
r"""Perform ``niter`` sweeps of a rejection-free Gibbs sampling MCMC
......@@ -1630,10 +1630,8 @@ class BlockState(object):
entropy_args : ``dict`` (optional, default: ``{}``)
Entropy arguments, with the same meaning and defaults as in
:meth:`graph_tool.inference.blockmodel.BlockState.entropy`.
allow_vacate : ``bool`` (optional, default: ``True``)
Allow groups to be vacated.
allow_new_group : ``bool`` (optional, default: ``True``)
Allow the number of groups to increase.
Allow the number of groups to increase and decrease.
sequential : ``bool`` (optional, default: ``True``)
If ``sequential == True`` each vertex move attempt is made
sequentially, where vertices are visited in random order. Otherwise
......
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