aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::learning::SimpleMiic Class Reference

The miic learning algorithm. More...

#include <SimpleMiic.h>

Inheritance diagram for gum::learning::SimpleMiic:
Collaboration diagram for gum::learning::SimpleMiic:

Public Types

enum class  ApproximationSchemeSTATE : char {
  Undefined , Continue , Epsilon , Rate ,
  Limit , TimeLimit , Stopped
}
 The different state of an approximation scheme. More...

Public Member Functions

SimpleMiicoperator= (const SimpleMiic &from)
 copy operator
SimpleMiicoperator= (SimpleMiic &&from)
 move operator
Constructors / Destructors
 SimpleMiic ()
 default constructor
 SimpleMiic (int maxLog)
 default constructor with maxLog
 SimpleMiic (const SimpleMiic &from)
 copy constructor
 SimpleMiic (SimpleMiic &&from)
 move constructor
 ~SimpleMiic () override
 destructor
Accessors / Modifiers
MixedGraph learnPDAG (CorrectedMutualInformation &mutualInformation, MixedGraph graph)
 learns the structure of an Essential Graph
MixedGraph learnMixedStructure (CorrectedMutualInformation &mutualInformation, MixedGraph graph)
 learns the structure of an Essential Graph
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 directing the remaining edges.
template<typename GUM_SCALAR = double, typename GRAPH_CHANGES_SELECTOR, typename PARAM_ESTIMATOR>
BayesNet< GUM_SCALAR > learnBN (GRAPH_CHANGES_SELECTOR &selector, PARAM_ESTIMATOR &estimator, DAG initial_dag=DAG())
 learns the structure and the parameters of a BN
const std::vector< ArclatentVariables () const
 get the list of arcs hiding latent variables
void addConstraints (HashTable< std::pair< NodeId, NodeId >, char > constraints)
 Set a ensemble of constraints for the orientation phase.
Getters and setters
void setEpsilon (double eps) override
 Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|.
double epsilon () const override
 Returns the value of epsilon.
void disableEpsilon () override
 Disable stopping criterion on epsilon.
void enableEpsilon () override
 Enable stopping criterion on epsilon.
bool isEnabledEpsilon () const override
 Returns true if stopping criterion on epsilon is enabled, false otherwise.
void setMinEpsilonRate (double rate) override
 Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|).
double minEpsilonRate () const override
 Returns the value of the minimal epsilon rate.
void disableMinEpsilonRate () override
 Disable stopping criterion on epsilon rate.
void enableMinEpsilonRate () override
 Enable stopping criterion on epsilon rate.
bool isEnabledMinEpsilonRate () const override
 Returns true if stopping criterion on epsilon rate is enabled, false otherwise.
void setMaxIter (Size max) override
 Stopping criterion on number of iterations.
Size maxIter () const override
 Returns the criterion on number of iterations.
void disableMaxIter () override
 Disable stopping criterion on max iterations.
void enableMaxIter () override
 Enable stopping criterion on max iterations.
bool isEnabledMaxIter () const override
 Returns true if stopping criterion on max iterations is enabled, false otherwise.
void setMaxTime (double timeout) override
 Stopping criterion on timeout.
double maxTime () const override
 Returns the timeout (in seconds).
double currentTime () const override
 Returns the current running time in second.
void disableMaxTime () override
 Disable stopping criterion on timeout.
void enableMaxTime () override
 Enable stopping criterion on timeout.
bool isEnabledMaxTime () const override
 Returns true if stopping criterion on timeout is enabled, false otherwise.
void setPeriodSize (Size p) override
 How many samples between two stopping is enable.
Size periodSize () const override
 Returns the period size.
void setVerbosity (bool v) override
 Set the verbosity on (true) or off (false).
bool verbosity () const override
 Returns true if verbosity is enabled.
ApproximationSchemeSTATE stateApproximationScheme () const override
 Returns the approximation scheme state.
Size nbrIterations () const override
 Returns the number of iterations.
const std::vector< double > & history () const override
 Returns the scheme history.
void initApproximationScheme ()
 Initialise the scheme.
bool startOfPeriod () const
 Returns true if we are at the beginning of a period (compute error is mandatory).
void updateApproximationScheme (unsigned int incr=1)
 Update the scheme w.r.t the new error and increment steps.
Size remainingBurnIn () const
 Returns the remaining burn in.
void stopApproximationScheme ()
 Stop the approximation scheme.
bool continueApproximationScheme (double error)
 Update the scheme w.r.t the new error.
Getters and setters
std::string messageApproximationScheme () const
 Returns the approximation scheme message.

Public Attributes

Signaler3< Size, double, doubleonProgress
 Progression, error and time.
Signaler1< const std::string & > onStop
 Criteria messageApproximationScheme.

Protected Member Functions

void orientationLatents_ (CorrectedMutualInformation &mutualInformation, MixedGraph &graph, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet)
 variant trying to propagate both orientations in a bidirected arc
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
std::vector< RankingunshieldedTriples_ (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})|
std::vector< ProbabilisticRankingunshieldedTriplesMiic_ (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})|, prepares the orientation matrix for MIIC
std::vector< ProbabilisticRankingupdateProbaTriples_ (const MixedGraph &graph, std::vector< ProbabilisticRanking > probaTriples)
 Gets the orientation probabilities like MIIC for the orientation phase.
bool propagatesRemainingOrientableEdges_ (MixedGraph &graph, NodeId xj)
 Propagates the orientation from a node to its neighbours.
void propagatesOrientationInChainOfRemainingEdges_ (MixedGraph &graph)
 heuristic for remaining edges when everything else has been tried
bool isForbidenArc_ (NodeId x, NodeId y) const
bool isOrientable_ (const MixedGraph &graph, NodeId xi, NodeId xj) const
Main phases
void initiation_ (CorrectedMutualInformation &mutualInformation, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, Heap< CondRanking, GreaterPairOn2nd > &rank)
 Initiation phase.
void iteration_ (CorrectedMutualInformation &mutualInformation, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, Heap< CondRanking, GreaterPairOn2nd > &rank)
 Iteration phase.
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.

Protected Attributes

double current_epsilon_
 Current epsilon.
double last_epsilon_
 Last epsilon value.
double current_rate_
 Current rate.
Size current_step_
 The current step.
Timer timer_
 The timer.
ApproximationSchemeSTATE current_state_
 The current state.
std::vector< doublehistory_
 The scheme history, used only if verbosity == true.
double eps_
 Threshold for convergence.
bool enabled_eps_
 If true, the threshold convergence is enabled.
double min_rate_eps_
 Threshold for the epsilon rate.
bool enabled_min_rate_eps_
 If true, the minimal threshold for epsilon rate is enabled.
double max_time_
 The timeout.
bool enabled_max_time_
 If true, the timeout is enabled.
Size max_iter_
 The maximum iterations.
bool enabled_max_iter_
 If true, the maximum iterations stopping criterion is enabled.
Size burn_in_
 Number of iterations before checking stopping criteria.
Size period_size_
 Checking criteria frequency.
bool verbosity_
 If true, verbosity is enabled.

Private Member Functions

void _orientingVstructureMiic_ (MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, char > &marks, NodeId x, NodeId y, NodeId z, double p1, double p2)
void _propagatingOrientationMiic_ (MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, char > &marks, NodeId x, NodeId y, NodeId z, double p1, double p2)
bool _isNotLatentCouple_ (NodeId x, NodeId y)
void stopScheme_ (ApproximationSchemeSTATE new_state)
 Stop the scheme given a new state.

Static Private Member Functions

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 directed path.
static bool _existsDirectedPath_ (const MixedGraph &graph, NodeId n1, NodeId n2)
 checks for directed paths in a graph, consider double arcs like edges

Private Attributes

int _maxLog_ = 100
 Fixes the maximum log that we accept in exponential computations.
const std::vector< NodeId_emptySet_
 an empty conditioning set
std::vector< Arc_latentCouples_
 an empty vector of arcs
Size _size_
 size of the database
ArcProperty< double_arcProbas_
 Storing the propabilities for each arc set in the graph.
HashTable< std::pair< NodeId, NodeId >, char > _initialMarks_
 Initial marks for the orientation phase, used to convey constraints.

Detailed Description

The miic learning algorithm.

The miic class implements the miic algorithm based on https://doi.org/10.1371/journal.pcbi.1005662. It starts by eliminating edges that correspond to independent variables to build the skeleton of the graph, and then directs the remaining edges to get an essential graph. Latent variables can be detected using bi-directed arcs.

Definition at line 83 of file SimpleMiic.h.

Member Enumeration Documentation

◆ ApproximationSchemeSTATE

The different state of an approximation scheme.

Enumerator
Undefined 
Continue 
Epsilon 
Rate 
Limit 
TimeLimit 
Stopped 

Definition at line 86 of file IApproximationSchemeConfiguration.h.

86 : char {
87 Undefined,
88 Continue,
89 Epsilon,
90 Rate,
91 Limit,
92 TimeLimit,
93 Stopped
94 };

Constructor & Destructor Documentation

◆ SimpleMiic() [1/4]

gum::learning::SimpleMiic::SimpleMiic ( )

default constructor

Definition at line 63 of file SimpleMiic.cpp.

63: _maxLog_(100), _size_(0) { GUM_CONSTRUCTOR(SimpleMiic); }
int _maxLog_
Fixes the maximum log that we accept in exponential computations.
Definition SimpleMiic.h:289
SimpleMiic()
default constructor
Size _size_
size of the database
Definition SimpleMiic.h:296

References SimpleMiic(), _maxLog_, and _size_.

