private DoubleFactor createQueryFactor(Query query){
  List<DoubleFactor> factors=new LinkedList<DoubleFactor>();
  Collection<String> queryVars=query.getQueryVars();
  Assignment evidence=query.getEvidence();
  for (  BNode n : query.getFilteredSortedNodes()) {
    DoubleFactor basicFactor=makeFactor(n,evidence);
    if (!basicFactor.isEmpty()) {
      factors.add(basicFactor);
      if (!queryVars.contains(n.getId())) {
        factors=sumOut(n.getId(),factors);
      }
    }
  }
  DoubleFactor finalProduct=pointwiseProduct(factors);
  finalProduct=addEvidencePairs(finalProduct,query);
  finalProduct.trim(queryVars);
  return finalProduct;
}

private DoubleFactor createQueryFactor ( Query query ) { List < DoubleFactor > factors = new LinkedList < DoubleFactor > ( ) ; Collection < String > queryVars = query . getQueryVars ( ) ; Assignment evidence = query . getEvidence ( ) ; for ( BNode n : query . getFilteredSortedNodes ( ) ) { DoubleFactor basicFactor = makeFactor ( n , evidence ) ; if ( ! basicFactor . isEmpty ( ) ) { factors . add ( basicFactor ) ; if ( ! queryVars . contains ( n . getId ( ) ) ) { factors = sumOut ( n . getId ( ) , factors ) ; } } } DoubleFactor finalProduct = pointwiseProduct ( factors ) ; finalProduct = addEvidencePairs ( finalProduct , query ) ; finalProduct . trim ( queryVars ) ; return finalProduct ; }
generates the full double factor associated with the query variables , using the variable - elimination algorithm .
