aGrUM 3.1.1
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<GUM_Numeric 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

Signaler< Size, double, doubleonProgress
 Progression, error and time.
Signaler< std::string_view > 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)
 Updates orientation probabilities for the remaining unoriented triples.
bool propagatesRemainingOrientableEdges_ (MixedGraph &graph, NodeId xj)
 Tries to orient edges incident to xj using Meek rules.
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 probabilities 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 87 of file IApproximationSchemeConfiguration.h.

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

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:288
SimpleMiic()
default constructor
Size _size_
size of the database
Definition SimpleMiic.h:295

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 851 of file SimpleMiic.cpp.

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

References gum::List< Val >::empty(), gum::Set< Key >::exists(), gum::List< Val >::front(), gum::Set< Key >::insert(), 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 837 of file SimpleMiic.cpp.

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

References _existsDirectedPath_().

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 1056 of file SimpleMiic.cpp.

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

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 888 of file SimpleMiic.cpp.

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

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 983 of file SimpleMiic.cpp.

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

References _arcProbas_, _existsDirectedPath_(), and _latentCouples_.

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 833 of file SimpleMiic.cpp.

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

References _initialMarks_.

◆ continueApproximationScheme()

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 69 of file approximationScheme.cpp.

69 {
70 // For coherence, we fix the time used in the method
71
72 double timer_step = timer_.step();
73
75 if (timer_step > max_time_) {
77 return false;
78 }
79 }
80
81 if (!startOfPeriod()) { return true; }
82
85 OperationNotAllowed,
86 "state of the approximation scheme is not correct : " << messageApproximationScheme());
87 }
88
89 if (verbosity()) { history_.push_back(error); }
90
92 if (current_step_ >= max_iter_) {
94 return false;
95 }
96 }
97
99 current_epsilon_ = error; // eps rate isEnabled needs it so affectation was
100 // moved from eps isEnabled below
101
102 if (enabled_eps_) {
103 if (current_epsilon_ <= eps_) {
105 return false;
106 }
107 }
108
109 if (last_epsilon_ >= 0.) {
110 if (current_epsilon_ > .0) {
111 // ! current_epsilon_ can be 0. AND epsilon
112 // isEnabled can be disabled !
114 }
115 // limit with current eps ---> 0 is | 1 - ( last_eps / 0 ) | --->
116 // infinity the else means a return false if we isEnabled the rate below,
117 // as we would have returned false if epsilon isEnabled was enabled
118 else {
120 }
121
125 return false;
126 }
127 }
128 }
129
131 if (onProgress.hasListener()) {
133 }
134
135 return true;
136 } else {
137 return false;
138 }
139 }
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.
Signaler< Size, double, double > onProgress
Progression, error and time.
std::string messageApproximationScheme() const
Returns the approximation scheme message.
#define GUM_ERROR(type, msg)
Definition exceptions.h:76
#define GUM_EMIT3(signal, arg1, arg2, arg3)
Definition signaler.h:291

References gum::IApproximationSchemeConfiguration::Continue, current_epsilon_, current_rate_, current_state_, current_step_, enabled_eps_, enabled_max_iter_, enabled_max_time_, enabled_min_rate_eps_, eps_, gum::IApproximationSchemeConfiguration::Epsilon, GUM_EMIT3, GUM_ERROR, history_, last_epsilon_, gum::IApproximationSchemeConfiguration::Limit, max_iter_, max_time_, gum::IApproximationSchemeConfiguration::messageApproximationScheme(), min_rate_eps_, gum::IApproximationSchemeConfiguration::onProgress, gum::IApproximationSchemeConfiguration::Rate, startOfPeriod(), stateApproximationScheme(), stopScheme_(), gum::IApproximationSchemeConfiguration::TimeLimit, timer_, and verbosity().

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::GreedyThickThinning::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 call graph for this function:
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 137 of file approximationScheme_inl.h.

137{ return timer_.step(); }

References timer_.

◆ disableEpsilon()

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

Disable stopping criterion on epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 75 of file approximationScheme_inl.h.