Referenced by SimpleMiic(), SimpleMiic(), SimpleMiic(), SimpleMiic(), ~SimpleMiic(), operator=(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SimpleMiic() [2/4]

gum::learning::SimpleMiic::SimpleMiic ( int maxLog)
explicit

default constructor with maxLog

Definition at line 66 of file SimpleMiic.cpp.

66 : _maxLog_(maxLog), _size_(0) {
67 GUM_CONSTRUCTOR(SimpleMiic);
68 }

References SimpleMiic(), _maxLog_, and _size_.

Here is the call graph for this function:

◆ SimpleMiic() [3/4]

gum::learning::SimpleMiic::SimpleMiic ( const SimpleMiic & from)

copy constructor

Definition at line 71 of file SimpleMiic.cpp.

71 :
72 ApproximationScheme(from), _size_(from._size_) {
73 GUM_CONS_CPY(SimpleMiic);
74 }
ApproximationScheme(bool verbosity=false)

References gum::ApproximationScheme::ApproximationScheme(), SimpleMiic(), and _size_.

Here is the call graph for this function:

◆ SimpleMiic() [4/4]

gum::learning::SimpleMiic::SimpleMiic ( SimpleMiic && from)

move constructor

Definition at line 77 of file SimpleMiic.cpp.

77 :
78 ApproximationScheme(std::move(from)), _size_(from._size_) {
79 GUM_CONS_MOV(SimpleMiic);
80 }

References gum::ApproximationScheme::ApproximationScheme(), SimpleMiic(), and _size_.

Here is the call graph for this function:

◆ ~SimpleMiic()

gum::learning::SimpleMiic::~SimpleMiic ( )
override

destructor

Definition at line 83 of file SimpleMiic.cpp.

83{ GUM_DESTRUCTOR(SimpleMiic); }

References SimpleMiic().

Here is the call graph for this function:

Member Function Documentation

◆ _existsDirectedPath_()

bool gum::learning::SimpleMiic::_existsDirectedPath_ ( const MixedGraph & graph,
NodeId n1,
NodeId n2 )
staticprivate

checks for directed paths in a graph, consider double arcs like edges

Parameters
graphMixedGraph in which to search the path
n1tail of the path
n2head of the path

Definition at line 852 of file SimpleMiic.cpp.

854 {
855 // not recursive version => use a FIFO for simulating the recursion
856 List< NodeId > nodeFIFO;
857 // mark[node] = successor if visited, else mark[node] does not exist
858 Set< NodeId > mark;
859
860 mark.insert(n2);
861 nodeFIFO.pushBack(n2);
862
863 NodeId current;
864
865 while (!nodeFIFO.empty()) {
866 current = nodeFIFO.front();
867 nodeFIFO.popFront();
868
869 // check the parents
870 for (const auto new_one: graph.parents(current)) {
871 if (graph.existsArc(current,
872 new_one)) // if there is a double arc, pass
873 continue;
874
875 if (new_one == n1) { return true; }
876
877 if (mark.exists(new_one)) // if this node is already marked, do not
878 continue; // check it again
879
880 mark.insert(new_one);
881 nodeFIFO.pushBack(new_one);
882 }
883 }
884
885 return false;
886 }
Size NodeId
Type for node ids.

References gum::List< Val >::empty(), gum::Set< Key >::exists(), gum::ArcGraphPart::existsArc(), gum::List< Val >::front(), gum::Set< Key >::insert(), gum::ArcGraphPart::parents(), gum::List< Val >::popFront(), and gum::List< Val >::pushBack().

Referenced by _existsNonTrivialDirectedPath_(), _propagatingOrientationMiic_(), isOrientable_(), and orientationMiic_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _existsNonTrivialDirectedPath_()

bool gum::learning::SimpleMiic::_existsNonTrivialDirectedPath_ ( const MixedGraph & graph,
NodeId n1,
NodeId n2 )
staticprivate

checks for directed paths in a graph, considering double arcs like edges, not considering arc as a directed path.

Parameters
graphMixedGraph in which to search the path
n1tail of the path
n2head of the path
countArcbool to know if we

Definition at line 838 of file SimpleMiic.cpp.

840 {
841 for (const auto parent: graph.parents(n2)) {
842 if (graph.existsArc(parent,
843 n2)) // if there is a double arc, pass
844 continue;
845 if (parent == n1) // trivial directed path => not recognized
846 continue;
847 if (_existsDirectedPath_(graph, n1, parent)) return true;
848 }
849 return false;
850 }
static bool _existsDirectedPath_(const MixedGraph &graph, NodeId n1, NodeId n2)
checks for directed paths in a graph, consider double arcs like edges

References _existsDirectedPath_(), gum::ArcGraphPart::existsArc(), and gum::ArcGraphPart::parents().

Referenced by _orientingVstructureMiic_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _isNotLatentCouple_()

bool gum::learning::SimpleMiic::_isNotLatentCouple_ ( NodeId x,
NodeId y )
private

Definition at line 1057 of file SimpleMiic.cpp.

1057 {
1058 const auto& lbeg = _latentCouples_.begin();
1059 const auto& lend = _latentCouples_.end();
1060
1061 return (std::find(lbeg, lend, Arc(x, y)) == lend)
1062 && (std::find(lbeg, lend, Arc(y, x)) == lend);
1063 }
std::vector< Arc > _latentCouples_
an empty vector of arcs
Definition SimpleMiic.h:293

References _latentCouples_.

Referenced by _orientingVstructureMiic_(), and orientationLatents_().

Here is the caller graph for this function:

◆ _orientingVstructureMiic_()

void gum::learning::SimpleMiic::_orientingVstructureMiic_ ( MixedGraph & graph,
HashTable< std::pair< NodeId, NodeId >, char > & marks,
NodeId x,
NodeId y,
NodeId z,
double p1,
double p2 )
private

Definition at line 889 of file SimpleMiic.cpp.

895 {
896 // v-structure discovery
897 if (marks[{x, z}] == 'o' && marks[{y, z}] == 'o') { // If x-z-y
898 if (!_existsNonTrivialDirectedPath_(graph, z, x)) {
899 graph.eraseEdge(Edge(x, z));
900 graph.addArc(x, z);
901 // GUM_TRACE("1.a Removing edge (" << x << "," << z << ")")
902 // GUM_TRACE("1.a Adding arc (" << x << "," << z << ")")
903 marks[{x, z}] = '>';
904 if (graph.existsArc(z, x) && _isNotLatentCouple_(z, x)) {
905 GUM_TRACE("Adding latent couple (" << z << "," << x << ")")
906 _latentCouples_.emplace_back(z, x);
907 }
908 if (!_arcProbas_.exists(Arc(x, z))) _arcProbas_.insert(Arc(x, z), p1);
909 } else {
910 graph.eraseEdge(Edge(x, z));
911 // GUM_TRACE("1.b Adding arc (" << x << "," << z << ")")
912 if (!_existsNonTrivialDirectedPath_(graph, x, z)) {
913 graph.addArc(z, x);
914 // GUM_TRACE("1.b Removing edge (" << x << "," << z << ")")
915 marks[{z, x}] = '>';
916 }
917 }
918
919 if (!_existsNonTrivialDirectedPath_(graph, z, y)) {
920 graph.eraseEdge(Edge(y, z));
921 graph.addArc(y, z);
922 // GUM_TRACE("1.c Removing edge (" << y << "," << z << ")")
923 // GUM_TRACE("1.c Adding arc (" << y << "," << z << ")")
924 marks[{y, z}] = '>';
925 if (graph.existsArc(z, y) && _isNotLatentCouple_(z, y)) {
926 GUM_TRACE("Adding latent couple (" << z << "," << y << ")")
927 _latentCouples_.emplace_back(z, y);
928 }
929 if (!_arcProbas_.exists(Arc(y, z))) _arcProbas_.insert(Arc(y, z), p2);
930 } else {
931 graph.eraseEdge(Edge(y, z));
932 // GUM_TRACE("1.d Removing edge (" << y << "," << z << ")")
933 if (!_existsNonTrivialDirectedPath_(graph, y, z)) {
934 graph.addArc(z, y);
935 // GUM_TRACE("1.d Adding arc (" << z << "," << y << ")")
936 marks[{z, y}] = '>';
937 }
938 }
939 } else if (marks[{x, z}] == '>' && marks[{y, z}] == 'o') { // If x->z-y
940 if (!_existsNonTrivialDirectedPath_(graph, z, y)) {
941 graph.eraseEdge(Edge(y, z));
942 graph.addArc(y, z);
943 // GUM_TRACE("2.a Removing edge (" << y << "," << z << ")")
944 // GUM_TRACE("2.a Adding arc (" << y << "," << z << ")")
945 marks[{y, z}] = '>';
946 if (graph.existsArc(z, y) && _isNotLatentCouple_(z, y)) {
947 GUM_TRACE("Adding latent couple (" << z << "," << y << ")")
948 _latentCouples_.emplace_back(z, y);
949 }
950 if (!_arcProbas_.exists(Arc(y, z))) _arcProbas_.insert(Arc(y, z), p2);
951 } else {
952 graph.eraseEdge(Edge(y, z));
953 // GUM_TRACE("2.b Removing edge (" << y << "," << z << ")")
954 if (!_existsNonTrivialDirectedPath_(graph, y, z)) {
955 graph.addArc(z, y);
956 // GUM_TRACE("2.b Adding arc (" << y << "," << z << ")")
957 marks[{z, y}] = '>';
958 }
959 }
960 } else if (marks[{y, z}] == '>' && marks[{x, z}] == 'o') {
961 if (!_existsNonTrivialDirectedPath_(graph, z, x)) {
962 graph.eraseEdge(Edge(x, z));
963 graph.addArc(x, z);
964 // GUM_TRACE("3.a Removing edge (" << x << "," << z << ")")
965 // GUM_TRACE("3.a Adding arc (" << x << "," << z << ")")
966 marks[{x, z}] = '>';
967 if (graph.existsArc(z, x) && _isNotLatentCouple_(z, x)) {
968 GUM_TRACE("Adding latent couple (" << z << "," << x << ")")
969 _latentCouples_.emplace_back(z, x);
970 }
971 if (!_arcProbas_.exists(Arc(x, z))) _arcProbas_.insert(Arc(x, z), p1);
972 } else {
973 graph.eraseEdge(Edge(x, z));
974 // GUM_TRACE("3.b Removing edge (" << x << "," << z << ")")
975 if (!_existsNonTrivialDirectedPath_(graph, x, z)) {
976 graph.addArc(z, x);
977 // GUM_TRACE("3.b Adding arc (" << x << "," << z << ")")
978 marks[{z, x}] = '>';
979 }
980 }
981 }
982 }
bool _isNotLatentCouple_(NodeId x, NodeId y)
ArcProperty< double > _arcProbas_
Storing the propabilities for each arc set in the graph.
Definition SimpleMiic.h:299
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...

References _arcProbas_, _existsNonTrivialDirectedPath_(), _isNotLatentCouple_(), _latentCouples_, gum::DiGraph::addArc(), gum::EdgeGraphPart::eraseEdge(), and gum::ArcGraphPart::existsArc().

Referenced by orientationMiic_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _propagatingOrientationMiic_()

void gum::learning::SimpleMiic::_propagatingOrientationMiic_ ( MixedGraph & graph,
HashTable< std::pair< NodeId, NodeId >, char > & marks,
NodeId x,
NodeId y,
NodeId z,
double p1,
double p2 )
private

Definition at line 984 of file SimpleMiic.cpp.

991 {
992 // orientation propagation
993 if (marks[{x, z}] == '>' && marks[{y, z}] == 'o' && marks[{z, y}] != '-') {
994 graph.eraseEdge(Edge(z, y));
995 // std::cout << "4. Removing edge (" << z << "," << y << ")" <<
996 // std::endl;
997 if (!_existsDirectedPath_(graph, y, z) && graph.parents(y).empty()) {
998 graph.addArc(z, y);
999 // GUM_TRACE("4.a Adding arc (" << z << "," << y << ")")
1000 marks[{z, y}] = '>';
1001 marks[{y, z}] = '-';
1002 if (!_arcProbas_.exists(Arc(z, y))) _arcProbas_.insert(Arc(z, y), p2);
1003 } else if (!_existsDirectedPath_(graph, z, y) && graph.parents(z).empty()) {
1004 graph.addArc(y, z);
1005 GUM_TRACE("4.b Adding arc (" << y << "," << z << ")")
1006 marks[{z, y}] = '-';
1007 marks[{y, z}] = '>';
1008 _latentCouples_.emplace_back(y, z);
1009 if (!_arcProbas_.exists(Arc(y, z))) _arcProbas_.insert(Arc(y, z), p2);
1010 } else if (!_existsDirectedPath_(graph, y, z)) {
1011 graph.addArc(z, y);
1012 // GUM_TRACE("4.c Adding arc (" << z << "," << y << ")")
1013 marks[{z, y}] = '>';
1014 marks[{y, z}] = '-';
1015 if (!_arcProbas_.exists(Arc(z, y))) _arcProbas_.insert(Arc(z, y), p2);
1016 } else if (!_existsDirectedPath_(graph, z, y)) {
1017 graph.addArc(y, z);
1018 GUM_TRACE("4.d Adding arc (" << y << "," << z << ")")
1019 _latentCouples_.emplace_back(y, z);
1020 marks[{z, y}] = '-';
1021 marks[{y, z}] = '>';
1022 if (!_arcProbas_.exists(Arc(y, z))) _arcProbas_.insert(Arc(y, z), p2);
1023 }
1024 } else if (marks[{y, z}] == '>' && marks[{x, z}] == 'o' && marks[{z, x}] != '-') {
1025 graph.eraseEdge(Edge(z, x));
1026 // GUM_TRACE("5. Removing edge (" << z << "," << x << ")")
1027 if (!_existsDirectedPath_(graph, x, z) && graph.parents(x).empty()) {
1028 graph.addArc(z, x);
1029 // GUM_TRACE("5.a Adding arc (" << z << "," << x << ")")
1030 marks[{z, x}] = '>';
1031 marks[{x, z}] = '-';
1032 if (!_arcProbas_.exists(Arc(z, x))) _arcProbas_.insert(Arc(z, x), p1);
1033 } else if (!_existsDirectedPath_(graph, z, x) && graph.parents(z).empty()) {
1034 graph.addArc(x, z);
1035 GUM_TRACE("5.b Adding arc (" << x << "," << z << ")")
1036 marks[{z, x}] = '-';
1037 marks[{x, z}] = '>';
1038 _latentCouples_.emplace_back(x, z);
1039 if (!_arcProbas_.exists(Arc(x, z))) _arcProbas_.insert(Arc(x, z), p1);
1040 } else if (!_existsDirectedPath_(graph, x, z)) {
1041 graph.addArc(z, x);
1042 // GUM_TRACE("5.c Adding arc (" << z << "," << x << ")")
1043 marks[{z, x}] = '>';
1044 marks[{x, z}] = '-';
1045 if (!_arcProbas_.exists(Arc(z, x))) _arcProbas_.insert(Arc(z, x), p1);
1046 } else if (!_existsDirectedPath_(graph, z, x)) {
1047 graph.addArc(x, z);
1048 GUM_TRACE("5.d Adding arc (" << x << "," << z << ")")
1049 marks[{z, x}] = '-';
1050 marks[{x, z}] = '>';
1051 _latentCouples_.emplace_back(x, z);
1052 if (!_arcProbas_.exists(Arc(x, z))) _arcProbas_.insert(Arc(x, z), p1);
1053 }
1054 }
1055 }

References _arcProbas_, _existsDirectedPath_(), _latentCouples_, gum::DiGraph::addArc(), gum::Set< Key >::empty(), gum::EdgeGraphPart::eraseEdge(), and gum::ArcGraphPart::parents().

Referenced by orientationMiic_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addConstraints()

void gum::learning::SimpleMiic::addConstraints ( HashTable< std::pair< NodeId, NodeId >, char > constraints)

Set a ensemble of constraints for the orientation phase.

Definition at line 834 of file SimpleMiic.cpp.

834 {
835 this->_initialMarks_ = constraints;
836 }
HashTable< std::pair< NodeId, NodeId >, char > _initialMarks_
Initial marks for the orientation phase, used to convey constraints.
Definition SimpleMiic.h:302

References _initialMarks_.

◆ continueApproximationScheme()

INLINE bool gum::ApproximationScheme::continueApproximationScheme ( double error)
inherited

Update the scheme w.r.t the new error.

Test the stopping criterion that are enabled.

Parameters
errorThe new error value.
Returns
false if state become != ApproximationSchemeSTATE::Continue
Exceptions
OperationNotAllowedRaised if state != ApproximationSchemeSTATE::Continue.

Definition at line 229 of file approximationScheme_inl.h.

229 {
230 // For coherence, we fix the time used in the method
231
232 double timer_step = timer_.step();
233
234 if (enabled_max_time_) {
235 if (timer_step > max_time_) {
237 return false;
238 }
239 }
240
241 if (!startOfPeriod()) { return true; }
242
244 GUM_ERROR(
245 OperationNotAllowed,
246 "state of the approximation scheme is not correct : " << messageApproximationScheme());
247 }
248
249 if (verbosity()) { history_.push_back(error); }
250
251 if (enabled_max_iter_) {
252 if (current_step_ > max_iter_) {
254 return false;
255 }
256 }
257
259 current_epsilon_ = error; // eps rate isEnabled needs it so affectation was
260 // moved from eps isEnabled below
261
262 if (enabled_eps_) {
263 if (current_epsilon_ <= eps_) {
265 return false;
266 }
267 }
268
269 if (last_epsilon_ >= 0.) {
270 if (current_epsilon_ > .0) {
271 // ! current_epsilon_ can be 0. AND epsilon
272 // isEnabled can be disabled !
274 }
275 // limit with current eps ---> 0 is | 1 - ( last_eps / 0 ) | --->
276 // infinity the else means a return false if we isEnabled the rate below,
277 // as we would have returned false if epsilon isEnabled was enabled
278 else {
280 }
281
285 return false;
286 }
287 }
288 }
289
291 if (onProgress.hasListener()) {
293 }
294
295 return true;
296 } else {
297 return false;
298 }
299 }
Size current_step_
The current step.
double current_epsilon_
Current epsilon.
double last_epsilon_
Last epsilon value.
double eps_
Threshold for convergence.
bool enabled_max_time_
If true, the timeout is enabled.
Size max_iter_
The maximum iterations.
bool enabled_eps_
If true, the threshold convergence is enabled.
ApproximationSchemeSTATE current_state_
The current state.
double min_rate_eps_
Threshold for the epsilon rate.
std::vector< double > history_
The scheme history, used only if verbosity == true.
double current_rate_
Current rate.
ApproximationSchemeSTATE stateApproximationScheme() const override
Returns the approximation scheme state.
bool startOfPeriod() const
Returns true if we are at the beginning of a period (compute error is mandatory).
bool enabled_max_iter_
If true, the maximum iterations stopping criterion is enabled.
void stopScheme_(ApproximationSchemeSTATE new_state)
Stop the scheme given a new state.
bool verbosity() const override
Returns true if verbosity is enabled.
bool enabled_min_rate_eps_
If true, the minimal threshold for epsilon rate is enabled.
std::string messageApproximationScheme() const
Returns the approximation scheme message.
Signaler3< Size, double, double > onProgress
Progression, error and time.
#define GUM_ERROR(type, msg)
Definition exceptions.h:72
#define GUM_EMIT3(signal, arg1, arg2, arg3)
Definition signaler3.h:61

