59#ifndef GUM_LEARNING_MIIC_H
60#define GUM_LEARNING_MIIC_H
65#include <agrum/config.h>
74#define GUM_SL_EMIT(x, y, action, explain) \
76 std::ostringstream action_stream; \
77 action_stream << action; \
78 std::ostringstream explain_stream; \
79 explain_stream << explain; \
80 GUM_EMIT4(onStructuralModification, x, y, action_stream.str(), explain_stream.str()); \
86 using CondThreePoints = std::tuple< NodeId, NodeId, NodeId, std::vector< NodeId > >;
90 using Ranking = std::pair< ThreePoints*, double >;
137 explicit Miic(
int maxLog);
202 template <
typename GUM_SCALAR =
double,
203 typename GRAPH_CHANGES_SELECTOR,
204 typename PARAM_ESTIMATOR >
205 BayesNet< GUM_SCALAR >
learnBN(GRAPH_CHANGES_SELECTOR& selector,
206 PARAM_ESTIMATOR& estimator,
244 HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > >& sepSet,
261 HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > >& sepSet,
275 const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > >& sepSet);
289 const std::vector< NodeId >& ui,
303 const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > >& sepSet);
315 const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > >& sepSet,
316 HashTable< std::pair< NodeId, NodeId >,
char >& marks);
322 std::vector< ProbabilisticRanking >
324 std::vector< ProbabilisticRanking > probaTriples);
383 HashTable< std::pair< NodeId, NodeId >,
char >& marks,
391 HashTable< std::pair< NodeId, NodeId >,
char >& marks,
Base classes for partially directed acyclic graphs.
This file contains general scheme for iteratively convergent algorithms.
ApproximationScheme(bool verbosity=false)
Base class for all oriented graphs.
The class for generic Hash Tables.
Base class for mixed graphs.
Base class for partially directed acyclic graphs.
bool operator()(const Ranking &e1, const Ranking &e2) const
bool operator()(const CondRanking &e1, const CondRanking &e2) const
bool operator()(const ProbabilisticRanking &e1, const ProbabilisticRanking &e2) const
static bool _existsDirectedPath_(const MixedGraph &graph, NodeId n1, NodeId n2)
checks for directed paths in a graph, consider double arcs like edges
std::vector< ProbabilisticRanking > updateProbaTriples_(const MixedGraph &graph, std::vector< ProbabilisticRanking > probaTriples)
Gets the orientation probabilities like MIIC for the orientation phase.
gum::DAG _mandatoryGraph_
Graph that contains the mandatories arcs.
bool isMaxIndegree_(MixedGraph graph, NodeId x)
void _orientingVstructureMiic_(MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, char > &marks, NodeId x, NodeId y, NodeId z, double p1, double p2)
void orientationMiic_(CorrectedMutualInformation &mutualInformation, MixedGraph &graph, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet)
Orientation phase from the MIIC algorithm, returns a mixed graph that may contain circles.
gum::DiGraph _forbiddenGraph_
Graph that contains the forbidden arcs.
void setMandatoryGraph(gum::DAG mandaGraph)
Miic & operator=(const Miic &from)
copy operator
MixedGraph learnMixedStructure(CorrectedMutualInformation &mutualInformation, MixedGraph graph)
learns the structure of a MixedGraph (Meek rules not used here).
void setMaxIndegree(gum::Size n)
gum::MeekRules meekRules_
Object that can propagates orientations to non-oriented edges.
gum::Size _maxIndegree_
maximum number of parents
const std::vector< NodeId > _emptySet_
an empty conditioning set
PDAG learnPDAG(CorrectedMutualInformation &mutualInformation, MixedGraph graph)
learns the structure of an Essential Graph
~Miic() override
destructor
std::vector< Arc > _latentCouples_
an empty vector of arcs
void addConstraints(HashTable< std::pair< NodeId, NodeId >, char > constraints)
Set a ensemble of constraints for the orientation phase.
void _propagatingOrientationMiic_(MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, char > &marks, NodeId x, NodeId y, NodeId z, double p1, double p2)
void iteration_(CorrectedMutualInformation &mutualInformation, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, Heap< CondRanking, GreaterPairOn2nd > &rank)
Iteration phase.
bool isArcValid_(MixedGraph graph, NodeId x, NodeId y)
void findBestContributor_(NodeId x, NodeId y, const std::vector< NodeId > &ui, const MixedGraph &graph, CorrectedMutualInformation &mutualInformation, Heap< CondRanking, GreaterPairOn2nd > &rank)
finds the best contributor node for a pair given a conditioning set
void setForbiddenGraph(gum::DiGraph forbidGraph)
Set ForbiddenGraph (resp. MadatoryGraph) which contains the forbidden (resp. mandatory) arcs.
std::vector< ProbabilisticRanking > unshieldedTriplesMiic_(const MixedGraph &graph, CorrectedMutualInformation &mutualInformation, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, HashTable< std::pair< NodeId, NodeId >, char > &marks)
gets the list of unshielded triples in the graph in decreasing value of |I'(x, y, z|{ui}...
bool isForbiddenArc_(NodeId x, NodeId y) const
Check constraints.
Miic()
default constructor
BayesNet< GUM_SCALAR > learnBN(GRAPH_CHANGES_SELECTOR &selector, PARAM_ESTIMATOR &estimator, DAG initial_dag=DAG())
learns the structure and the parameters of a BN
std::vector< Ranking > unshieldedTriples_(const MixedGraph &graph, CorrectedMutualInformation &mutualInformation, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet)
gets the list of unshielded triples in the graph in decreasing value of |I'(x, y, z|{ui}...
HashTable< std::pair< NodeId, NodeId >, char > _initialMarks_
Initial marks for the orientation phase, used to convey constraints.
bool isForbiddenEdge_(NodeId x, NodeId y)
ArcProperty< double > _arcProbas_
Storing the propabilities for each arc set in the graph.
Signaler4< gum::NodeId, gum::NodeId, std::string, std::string > onStructuralModification
void initiation_(CorrectedMutualInformation &mutualInformation, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, Heap< CondRanking, GreaterPairOn2nd > &rank)
Initiation phase.
static bool _existsNonTrivialDirectedPath_(const MixedGraph &graph, NodeId n1, NodeId n2)
checks for directed paths in a graph, considering double arcs like edges, not considering arc as a di...
Size _size_
size of the database
bool _isNotLatentCouple_(NodeId x, NodeId y)
void orientDoubleHeadedArcs_(MixedGraph &mg)
Orient double headed arcs to avoid cycles.
const std::vector< Arc > latentVariables() const
get the list of arcs hiding latent variables
int _maxLog_
Fixes the maximum log that we accept in exponential computations.
MixedGraph learnSkeleton(CorrectedMutualInformation &mutualInformation, MixedGraph graph)
learns the skeleton of a MixedGraph (no orientation).
DAG learnStructure(CorrectedMutualInformation &I, MixedGraph graph)
learns the structure of a Bayesian network, i.e. a DAG, by first learning an Essential graph and then...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
HashTable< Arc, VAL > ArcProperty
Property on graph elements.
std::pair< ThreePoints *, double > Ranking
std::pair< CondThreePoints *, double > CondRanking
std::tuple< NodeId, NodeId, NodeId, std::vector< NodeId > > CondThreePoints
std::tuple< NodeId, NodeId, NodeId > ThreePoints
std::tuple< ThreePoints *, double, double, double > ProbabilisticRanking
gum is the global namespace for all aGrUM entities