75{ 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 116 of file approximationScheme_inl.h.

116{ enabled_max_iter_ = false; }

References enabled_max_iter_.

Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing(), and gum::learning::GreedyThickThinning::GreedyThickThinning().

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 140 of file approximationScheme_inl.h.

140{ enabled_max_time_ = false; }

References enabled_max_time_.

Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing(), and gum::learning::GreedyThickThinning::GreedyThickThinning().

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 96 of file approximationScheme_inl.h.

96{ enabled_min_rate_eps_ = false; }

References enabled_min_rate_eps_.

Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing(), gum::learning::GreedyThickThinning::GreedyThickThinning(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< 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 78 of file approximationScheme_inl.h.

78{ 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 119 of file approximationScheme_inl.h.

119{ 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 143 of file approximationScheme_inl.h.

143{ 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 99 of file approximationScheme_inl.h.

99{ enabled_min_rate_eps_ = true; }

References enabled_min_rate_eps_.

Referenced by gum::learning::EMApproximationScheme::EMApproximationScheme(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and gum::MCBNDistance< 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 72 of file approximationScheme_inl.h.

72{ 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 417 of file SimpleMiic.cpp.

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

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 179 of file approximationScheme_inl.h.

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

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 190 of file approximationScheme_inl.h.

190 {
192 current_step_ = 0;
194 history_.clear();
195 timer_.reset();
196 }

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

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), initApproximationScheme(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::GreedyThickThinning::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:607
const std::vector< NodeId > _emptySet_
an empty conditioning set
Definition SimpleMiic.h:290
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_, 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 82 of file approximationScheme_inl.h.

82{ 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 123 of file approximationScheme_inl.h.

123{ 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 147 of file approximationScheme_inl.h.

147{ 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 103 of file approximationScheme_inl.h.

103{ return enabled_min_rate_eps_; }

References enabled_min_rate_eps_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and gum::MCBNDistance< 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 1064 of file SimpleMiic.cpp.

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

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 712 of file SimpleMiic.cpp.

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

References _existsDirectedPath_().

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_, 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 819 of file SimpleMiic.cpp.

819 {
820 // GUM_CHECKPOINT
821 return _latentCouples_;
822 }

References _latentCouples_.

◆ learnBN()

template<GUM_Numeric 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 826 of file SimpleMiic.cpp.

828 {
830 learnStructure(selector, initial_dag));
831 }
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 613 of file SimpleMiic.cpp.

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

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

113{ 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 134 of file approximationScheme_inl.h.

134{ return max_time_; }

References max_time_.

◆ messageApproximationScheme()

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

Returns the approximation scheme message.

Returns
Returns the approximation scheme message.

Definition at line 64 of file IApproximationSchemeConfiguration.cpp.

64 {
65 switch (stateApproximationScheme()) {
66 case ApproximationSchemeSTATE::Continue : return "in progress";
67
69 return std::format("stopped with epsilon={}", epsilon());
70
72 return std::format("stopped with rate={}", minEpsilonRate());
73
75 return std::format("stopped with max iteration={}", maxIter());
76
78 return std::format("stopped with timeout={}", maxTime());
79
80 case ApproximationSchemeSTATE::Stopped : return "stopped on request";
81
82 case ApproximationSchemeSTATE::Undefined : return "undefined state";
83 }
84 return {};
85 }
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::ApproximationScheme::continueApproximationScheme(), gum::credal::InferenceEngine< GUM_SCALAR >::getApproximationSchemeMsg(), and gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::isEnabledMaxIter().

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 93 of file approximationScheme_inl.h.

93{ 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 170 of file approximationScheme_inl.h.

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

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

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and gum::MCBNDistance< 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 // if we find a directed path, we force the competing edge
260 if (graph.hasDirectedPath(z, x)) _latentCouples_.emplace_back(z, x);
261 else graph.addArc(x, z);
262 graph.addArc(z, x);
263 } else {
264 // if we find a directed path, we force the competing edge
265 if (graph.hasDirectedPath(z, x)) {
266 graph.addArc(z, x);
267 _latentCouples_.emplace_back(z, x);
268 } else {
269 graph.addArc(x, z);
270 }
271 }
272 if (graph.existsArc(z, y)) {
273 graph.eraseArc(Arc(z, y));
274 // if we find a directed path, we force the competing edge
275 if (graph.hasDirectedPath(z, y)) _latentCouples_.emplace_back(z, y);
276 else graph.addArc(y, z);
277 graph.addArc(z, y);
278 } else {
279 // if we find a directed path, we force the competing edge
280 if (graph.hasDirectedPath(z, y)) {
281 graph.addArc(z, y);
282 _latentCouples_.emplace_back(z, y);
283 } else {
284 graph.addArc(y, z);
285 }
286 }
287 if (graph.existsArc(z, x) && _isNotLatentCouple_(z, x)) {
288 _latentCouples_.emplace_back(z, x);
289 }
290 if (graph.existsArc(z, y) && _isNotLatentCouple_(z, y)) {
291 _latentCouples_.emplace_back(z, y);
292 }
293 }
294 } else {
295 ++i;
296 }
297 } else { // try Rule 1
298 bool reset{false};
299 if (graph.existsArc(x, z) && !graph.existsArc(z, y) && !graph.existsArc(y, z)) {
300 reset = true;
301 graph.eraseEdge(Edge(z, y));
302 // if we find a directed path, we force the competing edge
303 if (graph.hasDirectedPath(y, z)) {
304 graph.addArc(y, z);
305 _latentCouples_.emplace_back(y, z);
306 } else {
307 graph.addArc(z, y);
308 }
309 }
310 if (graph.existsArc(y, z) && !graph.existsArc(z, x) && !graph.existsArc(x, z)) {
311 reset = true;
312 graph.eraseEdge(Edge(z, x));
313 // if we find a directed path, we force the competing edge
314 if (graph.hasDirectedPath(x, z)) {
315 graph.addArc(x, z);
316 _latentCouples_.emplace_back(x, z);
317 } else {
318 graph.addArc(z, x);
319 }
320 }
321
322 if (reset) {
323 i = 0;
324 } else {
325 ++i;
326 }
327 } // if rule 0 or rule 1
328 if (onProgress.hasListener()) {
330 ((current_step_ + i) * 100) / (past_steps + steps_orient),
331 0.,
332 timer_.step());
333 }
334 } // while
335
336 // erasing the the double headed arcs
337 for (const Arc& arc: _latentCouples_) {
338 graph.eraseArc(Arc(arc.head(), arc.tail()));
339 }
340 }
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:72

References _isNotLatentCouple_(), _latentCouples_, gum::ApproximationScheme::current_step_, 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 343 of file SimpleMiic.cpp.

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

References _existsDirectedPath_(), _initialMarks_, _latentCouples_, _orientingVstructureMiic_(), _propagatingOrientationMiic_(), gum::HashTable< Key, Val >::begin(), gum::ApproximationScheme::current_step_, gum::HashTable< Key, Val >::end(), 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 156 of file approximationScheme_inl.h.

156{ 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 745 of file SimpleMiic.cpp.

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

Tries to orient edges incident to xj using Meek rules.

Propagates the orientation from a node to its neighbours.

Parameters
graphthe graph (modified in place)
xjthe node whose incident undirected edges are examined

Definition at line 788 of file SimpleMiic.cpp.

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

References _latentCouples_, isOrientable_(), 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 213 of file approximationScheme_inl.h.

213 {
214 if (burn_in_ > current_step_) {
215 return burn_in_ - current_step_;
216 } else {
217 return 0;
218 }
219 }
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 64 of file approximationScheme_inl.h.

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

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::learning::GreedyThickThinning::GreedyThickThinning(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), 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 106 of file approximationScheme_inl.h.

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

References enabled_max_iter_, GUM_ERROR, and max_iter_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), 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 127 of file approximationScheme_inl.h.

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

References enabled_max_time_, GUM_ERROR, and max_time_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), 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 85 of file approximationScheme_inl.h.

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

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::MCBNDistance< GUM_SCALAR >::MCBNDistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), 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 150 of file approximationScheme_inl.h.

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

References GUM_ERROR.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), 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 159 of file approximationScheme_inl.h.

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

References verbosity_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), 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 200 of file approximationScheme_inl.h.

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

Referenced by continueApproximationScheme().

Here is the caller graph for this function:

◆ 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 165 of file approximationScheme_inl.h.

165 {
166 return current_state_;
167 }

Referenced by continueApproximationScheme(), 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 222 of file approximationScheme_inl.h.

Referenced by gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::GreedyThickThinning::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 231 of file approximationScheme_inl.h.

231 {
232 if (new_state == ApproximationSchemeSTATE::Continue) { return; }
233
234 if (new_state == ApproximationSchemeSTATE::Undefined) { return; }
235
236 current_state_ = new_state;
237 timer_.pause();
238
239 if (onStop.hasListener()) { GUM_EMIT1(onStop, messageApproximationScheme()); }
240 }
Signaler< std::string_view > onStop
Criteria messageApproximationScheme.
#define GUM_EMIT1(signal, arg1)
Definition signaler.h:289

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

Referenced by continueApproximationScheme(), and gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::disableMaxIter().

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})|

Parameters
graphthe graph in which to find the triples
mutualInformationmutual information object to compute the scores
sepSethashtable storing the separation sets for pairs of variables

Definition at line 493 of file SimpleMiic.cpp.

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

References 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

Parameters
graphthe graph in which to find the triples
mutualInformationmutual information object to compute the scores
sepSethashtable storing the separation sets for pairs of variables
markshashtable containing the orientation marks for edges