References enabled_max_time_, and timer_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), gum::SamplingInference< GUM_SCALAR >::loopApproxInference_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceByOrderedArcs_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceByRandomOrder_(), and gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceNodeToNeighbours_().

Here is the caller graph for this function:

◆ currentTime()

INLINE double gum::ApproximationScheme::currentTime ( ) const
overridevirtualinherited

Returns the current running time in second.

Returns
Returns the current running time in second.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 136 of file approximationScheme_inl.h.

136{ return timer_.step(); }

References timer_.

◆ disableEpsilon()

INLINE void gum::ApproximationScheme::disableEpsilon ( )
overridevirtualinherited

Disable stopping criterion on epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 74 of file approximationScheme_inl.h.

74{ enabled_eps_ = false; }

References enabled_eps_.

Referenced by gum::learning::EMApproximationScheme::EMApproximationScheme(), and gum::learning::EMApproximationScheme::setMinEpsilonRate().

Here is the caller graph for this function:

◆ disableMaxIter()

INLINE void gum::ApproximationScheme::disableMaxIter ( )
overridevirtualinherited

Disable stopping criterion on max iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 115 of file approximationScheme_inl.h.

115{ enabled_max_iter_ = false; }

References enabled_max_iter_.

Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing().

Here is the caller graph for this function:

◆ disableMaxTime()

INLINE void gum::ApproximationScheme::disableMaxTime ( )
overridevirtualinherited

Disable stopping criterion on timeout.

Returns
Disable stopping criterion on timeout.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 139 of file approximationScheme_inl.h.

139{ enabled_max_time_ = false; }

References enabled_max_time_.

Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing().

Here is the caller graph for this function:

◆ disableMinEpsilonRate()

INLINE void gum::ApproximationScheme::disableMinEpsilonRate ( )
overridevirtualinherited

Disable stopping criterion on epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 95 of file approximationScheme_inl.h.

95{ enabled_min_rate_eps_ = false; }

References enabled_min_rate_eps_.

Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and gum::learning::EMApproximationScheme::setEpsilon().

Here is the caller graph for this function:

◆ enableEpsilon()

INLINE void gum::ApproximationScheme::enableEpsilon ( )
overridevirtualinherited

Enable stopping criterion on epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 77 of file approximationScheme_inl.h.

77{ enabled_eps_ = true; }

References enabled_eps_.

◆ enableMaxIter()

INLINE void gum::ApproximationScheme::enableMaxIter ( )
overridevirtualinherited

Enable stopping criterion on max iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 118 of file approximationScheme_inl.h.

118{ enabled_max_iter_ = true; }

References enabled_max_iter_.

◆ enableMaxTime()

INLINE void gum::ApproximationScheme::enableMaxTime ( )
overridevirtualinherited

Enable stopping criterion on timeout.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 142 of file approximationScheme_inl.h.

142{ enabled_max_time_ = true; }

References enabled_max_time_.

◆ enableMinEpsilonRate()

INLINE void gum::ApproximationScheme::enableMinEpsilonRate ( )
overridevirtualinherited

Enable stopping criterion on epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 98 of file approximationScheme_inl.h.

98{ enabled_min_rate_eps_ = true; }

References enabled_min_rate_eps_.

Referenced by gum::learning::EMApproximationScheme::EMApproximationScheme(), and gum::GibbsBNdistance< GUM_SCALAR >::computeKL_().

Here is the caller graph for this function:

◆ epsilon()

INLINE double gum::ApproximationScheme::epsilon ( ) const
overridevirtualinherited

Returns the value of epsilon.

Returns
Returns the value of epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 71 of file approximationScheme_inl.h.

71{ return eps_; }

References eps_.

Referenced by gum::ImportanceSampling< GUM_SCALAR >::onContextualize_(), and gum::ImportanceSampling< GUM_SCALAR >::unsharpenBN_().

Here is the caller graph for this function:

◆ findBestContributor_()

void gum::learning::SimpleMiic::findBestContributor_ ( NodeId x,
NodeId y,
const std::vector< NodeId > & ui,
const MixedGraph & graph,
CorrectedMutualInformation & mutualInformation,
Heap< CondRanking, GreaterPairOn2nd > & rank )
protected

finds the best contributor node for a pair given a conditioning set

Parameters
xfirst node
ysecond node
uiconditioning set
mutualInformationA mutual information instance that will do the computations and has loaded the database.
graphcontaining the assessed nodes
rankthe heap of ranks of the algorithm

Definition at line 418 of file SimpleMiic.cpp.

423 {
424 double maxP = -1.0;
425 NodeId maxZ = 0;
426
427 // compute N
428 // __N = I.N();
429 const double Ixy_ui = mutualInformation.score(x, y, ui);
430
431 for (const NodeId z: graph) {
432 // if z!=x and z!=y and z not in ui
433 if (z != x && z != y && std::find(ui.begin(), ui.end(), z) == ui.end()) {
434 double Pnv;
435 double Pb;
436
437 // Computing Pnv
438 const double Ixyz_ui = mutualInformation.score(x, y, z, ui);
439 double calc_expo1 = -Ixyz_ui * M_LN2;
440 // if exponential are too high or to low, crop them at _maxLog_
441 if (calc_expo1 > _maxLog_) {
442 Pnv = 0.0;
443 } else if (calc_expo1 < -_maxLog_) {
444 Pnv = 1.0;
445 } else {
446 Pnv = 1 / (1 + std::exp(calc_expo1));
447 }
448
449 // Computing Pb
450 const double Ixz_ui = mutualInformation.score(x, z, ui);
451 const double Iyz_ui = mutualInformation.score(y, z, ui);
452
453 calc_expo1 = -(Ixz_ui - Ixy_ui) * M_LN2;
454 double calc_expo2 = -(Iyz_ui - Ixy_ui) * M_LN2;
455
456 // if exponential are too high or to low, crop them at _maxLog_
457 if (calc_expo1 > _maxLog_ || calc_expo2 > _maxLog_) {
458 Pb = 0.0;
459 } else if (calc_expo1 < -_maxLog_ && calc_expo2 < -_maxLog_) {
460 Pb = 1.0;
461 } else {
462 double expo1, expo2;
463 if (calc_expo1 < -_maxLog_) {
464 expo1 = 0.0;
465 } else {
466 expo1 = std::exp(calc_expo1);
467 }
468 if (calc_expo2 < -_maxLog_) {
469 expo2 = 0.0;
470 } else {
471 expo2 = std::exp(calc_expo2);
472 }
473 Pb = 1 / (1 + expo1 + expo2);
474 }
475
476 // Getting max(min(Pnv, pb))
477 const double min_pnv_pb = std::min(Pnv, Pb);
478 if (min_pnv_pb > maxP) {
479 maxP = min_pnv_pb;
480 maxZ = z;
481 }
482 } // if z not in (x, y)
483 } // for z in graph.nodes
484 // storing best z in rank_
485 CondRanking final;
486 auto tup = new CondThreePoints{x, y, maxZ, ui};
487 final.first = tup;
488 final.second = maxP;
489 rank.insert(final);
490 }
#define M_LN2
Definition math_utils.h:63
std::pair< CondThreePoints *, double > CondRanking
Definition Miic.h:87
std::tuple< NodeId, NodeId, NodeId, std::vector< NodeId > > CondThreePoints
Definition Miic.h:86

