void SharedParameters::collectSufficientStatistics( InfAlg &alg ) {
    for( std::map< FactorIndex, Permute >::iterator i = _perms.begin(); i != _perms.end(); ++i ) {
        Permute &perm = i->second;
        VarSet &vs = _varsets[i->first];

        Factor b = alg.belief(vs);
        Prob p( b.states(), 0.0 );
        for( size_t entry = 0; entry < b.states(); ++entry )
            p[entry] = b[perm.convertLinearIndex(entry)]; // apply inverse permutation
        _estimation->addSufficientStatistics( p );
    }
}
Esempio n. 2
0
void SharedParameters::collectExpectations( InfAlg &alg ) {
    for( std::map< FactorIndex, Permute >::iterator i = _perms.begin(); i != _perms.end(); ++i ) {
        Permute &perm = i->second;
        VarSet &vs = _varsets[i->first];

        Factor b = alg.belief(vs);
        Prob p( b.nrStates(), 0.0 );
        for( size_t entry = 0; entry < b.nrStates(); ++entry )
            p.set( entry, b[perm.convertLinearIndex(entry)] ); // apply inverse permutation
        (*_expectations) += p;
    }
}
Esempio n. 3
0
 vector<Factor> allBeliefs() {
     vector<Factor> result;
     for( size_t i = 0; i < obj->fg().nrVars(); i++ )
         result.push_back( obj->belief( obj->fg().var(i) ) );
     return result;
 }