/// Computes the joint marginal probability of the subset of variables `vars`
Computes the joint marginal probability of the subset of variables `vars`
Computes the joint marginal probability of the subset of variables ` vars `
pub fn joint_marginal(&mut self, st: &SymbolTable, vars: &[BnVar]) -> HashMap<Assignment, f64> {
        // iterate over assignments, create indicator for that assignment,
        // conjoin it to the bdd and do a weighted model count
        let mut r : HashMap<Assignment, f64> = HashMap::new();
        let mut weights = self.weights.clone();
        // insert all the weights from the symbol table
        for (bnlbl, highw) in st.symbol_map.iter() {
            // translate bnlbl into
            let bddlbl = self.symbolic_map[bnlbl];
            weights.insert(bddlbl, (1.0 - highw, *highw));
        }
        // do the weighted model counts
        for assgn in AssignmentIter::new(self.shape.clone(), vars.to_vec()) {
            let mut cur_bdd = self.bdd;
            assgn.iter().enumerate().for_each(|(var_idx, value)| {
                let indic = self.indicators[&(var_idx, *value)];
                let v = self.manager.var(indic, true);
                cur_bdd = self.manager.and(cur_bdd, v);
            });
            let wmc_param = BddWmc::new_with_default(0.0, 1.0, weights.clone());
            let wmc = self.manager.wmc(cur_bdd, &wmc_param);
            r.insert(assgn, wmc);
        }
        return r;
    }
pub fn joint_marginal ( & mut self , st : & SymbolTable , vars : & [ BnVar ] ) -> HashMap < Assignment , f64 > { // iterate over assignments, create indicator for that assignment, // conjoin it to the bdd and do a weighted model count let mut r : HashMap < Assignment , f64 > = HashMap :: new ( ) ; let mut weights = self . weights . clone ( ) ; // insert all the weights from the symbol table for ( bnlbl , highw ) in st . symbol_map . iter ( ) { // translate bnlbl into let bddlbl = self . symbolic_map [ bnlbl ] ; weights . insert ( bddlbl , ( 1.0 - highw , * highw ) ) ; } // do the weighted model counts for assgn in AssignmentIter :: new ( self . shape . clone ( ) , vars . to_vec ( ) ) { let mut cur_bdd = self . bdd ; assgn . iter ( ) . enumerate ( ) . for_each ( | ( var_idx , value ) | { let indic = self . indicators [ & ( var_idx , * value ) ] ; let v = self . manager . var ( indic , true ) ; cur_bdd = self . manager . and ( cur_bdd , v ) ; } ) ; let wmc_param = BddWmc :: new_with_default ( 0.0 , 1.0 , weights . clone ( ) ) ; let wmc = self . manager . wmc ( cur_bdd , & wmc_param ) ; r . insert ( assgn , wmc ) ; } return r ; }
Computes the joint marginal probability of the subset of variables `vars`
Computes the joint marginal probability of the subset of variables ` vars `
&mut self
st
&SymbolTable
vars
&[BnVar]