References _maxLog_, gum::Heap< Val, Cmp >::insert(), M_LN2, and gum::learning::CorrectedMutualInformation::score().

Referenced by initiation_(), and iteration_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ history()

INLINE const std::vector< double > & gum::ApproximationScheme::history ( ) const
overridevirtualinherited

Returns the scheme history.

Returns
Returns the scheme history.
Exceptions
OperationNotAllowedRaised if the scheme did not performed or if verbosity is set to false.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 178 of file approximationScheme_inl.h.

178 {
180 GUM_ERROR(OperationNotAllowed, "state of the approximation scheme is udefined")
181 }
182
183 if (!verbosity()) GUM_ERROR(OperationNotAllowed, "No history when verbosity=false")
184
185 return history_;
186 }

References GUM_ERROR, stateApproximationScheme(), and gum::IApproximationSchemeConfiguration::Undefined.

Here is the call graph for this function:

◆ initApproximationScheme()

INLINE void gum::ApproximationScheme::initApproximationScheme ( )
inherited

Initialise the scheme.

Definition at line 189 of file approximationScheme_inl.h.

189 {
191 current_step_ = 0;
193 history_.clear();
194 timer_.reset();
195 }

References ApproximationScheme(), gum::IApproximationSchemeConfiguration::Continue, current_epsilon_, current_rate_, current_state_, current_step_, and initApproximationScheme().

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), initApproximationScheme(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), gum::SamplingInference< GUM_SCALAR >::loopApproxInference_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInference(), and gum::SamplingInference< GUM_SCALAR >::onStateChanged_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initiation_()

void gum::learning::SimpleMiic::initiation_ ( CorrectedMutualInformation & mutualInformation,
MixedGraph & graph,
HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > & sepSet,
Heap< CondRanking, GreaterPairOn2nd > & rank )
protected

Initiation phase.

We go over all edges and test if the variables are marginally independent. If they are, the edge is deleted. If not, the best contributor is found.

Parameters
mutualInformationA mutual information instance that will do the computations and has loaded the database.
graphthe MixedGraph we start from for the learning
sepSetthe separation set for independent couples, here set to {}
rankthe heap of ranks of the algorithm

Definition at line 128 of file SimpleMiic.cpp.

132 {
133 NodeId x, y;
134 EdgeSet edges = graph.edges();
135 Size steps_init = edges.size();
136
137 for (const Edge& edge: edges) {
138 x = edge.first();
139 y = edge.second();
140 double Ixy = mutualInformation.score(x, y);
141
142 if (Ixy <= 0) { //< K
143 graph.eraseEdge(edge);
144 sepSet.insert(std::make_pair(x, y), _emptySet_);
145 } else {
146 findBestContributor_(x, y, _emptySet_, graph, mutualInformation, rank);
147 }
148
150 if (onProgress.hasListener()) {
151 GUM_EMIT3(onProgress, (current_step_ * 33) / steps_init, 0., timer_.step());
152 }
153 }
154 }
Size size() const noexcept
Returns the number of elements in the set.
Definition set_tpl.h:636
const std::vector< NodeId > _emptySet_
an empty conditioning set
Definition SimpleMiic.h:291
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
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Set< Edge > EdgeSet
Some typdefs and define for shortcuts ...

References _emptySet_, gum::ApproximationScheme::current_step_, gum::EdgeGraphPart::edges(), gum::EdgeGraphPart::eraseEdge(), findBestContributor_(), GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, gum::learning::CorrectedMutualInformation::score(), gum::Set< Key >::size(), and gum::ApproximationScheme::timer_.

Referenced by learnMixedStructure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEnabledEpsilon()

INLINE bool gum::ApproximationScheme::isEnabledEpsilon ( ) const
overridevirtualinherited

Returns true if stopping criterion on epsilon is enabled, false otherwise.

Returns
Returns true if stopping criterion on epsilon is enabled, false otherwise.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 81 of file approximationScheme_inl.h.

81{ return enabled_eps_; }

References enabled_eps_.

◆ isEnabledMaxIter()

INLINE bool gum::ApproximationScheme::isEnabledMaxIter ( ) const
overridevirtualinherited

Returns true if stopping criterion on max iterations is enabled, false otherwise.

Returns
Returns true if stopping criterion on max iterations is enabled, false otherwise.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 122 of file approximationScheme_inl.h.

122{ return enabled_max_iter_; }

References enabled_max_iter_.

◆ isEnabledMaxTime()

INLINE bool gum::ApproximationScheme::isEnabledMaxTime ( ) const
overridevirtualinherited

Returns true if stopping criterion on timeout is enabled, false otherwise.

Returns
Returns true if stopping criterion on timeout is enabled, false otherwise.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 146 of file approximationScheme_inl.h.

146{ return enabled_max_time_; }

References enabled_max_time_.

◆ isEnabledMinEpsilonRate()

INLINE bool gum::ApproximationScheme::isEnabledMinEpsilonRate ( ) const
overridevirtualinherited

Returns true if stopping criterion on epsilon rate is enabled, false otherwise.

Returns
Returns true if stopping criterion on epsilon rate is enabled, false otherwise.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 102 of file approximationScheme_inl.h.

102{ return enabled_min_rate_eps_; }

References enabled_min_rate_eps_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_().

Here is the caller graph for this function:

◆ isForbidenArc_()

bool gum::learning::SimpleMiic::isForbidenArc_ ( NodeId x,
NodeId y ) const
protected

Definition at line 1065 of file SimpleMiic.cpp.

1065 {
1066 return (_initialMarks_.exists({x, y}) && _initialMarks_[{x, y}] == '-');
1067 }

References _initialMarks_.

Referenced by learnPDAG(), and learnStructure().

Here is the caller graph for this function:

◆ isOrientable_()

bool gum::learning::SimpleMiic::isOrientable_ ( const MixedGraph & graph,
NodeId xi,
NodeId xj ) const
protected

Definition at line 713 of file SimpleMiic.cpp.

713 {
714 // no cycle
715 if (_existsDirectedPath_(graph, xj, xi)) {
716 // GUM_TRACE("cycle(" << xi << "-" << xj << ")")
717 return false;
718 }
719
720 // R1
721 if (!(graph.parents(xi) - graph.boundary(xj)).empty()) {
722 // GUM_TRACE("R1(" << xi << "-" << xj << ")")
723 return true;
724 }
725
726 // R2
727 if (_existsDirectedPath_(graph, xi, xj)) {
728 // GUM_TRACE("R2(" << xi << "-" << xj << ")")
729 return true;
730 }
731
732 // R3
733 int nbr = 0;
734 for (const auto p: graph.parents(xj)) {
735 if (!graph.mixedOrientedPath(xi, p).empty()) {
736 nbr += 1;
737 if (nbr == 2) {
738 // GUM_TRACE("R3(" << xi << "-" << xj << ")")
739 return true;
740 }
741 }
742 }
743 return false;
744 }

References _existsDirectedPath_(), gum::MixedGraph::boundary(), gum::MixedGraph::mixedOrientedPath(), and gum::ArcGraphPart::parents().

Referenced by propagatesRemainingOrientableEdges_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iteration_()

void gum::learning::SimpleMiic::iteration_ ( CorrectedMutualInformation & mutualInformation,
MixedGraph & graph,
HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > & sepSet,
Heap< CondRanking, GreaterPairOn2nd > & rank )
protected

Iteration phase.

As long as we find important nodes for edges, we go over them to see if we can assess the conditional independence of the variables.

Parameters
mutualInformationA mutual information instance that will do the computations and has loaded the database.
graphthe MixedGraph returned from the previous phase
sepSetthe separation set for independent couples, built during the iterations of the phase
rankthe heap of ranks of the algorithm

Definition at line 162 of file SimpleMiic.cpp.

166 {
167 // if no triples to further examine pass
168 CondRanking best;
169
170 Size steps_init = current_step_;
171 Size steps_iter = rank.size();
172
173 try {
174 while (rank.top().second > 0.5) {
175 best = rank.pop();
176
177 const NodeId x = std::get< 0 >(*(best.first));
178 const NodeId y = std::get< 1 >(*(best.first));
179 const NodeId z = std::get< 2 >(*(best.first));
180 std::vector< NodeId > ui = std::move(std::get< 3 >(*(best.first)));
181
182 ui.push_back(z);
183 const double i_xy_ui = mutualInformation.score(x, y, ui);
184 if (i_xy_ui < 0) {
185 graph.eraseEdge(Edge(x, y));
186 sepSet.insert(std::make_pair(x, y), std::move(ui));
187 } else {
188 findBestContributor_(x, y, ui, graph, mutualInformation, rank);
189 }
190
191 delete best.first;
192
194 if (onProgress.hasListener()) {
196 (current_step_ * 66) / (steps_init + steps_iter),
197 0.,
198 timer_.step());
199 }
200 }
201 } catch (...) {} // here, rank is empty
202 current_step_ = steps_init + steps_iter;
203 if (onProgress.hasListener()) { GUM_EMIT3(onProgress, 66, 0., timer_.step()); }
204 current_step_ = steps_init + steps_iter;
205 }

References gum::ApproximationScheme::current_step_, gum::EdgeGraphPart::eraseEdge(), findBestContributor_(), GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, gum::Heap< Val, Cmp >::pop(), gum::learning::CorrectedMutualInformation::score(), gum::Heap< Val, Cmp >::size(), gum::ApproximationScheme::timer_, and gum::Heap< Val, Cmp >::top().

Referenced by learnMixedStructure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ latentVariables()

const std::vector< Arc > gum::learning::SimpleMiic::latentVariables ( ) const

get the list of arcs hiding latent variables

Definition at line 820 of file SimpleMiic.cpp.

820 {
821 GUM_CHECKPOINT
822 return _latentCouples_;
823 }

References _latentCouples_.

◆ learnBN()

template<typename GUM_SCALAR, typename GRAPH_CHANGES_SELECTOR, typename PARAM_ESTIMATOR>
BayesNet< GUM_SCALAR > gum::learning::SimpleMiic::learnBN ( GRAPH_CHANGES_SELECTOR & selector,
PARAM_ESTIMATOR & estimator,
DAG initial_dag = DAG() )

learns the structure and the parameters of a BN

Parameters
selectorA selector class that computes the best changes that can be applied and that enables the user to get them very easily. Typically, the selector is a GraphChangesSelector4DiGraph<SCORE, STRUCT_CONSTRAINT, GRAPH_CHANGES_GENERATOR>.
estimatorA estimator.
namesThe variables names.
modalthe domain sizes of the random variables observed in the database
translatorThe cell translator to use.
initial_dagthe DAG we start from for our learning

Definition at line 827 of file SimpleMiic.cpp.

829 {
831 learnStructure(selector, initial_dag));
832 }
static BayesNet< GUM_SCALAR > createBN(ParamEstimator &estimator, const DAG &dag)
create a BN from a DAG using a one pass generator (typically ML)
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...

References gum::learning::DAG2BNLearner::createBN(), and learnStructure().

Here is the call graph for this function:

◆ learnMixedStructure()

MixedGraph gum::learning::SimpleMiic::learnMixedStructure ( CorrectedMutualInformation & mutualInformation,
MixedGraph graph )

learns the structure of an Essential Graph

learns the structure of a MixedGraph

Parameters
mutualInformationA mutual information instance that will do the computations and has loaded the database.
graphthe MixedGraph we start from for the learning

Definition at line 98 of file SimpleMiic.cpp.

99 {
100 timer_.reset();
101 current_step_ = 0;
102
103 // clear the vector of latent arcs to be sure
104 _latentCouples_.clear();
105
107 Heap< CondRanking, GreaterPairOn2nd > rank;
108
110 HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > sep_set;
111
112 initiation_(mutualInformation, graph, sep_set, rank);
113
114 iteration_(mutualInformation, graph, sep_set, rank);
115
116 orientationMiic_(mutualInformation, graph, sep_set);
117
118 return graph;
119 }
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 iteration_(CorrectedMutualInformation &mutualInformation, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, Heap< CondRanking, GreaterPairOn2nd > &rank)
Iteration phase.
void initiation_(CorrectedMutualInformation &mutualInformation, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, Heap< CondRanking, GreaterPairOn2nd > &rank)
Initiation phase.

References _latentCouples_, gum::ApproximationScheme::current_step_, initiation_(), iteration_(), orientationMiic_(), and gum::ApproximationScheme::timer_.

Referenced by learnPDAG(), and learnStructure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ learnPDAG()

MixedGraph gum::learning::SimpleMiic::learnPDAG ( CorrectedMutualInformation & mutualInformation,
MixedGraph graph )

learns the structure of an Essential Graph

learns the structure of a PDAG from à MixedGraph. It returns a MixedGraph with the constraints of a PDAG, to avoid changing the dependencies in the other methods of the MIIC class.

Parameters
mutualInformationA mutual information instance that will do the computations and has loaded the database.
graphthe MixedGraph we start from for the learning

Definition at line 614 of file SimpleMiic.cpp.

614 {
615 MixedGraph essentialGraph = learnMixedStructure(I, initialGraph);
616
617 // orientate remaining edges
618 const Sequence< NodeId > order = essentialGraph.topologicalOrder();
619
620 // first, forbidden arcs force arc in the other direction
621 for (NodeId x: order) {
622 const auto nei_x = essentialGraph.neighbours(x);
623 for (NodeId y: nei_x)
624 if (isForbidenArc_(x, y)) {
625 essentialGraph.eraseEdge(Edge(x, y));
626 if (isForbidenArc_(y, x)) {
627 // GUM_TRACE("Neither arc allowed for edge (" << x << "," << y << ")")
628 } else {
629 // GUM_TRACE("Forced orientation : " << y << "->" << x)
630 essentialGraph.addArc(y, x);
631 }
632 } else if (isForbidenArc_(y, x)) {
633 essentialGraph.eraseEdge(Edge(x, y));
634 // GUM_TRACE("Forced orientation : " << x << "->" << y)
635 essentialGraph.addArc(x, y);
636 }
637 }
638
639 // then propagates existing orientations thanks to Meek rules
640 bool newOrientation = true;
641 while (newOrientation) {
642 newOrientation = false;
643 for (NodeId x: order) {
644 if (!essentialGraph.parents(x).empty()) {
645 newOrientation |= propagatesRemainingOrientableEdges_(essentialGraph, x);
646 }
647 }
648 }
649 return essentialGraph;
650 }
MixedGraph learnMixedStructure(CorrectedMutualInformation &mutualInformation, MixedGraph graph)
learns the structure of an Essential Graph
bool propagatesRemainingOrientableEdges_(MixedGraph &graph, NodeId xj)
Propagates the orientation from a node to its neighbours.
bool isForbidenArc_(NodeId x, NodeId y) const

References gum::DiGraph::addArc(), gum::Set< Key >::empty(), gum::EdgeGraphPart::eraseEdge(), isForbidenArc_(), learnMixedStructure(), gum::EdgeGraphPart::neighbours(), gum::ArcGraphPart::parents(), propagatesRemainingOrientableEdges_(), and gum::DiGraph::topologicalOrder().

Here is the call graph for this function:

◆ learnStructure()

DAG gum::learning::SimpleMiic::learnStructure ( CorrectedMutualInformation & I,
MixedGraph graph )

learns the structure of a Bayesian network, i.e. a DAG, by first learning an Essential graph and then directing the remaining edges.

learns the structure of an Bayesian network, ie a DAG, from an Essential graph.

Parameters
IA mutual information instance that will do the computations and has loaded the database
graphthe MixedGraph we start from for the learning

Definition at line 654 of file SimpleMiic.cpp.

654 {
655 MixedGraph essentialGraph = learnMixedStructure(I, initialGraph);
656 // orientate remaining edges
657
658 const Sequence< NodeId > order = essentialGraph.topologicalOrder();
659
660 // first, forbidden arcs force arc in the other direction
661 for (NodeId x: order) {
662 const auto nei_x = essentialGraph.neighbours(x);
663 for (NodeId y: nei_x)
664 if (isForbidenArc_(x, y)) {
665 essentialGraph.eraseEdge(Edge(x, y));
666 if (isForbidenArc_(y, x)) {
667 // GUM_TRACE("Neither arc allowed for edge (" << x << "," << y << ")")
668 } else {
669 // GUM_TRACE("Forced orientation : " << y << "->" << x)
670 essentialGraph.addArc(y, x);
671 }
672 } else if (isForbidenArc_(y, x)) {
673 essentialGraph.eraseEdge(Edge(x, y));
674 // GUM_TRACE("Forced orientation : " << x << "->" << y)
675 essentialGraph.addArc(x, y);
676 }
677 }
678 // GUM_TRACE(essentialGraph.toDot());
679
680 // first, propagate existing orientations
681 bool newOrientation = true;
682 while (newOrientation) {
683 newOrientation = false;
684 for (NodeId x: order) {
685 if (!essentialGraph.parents(x).empty()) {
686 newOrientation |= propagatesRemainingOrientableEdges_(essentialGraph, x);
687 }
688 }
689 }
690 // GUM_TRACE(essentialGraph.toDot());
692 // GUM_TRACE(essentialGraph.toDot());
693
694 // then decide the orientation for double arcs
695 for (NodeId x: order)
696 for (NodeId y: essentialGraph.parents(x))
697 if (essentialGraph.parents(y).contains(x)) {
698 // GUM_TRACE(" + Resolving double arcs (poorly)")
699 essentialGraph.eraseArc(Arc(y, x));
700 }
701
702 DAG dag;
703 for (auto node: essentialGraph) {
704 dag.addNodeWithId(node);
705 }
706 for (const Arc& arc: essentialGraph.arcs()) {
707 dag.addArc(arc.tail(), arc.head());
708 }
709
710 return dag;
711 }
void propagatesOrientationInChainOfRemainingEdges_(MixedGraph &graph)
heuristic for remaining edges when everything else has been tried

References gum::DAG::addArc(), gum::DiGraph::addArc(), gum::NodeGraphPart::addNodeWithId(), gum::ArcGraphPart::arcs(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::ArcGraphPart::eraseArc(), gum::EdgeGraphPart::eraseEdge(), isForbidenArc_(), learnMixedStructure(), gum::EdgeGraphPart::neighbours(), gum::ArcGraphPart::parents(), propagatesOrientationInChainOfRemainingEdges_(), propagatesRemainingOrientableEdges_(), and gum::DiGraph::topologicalOrder().

Referenced by learnBN().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ maxIter()

INLINE Size gum::ApproximationScheme::maxIter ( ) const
overridevirtualinherited

Returns the criterion on number of iterations.

Returns
Returns the criterion on number of iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 112 of file approximationScheme_inl.h.

112{ return max_iter_; }

References max_iter_.

◆ maxTime()

INLINE double gum::ApproximationScheme::maxTime ( ) const
overridevirtualinherited

Returns the timeout (in seconds).

Returns
Returns the timeout (in seconds).

Implements gum::IApproximationSchemeConfiguration.

Definition at line 133 of file approximationScheme_inl.h.

133{ return max_time_; }

References max_time_.

◆ messageApproximationScheme()

INLINE std::string gum::IApproximationSchemeConfiguration::messageApproximationScheme ( ) const
inherited

Returns the approximation scheme message.

Returns
Returns the approximation scheme message.

Definition at line 59 of file IApproximationSchemeConfiguration_inl.h.

59 {
60 std::stringstream s;
61
62 switch (stateApproximationScheme()) {
63 case ApproximationSchemeSTATE::Continue : s << "in progress"; break;
64
65 case ApproximationSchemeSTATE::Epsilon : s << "stopped with epsilon=" << epsilon(); break;
66
67 case ApproximationSchemeSTATE::Rate : s << "stopped with rate=" << minEpsilonRate(); break;
68
69 case ApproximationSchemeSTATE::Limit : s << "stopped with max iteration=" << maxIter(); break;
70
71 case ApproximationSchemeSTATE::TimeLimit : s << "stopped with timeout=" << maxTime(); break;
72
73 case ApproximationSchemeSTATE::Stopped : s << "stopped on request"; break;
74
75 case ApproximationSchemeSTATE::Undefined : s << "undefined state"; break;
76 };
77
78 return s.str();
79 }
virtual double epsilon() const =0
Returns the value of epsilon.
virtual ApproximationSchemeSTATE stateApproximationScheme() const =0
Returns the approximation scheme state.
virtual double minEpsilonRate() const =0
Returns the value of the minimal epsilon rate.
virtual Size maxIter() const =0
Returns the criterion on number of iterations.
virtual double maxTime() const =0
Returns the timeout (in seconds).

References Continue, Epsilon, epsilon(), Limit, maxIter(), maxTime(), minEpsilonRate(), Rate, stateApproximationScheme(), Stopped, TimeLimit, and Undefined.

Referenced by gum::credal::InferenceEngine< GUM_SCALAR >::getApproximationSchemeMsg(), and gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::stateApproximationScheme().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ minEpsilonRate()

INLINE double gum::ApproximationScheme::minEpsilonRate ( ) const
overridevirtualinherited

Returns the value of the minimal epsilon rate.

Returns
Returns the value of the minimal epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 92 of file approximationScheme_inl.h.

92{ return min_rate_eps_; }

References min_rate_eps_.

◆ nbrIterations()

INLINE Size gum::ApproximationScheme::nbrIterations ( ) const
overridevirtualinherited

Returns the number of iterations.

Returns
Returns the number of iterations.
Exceptions
OperationNotAllowedRaised if the scheme did not perform.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 169 of file approximationScheme_inl.h.

169 {
171 GUM_ERROR(OperationNotAllowed, "state of the approximation scheme is undefined")
172 }
173
174 return current_step_;
175 }

References current_step_, GUM_ERROR, stateApproximationScheme(), and gum::IApproximationSchemeConfiguration::Undefined.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

SimpleMiic & gum::learning::SimpleMiic::operator= ( const SimpleMiic & from)

copy operator

Definition at line 86 of file SimpleMiic.cpp.

86 {
87 ApproximationScheme::operator=(from);
88 return *this;
89 }

References SimpleMiic().

Here is the call graph for this function:

◆ operator=() [2/2]

SimpleMiic & gum::learning::SimpleMiic::operator= ( SimpleMiic && from)

move operator

Definition at line 92 of file SimpleMiic.cpp.

92 {
93 ApproximationScheme::operator=(std::move(from));
94 return *this;
95 }

