template<class GM, class ACC> 00250 InferenceTermination 00251 Inference<GM, ACC>::modeFromFactorMarginal( 00252 std::vector<LabelType>& conf 00253 ) const 00254 { 00255 const GM& gm = graphicalModel(); 00256 std::vector<IndexType> knownVariables; 00257 std::vector<LabelType> knownStates; 00258 IndependentFactorType out; 00259 for(size_t node=0; node<gm.numberOfVariables(); ++node) { 00260 InferenceTermination term = marginal(node, out); 00261 if(NORMAL != term) { 00262 return term; 00263 } 00264 ValueType value = out(0); 00265 size_t state = 0; 00266 bool unique = true; 00267 for(size_t i=1; i<gm.numberOfLabels(node); ++i) { 00268 00269 //ValueType q = out(i)/value; 00270 //if(q<1.001 && q>0.999) { 00271 // unique=false; 00272 //} 00273 if(fabs(out(i) - value)<0.00001) { 00274 unique=false; 00275 } 00276 else if(ACC::bop(out(i), value)) { 00277 value = out(i); 00278 state = i; 00279 unique=true; 00280 } 00281 } 00282 if(unique) { 00283 knownVariables.push_back(node); 00284 knownStates.push_back(state); 00285 } 00286 } 00287 return constrainedOptimum( knownVariables, knownStates, conf); 00288 }
The probability of variable
最新推荐文章于 2019-04-03 15:38:49 发布