+* [Frederik Eaton] Added Gibbs::state() accessors/mutators
+* [Frederik Eaton] Fixed Gibbs::getVarDist(size_t) to return uniform
+ distribution if no state is allowed
* [Frederik Eaton] Improved parsing code in tests/testdai to allow recursive
alias substitutions
* Interface changes:
//@}
- /// @name Additional interface specific for BP
+ /// @name Additional interface specific for Gibbs
//@{
Factor beliefV( size_t i ) const;
Factor beliefF( size_t I ) const;
void randomizeState();
//@}
+ /// Return reference to current state vector
+ std::vector<size_t>& state() { return _state; }
+
+ /// Return const reference to current state vector
+ const std::vector<size_t>& state() const { return _state; }
+
private:
void updateCounts();
Prob getVarDist( size_t i );
size_t i_states = var(i).states();
Prob i_given_MB( i_states, 1.0 );
- // use markov blanket of var(i) to calculate distribution
+ // use Markov blanket of var(i) to calculate distribution
foreach( const Neighbor &I, nbV(i) ) {
const Factor &f_I = factor(I);
size_t I_skip = getFactorEntryDiff( I, i );
}
}
- return i_given_MB.normalized();
+ if( i_given_MB.sum() == 0.0 )
+ // If no state of i is allowed, use uniform distribution
+ // FIXME is that indeed the right thing to do?
+ i_given_MB = Prob( i_states );
+ else
+ i_given_MB.normalize();
+ return i_given_MB;
}