References SimpleMiic().

Here is the call graph for this function:

◆ orientationLatents_()

void gum::learning::SimpleMiic::orientationLatents_ ( CorrectedMutualInformation & mutualInformation,
MixedGraph & graph,
const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > & sepSet )
protected

variant trying to propagate both orientations in a bidirected arc

Definition at line 214 of file SimpleMiic.cpp.

217 {
218 std::vector< Ranking > triples = unshieldedTriples_(graph, mutualInformation, sepSet);
219 Size steps_orient = triples.size();
220 Size past_steps = current_step_;
221
222 NodeId i = 0;
223 // list of elements that we shouldnt read again, ie elements that are
224 // eligible to
225 // rule 0 after the first time they are tested, and elements on which rule 1
226 // has been applied
227 while (i < triples.size()) {
228 // if i not in do_not_reread
229 Ranking triple = triples[i];
230 NodeId x, y, z;
231 x = std::get< 0 >(*triple.first);
232 y = std::get< 1 >(*triple.first);
233 z = std::get< 2 >(*triple.first);
234
235 std::vector< NodeId > ui;
236 std::pair< NodeId, NodeId > key = {x, y};
237 std::pair< NodeId, NodeId > rev_key = {y, x};
238 if (sepSet.exists(key)) {
239 ui = sepSet[key];
240 } else if (sepSet.exists(rev_key)) {
241 ui = sepSet[rev_key];
242 }
243 double Ixyz_ui = triple.second;
244 // try Rule 0
245 if (Ixyz_ui < 0) {
246 // if ( z not in Sep[x,y])
247 if (std::find(ui.begin(), ui.end(), z) == ui.end()) {
248 // if what we want to add already exists : pass
249 if ((graph.existsArc(x, z) || graph.existsArc(z, x))
250 && (graph.existsArc(y, z) || graph.existsArc(z, y))) {
251 ++i;
252 } else {
253 i = 0;
254 graph.eraseEdge(Edge(x, z));
255 graph.eraseEdge(Edge(y, z));
256 // checking for cycles
257 if (graph.existsArc(z, x)) {
258 graph.eraseArc(Arc(z, x));
259 try {
260 std::vector< NodeId > path = graph.directedPath(z, x);
261 // if we find a cycle, we force the competing edge
262 _latentCouples_.emplace_back(z, x);
263 } catch (const gum::NotFound&) { graph.addArc(x, z); }
264 graph.addArc(z, x);
265 } else {
266 try {
267 std::vector< NodeId > path = graph.directedPath(z, x);
268 // if we find a cycle, we force the competing edge
269 graph.addArc(z, x);
270 _latentCouples_.emplace_back(z, x);
271 } catch (const gum::NotFound&) { graph.addArc(x, z); }
272 }
273 if (graph.existsArc(z, y)) {
274 graph.eraseArc(Arc(z, y));
275 try {
276 std::vector< NodeId > path = graph.directedPath(z, y);
277 // if we find a cycle, we force the competing edge
278 _latentCouples_.emplace_back(z, y);
279 } catch (const gum::NotFound&) { graph.addArc(y, z); }
280 graph.addArc(z, y);
281 } else {
282 try {
283 std::vector< NodeId > path = graph.directedPath(z, y);
284 // if we find a cycle, we force the competing edge
285 graph.addArc(z, y);
286 _latentCouples_.emplace_back(z, y);
287
288 } catch (const gum::NotFound&) { graph.addArc(y, z); }
289 }
290 if (graph.existsArc(z, x) && _isNotLatentCouple_(z, x)) {
291 _latentCouples_.emplace_back(z, x);
292 }
293 if (graph.existsArc(z, y) && _isNotLatentCouple_(z, y)) {
294 _latentCouples_.emplace_back(z, y);
295 }
296 }
297 } else {
298 ++i;
299 }
300 } else { // try Rule 1
301 bool reset{false};
302 if (graph.existsArc(x, z) && !graph.existsArc(z, y) && !graph.existsArc(y, z)) {
303 reset = true;
304 graph.eraseEdge(Edge(z, y));
305 try {
306 std::vector< NodeId > path = graph.directedPath(y, z);
307 // if we find a cycle, we force the competing edge
308 graph.addArc(y, z);
309 _latentCouples_.emplace_back(y, z);
310 } catch (const gum::NotFound&) { graph.addArc(z, y); }
311 }
312 if (graph.existsArc(y, z) && !graph.existsArc(z, x) && !graph.existsArc(x, z)) {
313 reset = true;
314 graph.eraseEdge(Edge(z, x));
315 try {
316 std::vector< NodeId > path = graph.directedPath(x, z);
317 // if we find a cycle, we force the competing edge
318 graph.addArc(x, z);
319 _latentCouples_.emplace_back(x, z);
320 } catch (const gum::NotFound&) { graph.addArc(z, x); }
321 }
322
323 if (reset) {
324 i = 0;
325 } else {
326 ++i;
327 }
328 } // if rule 0 or rule 1
329 if (onProgress.hasListener()) {
331 ((current_step_ + i) * 100) / (past_steps + steps_orient),
332 0.,
333 timer_.step());
334 }
335 } // while
336
337 // erasing the the double headed arcs
338 for (const Arc& arc: _latentCouples_) {
339 graph.eraseArc(Arc(arc.head(), arc.tail()));
340 }
341 }
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}...
std::pair< ThreePoints *, double > Ranking
Definition Miic.h:90

References _isNotLatentCouple_(), _latentCouples_, gum::DiGraph::addArc(), gum::ApproximationScheme::current_step_, gum::ArcGraphPart::directedPath(), gum::ArcGraphPart::eraseArc(), gum::EdgeGraphPart::eraseEdge(), gum::ArcGraphPart::existsArc(), GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, gum::ApproximationScheme::timer_, and unshieldedTriples_().

Here is the call graph for this function:

◆ orientationMiic_()

void gum::learning::SimpleMiic::orientationMiic_ ( CorrectedMutualInformation & mutualInformation,
MixedGraph & graph,
const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > & sepSet )
protected

Orientation phase from the MIIC algorithm, returns a mixed graph that may contain circles.

Orientation protocol of MIIC.

Parameters
mutualInformationA mutual information instance that will do the computations and has loaded the database.
graphthe MixedGraph returned from the previous phase
sepSetthe separation set for independent couples, built during the previous phase

Definition at line 344 of file SimpleMiic.cpp.

347 {
348 // structure to store the orientations marks -, o, or >,
349 // Considers the head of the arc/edge first node -* second node
350 HashTable< std::pair< NodeId, NodeId >, char > marks = _initialMarks_;
351
352 // marks always correspond to the head of the arc/edge. - is for a forbidden
353 // arc, > for a mandatory arc
354 // we start by adding the mandatory arcs
355 for (auto iter = marks.begin(); iter != marks.end(); ++iter) {
356 if (graph.existsEdge(iter.key().first, iter.key().second) && iter.val() == '>') {
357 graph.eraseEdge(Edge(iter.key().first, iter.key().second));
358 graph.addArc(iter.key().first, iter.key().second);
359 }
360 }
361
362 std::vector< ProbabilisticRanking > proba_triples
363 = unshieldedTriplesMiic_(graph, mutualInformation, sepSet, marks);
364
365 const Size steps_orient = proba_triples.size();
366 Size past_steps = current_step_;
367
369 if (steps_orient > 0) { best = proba_triples[0]; }
370
371 while (!proba_triples.empty() && std::max(std::get< 2 >(best), std::get< 3 >(best)) > 0.5) {
372 const NodeId x = std::get< 0 >(*std::get< 0 >(best));
373 const NodeId y = std::get< 1 >(*std::get< 0 >(best));
374 const NodeId z = std::get< 2 >(*std::get< 0 >(best));
375
376 const double i3 = std::get< 1 >(best);
377
378 const double p1 = std::get< 2 >(best);
379 const double p2 = std::get< 3 >(best);
380 if (i3 <= 0) {
381 _orientingVstructureMiic_(graph, marks, x, y, z, p1, p2);
382 } else {
383 _propagatingOrientationMiic_(graph, marks, x, y, z, p1, p2);
384 }
385
386 delete std::get< 0 >(best);
387 proba_triples.erase(proba_triples.begin());
388 // actualisation of the list of triples
389 proba_triples = updateProbaTriples_(graph, proba_triples);
390
391 if (!proba_triples.empty()) best = proba_triples[0];
392
394 if (onProgress.hasListener()) {
396 (current_step_ * 100) / (steps_orient + past_steps),
397 0.,
398 timer_.step());
399 }
400 } // while
401
402 // erasing the double headed arcs
403 GUM_TRACE(_latentCouples_)
404 for (auto iter = _latentCouples_.rbegin(); iter != _latentCouples_.rend(); ++iter) {
405 graph.eraseArc(Arc(iter->head(), iter->tail()));
406 if (_existsDirectedPath_(graph, iter->head(), iter->tail())) {
407 // if we find a cycle, we force the competing edge
408 graph.addArc(iter->head(), iter->tail());
409 graph.eraseArc(Arc(iter->tail(), iter->head()));
410 *iter = Arc(iter->head(), iter->tail());
411 }
412 }
413
414 if (onProgress.hasListener()) { GUM_EMIT3(onProgress, 100, 0., timer_.step()); }
415 }
void _propagatingOrientationMiic_(MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, char > &marks, NodeId x, NodeId y, NodeId z, double p1, double p2)
void _orientingVstructureMiic_(MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, char > &marks, NodeId x, NodeId y, NodeId z, double p1, double p2)
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}...
std::vector< ProbabilisticRanking > updateProbaTriples_(const MixedGraph &graph, std::vector< ProbabilisticRanking > probaTriples)
Gets the orientation probabilities like MIIC for the orientation phase.
std::tuple< ThreePoints *, double, double, double > ProbabilisticRanking
Definition Miic.h:92

References _existsDirectedPath_(), _initialMarks_, _latentCouples_, _orientingVstructureMiic_(), _propagatingOrientationMiic_(), gum::DiGraph::addArc(), gum::HashTable< Key, Val >::begin(), gum::ApproximationScheme::current_step_, gum::HashTable< Key, Val >::end(), gum::ArcGraphPart::eraseArc(), gum::EdgeGraphPart::eraseEdge(), gum::EdgeGraphPart::existsEdge(), GUM_EMIT3, gum::IApproximationSchemeConfiguration::onProgress, gum::ApproximationScheme::timer_, unshieldedTriplesMiic_(), and updateProbaTriples_().

Referenced by learnMixedStructure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ periodSize()

INLINE Size gum::ApproximationScheme::periodSize ( ) const
overridevirtualinherited

Returns the period size.

Returns
Returns the period size.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 155 of file approximationScheme_inl.h.

155{ return period_size_; }
Size period_size_
Checking criteria frequency.

References period_size_.

◆ propagatesOrientationInChainOfRemainingEdges_()

void gum::learning::SimpleMiic::propagatesOrientationInChainOfRemainingEdges_ ( MixedGraph & graph)
protected

heuristic for remaining edges when everything else has been tried

Definition at line 746 of file SimpleMiic.cpp.

