[pyAgrum] still hybrid inference to test

parent 82f88b04
......@@ -70,7 +70,9 @@ namespace gum {
}
for (auto nod : this->samplingBN().topologicalOrder()) {
this->_addVarSample(nod, &prev);
if (!this->hasHardEvidence(nod)) {
this->_addVarSample(nod, &prev);
}
auto probaP = this->BN().cpt(nod).get(prev);
auto probaQ = this->samplingBN().cpt(nod).get(prev);
if ((probaP == 0) || (probaQ == 0)) {
......@@ -119,11 +121,6 @@ namespace gum {
// bn->uninstallNode( sid[i] );
}
GUM_CHECKPOINT;
for (auto targ : this->targets()) {
if (this->BN().dag().exists(targ)) this->addTarget(targ);
}
GUM_CHECKPOINT;
auto minParam = bn->minNonZeroParam();
auto minAccepted = this->epsilon() / bn->maxVarDomainSize();
......
......@@ -29,7 +29,12 @@ bool __compareInference(const gum::BayesNet< GUM_SCALAR >& bn,
} catch (gum::FatalError) {
// 0 in a proba
e = std::numeric_limits< GUM_SCALAR >::infinity();
try {
// we cannot use KL, we use quadratic error
e = (inf.posterior(node) - lazy.posterior(node)).sq().sum();
} catch (gum::FatalError) {
e = std::numeric_limits< GUM_SCALAR >::infinity();
}
}
......@@ -45,7 +50,10 @@ bool __compareInference(const gum::BayesNet< GUM_SCALAR >& bn,
argstr += " inf : " + inf.posterior(node).toString() + " \n";
}
}
if (err > errmax) GUM_TRACE(argstr)
if (err > errmax) {
GUM_TRACE(argstr);
GUM_TRACE(inf.messageApproximationScheme());
}
return err <= errmax;
}
......
......@@ -349,17 +349,13 @@ namespace gum_tests {
try {
gum::ImportanceSampling< float > inf(&bn);
GUM_CHECKPOINT;
inf.addEvidence(bn.idFromName("d"), 0);
TS_ASSERT_THROWS(inf.addEvidence("i", std::vector< float >{1, 0, 1}),
gum::FatalError);
GUM_TRACE_VAR(inf.evidence());
inf.setVerbosity(false);
inf.setEpsilon(EPSILON_FOR_IMPORTANCE);
GUM_TRACE_VAR(inf.evidence());
inf.makeInference();
GUM_CHECKPOINT;
TS_GUM_ASSERT_THROWS_NOTHING(inf.posterior("d"));
TS_GUM_ASSERT_THROWS_NOTHING(inf.posterior(bn.idFromName("d")));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment