39 #ifndef GUM_LEARNING_3_OFF_2_H 40 #define GUM_LEARNING_3_OFF_2_H 45 #include <agrum/BN/BayesNet.h> 46 #include <agrum/config.h> 47 #include <agrum/tools/core/approximations/IApproximationSchemeConfiguration.h> 48 #include <agrum/tools/core/approximations/approximationScheme.h> 49 #include <agrum/tools/core/heap.h> 50 #include <agrum/tools/graphs/DAG.h> 51 #include <agrum/tools/graphs/mixedGraph.h> 52 #include <agrum/tools/stattests/correctedMutualInformation.h> 67 bool operator()(
const CondRanking& e1,
const CondRanking& e2)
const;
72 bool operator()(
const Ranking& e1,
const Ranking& e2)
const;
77 bool operator()(
const ProbabilisticRanking& e1,
const ProbabilisticRanking& e2)
const;
109 explicit Miic(
int maxLog);
161 template <
typename GUM_SCALAR =
double,
162 typename GRAPH_CHANGES_SELECTOR,
163 typename PARAM_ESTIMATOR >
178 void addConstraints(HashTable< std::pair< NodeId, NodeId >,
char > constraints);
198 void initiation_(CorrectedMutualInformation<>& mutualInformation,
215 void iteration_(CorrectedMutualInformation<>& mutualInformation,
228 CorrectedMutualInformation<>& mutualInformation,
241 CorrectedMutualInformation<>& mutualInformation,
254 CorrectedMutualInformation<>& mutualInformation,
270 const std::vector< NodeId >& ui,
271 const MixedGraph& graph,
272 CorrectedMutualInformation<>& mutualInformation,
273 Heap< CondRanking, GreaterPairOn2nd >& rank);
319 bool isOrientable_(
const MixedGraph& graph, NodeId xi, NodeId xj)
const;
357 HashTable< std::pair< NodeId, NodeId >,
char >& marks,
365 HashTable< std::pair< NodeId, NodeId >,
char >& marks,
std::vector< Arc > _latentCouples_
an empty vector of arcs
ArcProperty< double > _arcProbas_
Storing the propabilities for each arc set in the graph.
bool isOrientable_(const MixedGraph &graph, NodeId xi, NodeId xj) const
bool operator()(const CondRanking &e1, const CondRanking &e2) const
bool operator()(const ProbabilisticRanking &e1, const ProbabilisticRanking &e2) const
void iteration_(CorrectedMutualInformation<> &mutualInformation, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, Heap< CondRanking, GreaterPairOn2nd > &rank)
Iteration phase.
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
INLINE void emplace(Args &&... args)
Miic & operator=(const Miic &from)
copy operator
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...
void addConstraints(HashTable< std::pair< NodeId, NodeId >, char > constraints)
Set a ensemble of constraints for the orientation phase.
std::vector< ProbabilisticRanking > updateProbaTriples_(const MixedGraph &graph, std::vector< ProbabilisticRanking > probaTriples)
Gets the orientation probabilities like MIIC for the orientation phase.
Miic(int maxLog)
default constructor with maxLog
const std::vector< Arc > latentVariables() const
get the list of arcs hiding latent variables
void orientationLatents_(CorrectedMutualInformation<> &mutualInformation, MixedGraph &graph, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet)
Modified version of the orientation phase that tries to propagate orientations from both orientations...
void set3of2Behaviour()
Sets the orientation phase to follow the one of the 3off2 algorithm.
Miic & operator=(Miic &&from)
move operator
void setMiicBehaviour()
Sets the orientation phase to follow the one of the MIIC algorithm.
int _maxLog_
Fixes the maximum log that we accept in exponential computations.
bool operator()(const Ranking &e1, const Ranking &e2) const
const std::vector< NodeId > _emptySet_
an empty conditioning set
void propagatesOrientationInChainOfRemainingEdges_(MixedGraph &graph)
heuristic for remaining edges when everything else has been tried
void orientation3off2_(CorrectedMutualInformation<> &mutualInformation, MixedGraph &graph, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet)
Orientation phase from the 3off2 algorithm, returns a CPDAG.
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 isForbidenArc_(NodeId x, NodeId y) const
static bool _existsDirectedPath_(const MixedGraph &graph, NodeId n1, NodeId n2)
checks for directed paths in a graph, consider double arcs like edges
bool _useMiic_
wether to use the miic algorithm or not
bool propagatesRemainingOrientableEdges_(MixedGraph &graph, NodeId xj)
Propagates the orientation from a node to its neighbours.
HashTable< std::pair< NodeId, NodeId >, char > _initialMarks_
Initial marks for the orientation phase, used to convey constraints.
void initiation_(CorrectedMutualInformation<> &mutualInformation, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, Heap< CondRanking, GreaterPairOn2nd > &rank)
Initiation phase.
Size _size_
size of the database
Miic()
default constructor
Miic(const Miic &from)
copy constructor
bool _isNotLatentCouple_(NodeId x, NodeId y)
~Miic() override
destructor
The miic learning algorithm.
void _propagatingOrientationMiic_(MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, char > &marks, NodeId x, NodeId y, NodeId z, double p1, double p2)
MixedGraph learnMixedStructure(CorrectedMutualInformation<> &mutualInformation, MixedGraph graph)
learns the structure of an Essential Graph
Miic(Miic &&from)
move constructor
void _orientingVstructureMiic_(MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, char > &marks, NodeId x, NodeId y, NodeId z, double p1, double p2)
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...
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)
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})| ...
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...