746 {
747 // then decide the orientation for remaining edges
748 while (!essentialGraph.edges().empty()) {
749 const auto& edge = *(essentialGraph.edges().begin());
750 NodeId root = edge.first();
751 Size size_children_root = essentialGraph.children(root).size();
752 NodeSet visited;
753 NodeSet stack{root};
754 // check the best root for the set of neighbours
755 while (!stack.empty()) {
756 NodeId next = *(stack.begin());
757 stack.erase(next);
758 if (visited.contains(next)) continue;
759 if (essentialGraph.children(next).size() > size_children_root) {
760 size_children_root = essentialGraph.children(next).size();
761 root = next;
762 }
763 for (const auto n: essentialGraph.neighbours(next))
764 if (!stack.contains(n) && !visited.contains(n)) stack.insert(n);
765 visited.insert(next);
766 }
767 // orientation now
768 visited.clear();
769 stack.clear();
770 stack.insert(root);
771 while (!stack.empty()) {
772 NodeId next = *(stack.begin());
773 stack.erase(next);
774 if (visited.contains(next)) continue;
775 const auto nei = essentialGraph.neighbours(next);
776 for (const auto n: nei) {
777 if (!stack.contains(n) && !visited.contains(n)) stack.insert(n);
778 // GUM_TRACE(" + amap reasonably orientation for " << n << "->" << next);
779 if (propagatesRemainingOrientableEdges_(essentialGraph, next)) continue;
780 else essentialGraph.eraseEdge(Edge(n, next));
781 essentialGraph.addArc(n, next);
782 }
783 visited.insert(next);
784 }
785 }
786 }
void clear()
Removes all the elements, if any, from the set.
Definition set_tpl.h:338
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...

References gum::DiGraph::addArc(), gum::Set< Key >::begin(), gum::ArcGraphPart::children(), gum::Set< Key >::clear(), gum::Set< Key >::contains(), gum::EdgeGraphPart::edges(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), gum::EdgeGraphPart::eraseEdge(), gum::Set< Key >::insert(), gum::EdgeGraphPart::neighbours(), propagatesRemainingOrientableEdges_(), and gum::Set< Key >::size().

Referenced by learnStructure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ propagatesRemainingOrientableEdges_()

bool gum::learning::SimpleMiic::propagatesRemainingOrientableEdges_ ( MixedGraph & graph,
NodeId xj )
protected

Propagates the orientation from a node to its neighbours.

Definition at line 789 of file SimpleMiic.cpp.

789 {
790 bool res = false;
791 const auto neighbours = graph.neighbours(xj);
792 for (auto& xi: neighbours) {
793 bool i_j = isOrientable_(graph, xi, xj);
794 bool j_i = isOrientable_(graph, xj, xi);
795 if (i_j || j_i) {
796 // GUM_TRACE(" + Removing edge (" << xi << "," << xj << ")")
797 graph.eraseEdge(Edge(xi, xj));
798 res = true;
799 }
800 if (i_j) {
801 // GUM_TRACE(" + add arc (" << xi << "," << xj << ")")
802 graph.addArc(xi, xj);
804 }
805 if (j_i) {
806 // GUM_TRACE(" + add arc (" << xi << "," << xj << ")")
807 graph.addArc(xj, xi);
809 }
810 if (i_j && j_i) {
811 GUM_TRACE(" + add arc (" << xi << "," << xj << ")")
812 _latentCouples_.emplace_back(xi, xj);
813 }
814 }
815
816 return res;
817 }
bool isOrientable_(const MixedGraph &graph, NodeId xi, NodeId xj) const

References _latentCouples_, gum::DiGraph::addArc(), gum::EdgeGraphPart::eraseEdge(), isOrientable_(), gum::EdgeGraphPart::neighbours(), and propagatesRemainingOrientableEdges_().

Referenced by learnPDAG(), learnStructure(), propagatesOrientationInChainOfRemainingEdges_(), and propagatesRemainingOrientableEdges_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remainingBurnIn()

INLINE Size gum::ApproximationScheme::remainingBurnIn ( ) const
inherited

Returns the remaining burn in.

Returns
Returns the remaining burn in.

Definition at line 212 of file approximationScheme_inl.h.

212 {
213 if (burn_in_ > current_step_) {
214 return burn_in_ - current_step_;
215 } else {
216 return 0;
217 }
218 }
Size burn_in_
Number of iterations before checking stopping criteria.

References burn_in_, and current_step_.

◆ setEpsilon()

INLINE void gum::ApproximationScheme::setEpsilon ( double eps)
overridevirtualinherited

Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|.

If the criterion was disabled it will be enabled.

Parameters
epsThe new epsilon value.
Exceptions
OutOfBoundsRaised if eps < 0.

Implements gum::IApproximationSchemeConfiguration.

Reimplemented in gum::learning::EMApproximationScheme.

Definition at line 63 of file approximationScheme_inl.h.

63 {
64 if (eps < 0.) { GUM_ERROR(OutOfBounds, "eps should be >=0") }
65
66 eps_ = eps;
67 enabled_eps_ = true;
68 }

References enabled_eps_, eps_, and GUM_ERROR.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsSampling< GUM_SCALAR >::GibbsSampling(), gum::learning::GreedyHillClimbing::GreedyHillClimbing(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::EMApproximationScheme::setEpsilon().

Here is the caller graph for this function:

◆ setMaxIter()

INLINE void gum::ApproximationScheme::setMaxIter ( Size max)
overridevirtualinherited

Stopping criterion on number of iterations.

If the criterion was disabled it will be enabled.

Parameters
maxThe maximum number of iterations.
Exceptions
OutOfBoundsRaised if max <= 1.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 105 of file approximationScheme_inl.h.

105 {
106 if (max < 1) { GUM_ERROR(OutOfBounds, "max should be >=1") }
107 max_iter_ = max;
108 enabled_max_iter_ = true;
109 }

References enabled_max_iter_, GUM_ERROR, and max_iter_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), and gum::SamplingInference< GUM_SCALAR >::SamplingInference().

Here is the caller graph for this function:

◆ setMaxTime()

INLINE void gum::ApproximationScheme::setMaxTime ( double timeout)
overridevirtualinherited

Stopping criterion on timeout.

If the criterion was disabled it will be enabled.

Parameters
timeoutThe timeout value in seconds.
Exceptions
OutOfBoundsRaised if timeout <= 0.0.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 126 of file approximationScheme_inl.h.

126 {
127 if (timeout <= 0.) { GUM_ERROR(OutOfBounds, "timeout should be >0.") }
128 max_time_ = timeout;
129 enabled_max_time_ = true;
130 }

References enabled_max_time_, GUM_ERROR, and max_time_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), and gum::SamplingInference< GUM_SCALAR >::SamplingInference().

Here is the caller graph for this function:

◆ setMinEpsilonRate()

INLINE void gum::ApproximationScheme::setMinEpsilonRate ( double rate)
overridevirtualinherited

Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|).

If the criterion was disabled it will be enabled

Parameters
rateThe minimal epsilon rate.
Exceptions
OutOfBoundsif rate<0

Implements gum::IApproximationSchemeConfiguration.

Reimplemented in gum::learning::EMApproximationScheme.

Definition at line 84 of file approximationScheme_inl.h.

84 {
85 if (rate < 0) { GUM_ERROR(OutOfBounds, "rate should be >=0") }
86
87 min_rate_eps_ = rate;
89 }

References enabled_min_rate_eps_, GUM_ERROR, and min_rate_eps_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsSampling< GUM_SCALAR >::GibbsSampling(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::EMApproximationScheme::setMinEpsilonRate().

Here is the caller graph for this function:

◆ setPeriodSize()

INLINE void gum::ApproximationScheme::setPeriodSize ( Size p)
overridevirtualinherited

How many samples between two stopping is enable.

Parameters
pThe new period value.
Exceptions
OutOfBoundsRaised if p < 1.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 149 of file approximationScheme_inl.h.

149 {
150 if (p < 1) { GUM_ERROR(OutOfBounds, "p should be >=1") }
151
152 period_size_ = p;
153 }

References GUM_ERROR, and period_size_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), and gum::SamplingInference< GUM_SCALAR >::SamplingInference().

Here is the caller graph for this function:

◆ setVerbosity()

INLINE void gum::ApproximationScheme::setVerbosity ( bool v)
overridevirtualinherited

Set the verbosity on (true) or off (false).

Parameters
vIf true, then verbosity is turned on.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 158 of file approximationScheme_inl.h.

158{ verbosity_ = v; }
bool verbosity_
If true, verbosity is enabled.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), and gum::SamplingInference< GUM_SCALAR >::SamplingInference().

Here is the caller graph for this function:

◆ startOfPeriod()

INLINE bool gum::ApproximationScheme::startOfPeriod ( ) const
inherited

Returns true if we are at the beginning of a period (compute error is mandatory).

Returns
Returns true if we are at the beginning of a period (compute error is mandatory).

Definition at line 199 of file approximationScheme_inl.h.

199 {
200 if (current_step_ < burn_in_) { return false; }
201
202 if (period_size_ == 1) { return true; }
203
204 return ((current_step_ - burn_in_) % period_size_ == 0);
205 }

References burn_in_, and current_step_.

◆ stateApproximationScheme()

INLINE IApproximationSchemeConfiguration::ApproximationSchemeSTATE gum::ApproximationScheme::stateApproximationScheme ( ) const
overridevirtualinherited

Returns the approximation scheme state.

Returns
Returns the approximation scheme state.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 164 of file approximationScheme_inl.h.

164 {
165 return current_state_;
166 }

References current_state_.

Referenced by history(), and nbrIterations().

Here is the caller graph for this function:

◆ stopApproximationScheme()

INLINE void gum::ApproximationScheme::stopApproximationScheme ( )
inherited

Stop the approximation scheme.

Definition at line 221 of file approximationScheme_inl.h.

Referenced by gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), and gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceNodeToNeighbours_().

Here is the caller graph for this function:

◆ stopScheme_()

INLINE void gum::ApproximationScheme::stopScheme_ ( ApproximationSchemeSTATE new_state)
privateinherited

Stop the scheme given a new state.

Parameters
new_stateThe scheme new state.

Definition at line 301 of file approximationScheme_inl.h.

301 {
302 if (new_state == ApproximationSchemeSTATE::Continue) { return; }
303
304 if (new_state == ApproximationSchemeSTATE::Undefined) { return; }
305
306 current_state_ = new_state;
307 timer_.pause();
308
309 if (onStop.hasListener()) { GUM_EMIT1(onStop, messageApproximationScheme()); }
310 }
Signaler1< const std::string & > onStop
Criteria messageApproximationScheme.
#define GUM_EMIT1(signal, arg1)
Definition signaler1.h:61

References gum::IApproximationSchemeConfiguration::Continue, current_state_, and gum::IApproximationSchemeConfiguration::Undefined.

Referenced by gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::disableMaxIter(), gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::disableMaxTime(), gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::isEnabledMaxIter(), gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::maxTime(), and gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::setPeriodSize().

Here is the caller graph for this function:

◆ unshieldedTriples_()

std::vector< Ranking > gum::learning::SimpleMiic::unshieldedTriples_ ( const MixedGraph & graph,
CorrectedMutualInformation & mutualInformation,
const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > & sepSet )
protected

gets the list of unshielded triples in the graph in decreasing value of |I'(x, y, z|{ui})|

Definition at line 494 of file SimpleMiic.cpp.

497 {
498 std::vector< Ranking > triples;
499 for (NodeId z: graph) {
500 for (NodeId x: graph.neighbours(z)) {
501 for (NodeId y: graph.neighbours(z)) {
502 if (y < x && !graph.existsEdge(x, y)) {
503 std::vector< NodeId > ui;
504 std::pair< NodeId, NodeId > key = {x, y};
505 std::pair< NodeId, NodeId > rev_key = {y, x};
506 if (sepSet.exists(key)) {
507 ui = sepSet[key];
508 } else if (sepSet.exists(rev_key)) {
509 ui = sepSet[rev_key];
510 }
511 // remove z from ui if it's present
512 const auto iter_z_place = std::find(ui.begin(), ui.end(), z);
513 if (iter_z_place != ui.end()) { ui.erase(iter_z_place); }
514
515 double Ixyz_ui = mutualInformation.score(x, y, z, ui);
516 Ranking triple;
517 auto tup = new ThreePoints{x, y, z};
518 triple.first = tup;
519 triple.second = Ixyz_ui;
520 triples.push_back(triple);
521 }
522 }
523 }
524 }
525 std::sort(triples.begin(), triples.end(), GreaterAbsPairOn2nd());
526 return triples;
527 }
std::tuple< NodeId, NodeId, NodeId > ThreePoints
Definition Miic.h:89

