/** * Create a model with the variables given. This is much faster * than adding the variables one at a time. */ public FactorGraph (Variable[] vars) { this(); setCachesCapacity (vars.length); for (int i = 0; i < vars.length; i++) { cacheVariable (vars [i]); } }
/** * Create a model with the variables given. This is much faster * than adding the variables one at a time. */ public FactorGraph (Variable[] vars) { this(); setCachesCapacity (vars.length); for (int i = 0; i < vars.length; i++) { cacheVariable (vars [i]); } }
/** * Create a model with the variables given. This is much faster * than adding the variables one at a time. */ public FactorGraph (Variable[] vars) { this(); setCachesCapacity (vars.length); for (int i = 0; i < vars.length; i++) { cacheVariable (vars [i]); } }
/** * Returns a copy of this model. The variable objects are shared * between this model and its copy, but the factor objects are deep-copied. */ public Factor duplicate () { FactorGraph dup = new FactorGraph (numVariables ()); try { for (Iterator it = variablesSet ().iterator(); it.hasNext();) { Variable var = (Variable) it.next(); dup.cacheVariable (var); } for (Iterator it = factorsIterator (); it.hasNext();) { Factor pot = (Factor) it.next(); dup.addFactor (pot.duplicate ()); } } catch (Exception e) { e.printStackTrace (); } return dup; }
/** * Returns a copy of this model. The variable objects are shared * between this model and its copy, but the factor objects are deep-copied. */ public Factor duplicate () { FactorGraph dup = new FactorGraph (numVariables ()); try { for (Iterator it = variablesSet ().iterator(); it.hasNext();) { Variable var = (Variable) it.next(); dup.cacheVariable (var); } for (Iterator it = factorsIterator (); it.hasNext();) { Factor pot = (Factor) it.next(); dup.addFactor (pot.duplicate ()); } } catch (Exception e) { e.printStackTrace (); } return dup; }
/** * Returns a copy of this model. The variable objects are shared * between this model and its copy, but the factor objects are deep-copied. */ public Factor duplicate () { FactorGraph dup = new FactorGraph (numVariables ()); try { for (Iterator it = variablesSet ().iterator(); it.hasNext();) { Variable var = (Variable) it.next(); dup.cacheVariable (var); } for (Iterator it = factorsIterator (); it.hasNext();) { Factor pot = (Factor) it.next(); dup.addFactor (pot.duplicate ()); } } catch (Exception e) { e.printStackTrace (); } return dup; }
private void addVarsIfNecessary (VarSet varSet) { for (int i = 0; i < varSet.size(); i++) { Variable var = varSet.get (i); if (universe == null) { universe = var.getUniverse (); } if (getIndex (var) < 0) { cacheVariable (var); } } }
private void addVarsIfNecessary (VarSet varSet) { for (int i = 0; i < varSet.size(); i++) { Variable var = varSet.get (i); if (universe == null) { universe = var.getUniverse (); } if (getIndex (var) < 0) { cacheVariable (var); } } }
private void addVarsIfNecessary (VarSet varSet) { for (int i = 0; i < varSet.size(); i++) { Variable var = varSet.get (i); if (universe == null) { universe = var.getUniverse (); } if (getIndex (var) < 0) { cacheVariable (var); } } }