}
public void testEarlyStopping ()
{
FactorGraph grid = RandomGraphs.randomAttractiveGrid (5, 0.5, new Random (2413421));
TRP trp = new TRP (new TRP.IterationTerminator (1));
trp.setRandomSeed (14312341);
trp.computeMarginals (grid);
boolean oneIsDifferent = false;
// check no exceptions thrown when asking for all marginals,
// and check that at least one factors' belief has changed
// from the choice at zero iterations.
for (Iterator it = grid.factorsIterator (); it.hasNext();) {
Factor f = (Factor) it.next ();
Factor marg = trp.lookupMarginal (f.varSet ());// test no exception thrown
if (!marg.almostEquals (f.duplicate ().normalize ())) {
oneIsDifferent = true;
}
}