References gum::EdgeGraphPart::existsEdge(), gum::EdgeGraphPart::neighbours(), and gum::learning::CorrectedMutualInformation::score().

Referenced by orientationLatents_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unshieldedTriplesMiic_()

std::vector< ProbabilisticRanking > gum::learning::SimpleMiic::unshieldedTriplesMiic_ ( const MixedGraph & graph,
CorrectedMutualInformation & mutualInformation,
const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > & sepSet,
HashTable< std::pair< NodeId, NodeId >, char > & marks )
protected

gets the list of unshielded triples in the graph in decreasing value of |I'(x, y, z|{ui})|, prepares the orientation matrix for MIIC

Definition at line 531 of file SimpleMiic.cpp.

535 {
536 std::vector< ProbabilisticRanking > triples;
537 for (NodeId z: graph) {
538 for (NodeId x: graph.neighbours(z)) {
539 for (NodeId y: graph.neighbours(z)) {
540 if (y < x && !graph.existsEdge(x, y)) {
541 std::vector< NodeId > ui;
542 std::pair< NodeId, NodeId > key = {x, y};
543 std::pair< NodeId, NodeId > rev_key = {y, x};
544 if (sepSet.exists(key)) {
545 ui = sepSet[key];
546 } else if (sepSet.exists(rev_key)) {
547 ui = sepSet[rev_key];
548 }
549 // remove z from ui if it's present
550 const auto iter_z_place = std::find(ui.begin(), ui.end(), z);
551 if (iter_z_place != ui.end()) { ui.erase(iter_z_place); }
552
553 const double Ixyz_ui = mutualInformation.score(x, y, z, ui);
554 auto tup = new ThreePoints{x, y, z};
555 ProbabilisticRanking triple{tup, Ixyz_ui, 0.5, 0.5};
556 triples.push_back(triple);
557 if (!marks.exists({x, z})) { marks.insert({x, z}, 'o'); }
558 if (!marks.exists({z, x})) { marks.insert({z, x}, 'o'); }
559 if (!marks.exists({y, z})) { marks.insert({y, z}, 'o'); }
560 if (!marks.exists({z, y})) { marks.insert({z, y}, 'o'); }
561 }
562 }
563 }
564 }
565 triples = updateProbaTriples_(graph, triples);
566 std::sort(triples.begin(), triples.end(), GreaterTupleOnLast());
567 return triples;
568 }

References gum::EdgeGraphPart::existsEdge(), gum::EdgeGraphPart::neighbours(), gum::learning::CorrectedMutualInformation::score(), and updateProbaTriples_().

Referenced by orientationMiic_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateApproximationScheme()

INLINE void gum::ApproximationScheme::updateApproximationScheme ( unsigned int incr = 1)
inherited

Update the scheme w.r.t the new error and increment steps.

Parameters
incrThe new increment steps.

Definition at line 208 of file approximationScheme_inl.h.

208 {
209 current_step_ += incr;
210 }

References current_step_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), gum::SamplingInference< GUM_SCALAR >::loopApproxInference_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceByOrderedArcs_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceByRandomOrder_(), and gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceNodeToNeighbours_().

Here is the caller graph for this function:

◆ updateProbaTriples_()

std::vector< ProbabilisticRanking > gum::learning::SimpleMiic::updateProbaTriples_ ( const MixedGraph & graph,
std::vector< ProbabilisticRanking > probaTriples )
protected

Gets the orientation probabilities like MIIC for the orientation phase.

Definition at line 572 of file SimpleMiic.cpp.

573 {
574 for (auto& triple: probaTriples) {
575 NodeId x, y, z;
576 x = std::get< 0 >(*std::get< 0 >(triple));
577 y = std::get< 1 >(*std::get< 0 >(triple));
578 z = std::get< 2 >(*std::get< 0 >(triple));
579 const double Ixyz = std::get< 1 >(triple);
580 double Pxz = std::get< 2 >(triple);
581 double Pyz = std::get< 3 >(triple);
582
583 if (Ixyz <= 0) {
584 const double expo = std::exp(Ixyz);
585 const double P0 = (1 + expo) / (1 + 3 * expo);
586 // distinguish between the initialization and the update process
587 if (Pxz == Pyz && Pyz == 0.5) {
588 std::get< 2 >(triple) = P0;
589 std::get< 3 >(triple) = P0;
590 } else {
591 if (graph.existsArc(x, z) && Pxz >= P0) {
592 std::get< 3 >(triple) = Pxz * (1 / (1 + expo) - 0.5) + 0.5;
593 } else if (graph.existsArc(y, z) && Pyz >= P0) {
594 std::get< 2 >(triple) = Pyz * (1 / (1 + expo) - 0.5) + 0.5;
595 }
596 }
597 } else {
598 const double expo = std::exp(-Ixyz);
599 if (graph.existsArc(x, z) && Pxz >= 0.5) {
600 std::get< 3 >(triple) = Pxz * (1 / (1 + expo) - 0.5) + 0.5;
601 } else if (graph.existsArc(y, z) && Pyz >= 0.5) {
602 std::get< 2 >(triple) = Pyz * (1 / (1 + expo) - 0.5) + 0.5;
603 }
604 }
605 }
606 std::sort(probaTriples.begin(), probaTriples.end(), GreaterTupleOnLast());
607 return probaTriples;
608 }

References gum::ArcGraphPart::existsArc().

Referenced by orientationMiic_(), and unshieldedTriplesMiic_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verbosity()

INLINE bool gum::ApproximationScheme::verbosity ( ) const
overridevirtualinherited

Returns true if verbosity is enabled.

Returns
Returns true if verbosity is enabled.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 160 of file approximationScheme_inl.h.

160{ return verbosity_; }

References verbosity_.

Referenced by ApproximationScheme(), and gum::learning::EMApproximationScheme::EMApproximationScheme().

Here is the caller graph for this function:

Member Data Documentation

◆ _arcProbas_

ArcProperty< double > gum::learning::SimpleMiic::_arcProbas_
private

Storing the propabilities for each arc set in the graph.

Definition at line 299 of file SimpleMiic.h.

Referenced by _orientingVstructureMiic_(), and _propagatingOrientationMiic_().

◆ _emptySet_

const std::vector< NodeId > gum::learning::SimpleMiic::_emptySet_
private

an empty conditioning set

Definition at line 291 of file SimpleMiic.h.

Referenced by initiation_().

◆ _initialMarks_

HashTable< std::pair< NodeId, NodeId >, char > gum::learning::SimpleMiic::_initialMarks_
private

Initial marks for the orientation phase, used to convey constraints.

Definition at line 302 of file SimpleMiic.h.

Referenced by addConstraints(), isForbidenArc_(), and orientationMiic_().

◆ _latentCouples_

std::vector< Arc > gum::learning::SimpleMiic::_latentCouples_
private

◆ _maxLog_

int gum::learning::SimpleMiic::_maxLog_ = 100
private

Fixes the maximum log that we accept in exponential computations.

Definition at line 289 of file SimpleMiic.h.

Referenced by SimpleMiic(), SimpleMiic(), and findBestContributor_().

◆ _size_

Size gum::learning::SimpleMiic::_size_
private

size of the database

Definition at line 296 of file SimpleMiic.h.

Referenced by SimpleMiic(), SimpleMiic(), SimpleMiic(), and SimpleMiic().

◆ burn_in_

Size gum::ApproximationScheme::burn_in_
protectedinherited

◆ current_epsilon_

double gum::ApproximationScheme::current_epsilon_
protectedinherited

Current epsilon.

Definition at line 378 of file approximationScheme.h.

Referenced by initApproximationScheme().

◆ current_rate_

double gum::ApproximationScheme::current_rate_
protectedinherited

Current rate.

Definition at line 384 of file approximationScheme.h.

Referenced by initApproximationScheme().

◆ current_state_

ApproximationSchemeSTATE gum::ApproximationScheme::current_state_
protectedinherited

The current state.

Definition at line 393 of file approximationScheme.h.

Referenced by ApproximationScheme(), initApproximationScheme(), stateApproximationScheme(), and stopScheme_().

◆ current_step_

◆ enabled_eps_

bool gum::ApproximationScheme::enabled_eps_
protectedinherited

If true, the threshold convergence is enabled.

Definition at line 402 of file approximationScheme.h.

Referenced by ApproximationScheme(), disableEpsilon(), enableEpsilon(), isEnabledEpsilon(), and setEpsilon().

◆ enabled_max_iter_

bool gum::ApproximationScheme::enabled_max_iter_
protectedinherited

If true, the maximum iterations stopping criterion is enabled.

Definition at line 420 of file approximationScheme.h.

Referenced by ApproximationScheme(), disableMaxIter(), enableMaxIter(), isEnabledMaxIter(), and setMaxIter().

◆ enabled_max_time_

bool gum::ApproximationScheme::enabled_max_time_
protectedinherited

If true, the timeout is enabled.

Definition at line 414 of file approximationScheme.h.

Referenced by ApproximationScheme(), continueApproximationScheme(), disableMaxTime(), enableMaxTime(), isEnabledMaxTime(), and setMaxTime().

◆ enabled_min_rate_eps_

bool gum::ApproximationScheme::enabled_min_rate_eps_
protectedinherited

If true, the minimal threshold for epsilon rate is enabled.

Definition at line 408 of file approximationScheme.h.

Referenced by ApproximationScheme(), disableMinEpsilonRate(), enableMinEpsilonRate(), isEnabledMinEpsilonRate(), and setMinEpsilonRate().

◆ eps_

double gum::ApproximationScheme::eps_
protectedinherited

Threshold for convergence.

Definition at line 399 of file approximationScheme.h.

Referenced by ApproximationScheme(), epsilon(), and setEpsilon().

◆ history_

std::vector< double > gum::ApproximationScheme::history_
protectedinherited

The scheme history, used only if verbosity == true.

Definition at line 396 of file approximationScheme.h.

◆ last_epsilon_

double gum::ApproximationScheme::last_epsilon_
protectedinherited

Last epsilon value.

Definition at line 381 of file approximationScheme.h.

◆ max_iter_

Size gum::ApproximationScheme::max_iter_
protectedinherited

The maximum iterations.

Definition at line 417 of file approximationScheme.h.

Referenced by ApproximationScheme(), maxIter(), and setMaxIter().

◆ max_time_

double gum::ApproximationScheme::max_time_
protectedinherited

The timeout.

Definition at line 411 of file approximationScheme.h.

Referenced by ApproximationScheme(), maxTime(), and setMaxTime().

◆ min_rate_eps_

double gum::ApproximationScheme::min_rate_eps_
protectedinherited

Threshold for the epsilon rate.

Definition at line 405 of file approximationScheme.h.

Referenced by ApproximationScheme(), minEpsilonRate(), and setMinEpsilonRate().

◆ onProgress

◆ onStop

Signaler1< const std::string& > gum::IApproximationSchemeConfiguration::onStop
inherited

Criteria messageApproximationScheme.

Definition at line 83 of file IApproximationSchemeConfiguration.h.

Referenced by gum::learning::IBNLearner::distributeStop().

◆ period_size_

Size gum::ApproximationScheme::period_size_
protectedinherited

Checking criteria frequency.

Definition at line 426 of file approximationScheme.h.

Referenced by ApproximationScheme(), periodSize(), and setPeriodSize().

◆ timer_

◆ verbosity_

bool gum::ApproximationScheme::verbosity_
protectedinherited

If true, verbosity is enabled.

Definition at line 429 of file approximationScheme.h.

Referenced by ApproximationScheme(), and verbosity().


The documentation for this class was generated from the following files: