Use of empty groups plus clabels breaks move proposals
So, here's another example involving zero weighted vertices / empty groups, now with clabels, that goes into infinite looping despite the recent patch:
import graph_tool.all as gt
verbose = True
g = gt.collection.data["karate"]
vweight = g.new_vertex_property('int',
vals=[(0 if int(v)==0 else 1)
for v in g.vertices()] )
s = gt.minimize_blockmodel_dl( g, verbose=verbose,
state_args={'vweight':vweight,
'pclabel':vweight} )
What is happening here, again during mcmc_multilevel
:
- in
state.shrink()
we haveMergeBlockState::move_proposal
checking for_state.allow_move(r, s, allow_empty=false)
, which is fine - in
mcmc_equilibrate()
we haveMCMCBlockState::move_proposal
checking for_state.allow_move(r, s, allow_empty=true)
, which leads to states that violateclabel
because of the zero weighted vertices
I've patched graph_blockmodel_mcmc.hh
to use _state.allow_move(r, s, false)
and it fixes the infinite loop in the example, returning normally.
However, I notice that throughout the varied allow_move
s and their different uses, MergeBlockState::move_proposal
is the only place where currently allow_empty=false
. So I'm not sure if this is the right thing to do, even though it fixes the example and is coherent with what is tested in _check_clabel()
, where clabel is honoured for zero weighted vertices as well.
So perhaps the question is whether the default in allow_move
s should be changed to allow_empty=false
, which as I understand translates to: do we honour clabels for zero weighted vertices? As far as I understand I would tend towards honouring, but there may be other arguments.
Ni!