Definition at line 530 of file SimpleMiic.cpp.

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

References 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

◆ updateProbaTriples_()

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

Updates orientation probabilities for the remaining unoriented triples.

Gets the orientation probabilities like MIIC for the orientation phase.

Parameters
graphthe graph in which to find the triples
probaTriplesprobabilities for the different triples to update

Definition at line 571 of file SimpleMiic.cpp.

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

Referenced by orientationMiic_(), and unshieldedTriplesMiic_().

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 161 of file approximationScheme_inl.h.

161{ return verbosity_; }

References verbosity_.

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

Here is the caller graph for this function:

Member Data Documentation

◆ _arcProbas_

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

Storing the probabilities for each arc set in the graph.

Definition at line 298 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 290 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 301 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 288 of file SimpleMiic.h.

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

◆ _size_

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

size of the database

Definition at line 295 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 continueApproximationScheme().

◆ current_rate_

double gum::ApproximationScheme::current_rate_
protectedinherited

Current rate.

Definition at line 384 of file approximationScheme.h.

Referenced by continueApproximationScheme().

◆ current_state_

ApproximationSchemeSTATE gum::ApproximationScheme::current_state_
protectedinherited

The current state.

Definition at line 393 of file approximationScheme.h.

Referenced by ApproximationScheme(), continueApproximationScheme(), and initApproximationScheme().

◆ 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(), continueApproximationScheme(), 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(), continueApproximationScheme(), 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(), continueApproximationScheme(), 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(), continueApproximationScheme(), 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.

Referenced by continueApproximationScheme().

◆ last_epsilon_

double gum::ApproximationScheme::last_epsilon_
protectedinherited

Last epsilon value.

Definition at line 381 of file approximationScheme.h.

Referenced by continueApproximationScheme().

◆ max_iter_

Size gum::ApproximationScheme::max_iter_
protectedinherited

The maximum iterations.

Definition at line 417 of file approximationScheme.h.

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

◆ max_time_

double gum::ApproximationScheme::max_time_
protectedinherited

The timeout.

Definition at line 411 of file approximationScheme.h.

Referenced by ApproximationScheme(), continueApproximationScheme(), 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(), continueApproximationScheme(), minEpsilonRate(), and setMinEpsilonRate().

◆ onProgress

◆ onStop

Signaler< std::string_view > gum::IApproximationSchemeConfiguration::onStop
inherited

Criteria messageApproximationScheme.

Definition at line 84 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(), and periodSize().

◆ timer_

◆ verbosity_

bool gum::ApproximationScheme::verbosity_
protectedinherited

If true, verbosity is enabled.

Definition at line 429 of file approximationScheme.h.

Referenced by ApproximationScheme(), setVerbosity(), and verbosity().


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