Commit 9f8d92c5 authored by Pierre-Henri Wuillemin's avatar Pierre-Henri Wuillemin

refreshing bug/ambiguousIdOrString_in_pyAgrum

parents f2f11ed8 90988d4d
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
* @brief Implementation of the BayesBall class. * @brief Implementation of the BayesBall class.
*/ */
#include <agrum/BN/inference/BayesBall.h> #include <agrum/BN/algorithms/BayesBall.h>
#ifdef GUM_NO_INLINE #ifdef GUM_NO_INLINE
#include <agrum/BN/inference/BayesBall_inl.h> #include <agrum/BN/algorithms/BayesBall_inl.h>
#endif // GUM_NO_INLINE #endif // GUM_NO_INLINE
namespace gum { namespace gum {
......
...@@ -92,9 +92,9 @@ namespace gum { ...@@ -92,9 +92,9 @@ namespace gum {
} /* namespace gum */ } /* namespace gum */
#ifndef GUM_NO_INLINE #ifndef GUM_NO_INLINE
#include <agrum/BN/inference/BayesBall_inl.h> #include <agrum/BN/algorithms/BayesBall_inl.h>
#endif // GUM_NO_INLINE #endif // GUM_NO_INLINE
#include <agrum/BN/inference/BayesBall_tpl.h> #include <agrum/BN/algorithms/BayesBall_tpl.h>
#endif /* GUM_BAYESBALLS_H */ #endif /* GUM_BAYESBALLS_H */
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
*/ */
// to ease IDE parser // to ease IDE parser
#include <agrum/BN/inference/BayesBall.h> #include <agrum/BN/algorithms/BayesBall.h>
namespace gum { namespace gum {
......
...@@ -23,12 +23,12 @@ ...@@ -23,12 +23,12 @@
*/ */
#include <limits> #include <limits>
#include <agrum/BN/inference/barrenNodesFinder.h> #include <agrum/BN/algorithms/barrenNodesFinder.h>
#include <agrum/core/list.h> #include <agrum/core/list.h>
#include <agrum/core/sequence.h> #include <agrum/core/sequence.h>
#ifdef GUM_NO_INLINE #ifdef GUM_NO_INLINE
#include <agrum/BN/inference/barrenNodesFinder_inl.h> #include <agrum/BN/algorithms/barrenNodesFinder_inl.h>
#endif // GUM_NO_INLINE #endif // GUM_NO_INLINE
namespace gum { namespace gum {
......
...@@ -121,11 +121,11 @@ namespace gum { ...@@ -121,11 +121,11 @@ namespace gum {
#ifndef GUM_NO_INLINE #ifndef GUM_NO_INLINE
#include <agrum/BN/inference/barrenNodesFinder_inl.h> #include <agrum/BN/algorithms/barrenNodesFinder_inl.h>
#endif // GUM_NO_INLINE #endif // GUM_NO_INLINE
#include <agrum/BN/inference/barrenNodesFinder_tpl.h> #include <agrum/BN/algorithms/barrenNodesFinder_tpl.h>
#endif /* GUM_BARREN_NODES_FINDER_H */ #endif /* GUM_BARREN_NODES_FINDER_H */
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
* @author Christophe GONZALES and Pierre-Henri WUILLEMIN * @author Christophe GONZALES and Pierre-Henri WUILLEMIN
*/ */
#include <agrum/BN/inference/dSeparation.h> #include <agrum/BN/algorithms/dSeparation.h>
#include <agrum/core/list.h> #include <agrum/core/list.h>
#ifdef GUM_NO_INLINE #ifdef GUM_NO_INLINE
#include <agrum/BN/inference/dSeparation_inl.h> #include <agrum/BN/algorithms/dSeparation_inl.h>
#endif // GUM_NO_INLINE #endif // GUM_NO_INLINE
namespace gum { namespace gum {
......
...@@ -108,10 +108,10 @@ namespace gum { ...@@ -108,10 +108,10 @@ namespace gum {
#ifndef GUM_NO_INLINE #ifndef GUM_NO_INLINE
#include <agrum/BN/inference/dSeparation_inl.h> #include <agrum/BN/algorithms/dSeparation_inl.h>
#endif // GUM_NO_INLINE #endif // GUM_NO_INLINE
#include <agrum/BN/inference/dSeparation_tpl.h> #include <agrum/BN/algorithms/dSeparation_tpl.h>
#endif /* GUM_D_SEPARATION_H */ #endif /* GUM_D_SEPARATION_H */
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <cmath> #include <cmath>
#include <utility> #include <utility>
#include <agrum/BN/inference/barrenNodesFinder.h> #include <agrum/BN/algorithms/barrenNodesFinder.h>
#include <agrum/BN/inference/evidenceInference.h> #include <agrum/BN/inference/evidenceInference.h>
#include <agrum/BN/inference/jointTargetedInference.h> #include <agrum/BN/inference/jointTargetedInference.h>
#include <agrum/config.h> #include <agrum/config.h>
......
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
#ifndef DOXYGEN_SHOULD_SKIP_THIS #ifndef DOXYGEN_SHOULD_SKIP_THIS
#include <agrum/BN/inference/ShaferShenoyInference.h> #include <agrum/BN/inference/ShaferShenoyInference.h>
#include <agrum/BN/inference/BayesBall.h> #include <agrum/BN/algorithms/BayesBall.h>
#include <agrum/BN/inference/barrenNodesFinder.h> #include <agrum/BN/algorithms/barrenNodesFinder.h>
#include <agrum/BN/inference/dSeparation.h> #include <agrum/BN/algorithms/dSeparation.h>
#include <agrum/graphs/algorithms/binaryJoinTreeConverterDefault.h> #include <agrum/graphs/algorithms/binaryJoinTreeConverterDefault.h>
#include <agrum/multidim/instantiation.h> #include <agrum/multidim/instantiation.h>
#include <agrum/multidim/operators/multiDimCombineAndProjectDefault.h> #include <agrum/multidim/operators/multiDimCombineAndProjectDefault.h>
...@@ -346,7 +346,7 @@ namespace gum { ...@@ -346,7 +346,7 @@ namespace gum {
// however, note that the nodes that received hard evidence do not belong to // however, note that the nodes that received hard evidence do not belong to
// the graph and, therefore, should not be taken into account // the graph and, therefore, should not be taken into account
const auto& hard_ev_nodes = this->hardEvidenceNodes(); const auto& hard_ev_nodes = this->hardEvidenceNodes();
for ( const auto node : this->targets() ) { for ( const auto node : this->allTargets() ) {
if ( !__graph.exists( node ) && !hard_ev_nodes.exists( node ) ) return true; if ( !__graph.exists( node ) && !hard_ev_nodes.exists( node ) ) return true;
} }
for ( const auto& nodes : this->jointTargets() ) { for ( const auto& nodes : this->jointTargets() ) {
...@@ -412,7 +412,7 @@ namespace gum { ...@@ -412,7 +412,7 @@ namespace gum {
// the BN without altering the inference output // the BN without altering the inference output
if ( __barren_nodes_type == FindBarrenNodesType::FIND_BARREN_NODES ) { if ( __barren_nodes_type == FindBarrenNodesType::FIND_BARREN_NODES ) {
// identify the barren nodes // identify the barren nodes
NodeSet target_nodes = this->targets(); NodeSet target_nodes = this->allTargets();
for ( const auto& nodeset : this->jointTargets() ) { for ( const auto& nodeset : this->jointTargets() ) {
target_nodes += nodeset; target_nodes += nodeset;
} }
...@@ -999,7 +999,7 @@ namespace gum { ...@@ -999,7 +999,7 @@ namespace gum {
void ShaferShenoyInference<GUM_SCALAR>::__computeJoinTreeRoots() { void ShaferShenoyInference<GUM_SCALAR>::__computeJoinTreeRoots() {
// get the set of cliques in which we can find the targets and joint_targets // get the set of cliques in which we can find the targets and joint_targets
NodeSet clique_targets; NodeSet clique_targets;
for ( const auto node : this->targets() ) { for ( const auto node : this->allTargets() ) {
try { try {
clique_targets.insert( __node_to_clique[node] ); clique_targets.insert( __node_to_clique[node] );
} catch ( Exception& ) { } catch ( Exception& ) {
...@@ -1288,7 +1288,7 @@ namespace gum { ...@@ -1288,7 +1288,7 @@ namespace gum {
template <typename GUM_SCALAR> template <typename GUM_SCALAR>
INLINE void ShaferShenoyInference<GUM_SCALAR>::_makeInference() { INLINE void ShaferShenoyInference<GUM_SCALAR>::_makeInference() {
// collect messages for all single targets // collect messages for all single targets
for ( const auto node : this->targets() ) { for ( const auto node : this->allTargets() ) {
// perform only collects in the join tree for nodes that have // perform only collects in the join tree for nodes that have
// not received hard evidence (those that received hard evidence were // not received hard evidence (those that received hard evidence were
// not included into the join tree for speed-up reasons) // not included into the join tree for speed-up reasons)
......
...@@ -237,7 +237,7 @@ namespace gum { ...@@ -237,7 +237,7 @@ namespace gum {
template <typename GUM_SCALAR> template <typename GUM_SCALAR>
const Potential<GUM_SCALAR>& const Potential<GUM_SCALAR>&
JointTargetedInference<GUM_SCALAR>::posterior( const NodeId node ) { JointTargetedInference<GUM_SCALAR>::posterior( const NodeId node ) {
if ( this->targets().contains( node ) ) if ( this->isTarget( node ) )
return MarginalTargetedInference<GUM_SCALAR>::posterior( node ); return MarginalTargetedInference<GUM_SCALAR>::posterior( node );
else else
return jointPosterior( NodeSet{node} ); return jointPosterior( NodeSet{node} );
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <cmath> #include <cmath>
#include <utility> #include <utility>
#include <agrum/BN/inference/barrenNodesFinder.h> #include <agrum/BN/algorithms/barrenNodesFinder.h>
#include <agrum/BN/inference/evidenceInference.h> #include <agrum/BN/inference/evidenceInference.h>
#include <agrum/BN/inference/jointTargetedInference.h> #include <agrum/BN/inference/jointTargetedInference.h>
#include <agrum/BN/inference/relevantPotentialsFinderType.h> #include <agrum/BN/inference/relevantPotentialsFinderType.h>
......
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
#ifndef DOXYGEN_SHOULD_SKIP_THIS #ifndef DOXYGEN_SHOULD_SKIP_THIS
#include <algorithm> #include <algorithm>
#include <agrum/BN/inference/BayesBall.h> #include <agrum/BN/algorithms/BayesBall.h>
#include <agrum/BN/inference/barrenNodesFinder.h> #include <agrum/BN/algorithms/barrenNodesFinder.h>
#include <agrum/BN/inference/dSeparation.h> #include <agrum/BN/algorithms/dSeparation.h>
#include <agrum/graphs/algorithms/binaryJoinTreeConverterDefault.h> #include <agrum/graphs/algorithms/binaryJoinTreeConverterDefault.h>
#include <agrum/multidim/instantiation.h> #include <agrum/multidim/instantiation.h>
#include <agrum/multidim/operators/multiDimCombineAndProjectDefault.h> #include <agrum/multidim/operators/multiDimCombineAndProjectDefault.h>
...@@ -385,7 +385,7 @@ namespace gum { ...@@ -385,7 +385,7 @@ namespace gum {
// however, note that the nodes that received hard evidence do not belong to // however, note that the nodes that received hard evidence do not belong to
// the graph and, therefore, should not be taken into account // the graph and, therefore, should not be taken into account
const auto& hard_ev_nodes = this->hardEvidenceNodes(); const auto& hard_ev_nodes = this->hardEvidenceNodes();
for ( const auto node : this->targets() ) { for ( const auto node : this->allTargets() ) {
if ( !__graph.exists( node ) && !hard_ev_nodes.exists( node ) ) return true; if ( !__graph.exists( node ) && !hard_ev_nodes.exists( node ) ) return true;
} }
for ( const auto& nodes : this->jointTargets() ) { for ( const auto& nodes : this->jointTargets() ) {
...@@ -452,7 +452,7 @@ namespace gum { ...@@ -452,7 +452,7 @@ namespace gum {
// altering the inference output // altering the inference output
if ( __barren_nodes_type == FindBarrenNodesType::FIND_BARREN_NODES ) { if ( __barren_nodes_type == FindBarrenNodesType::FIND_BARREN_NODES ) {
// identify the barren nodes // identify the barren nodes
NodeSet target_nodes = this->targets(); NodeSet target_nodes = this->allTargets();
for ( const auto& nodeset : this->jointTargets() ) { for ( const auto& nodeset : this->jointTargets() ) {
target_nodes += nodeset; target_nodes += nodeset;
} }
...@@ -968,7 +968,7 @@ namespace gum { ...@@ -968,7 +968,7 @@ namespace gum {
void LazyPropagation<GUM_SCALAR>::__computeJoinTreeRoots() { void LazyPropagation<GUM_SCALAR>::__computeJoinTreeRoots() {
// get the set of cliques in which we can find the targets and joint_targets // get the set of cliques in which we can find the targets and joint_targets
NodeSet clique_targets; NodeSet clique_targets;
for ( const auto node : this->targets() ) { for ( const auto node : this->allTargets() ) {
try { try {
clique_targets.insert( __node_to_clique[node] ); clique_targets.insert( __node_to_clique[node] );
} catch ( Exception& ) { } catch ( Exception& ) {
...@@ -1347,7 +1347,7 @@ namespace gum { ...@@ -1347,7 +1347,7 @@ namespace gum {
template <typename GUM_SCALAR> template <typename GUM_SCALAR>
INLINE void LazyPropagation<GUM_SCALAR>::_makeInference() { INLINE void LazyPropagation<GUM_SCALAR>::_makeInference() {
// collect messages for all single targets // collect messages for all single targets
for ( const auto node : this->targets() ) { for ( const auto node : this->allTargets() ) {
// perform only collects in the join tree for nodes that have // perform only collects in the join tree for nodes that have
// not received hard evidence (those that received hard evidence were // not received hard evidence (those that received hard evidence were
// not included into the join tree for speed-up reasons) // not included into the join tree for speed-up reasons)
......
...@@ -50,19 +50,21 @@ namespace gum { ...@@ -50,19 +50,21 @@ namespace gum {
* the current state of the inference. Note that the MarginalTargetedInference * the current state of the inference. Note that the MarginalTargetedInference
* is designed to be used in incremental inference engines. * is designed to be used in incremental inference engines.
*/ */
template<typename GUM_SCALAR> template <typename GUM_SCALAR>
class MarginalTargetedInference : public virtual BayesNetInference<GUM_SCALAR> { class MarginalTargetedInference : public virtual BayesNetInference<GUM_SCALAR> {
public: public:
// ############################################################################ // ############################################################################
/// @name Constructors / Destructors /// @name Constructors / Destructors
// ############################################################################ // ############################################################################
/// @{ /// @{
/// default constructor /// default constructor
/** @warning By default, all the nodes of the Bayes net are targets. /** @warning By default (when the targets set is empty), all the nodes of
* the Bayes net are considered as targets. Once a first target is added to the
* set, the remaining nodes are not considered as default targets anymore.
* @warning note that, by aGrUM's rule, the BN is not copied but only * @warning note that, by aGrUM's rule, the BN is not copied but only
* referenced by the inference algorithm. */ * referenced by the inference algorithm. */
MarginalTargetedInference(const IBayesNet<GUM_SCALAR> *bn); MarginalTargetedInference( const IBayesNet<GUM_SCALAR>* bn );
/// destructor /// destructor
virtual ~MarginalTargetedInference(); virtual ~MarginalTargetedInference();
...@@ -90,7 +92,7 @@ namespace gum { ...@@ -90,7 +92,7 @@ namespace gum {
* *
* @throw UndefinedElement if node is not in the set of targets * @throw UndefinedElement if node is not in the set of targets
*/ */
virtual const Potential<GUM_SCALAR> &posterior(const NodeId node); virtual const Potential<GUM_SCALAR>& posterior( const NodeId node );
/// Computes and returns the posterior of a node. /// Computes and returns the posterior of a node.
/** /**
...@@ -108,7 +110,7 @@ namespace gum { ...@@ -108,7 +110,7 @@ namespace gum {
* *
* @throw UndefinedElement if node is not in the set of targets * @throw UndefinedElement if node is not in the set of targets
*/ */
virtual const Potential<GUM_SCALAR> &posterior(const std::string &nodeName); virtual const Potential<GUM_SCALAR>& posterior( const std::string& nodeName );
/// @} /// @}
...@@ -119,44 +121,62 @@ namespace gum { ...@@ -119,44 +121,62 @@ namespace gum {
/// @{ /// @{
/// Clear all previously defined targets /// Clear all previously defined targets
/// @warning this means that every node is now a target by default
virtual void eraseAllTargets(); virtual void eraseAllTargets();
/// adds all nodes as targets /// adds all nodes as targets
/// @warning due to the semantic of targets, this function is an alias of
/// eraseAllTargets()
virtual void addAllTargets() final; virtual void addAllTargets() final;
/// Add a marginal target to the list of targets /// Add a marginal target to the list of targets
/** /**
* @throw UndefinedElement if target is not a NodeId in the Bayes net * @throw UndefinedElement if target is not a NodeId in the Bayes net
*/ */
virtual void addTarget(const NodeId target) final; virtual void addTarget( const NodeId target ) final;
/// Add a marginal target to the list of targets /// Add a marginal target to the list of targets
/** /**
* @throw UndefinedElement if target is not a NodeId in the Bayes net * @throw UndefinedElement if target is not a NodeId in the Bayes net
*/ */
virtual void addTarget(const std::string &nodeName) final; virtual void addTarget( const std::string& nodeName ) final;
/// removes an existing (marginal) target /// removes an existing (marginal) target
/** @warning If the target does not already exist, the method does nothing. /** @warning If the target does not already exist, the method does nothing.
* In particular, it does not raise any exception. */ * In particular, it does not raise any exception.
virtual void eraseTarget(const NodeId target) final; * @warning Erasing the last target implies that every node is now a target by
* default.
* */
virtual void eraseTarget( const NodeId target ) final;
/// removes an existing (marginal) target /// removes an existing (marginal) target
/** @warning If the target does not already exist, the method does nothing. /** @warning If the target does not already exist, the method does nothing.
* In particular, it does not raise any exception. */ * In particular, it does not raise any exception.
virtual void eraseTarget(const std::string &nodeName) final; * @warning Erasing the last target implies that every node is now a target by
* default.*/
virtual void eraseTarget( const std::string& nodeName ) final;
/// return true if variable is a (marginal) target /// return true if variable is a (marginal) target
virtual bool isTarget(const NodeId variable) const final; virtual bool isTarget( const NodeId variable ) const final;
/// return true if variable is a (marginal) target /// return true if variable is a (marginal) target
virtual bool isTarget(const std::string &nodeName) const final; virtual bool isTarget( const std::string& nodeName ) const final;
/// returns the number of marginal targets /// returns the number of marginal targets.
//// @warning if the result is 0, it means that all the nodes are targets by
/// default.
virtual const Size nbrTargets() const noexcept final; virtual const Size nbrTargets() const noexcept final;
/// returns the list of marginal targets /// returns the set of marginal targets
virtual const NodeSet &targets() const noexcept final; //// @warning if the set is empty, it means that all the nodes are targets by
/// default.
virtual const NodeSet& targets() const noexcept final;
/// return all the marginal targets.
/** Particularly, if the targetSet is empty, allTargets will send a copy of the
* nodeSet of the BN
*/
virtual NodeSet allTargets() const noexcept final;
/// @} /// @}
...@@ -169,13 +189,13 @@ namespace gum { ...@@ -169,13 +189,13 @@ namespace gum {
* Compute Shanon's entropy of a node given the observation * Compute Shanon's entropy of a node given the observation
* @see http://en.wikipedia.org/wiki/Information_entropy * @see http://en.wikipedia.org/wiki/Information_entropy
*/ */
virtual GUM_SCALAR H(const NodeId X) final; virtual GUM_SCALAR H( const NodeId X ) final;
/** Entropy /** Entropy
* Compute Shanon's entropy of a node given the observation * Compute Shanon's entropy of a node given the observation
* @see http://en.wikipedia.org/wiki/Information_entropy * @see http://en.wikipedia.org/wiki/Information_entropy
*/ */
virtual GUM_SCALAR H(const std::string &nodeName) final; virtual GUM_SCALAR H( const std::string& nodeName ) final;
///@} ///@}
...@@ -191,8 +211,8 @@ namespace gum { ...@@ -191,8 +211,8 @@ namespace gum {
* @param evs the vector of nodeId of the observed variables * @param evs the vector of nodeId of the observed variables
* @return a Potential * @return a Potential
*/ */
Potential<GUM_SCALAR> evidenceImpact(NodeId target, Potential<GUM_SCALAR> evidenceImpact( NodeId target,
const std::vector<NodeId>& evs); const std::vector<NodeId>& evs );
/** /**
* Create a gum::Potential for P(target|evs) (for all instanciation of target * Create a gum::Potential for P(target|evs) (for all instanciation of target
...@@ -204,17 +224,17 @@ namespace gum { ...@@ -204,17 +224,17 @@ namespace gum {
* @param evs the nodeId of the observed variable * @param evs the nodeId of the observed variable
* @return a Potential * @return a Potential
*/ */
Potential<GUM_SCALAR> evidenceImpact(const std::string& target, Potential<GUM_SCALAR> evidenceImpact( const std::string& target,
const std::vector<std::string>& evs); const std::vector<std::string>& evs );
protected: protected:
/// fired after a new marginal target is inserted /// fired after a new marginal target is inserted
/** @param id The target variable's id. */ /** @param id The target variable's id. */
virtual void _onMarginalTargetAdded(const NodeId id) = 0; virtual void _onMarginalTargetAdded( const NodeId id ) = 0;
/// fired before a marginal target is removed /// fired before a marginal target is removed
/** @param id The target variable's id. */ /** @param id The target variable's id. */
virtual void _onMarginalTargetErased(const NodeId id) = 0; virtual void _onMarginalTargetErased( const NodeId id ) = 0;
/// fired after all the nodes of the BN are added as marginal targets /// fired after all the nodes of the BN are added as marginal targets
virtual void _onAllMarginalTargetsAdded() = 0; virtual void _onAllMarginalTargetsAdded() = 0;
...@@ -223,16 +243,16 @@ namespace gum { ...@@ -223,16 +243,16 @@ namespace gum {
virtual void _onAllMarginalTargetsErased() = 0; virtual void _onAllMarginalTargetsErased() = 0;
/// fired after a new Bayes net has been assigned to the engine /// fired after a new Bayes net has been assigned to the engine
virtual void _onBayesNetChanged(const IBayesNet<GUM_SCALAR> *bn); virtual void _onBayesNetChanged( const IBayesNet<GUM_SCALAR>* bn );
/// asks derived classes for the posterior of a given variable /// asks derived classes for the posterior of a given variable
/** @param id The variable's id. */ /** @param id The variable's id. */
virtual const Potential<GUM_SCALAR> &_posterior(const NodeId id) = 0; virtual const Potential<GUM_SCALAR>& _posterior( const NodeId id ) = 0;
private: private:
/// the set of marginal targets /// the set of marginal targets
NodeSet __targets; NodeSet __targetsSet;
/// remove all the marginal posteriors computed /// remove all the marginal posteriors computed
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <cmath> #include <cmath>
#include <utility> #include <utility>
#include <agrum/BN/inference/barrenNodesFinder.h> #include <agrum/BN/algorithms/barrenNodesFinder.h>
#include <agrum/BN/inference/jointTargetedInference.h> #include <agrum/BN/inference/jointTargetedInference.h>
#include <agrum/BN/inference/relevantPotentialsFinderType.h> #include <agrum/BN/inference/relevantPotentialsFinderType.h>
#include <agrum/config.h> #include <agrum/config.h>
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
#include <agrum/BN/inference/variableElimination.h> #include <agrum/BN/inference/variableElimination.h>
#include <agrum/BN/inference/BayesBall.h> #include <agrum/BN/algorithms/BayesBall.h>
#include <agrum/BN/inference/dSeparation.h> #include <agrum/BN/algorithms/dSeparation.h>
#include <agrum/graphs/algorithms/binaryJoinTreeConverterDefault.h> #include <agrum/graphs/algorithms/binaryJoinTreeConverterDefault.h>
#include <agrum/multidim/instantiation.h> #include <agrum/multidim/instantiation.h>
#include <agrum/multidim/operators/multiDimCombineAndProjectDefault.h> #include <agrum/multidim/operators/multiDimCombineAndProjectDefault.h>
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <cxxtest/testsuite_utils.h> #include <cxxtest/testsuite_utils.h>
#include <agrum/BN/generator/simpleBayesNetGenerator.h> #include <agrum/BN/generator/simpleBayesNetGenerator.h>
#include <agrum/BN/inference/BayesBall.h> #include <agrum/BN/algorithms/BayesBall.h>
namespace gum_tests { namespace gum_tests {
......
...@@ -345,6 +345,7 @@ namespace gum_tests { ...@@ -345,6 +345,7 @@ namespace gum_tests {
TS_ASSERT_DELTA( proba, proba2, 1e-5 ); TS_ASSERT_DELTA( proba, proba2, 1e-5 );
} }
void testAsia() { void testAsia() {
std::string file = GET_RESSOURCES_PATH( "asia.bif" ); std::string file = GET_RESSOURCES_PATH( "asia.bif" );
gum::BayesNet<float> bn; gum::BayesNet<float> bn;
...@@ -832,16 +833,16 @@ namespace gum_tests { ...@@ -832,16 +833,16 @@ namespace gum_tests {
TS_ASSERT_EQUALS( res.nbrDim(), TS_ASSERT_EQUALS( res.nbrDim(),
gum::Size( 4 ) ); // MarkovBlanket(E)=(A,D,C) gum::Size( 4 ) ); // MarkovBlanket(E)=(A,D,C)
try { try {
auto joint = bn.cpt("A") * bn.cpt("B") * bn.cpt("C") * bn.cpt("D") * auto joint = bn.cpt( "A" ) * bn.cpt( "B" ) * bn.cpt( "C" ) *
bn.cpt("E") * bn.cpt("F") * bn.cpt("H"); bn.cpt( "D" ) * bn.cpt( "E" ) * bn.cpt( "F" ) * bn.cpt( "H" );
auto pADCE = joint.margSumIn({&bn.variableFromName("A"), auto pADCE = joint.margSumIn( {&bn.variableFromName( "A" ),
&bn.variableFromName("C"), &bn.variableFromName( "C" ),
&bn.variableFromName("D"), &bn.variableFromName( "D" ),
&bn.variableFromName("E")}); &bn.variableFromName( "E" )} );
auto pADC = pADCE.margSumOut({&bn.variableFromName("E")}); auto pADC = pADCE.margSumOut( {&bn.variableFromName( "E" )} );
TS_ASSERT_EQUALS(res, pADCE / pADC); TS_ASSERT_EQUALS( res, pADCE / pADC );
} catch (gum::Exception& e) { } catch ( gum::Exception& e ) {
GUM_SHOWERROR(e); GUM_SHOWERROR( e );
} }
} }
void testJointWithHardEvidence() { void testJointWithHardEvidence() {
...@@ -871,39 +872,39 @@ namespace gum_tests { ...@@ -871,39 +872,39 @@ namespace gum_tests {
TS_ASSERT( false ); TS_ASSERT( false );
} }
} }
void testJointEvidenceImpact() { void testJointEvidenceImpact() {
/* /*
F A F A
\ / \ \ / \
B | B |
| E | E