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

The Miic learning algorithm. More...

#include <Miic.h>

Inheritance diagram for gum::learning::Miic:
Collaboration diagram for gum::learning::Miic:

Public Types

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

Public Member Functions

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

Public Attributes

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

Protected Member Functions

void findBestContributor_ (NodeId x, NodeId y, const std::vector< NodeId > &ui, const MixedGraph &graph, CorrectedMutualInformation &mutualInformation, Heap< CondRanking, GreaterPairOn2nd > &rank)
 finds the best contributor node for a pair given a conditioning set
std::vector< RankingunshieldedTriples_ (const MixedGraph &graph, CorrectedMutualInformation &mutualInformation, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet)
 gets the list of unshielded triples in the graph in decreasing value of |I'(x, y, z|{ui})|
std::vector< ProbabilisticRankingunshieldedTriplesMiic_ (const MixedGraph &graph, CorrectedMutualInformation &mutualInformation, const HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, HashTable< std::pair< NodeId, NodeId >, char > &marks)
 gets the list of unshielded triples in the graph in decreasing value of |I'(x, y, z|{ui})|, prepares the orientation matrix for MIIC
std::vector< ProbabilisticRankingupdateProbaTriples_ (const MixedGraph &graph, std::vector< ProbabilisticRanking > probaTriples)
 Gets the orientation probabilities like MIIC for the orientation phase.
void orientDoubleHeadedArcs_ (MixedGraph &mg)
 Orient double headed arcs to avoid cycles.
bool isForbiddenArc_ (NodeId x, NodeId y) const
 Check constraints.
bool isForbiddenEdge_ (NodeId x, NodeId y)
bool isMaxIndegree_ (MixedGraph graph, NodeId x)
bool isArcValid_ (MixedGraph graph, NodeId x, NodeId y)
Main phases

Set a ensemble of constraints for the learning/orientation phase

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

gum::MeekRules meekRules_
 Object that can propagates orientations to non-oriented edges.
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
gum::Size _maxIndegree_
 maximum number of parents
Size _size_
 size of the database
ArcProperty< double_arcProbas_
 Storing the propabilities for each arc set in the graph.
HashTable< std::pair< NodeId, NodeId >, char > _initialMarks_
 Initial marks for the orientation phase, used to convey constraints.
gum::DAG _mandatoryGraph_
 Graph that contains the mandatories arcs.
gum::DiGraph _forbiddenGraph_
 Graph that contains the forbidden arcs.

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.

Miic allows the option of adding constraints on the skeleton construction such as: a maximum number of parents, mandatory arcs, forbidden arcs or an order between the variables.

Definition at line 126 of file Miic.h.

Member Enumeration Documentation

◆ ApproximationSchemeSTATE

The different state of an approximation scheme.

Enumerator
Undefined 
Continue 
Epsilon 
Rate 
Limit 
TimeLimit 
Stopped 

Definition at line 86 of file IApproximationSchemeConfiguration.h.

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

Constructor & Destructor Documentation

◆ Miic() [1/4]

gum::learning::Miic::Miic ( )

default constructor

Definition at line 63 of file Miic.cpp.

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

References Miic(), _maxLog_, and _size_.

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

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

◆ Miic() [2/4]

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

default constructor with maxLog

Definition at line 66 of file Miic.cpp.

66: _maxLog_(maxLog), _size_(0) { GUM_CONSTRUCTOR(Miic); }

References Miic(), _maxLog_, and _size_.

Here is the call graph for this function:

◆ Miic() [3/4]

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

copy constructor

Definition at line 69 of file Miic.cpp.

69 : ApproximationScheme(from), _size_(from._size_) {
70 GUM_CONS_CPY(Miic);
71 }
ApproximationScheme(bool verbosity=false)

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

Here is the call graph for this function:

◆ Miic() [4/4]

gum::learning::Miic::Miic ( Miic && from)

move constructor

Definition at line 74 of file Miic.cpp.

74 : ApproximationScheme(std::move(from)), _size_(from._size_) {
75 GUM_CONS_MOV(Miic);
76 }

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

Here is the call graph for this function:

◆ ~Miic()

gum::learning::Miic::~Miic ( )
override

destructor

Definition at line 79 of file Miic.cpp.

79{ GUM_DESTRUCTOR(Miic); }

References Miic().

Here is the call graph for this function:

Member Function Documentation

◆ _existsDirectedPath_()

bool gum::learning::Miic::_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 930 of file Miic.cpp.

930 {
931 // not recursive version => use a FIFO for simulating the recursion
932 List< NodeId > nodeFIFO;
933 // mark[node] = successor if visited, else mark[node] does not exist
934 Set< NodeId > mark;
935
936 mark.insert(n2);
937 nodeFIFO.pushBack(n2);
938
939 NodeId current;
940
941 while (!nodeFIFO.empty()) {
942 current = nodeFIFO.front();
943 nodeFIFO.popFront();
944
945 // check the parents
946 for (const auto new_one: graph.parents(current)) {
947 if (graph.existsArc(current,
948 new_one)) // if there is a double arc, pass
949 continue;
950
951 if (new_one == n1) { return true; }
952
953 if (mark.exists(new_one)) // if this node is already marked, do not
954 continue; // check it again
955
956 mark.insert(new_one);
957 nodeFIFO.pushBack(new_one);
958 }
959 }
960
961 return false;
962 }
Size NodeId
Type for node ids.

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

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

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

◆ _existsNonTrivialDirectedPath_()

bool gum::learning::Miic::_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 917 of file Miic.cpp.

919 {
920 for (const auto parent: graph.parents(n2)) {
921 if (graph.existsArc(n2, parent)) // if there is a double arc, pass
922 continue;
923 if (parent == n1) // trivial directed path => not recognized
924 continue;
925 if (_existsDirectedPath_(graph, n1, parent)) return true;
926 }
927 return false;
928 }
static bool _existsDirectedPath_(const MixedGraph &graph, NodeId n1, NodeId n2)
checks for directed paths in a graph, consider double arcs like edges
Definition Miic.cpp:930

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

Referenced by _orientingVstructureMiic_().

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

◆ _isNotLatentCouple_()

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

Definition at line 964 of file Miic.cpp.

964 {
965 const auto& lbeg = _latentCouples_.begin();
966 const auto& lend = _latentCouples_.end();
967
968 return (std::find(lbeg, lend, Arc(x, y)) == lend)
969 && (std::find(lbeg, lend, Arc(y, x)) == lend);
970 }
std::vector< Arc > _latentCouples_
an empty vector of arcs
Definition Miic.h:346

References _latentCouples_.

Referenced by _orientingVstructureMiic_().

Here is the caller graph for this function:

◆ _orientingVstructureMiic_()

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

Definition at line 420 of file Miic.cpp.

426 {
427 // v-structure discovery
428 if (marks[{x, z}] == 'o' && marks[{y, z}] == 'o') { // If x-z-y
429 if (!_existsNonTrivialDirectedPath_(graph, z, x)) {
430 if (isArcValid_(graph, x, z)) {
431 graph.eraseEdge(Edge(x, z));
432 graph.addArc(x, z);
433 GUM_SL_EMIT(x, z, "Add Arc " << x << " -> " << z, "V-structure Orientation")
434 // GUM_TRACE("1.a Removing edge (" << x << "," << z << ")")
435 // GUM_TRACE("1.a Adding arc (" << x << "," << z << ")")
436
437 marks[{x, z}] = '>';
438 if (graph.existsArc(z, x) && _isNotLatentCouple_(z, x)) {
439 // GUM_TRACE("Adding latent couple (" << z << "," << x << ")")
440 _latentCouples_.emplace_back(z, x);
441 }
442 if (!_arcProbas_.exists(Arc(x, z))) _arcProbas_.insert(Arc(x, z), p1);
443 }
444
445 } else {
446 graph.eraseEdge(Edge(x, z));
447 // GUM_TRACE("1.b Adding arc (" << x << "," << z << ")")
448 if (!_existsNonTrivialDirectedPath_(graph, x, z)) {
449 if (isArcValid_(graph, z, x)) {
450 graph.addArc(z, x);
451 GUM_SL_EMIT(z, x, "Add Arc " << z << " -> " << x, "V-structure Orientation")
452 // GUM_TRACE("1.b Removing edge (" << x << "," << z << ")")
453 marks[{z, x}] = '>';
454 }
455 }
456 }
457
458 if (!_existsNonTrivialDirectedPath_(graph, z, y)) {
459 if (isArcValid_(graph, y, z)) {
460 graph.eraseEdge(Edge(y, z));
461 graph.addArc(y, z);
462 GUM_SL_EMIT(y, z, "Add Arc " << y << " -> " << z, "V-structure Orientation")
463 // GUM_TRACE("1.c Removing edge (" << y << "," << z << ")")
464 // GUM_TRACE("1.c Adding arc (" << y << "," << z << ")")
465 marks[{y, z}] = '>';
466 if (graph.existsArc(z, y) && _isNotLatentCouple_(z, y)) {
467 _latentCouples_.emplace_back(z, y);
468 }
469 if (!_arcProbas_.exists(Arc(y, z))) _arcProbas_.insert(Arc(y, z), p2);
470 }
471 } else {
472 graph.eraseEdge(Edge(y, z));
473 // GUM_TRACE("1.d Removing edge (" << y << "," << z << ")")
474 if (!_existsNonTrivialDirectedPath_(graph, y, z)) {
475 if (isArcValid_(graph, z, y)) {
476 graph.addArc(z, y);
477 GUM_SL_EMIT(z, y, "Add Arc " << z << " -> " << y, "V-structure Orientation")
478 // GUM_TRACE("1.d Adding arc (" << z << "," << y << ")")
479 marks[{z, y}] = '>';
480 }
481 }
482 }
483 } else if (marks[{x, z}] == '>' && marks[{y, z}] == 'o') { // If x->z-y
484 if (!_existsNonTrivialDirectedPath_(graph, z, y)) {
485 if (isArcValid_(graph, y, z)) {
486 graph.eraseEdge(Edge(y, z));
487 graph.addArc(y, z);
488 GUM_SL_EMIT(y,
489 z,
490 "Add Arc " << y << " -> " << z,
491 "V-structure Orientation | existing "
492 << x << " -> " << z << ", then orienting " << y << " -> " << z)
493 // GUM_TRACE("2.a Removing edge (" << y << "," << z << ")")
494 // GUM_TRACE("2.a Adding arc (" << y << "," << z << ")")
495 marks[{y, z}] = '>';
496 if (graph.existsArc(z, y) && _isNotLatentCouple_(z, y)) {
497 _latentCouples_.emplace_back(z, y);
498 }
499 if (!_arcProbas_.exists(Arc(y, z))) _arcProbas_.insert(Arc(y, z), p2);
500 }
501 } else {
502 graph.eraseEdge(Edge(y, z));
503 // GUM_TRACE("2.b Removing edge (" << y << "," << z << ")")
504 if (!_existsNonTrivialDirectedPath_(graph, y, z)) {
505 if (isArcValid_(graph, z, y)) {
506 graph.addArc(z, y);
507 GUM_SL_EMIT(z,
508 y,
509 "Add Arc " << z << " -> " << y,
510 "V-structure Orientation | existing "
511 << x << " -> " << z << ", then orienting " << z << " -> " << y)
512 // GUM_TRACE("2.b Adding arc (" << y << "," << z << ")")
513 marks[{z, y}] = '>';
514 }
515 }
516 }
517
518 } else if (marks[{y, z}] == '>' && marks[{x, z}] == 'o') { // If y->z-x
519 if (!_existsNonTrivialDirectedPath_(graph, z, x)) {
520 if (isArcValid_(graph, x, z)) {
521 graph.eraseEdge(Edge(x, z));
522 graph.addArc(x, z);
523 GUM_SL_EMIT(x, z, "Add Arc " << x << " -> " << z, "V-structure Orientation")
524 // GUM_TRACE("3.a Removing edge (" << x << "," << z << ")")
525 // GUM_TRACE("3.a Adding arc (" << x << "," << z << ")")
526 marks[{x, z}] = '>';
527 if (graph.existsArc(z, x) && _isNotLatentCouple_(z, x)) {
528 _latentCouples_.emplace_back(z, x);
529 }
530 if (!_arcProbas_.exists(Arc(x, z))) _arcProbas_.insert(Arc(x, z), p1);
531 }
532
533 } else {
534 graph.eraseEdge(Edge(x, z));
535 // GUM_TRACE("3.b Removing edge (" << x << "," << z << ")")
536 if (!_existsNonTrivialDirectedPath_(graph, x, z)) {
537 if (isArcValid_(graph, z, x)) {
538 graph.addArc(z, x);
539 GUM_SL_EMIT(z, x, "Add Arc " << z << " -> " << x, "V-structure Orientation")
540 // GUM_TRACE("3.b Adding arc (" << x << "," << z << ")")
541 marks[{z, x}] = '>';
542 }
543 }
544 }
545 }
546 }
#define GUM_SL_EMIT(x, y, action, explain)
Definition Miic.h:74
bool isArcValid_(MixedGraph graph, NodeId x, NodeId y)
Definition Miic.cpp:988
ArcProperty< double > _arcProbas_
Storing the propabilities for each arc set in the graph.
Definition Miic.h:355
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...
Definition Miic.cpp:917
bool _isNotLatentCouple_(NodeId x, NodeId y)
Definition Miic.cpp:964

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

Referenced by orientationMiic_().

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

◆ _propagatingOrientationMiic_()

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

Definition at line 548 of file Miic.cpp.

554 {
555 // orientation propagation
556 if (marks[{x, z}] == '>' && marks[{y, z}] == 'o' && marks[{z, y}] != '-') {
557 graph.eraseEdge(Edge(z, y));
558 if (!_existsDirectedPath_(graph, y, z) && graph.parents(y).empty()) {
559 if (isArcValid_(graph, z, y)) {
560 graph.addArc(z, y);
561 GUM_SL_EMIT(z,
562 y,
563 "Add Arc " << z << " -> " << y,
564 "Propagation MIIC (919) | existing x -> " << z << " and " << z << " - "
565 << y)
566 // GUM_TRACE("4.a Adding arc (" << z << "," << y << ")")
567 marks[{z, y}] = '>';
568 marks[{y, z}] = '-';
569 if (!_arcProbas_.exists(Arc(z, y))) _arcProbas_.insert(Arc(z, y), p2);
570 }
571
572 } else if (!_existsDirectedPath_(graph, z, y) && graph.parents(z).empty()) {
573 if (isArcValid_(graph, y, z)) {
574 graph.addArc(y, z);
575 GUM_SL_EMIT(y, z, "Add Arc " << y << " -> " << z, "Propagation MIIC line 932 ")
576 // GUM_TRACE("4.b Adding arc (" << y << "," << z << ")")
577
578 marks[{z, y}] = '-';
579 marks[{y, z}] = '>';
580 _latentCouples_.emplace_back(y, z);
581 if (!_arcProbas_.exists(Arc(y, z))) _arcProbas_.insert(Arc(y, z), p2);
582 }
583
584 } else if (!_existsDirectedPath_(graph, y, z)) {
585 if (isArcValid_(graph, z, y)) {
586 graph.addArc(z, y);
587 GUM_SL_EMIT(z, y, "Add Arc " << z << "->" << y, "Propagation MIIC 947 ")
588 // GUM_TRACE("4.c Adding arc (" << z << "," << y << ")")
589 marks[{z, y}] = '>';
590 marks[{y, z}] = '-';
591 if (!_arcProbas_.exists(Arc(z, y))) _arcProbas_.insert(Arc(z, y), p2);
592 }
593
594 } else if (!_existsDirectedPath_(graph, z, y)) {
595 if (isArcValid_(graph, y, z)) {
596 graph.addArc(y, z);
597 GUM_SL_EMIT(z, y, "Add Arc " << z << "->" << y, "Propagation MIIC 959")
598 // GUM_TRACE("4.d Adding arc (" << y << "," << z << ")")
599
600 _latentCouples_.emplace_back(y, z);
601 marks[{z, y}] = '-';
602 marks[{y, z}] = '>';
603 if (!_arcProbas_.exists(Arc(y, z))) _arcProbas_.insert(Arc(y, z), p2);
604 }
605 }
606 } else if (marks[{y, z}] == '>' && marks[{x, z}] == 'o' && marks[{z, x}] != '-') {
607 graph.eraseEdge(Edge(z, x));
608 // GUM_TRACE("5. Removing edge (" << z << "," << x << ")")
609 if (!_existsDirectedPath_(graph, x, z) && graph.parents(x).empty()) {
610 if (isArcValid_(graph, z, x)) {
611 graph.addArc(z, x);
612 GUM_SL_EMIT(z, x, "Add Arc " << z << " -> " << x, "Propagation MIIC 977")
613 // GUM_TRACE("5.a Adding arc (" << z << "," << x << ")")
614 marks[{z, x}] = '>';
615 marks[{x, z}] = '-';
616 if (!_arcProbas_.exists(Arc(z, x))) _arcProbas_.insert(Arc(z, x), p1);
617 }
618
619 } else if (!_existsDirectedPath_(graph, z, x) && graph.parents(z).empty()) {
620 if (isArcValid_(graph, x, z)) {
621 graph.addArc(x, z);
622 GUM_SL_EMIT(x, z, "Add Arc " << x << "->" << z, "Propagation MIIC 990")
623 // GUM_TRACE("5.b Adding arc (" << x << "," << z << ")")
624 marks[{z, x}] = '-';
625 marks[{x, z}] = '>';
626 _latentCouples_.emplace_back(x, z);
627 if (!_arcProbas_.exists(Arc(x, z))) _arcProbas_.insert(Arc(x, z), p1);
628 }
629
630 } else if (!_existsDirectedPath_(graph, x, z)) {
631 if (isArcValid_(graph, z, x)) {
632 graph.addArc(z, x);
633 GUM_SL_EMIT(z, x, "Add Arc " << z << " -> " << x, "Propagation MIIC 1004")
634 // GUM_TRACE("5.c Adding arc (" << z << "," << x << ")")
635 marks[{z, x}] = '>';
636 marks[{x, z}] = '-';
637 if (!_arcProbas_.exists(Arc(z, x))) _arcProbas_.insert(Arc(z, x), p1);
638 }
639 } else if (!_existsDirectedPath_(graph, z, x)) {
640 if (isArcValid_(graph, x, z)) {
641 graph.addArc(x, z);
642 GUM_SL_EMIT(x, z, "Add Arc " << x << " -> " << z, "Propagation MIIC 1016")
643 // GUM_TRACE("5.d Adding arc (" << x << "," << z << ")")
644 marks[{z, x}] = '-';
645 marks[{x, z}] = '>';
646 _latentCouples_.emplace_back(x, z);
647 if (!_arcProbas_.exists(Arc(x, z))) _arcProbas_.insert(Arc(x, z), p1);
648 }
649 }
650 }
651 }

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

Referenced by orientationMiic_().

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

◆ addConstraints()

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

Set a ensemble of constraints for the orientation phase.

Definition at line 913 of file Miic.cpp.

913 {
914 this->_initialMarks_ = constraints;
915 }
HashTable< std::pair< NodeId, NodeId >, char > _initialMarks_
Initial marks for the orientation phase, used to convey constraints.
Definition Miic.h:358

References _initialMarks_.

◆ continueApproximationScheme()

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

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

Test the stopping criterion that are enabled.

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

Definition at line 229 of file approximationScheme_inl.h.

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

References enabled_max_time_, and timer_.

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

Here is the caller graph for this function:

◆ currentTime()

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

Returns the current running time in second.

Returns
Returns the current running time in second.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 136 of file approximationScheme_inl.h.

136{ return timer_.step(); }

References timer_.

◆ disableEpsilon()

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

Disable stopping criterion on epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 74 of file approximationScheme_inl.h.

74{ enabled_eps_ = false; }

References enabled_eps_.

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

Here is the caller graph for this function:

◆ disableMaxIter()

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

Disable stopping criterion on max iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 115 of file approximationScheme_inl.h.

115{ enabled_max_iter_ = false; }

References enabled_max_iter_.

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

Here is the caller graph for this function:

◆ disableMaxTime()

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

Disable stopping criterion on timeout.

Returns
Disable stopping criterion on timeout.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 139 of file approximationScheme_inl.h.

139{ enabled_max_time_ = false; }

References enabled_max_time_.

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

Here is the caller graph for this function:

◆ disableMinEpsilonRate()

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

Disable stopping criterion on epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 95 of file approximationScheme_inl.h.

95{ enabled_min_rate_eps_ = false; }

References enabled_min_rate_eps_.

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

Here is the caller graph for this function:

◆ enableEpsilon()

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

Enable stopping criterion on epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 77 of file approximationScheme_inl.h.

77{ enabled_eps_ = true; }

References enabled_eps_.

◆ enableMaxIter()

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

Enable stopping criterion on max iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 118 of file approximationScheme_inl.h.

118{ enabled_max_iter_ = true; }

References enabled_max_iter_.

◆ enableMaxTime()

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

Enable stopping criterion on timeout.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 142 of file approximationScheme_inl.h.

142{ enabled_max_time_ = true; }

References enabled_max_time_.

◆ enableMinEpsilonRate()

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

Enable stopping criterion on epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 98 of file approximationScheme_inl.h.

98{ enabled_min_rate_eps_ = true; }

References enabled_min_rate_eps_.

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

Here is the caller graph for this function:

◆ epsilon()

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

Returns the value of epsilon.

Returns
Returns the value of epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 71 of file approximationScheme_inl.h.

71{ return eps_; }

References eps_.

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

Here is the caller graph for this function:

◆ findBestContributor_()

void gum::learning::Miic::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 718 of file Miic.cpp.

723 {
724 double maxP = -1.0;
725 NodeId maxZ = 0;
726
727 // compute N
728 // __N = I.N();
729 const double Ixy_ui = mutualInformation.score(x, y, ui);
730
731 for (const NodeId z: graph) {
732 // if z!=x and z!=y and z not in ui
733 if (z != x && z != y && std::find(ui.begin(), ui.end(), z) == ui.end()) {
734 double Pnv;
735 double Pb;
736
737 // Computing Pnv
738 const double Ixyz_ui = mutualInformation.score(x, y, z, ui);
739 double calc_expo1 = -Ixyz_ui * M_LN2;
740 // if exponential are too high or to low, crop them at _maxLog_
741 if (calc_expo1 > _maxLog_) {
742 Pnv = 0.0;
743 } else if (calc_expo1 < -_maxLog_) {
744 Pnv = 1.0;
745 } else {
746 Pnv = 1 / (1 + std::exp(calc_expo1));
747 }
748
749 // Computing Pb
750 const double Ixz_ui = mutualInformation.score(x, z, ui);
751 const double Iyz_ui = mutualInformation.score(y, z, ui);
752
753 calc_expo1 = -(Ixz_ui - Ixy_ui) * M_LN2;
754 double calc_expo2 = -(Iyz_ui - Ixy_ui) * M_LN2;
755
756 // if exponential are too high or to low, crop them at _maxLog_
757 if (calc_expo1 > _maxLog_ || calc_expo2 > _maxLog_) {
758 Pb = 0.0;
759 } else if (calc_expo1 < -_maxLog_ && calc_expo2 < -_maxLog_) {
760 Pb = 1.0;
761 } else {
762 double expo1, expo2;
763 if (calc_expo1 < -_maxLog_) {
764 expo1 = 0.0;
765 } else {
766 expo1 = std::exp(calc_expo1);
767 }
768 if (calc_expo2 < -_maxLog_) {
769 expo2 = 0.0;
770 } else {
771 expo2 = std::exp(calc_expo2);
772 }
773 Pb = 1 / (1 + expo1 + expo2);
774 }
775
776 // Getting max(min(Pnv, pb))
777 const double min_pnv_pb = std::min(Pnv, Pb);
778 if (min_pnv_pb > maxP) {
779 maxP = min_pnv_pb;
780 maxZ = z;
781 }
782 } // if z not in (x, y)
783 } // for z in graph.nodes
784 // storing best z in rank_
785 CondRanking final;
786 auto tup = new CondThreePoints{x, y, maxZ, ui};
787 final.first = tup;
788 final.second = maxP;
789 rank.insert(final);
790 }
#define M_LN2
Definition math_utils.h:63
std::pair< CondThreePoints *, double > CondRanking
Definition Miic.h:87
std::tuple< NodeId, NodeId, NodeId, std::vector< NodeId > > CondThreePoints
Definition Miic.h:86

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

Referenced by initiation_(), and iteration_().

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

◆ history()

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

Returns the scheme history.

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 178 of file approximationScheme_inl.h.

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

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

Here is the call graph for this function:

◆ initApproximationScheme()

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

Initialise the scheme.

Definition at line 189 of file approximationScheme_inl.h.

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

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

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

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

◆ initiation_()

void gum::learning::Miic::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 204 of file Miic.cpp.

207 {
208 NodeId x, y;
209 EdgeSet edges = graph.edges();
210 Size steps_init = edges.size();
211
212 for (const Edge& edge: edges) {
213 x = edge.first();
214 y = edge.second();
215 if (isForbiddenEdge_(x, y)) { // Erase Forbidden edges
216 GUM_SL_EMIT(x, y, "Remove " << x << " - " << y, " Constraints : Forbidden edge")
217 graph.eraseEdge(edge);
218 }
219
220 else {
221 double Ixy = mutualInformation.score(x, y);
222
223 if (Ixy <= 0) { //< K
224 graph.eraseEdge(edge);
225 GUM_SL_EMIT(x,
226 y,
227 "Remove " << x << " - " << y,
228 "Independent based on Mutual Information :" << Ixy)
229
230 sepSet.insert(std::make_pair(x, y), _emptySet_);
231 } else {
232 findBestContributor_(x, y, _emptySet_, graph, mutualInformation, rank);
233 GUM_SL_EMIT(x,
234 y,
235 "Keep " << x << " - " << y,
236 "Dependent based on Mutual Information :" << Ixy)
237 }
238
240 if (onProgress.hasListener()) {
241 GUM_EMIT3(onProgress, (current_step_ * 33) / steps_init, 0., timer_.step());
242 }
243 }
244 }
245 }
Size size() const noexcept
Returns the number of elements in the set.
Definition set_tpl.h:636
const std::vector< NodeId > _emptySet_
an empty conditioning set
Definition Miic.h:344
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
Definition Miic.cpp:718
bool isForbiddenEdge_(NodeId x, NodeId y)
Definition Miic.cpp:992
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Set< Edge > EdgeSet
Some typdefs and define for shortcuts ...

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

Referenced by learnMixedStructure(), and learnSkeleton().

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

◆ isArcValid_()

bool gum::learning::Miic::isArcValid_ ( MixedGraph graph,
NodeId x,
NodeId y )
protected

Definition at line 988 of file Miic.cpp.

988 {
989 return (isForbiddenArc_(x, y) == false && isMaxIndegree_(graph, y) == false);
990 }
bool isMaxIndegree_(MixedGraph graph, NodeId x)
Definition Miic.cpp:980
bool isForbiddenArc_(NodeId x, NodeId y) const
Check constraints.
Definition Miic.cpp:984

References isForbiddenArc_(), and isMaxIndegree_().

Referenced by _orientingVstructureMiic_(), and _propagatingOrientationMiic_().

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

◆ isEnabledEpsilon()

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

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

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 81 of file approximationScheme_inl.h.

81{ return enabled_eps_; }

References enabled_eps_.

◆ isEnabledMaxIter()

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

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

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 122 of file approximationScheme_inl.h.

122{ return enabled_max_iter_; }

References enabled_max_iter_.

◆ isEnabledMaxTime()

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

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

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 146 of file approximationScheme_inl.h.

146{ return enabled_max_time_; }

References enabled_max_time_.

◆ isEnabledMinEpsilonRate()

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

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

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 102 of file approximationScheme_inl.h.

102{ return enabled_min_rate_eps_; }

References enabled_min_rate_eps_.

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

Here is the caller graph for this function:

◆ isForbiddenArc_()

bool gum::learning::Miic::isForbiddenArc_ ( NodeId x,
NodeId y ) const
protected

Check constraints.

Definition at line 984 of file Miic.cpp.

984 {
985 return (_forbiddenGraph_.existsArc(x, y));
986 }
gum::DiGraph _forbiddenGraph_
Graph that contains the forbidden arcs.
Definition Miic.h:364

References _forbiddenGraph_.

Referenced by isArcValid_().

Here is the caller graph for this function:

◆ isForbiddenEdge_()

bool gum::learning::Miic::isForbiddenEdge_ ( NodeId x,
NodeId y )
protected

Definition at line 992 of file Miic.cpp.

992 {
993 return (_forbiddenGraph_.existsArc(x, y) && _forbiddenGraph_.existsArc(y, x));
994 }

References _forbiddenGraph_.

Referenced by initiation_().

Here is the caller graph for this function:

◆ isMaxIndegree_()

bool gum::learning::Miic::isMaxIndegree_ ( MixedGraph graph,
NodeId x )
protected

Definition at line 980 of file Miic.cpp.

980 {
981 return ((graph.parents(x).size() >= _maxIndegree_));
982 }
gum::Size _maxIndegree_
maximum number of parents
Definition Miic.h:349

References _maxIndegree_, gum::ArcGraphPart::parents(), and gum::Set< Key >::size().

Referenced by isArcValid_().

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

◆ iteration_()

void gum::learning::Miic::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 253 of file Miic.cpp.

256 {
257 // if no triples to further examine pass
258 CondRanking best;
259 Size steps_init = current_step_;
260 Size steps_iter = rank.size();
261
262 try {
263 while (rank.top().second > 0.5) {
264 best = rank.pop();
265
266 const NodeId x = std::get< 0 >(*(best.first));
267 const NodeId y = std::get< 1 >(*(best.first));
268 const NodeId z = std::get< 2 >(*(best.first));
269 std::vector< NodeId > ui = std::move(std::get< 3 >(*(best.first)));
270
271 ui.push_back(z);
272 const double i_xy_ui = mutualInformation.score(x, y, ui);
273 if (i_xy_ui < 0) {
274 graph.eraseEdge(Edge(x, y));
275 GUM_SL_EMIT(x,
276 y,
277 "Remove " << x << " - " << y,
278 "Independent based on MutualInformation knowing Sep "
279 << ui << "Mutual information:" << i_xy_ui)
280
281 sepSet.insert(std::make_pair(x, y), std::move(ui));
282 } else {
283 findBestContributor_(x, y, ui, graph, mutualInformation, rank);
284 }
285
286 delete best.first;
287
289 if (onProgress.hasListener()) {
291 (current_step_ * 66) / (steps_init + steps_iter),
292 0.,
293 timer_.step());
294 }
295 }
296 } catch (...) {} // here, rank is empty
297 current_step_ = steps_init + steps_iter;
298 if (onProgress.hasListener()) { GUM_EMIT3(onProgress, 66, 0., timer_.step()); }
299 current_step_ = steps_init + steps_iter;
300 }

References gum::ApproximationScheme::current_step_, gum::EdgeGraphPart::eraseEdge(), findBestContributor_(), GUM_EMIT3, GUM_SL_EMIT, 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(), and learnSkeleton().

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

◆ latentVariables()

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

get the list of arcs hiding latent variables

Definition at line 911 of file Miic.cpp.

911{ return _latentCouples_; }

References _latentCouples_.

◆ learnBN()

template<typename GUM_SCALAR, typename GRAPH_CHANGES_SELECTOR, typename PARAM_ESTIMATOR>
BayesNet< GUM_SCALAR > gum::learning::Miic::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 190 of file Miic.cpp.

192 {
194 learnStructure(selector, initial_dag));
195 }
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...
Definition Miic.cpp:183

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

Here is the call graph for this function:

◆ learnMixedStructure()

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

learns the structure of a MixedGraph (Meek rules not used here).

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 147 of file Miic.cpp.

148 {
149 // GUM_TRACE_VAR(mutualInformation.score(gum::NodeId (5), gum::NodeId (6)) );
150
151 timer_.reset();
152 current_step_ = 0;
153
154 // clear the vector of latent arcs to be sure
155 _latentCouples_.clear();
156
158 Heap< CondRanking, GreaterPairOn2nd > rank;
159
161 HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > sep_set;
162
163 initiation_(mutualInformation, graph, sep_set, rank);
164
165 iteration_(mutualInformation, graph, sep_set, rank);
166
167 orientationMiic_(mutualInformation, graph, sep_set);
168 // Propagates existing orientations thanks to Meek rules
169
170 return meekRules_.propagate(graph);
171 // todo : check meekRules_.choices()
172 }
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.
Definition Miic.cpp:309
gum::MeekRules meekRules_
Object that can propagates orientations to non-oriented edges.
Definition Miic.h:332
void iteration_(CorrectedMutualInformation &mutualInformation, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, Heap< CondRanking, GreaterPairOn2nd > &rank)
Iteration phase.
Definition Miic.cpp:253
void initiation_(CorrectedMutualInformation &mutualInformation, MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > &sepSet, Heap< CondRanking, GreaterPairOn2nd > &rank)
Initiation phase.
Definition Miic.cpp:204

References _latentCouples_, gum::ApproximationScheme::current_step_, initiation_(), iteration_(), meekRules_, 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()

PDAG gum::learning::Miic::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 178 of file Miic.cpp.

178 {
179 return meekRules_.propagateToCPDAG(learnMixedStructure(I, initialGraph));
180 // @todo: check the meekRules.choices()
181 }
MixedGraph learnMixedStructure(CorrectedMutualInformation &mutualInformation, MixedGraph graph)
learns the structure of a MixedGraph (Meek rules not used here).
Definition Miic.cpp:147

References learnMixedStructure(), and meekRules_.

Here is the call graph for this function:

◆ learnSkeleton()

MixedGraph gum::learning::Miic::learnSkeleton ( CorrectedMutualInformation & mutualInformation,
MixedGraph graph )

learns the skeleton of a MixedGraph (no orientation).

learns the skeleton of a Graph from a fully connected graph

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 124 of file Miic.cpp.

125 {
126 // GUM_TRACE_VAR(mutualInformation.score(gum::NodeId (5), gum::NodeId (6)) );
127
128 timer_.reset();
129 current_step_ = 0;
130
131 // clear the vector of latent arcs to be sure
132 _latentCouples_.clear();
133
135 Heap< CondRanking, GreaterPairOn2nd > rank;
136
138 HashTable< std::pair< NodeId, NodeId >, std::vector< NodeId > > sep_set;
139
140 initiation_(mutualInformation, graph, sep_set, rank);
141
142 iteration_(mutualInformation, graph, sep_set, rank);
143
144 return graph;
145 }

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

Here is the call graph for this function:

◆ learnStructure()

DAG gum::learning::Miic::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.

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 183 of file Miic.cpp.

183 {
184 return meekRules_.propagateToDAG(learnMixedStructure(I, initialGraph));
185 // @todo: check the meekRules.choices()
186 }

References learnMixedStructure(), and meekRules_.

Referenced by learnBN().

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

◆ maxIter()

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

Returns the criterion on number of iterations.

Returns
Returns the criterion on number of iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 112 of file approximationScheme_inl.h.

112{ return max_iter_; }

References max_iter_.

◆ maxTime()

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

Returns the timeout (in seconds).

Returns
Returns the timeout (in seconds).

Implements gum::IApproximationSchemeConfiguration.

Definition at line 133 of file approximationScheme_inl.h.

133{ return max_time_; }

References max_time_.

◆ messageApproximationScheme()

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

Returns the approximation scheme message.

Returns
Returns the approximation scheme message.

Definition at line 59 of file IApproximationSchemeConfiguration_inl.h.

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

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

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

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

◆ minEpsilonRate()

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

Returns the value of the minimal epsilon rate.

Returns
Returns the value of the minimal epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 92 of file approximationScheme_inl.h.

92{ return min_rate_eps_; }

References min_rate_eps_.

◆ nbrIterations()

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

Returns the number of iterations.

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 169 of file approximationScheme_inl.h.

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

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

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

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

◆ operator=() [1/2]

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

copy operator

Definition at line 82 of file Miic.cpp.

82 {
83 ApproximationScheme::operator=(from);
84 return *this;
85 }

References Miic().

Here is the call graph for this function:

◆ operator=() [2/2]

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

move operator

Definition at line 88 of file Miic.cpp.

88 {
89 ApproximationScheme::operator=(std::move(from));
90 return *this;
91 }

References Miic().

Here is the call graph for this function:

◆ orientationMiic_()

void gum::learning::Miic::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.

The 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 309 of file Miic.cpp.

312 {
313 // structure to store the orientations marks -, o, or >,
314 // Considers the head of the arc/edge: first node -* second node
315 HashTable< std::pair< NodeId, NodeId >, char > marks = _initialMarks_;
316
317 // marks always correspond to the head of the arc/edge. - is for a forbidden
318 // arc, > for a mandatory arc
319 // we start @by adding the mandatory arcs
320
321
322 /* for (auto& iter = mandaArcs.begin(); iter != mandaArcs.end(); ++iter) {
323 // if (graph.existsEdge(iter.value_type().head(), iter.tail()) &&
324 // _isMandatoryArc_(iter.head(), iter.tail())) {
325 // graph.eraseEdge(Edge(iter.head(), iter.tail()));
326 // graph.addArc(iter.head(), iter.tail());
327 // }
328 }*/
329
330 for (auto& arc: _mandatoryGraph_.arcs()) {
331 // Check if the edge exists in graph
332 if (graph.existsEdge(arc.head(), arc.tail())) {
333 graph.eraseEdge(Edge(arc.head(), arc.tail()));
334 GUM_SL_EMIT(arc.tail(),
335 arc.head(),
336 "Add Arc" << arc.tail() << "->" << arc.head(),
337 "Mandatory")
338 graph.addArc(arc.tail(), arc.head());
339 marks.insert({arc.tail(), arc.head()}, '>');
340 marks.insert({arc.head(), arc.tail()}, '-');
341 } else {
342 // If the edge doesn't exist we add the arc as is to graph
343 graph.addArc(arc.tail(), arc.head());
344 marks.insert({arc.tail(), arc.head()}, '>');
345 marks.insert({arc.head(), arc.tail()}, '-');
346 }
347 }
348
349 for (Arc arc: _forbiddenGraph_.arcs()) {
350 // Check if the edge exists in graph
351 if (graph.existsEdge(Edge(arc.tail(), arc.head()))) {
352 graph.eraseEdge(Edge(arc.tail(), arc.head()));
353
354 // Arc is forced in the other direction
355 graph.addArc(arc.head(), arc.tail());
356 GUM_SL_EMIT(arc.head(),
357 arc.tail(),
358 "Add Arc" << arc.head() << "->" << arc.tail(),
359 "Forbidden in the other orientation")
360 marks.insert({arc.tail(), arc.head()}, '-');
361 marks.insert({arc.head(), arc.tail()}, '>');
362 }
363 }
364
365 std::vector< ProbabilisticRanking > proba_triples
366 = unshieldedTriplesMiic_(graph, mutualInformation, sepSet, marks);
367
368 const Size steps_orient = proba_triples.size();
369 Size past_steps = current_step_;
370
372 if (steps_orient > 0) { best = proba_triples[0]; }
373
374 while (!proba_triples.empty() && std::max(std::get< 2 >(best), std::get< 3 >(best)) >= 0.5) {
375 const NodeId x = std::get< 0 >(*std::get< 0 >(best));
376 const NodeId y = std::get< 1 >(*std::get< 0 >(best));
377 const NodeId z = std::get< 2 >(*std::get< 0 >(best));
378
379 const double i3 = std::get< 1 >(best);
380
381 const double p1 = std::get< 2 >(best);
382 const double p2 = std::get< 3 >(best);
383
384 if (i3 <= 0) {
385 _orientingVstructureMiic_(graph, marks, x, y, z, p1, p2);
386 } else {
387 _propagatingOrientationMiic_(graph, marks, x, y, z, p1, p2);
388 }
389
390 delete std::get< 0 >(best);
391 proba_triples.erase(proba_triples.begin());
392 // actualisation of the list of triples
393 proba_triples = updateProbaTriples_(graph, proba_triples);
394
395 if (!proba_triples.empty()) best = proba_triples[0];
396
398 if (onProgress.hasListener()) {
400 (current_step_ * 100) / (steps_orient + past_steps),
401 0.,
402 timer_.step());
403 }
404 } // while
405
406 // erasing the double headed arcs
407 for (auto iter = _latentCouples_.rbegin(); iter != _latentCouples_.rend(); ++iter) {
408 graph.eraseArc(Arc(iter->head(), iter->tail()));
409 if (_existsDirectedPath_(graph, iter->head(), iter->tail())) {
410 // if we find a cycle, we force the competing edge
411 graph.addArc(iter->head(), iter->tail());
412 graph.eraseArc(Arc(iter->tail(), iter->head()));
413 *iter = Arc(iter->head(), iter->tail());
414 }
415 }
416
417 if (onProgress.hasListener()) { GUM_EMIT3(onProgress, 100, 0., timer_.step()); }
418 }
std::vector< ProbabilisticRanking > updateProbaTriples_(const MixedGraph &graph, std::vector< ProbabilisticRanking > probaTriples)
Gets the orientation probabilities like MIIC for the orientation phase.
Definition Miic.cpp:872
gum::DAG _mandatoryGraph_
Graph that contains the mandatories arcs.
Definition Miic.h:361
void _orientingVstructureMiic_(MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, char > &marks, NodeId x, NodeId y, NodeId z, double p1, double p2)
Definition Miic.cpp:420
void _propagatingOrientationMiic_(MixedGraph &graph, HashTable< std::pair< NodeId, NodeId >, char > &marks, NodeId x, NodeId y, NodeId z, double p1, double p2)
Definition Miic.cpp:548
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}...
Definition Miic.cpp:831
std::tuple< ThreePoints *, double, double, double > ProbabilisticRanking
Definition Miic.h:92

References _existsDirectedPath_(), _forbiddenGraph_, _initialMarks_, _latentCouples_, _mandatoryGraph_, _orientingVstructureMiic_(), _propagatingOrientationMiic_(), gum::DiGraph::addArc(), gum::ApproximationScheme::current_step_, gum::ArcGraphPart::eraseArc(), gum::EdgeGraphPart::eraseEdge(), gum::EdgeGraphPart::existsEdge(), GUM_EMIT3, GUM_SL_EMIT, gum::HashTable< Key, Val >::insert(), 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:

◆ orientDoubleHeadedArcs_()

void gum::learning::Miic::orientDoubleHeadedArcs_ ( MixedGraph & mg)
protected

Orient double headed arcs to avoid cycles.

Parameters
mgthe MixedGraph from which the double headed arcs will be oriented.

Definition at line 653 of file Miic.cpp.

653 {
654 gum::ArcSet L; // create a set of all double-headed arcs
655 for (gum::NodeId x: mg.nodes())
656 for (NodeId y: mg.parents(x))
657 // If there is a mutual parent-child relationship, add the arc to the set
658 if (mg.parents(y).contains(x)) {
659 if (x > y) {
660 continue; // Avoid duplicate arcs by considering only one direction
661 } else {
662 L.insert(gum::Arc(x, y));
663 }
664 }
665
666 // If there are double-headed arcs
667 if (not L.empty()) {
668 while (true) {
669 bool withdrawFlag_L = false;
670 for (auto arc: ArcSet(L)) {
671 bool tail_head = _existsDirectedPath_(mg, arc.tail(), arc.head());
672 bool head_tail = _existsDirectedPath_(mg, arc.head(), arc.tail());
673 bool withdrawFlag_arc = false;
674
675 // Case 1: There is already a path from tail to head and no path from head to tail
676 if (tail_head && !head_tail) {
677 // Erase the arc from head to tail to avoid cycles
678 mg.eraseArc(Arc(arc.head(), arc.tail()));
679 withdrawFlag_arc = true;
680
681 // Case 2: There is already a path from head to tail and no path from tail to head
682 } else if (!tail_head && head_tail) {
683 // Erase the arc from tail to head to avoid cycles
684 mg.eraseArc(Arc(arc.tail(), arc.head()));
685 withdrawFlag_arc = true;
686
687 // Case 3: There is no path between tail and head
688 } else if (!tail_head && !head_tail) {
689 // Choose an arbitrary orientation and erase the corresponding arc
690 mg.eraseArc(Arc(arc.head(), arc.tail()));
691 withdrawFlag_arc = true;
692 }
693
694 // Remove the arc from the set if it was processed
695 if (withdrawFlag_arc) {
696 L.erase(arc);
697 withdrawFlag_L = true;
698 }
699 }
700 // If all double-headed arcs are processed, exit the loop
701 if (L.empty()) { break; }
702
703 // If no arcs were withdrawn, erase an arbitrary double arc in the graph (the first one in
704 // L). Hoping the situation will improve. ┐( ̄ヘ ̄)┌ If we arrive here, it's because the
705 // double-headed arc creates cycles in both directions
706 if (!withdrawFlag_L) {
707 auto it = L.begin();
708 auto arc = *it;
709 mg.eraseArc(Arc(arc.head(), arc.tail()));
710 mg.eraseArc(Arc(arc.tail(), arc.head()));
711 L.erase(arc);
712 }
713 }
714 }
715 }
iterator begin() const
The usual unsafe begin iterator to parse the set.
Definition set_tpl.h:438
void insert(const Key &k)
Inserts a new element into the set.
Definition set_tpl.h:539
bool empty() const noexcept
Indicates whether the set is the empty set.
Definition set_tpl.h:642
void erase(const Key &k)
Erases an element from the set.
Definition set_tpl.h:582
Set< Arc > ArcSet
Some typdefs and define for shortcuts ...

References _existsDirectedPath_(), gum::Set< Key >::begin(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), gum::ArcGraphPart::eraseArc(), gum::Set< Key >::insert(), gum::NodeGraphPart::nodes(), and gum::ArcGraphPart::parents().

Here is the call graph for this function:

◆ periodSize()

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

Returns the period size.

Returns
Returns the period size.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 155 of file approximationScheme_inl.h.

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

References period_size_.

◆ remainingBurnIn()

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

Returns the remaining burn in.

Returns
Returns the remaining burn in.

Definition at line 212 of file approximationScheme_inl.h.

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

References burn_in_, and current_step_.

◆ setEpsilon()

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

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

If the criterion was disabled it will be enabled.

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

Implements gum::IApproximationSchemeConfiguration.

Reimplemented in gum::learning::EMApproximationScheme.

Definition at line 63 of file approximationScheme_inl.h.

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

References enabled_eps_, eps_, and GUM_ERROR.

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

Here is the caller graph for this function:

◆ setForbiddenGraph()

void gum::learning::Miic::setForbiddenGraph ( gum::DiGraph forbidGraph)

Set ForbiddenGraph (resp. MadatoryGraph) which contains the forbidden (resp. mandatory) arcs.

Definition at line 974 of file Miic.cpp.

974 {
975 this->_forbiddenGraph_ = forbidGraph;
976 }

References _forbiddenGraph_.

◆ setMandatoryGraph()

void gum::learning::Miic::setMandatoryGraph ( gum::DAG mandaGraph)

Definition at line 972 of file Miic.cpp.

972{ this->_mandatoryGraph_ = mandaGraph; }

References _mandatoryGraph_.

◆ setMaxIndegree()

void gum::learning::Miic::setMaxIndegree ( gum::Size n)

Definition at line 978 of file Miic.cpp.

978{ this->_maxIndegree_ = n; }

References _maxIndegree_.

◆ setMaxIter()

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

Stopping criterion on number of iterations.

If the criterion was disabled it will be enabled.

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 105 of file approximationScheme_inl.h.

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

References enabled_max_iter_, GUM_ERROR, and max_iter_.

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

Here is the caller graph for this function:

◆ setMaxTime()

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

Stopping criterion on timeout.

If the criterion was disabled it will be enabled.

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 126 of file approximationScheme_inl.h.

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

References enabled_max_time_, GUM_ERROR, and max_time_.

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

Here is the caller graph for this function:

◆ setMinEpsilonRate()

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

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

If the criterion was disabled it will be enabled

Parameters
rateThe minimal epsilon rate.
Exceptions
OutOfBoundsif rate<0

Implements gum::IApproximationSchemeConfiguration.

Reimplemented in gum::learning::EMApproximationScheme.

Definition at line 84 of file approximationScheme_inl.h.

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

References enabled_min_rate_eps_, GUM_ERROR, and min_rate_eps_.

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

Here is the caller graph for this function:

◆ setPeriodSize()

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

How many samples between two stopping is enable.

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

Implements gum::IApproximationSchemeConfiguration.

Definition at line 149 of file approximationScheme_inl.h.

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

References GUM_ERROR, and period_size_.

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

Here is the caller graph for this function:

◆ setVerbosity()

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

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

Parameters
vIf true, then verbosity is turned on.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 158 of file approximationScheme_inl.h.

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

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

Here is the caller graph for this function:

◆ startOfPeriod()

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

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

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

Definition at line 199 of file approximationScheme_inl.h.

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

References burn_in_, and current_step_.

◆ stateApproximationScheme()

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

Returns the approximation scheme state.

Returns
Returns the approximation scheme state.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 164 of file approximationScheme_inl.h.

164 {
165 return current_state_;
166 }

References current_state_.

Referenced by history(), and nbrIterations().

Here is the caller graph for this function:

◆ stopApproximationScheme()

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

Stop the approximation scheme.

Definition at line 221 of file approximationScheme_inl.h.

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

Here is the caller graph for this function:

◆ stopScheme_()

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

Stop the scheme given a new state.

Parameters
new_stateThe scheme new state.

Definition at line 301 of file approximationScheme_inl.h.

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

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

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

Here is the caller graph for this function:

◆ unshieldedTriples_()

std::vector< Ranking > gum::learning::Miic::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
graphgraph in which to find the triples
Imutual information object to compute the scores
sep_sethashtable storing the separation sets for pairs of variables

Definition at line 794 of file Miic.cpp.

797 {
798 std::vector< Ranking > triples;
799 for (NodeId z: graph) {
800 for (NodeId x: graph.neighbours(z)) {
801 for (NodeId y: graph.neighbours(z)) {
802 if (y < x && !graph.existsEdge(x, y)) {
803 std::vector< NodeId > ui;
804 std::pair< NodeId, NodeId > key = {x, y};
805 std::pair< NodeId, NodeId > rev_key = {y, x};
806 if (sepSet.exists(key)) {
807 ui = sepSet[key];
808 } else if (sepSet.exists(rev_key)) {
809 ui = sepSet[rev_key];
810 }
811 // remove z from ui if it's present
812 const auto iter_z_place = std::find(ui.begin(), ui.end(), z);
813 if (iter_z_place != ui.end()) { ui.erase(iter_z_place); }
814
815 double Ixyz_ui = mutualInformation.score(x, y, z, ui);
816 Ranking triple;
817 auto tup = new ThreePoints{x, y, z};
818 triple.first = tup;
819 triple.second = Ixyz_ui;
820 triples.push_back(triple);
821 }
822 }
823 }
824 }
825 std::sort(triples.begin(), triples.end(), GreaterAbsPairOn2nd());
826 return triples;
827 }
std::pair< ThreePoints *, double > Ranking
Definition Miic.h:90
std::tuple< NodeId, NodeId, NodeId > ThreePoints
Definition Miic.h:89

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

Here is the call graph for this function:

◆ unshieldedTriplesMiic_()

std::vector< ProbabilisticRanking > gum::learning::Miic::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
graphgraph in which to find the triples
Imutual information object to compute the scores
sep_sethashtable storing the separation sets for pairs of variables
markshashtable containing the orientation marks for edges

Definition at line 831 of file Miic.cpp.

835 {
836 std::vector< ProbabilisticRanking > triples;
837 for (NodeId z: graph) {
838 for (NodeId x: graph.neighbours(z)) {
839 for (NodeId y: graph.neighbours(z)) {
840 if (y < x && !graph.existsEdge(x, y)) {
841 std::vector< NodeId > ui;
842 std::pair< NodeId, NodeId > key = {x, y};
843 std::pair< NodeId, NodeId > rev_key = {y, x};
844 if (sepSet.exists(key)) {
845 ui = sepSet[key];
846 } else if (sepSet.exists(rev_key)) {
847 ui = sepSet[rev_key];
848 }
849 // remove z from ui if it's present
850 const auto iter_z_place = std::find(ui.begin(), ui.end(), z);
851 if (iter_z_place != ui.end()) { ui.erase(iter_z_place); }
852
853 const double Ixyz_ui = mutualInformation.score(x, y, z, ui);
854 auto tup = new ThreePoints{x, y, z};
855 ProbabilisticRanking triple{tup, Ixyz_ui, 0.5, 0.5};
856 triples.push_back(triple);
857 if (!marks.exists({x, z})) { marks.insert({x, z}, 'o'); }
858 if (!marks.exists({z, x})) { marks.insert({z, x}, 'o'); }
859 if (!marks.exists({y, z})) { marks.insert({y, z}, 'o'); }
860 if (!marks.exists({z, y})) { marks.insert({z, y}, 'o'); }
861 }
862 }
863 }
864 }
865 triples = updateProbaTriples_(graph, triples);
866 std::sort(triples.begin(), triples.end(), GreaterTupleOnLast());
867 return triples;
868 }

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

Referenced by orientationMiic_().

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

◆ updateApproximationScheme()

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

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

Parameters
incrThe new increment steps.

Definition at line 208 of file approximationScheme_inl.h.

208 {
209 current_step_ += incr;
210 }

References current_step_.

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

Here is the caller graph for this function:

◆ updateProbaTriples_()

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

Gets the orientation probabilities like MIIC for the orientation phase.

Parameters
graphgraph in which to find the triples
proba_triplesprobabilities for the different triples to update

Definition at line 872 of file Miic.cpp.

873 {
874 for (auto& triple: probaTriples) {
875 NodeId x, y, z;
876 x = std::get< 0 >(*std::get< 0 >(triple));
877 y = std::get< 1 >(*std::get< 0 >(triple));
878 z = std::get< 2 >(*std::get< 0 >(triple));
879 const double Ixyz = std::get< 1 >(triple);
880 double Pxz = std::get< 2 >(triple);
881 double Pyz = std::get< 3 >(triple);
882
883 if (Ixyz <= 0) {
884 const double expo = std::exp(Ixyz);
885 const double P0 = (1 + expo) / (1 + 3 * expo);
886 // distinguish between the initialization and the update process
887 if (Pxz == Pyz && Pyz == 0.5) {
888 std::get< 2 >(triple) = P0;
889 std::get< 3 >(triple) = P0;
890 } else {
891 if (graph.existsArc(x, z) && Pxz >= P0) {
892 std::get< 3 >(triple) = Pxz * (1 / (1 + expo) - 0.5) + 0.5;
893 } else if (graph.existsArc(y, z) && Pyz >= P0) {
894 std::get< 2 >(triple) = Pyz * (1 / (1 + expo) - 0.5) + 0.5;
895 }
896 }
897 } else {
898 const double expo = std::exp(-Ixyz);
899 if (graph.existsArc(x, z) && Pxz >= 0.5) {
900 std::get< 3 >(triple) = Pxz * (1 / (1 + expo) - 0.5) + 0.5;
901 } else if (graph.existsArc(y, z) && Pyz >= 0.5) {
902 std::get< 2 >(triple) = Pyz * (1 / (1 + expo) - 0.5) + 0.5;
903 }
904 }
905 }
906 std::sort(probaTriples.begin(), probaTriples.end(), GreaterTupleOnLast());
907 return probaTriples;
908 }

References gum::ArcGraphPart::existsArc().

Referenced by orientationMiic_(), and unshieldedTriplesMiic_().

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

◆ verbosity()

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

Returns true if verbosity is enabled.

Returns
Returns true if verbosity is enabled.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 160 of file approximationScheme_inl.h.

160{ return verbosity_; }

References verbosity_.

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

Here is the caller graph for this function:

Member Data Documentation

◆ _arcProbas_

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

Storing the propabilities for each arc set in the graph.

Definition at line 355 of file Miic.h.

Referenced by _orientingVstructureMiic_(), and _propagatingOrientationMiic_().

◆ _emptySet_

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

an empty conditioning set

Definition at line 344 of file Miic.h.

Referenced by initiation_().

◆ _forbiddenGraph_

gum::DiGraph gum::learning::Miic::_forbiddenGraph_
private

Graph that contains the forbidden arcs.

Definition at line 364 of file Miic.h.

Referenced by isForbiddenArc_(), isForbiddenEdge_(), orientationMiic_(), and setForbiddenGraph().

◆ _initialMarks_

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

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

Definition at line 358 of file Miic.h.

Referenced by addConstraints(), and orientationMiic_().

◆ _latentCouples_

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

◆ _mandatoryGraph_

gum::DAG gum::learning::Miic::_mandatoryGraph_
private

Graph that contains the mandatories arcs.

Definition at line 361 of file Miic.h.

Referenced by orientationMiic_(), and setMandatoryGraph().

◆ _maxIndegree_

gum::Size gum::learning::Miic::_maxIndegree_
private

maximum number of parents

Definition at line 349 of file Miic.h.

Referenced by isMaxIndegree_(), and setMaxIndegree().

◆ _maxLog_

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

Fixes the maximum log that we accept in exponential computations.

Definition at line 342 of file Miic.h.

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

◆ _size_

Size gum::learning::Miic::_size_
private

size of the database

Definition at line 352 of file Miic.h.

Referenced by Miic(), Miic(), Miic(), and Miic().

◆ burn_in_

Size gum::ApproximationScheme::burn_in_
protectedinherited

◆ current_epsilon_

double gum::ApproximationScheme::current_epsilon_
protectedinherited

Current epsilon.

Definition at line 378 of file approximationScheme.h.

Referenced by initApproximationScheme().

◆ current_rate_

double gum::ApproximationScheme::current_rate_
protectedinherited

Current rate.

Definition at line 384 of file approximationScheme.h.

Referenced by initApproximationScheme().

◆ current_state_

ApproximationSchemeSTATE gum::ApproximationScheme::current_state_
protectedinherited

The current state.

Definition at line 393 of file approximationScheme.h.

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

◆ current_step_

◆ enabled_eps_

bool gum::ApproximationScheme::enabled_eps_
protectedinherited

If true, the threshold convergence is enabled.

Definition at line 402 of file approximationScheme.h.

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

◆ enabled_max_iter_

bool gum::ApproximationScheme::enabled_max_iter_
protectedinherited

If true, the maximum iterations stopping criterion is enabled.

Definition at line 420 of file approximationScheme.h.

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

◆ enabled_max_time_

bool gum::ApproximationScheme::enabled_max_time_
protectedinherited

If true, the timeout is enabled.

Definition at line 414 of file approximationScheme.h.

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

◆ enabled_min_rate_eps_

bool gum::ApproximationScheme::enabled_min_rate_eps_
protectedinherited

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

Definition at line 408 of file approximationScheme.h.

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

◆ eps_

double gum::ApproximationScheme::eps_
protectedinherited

Threshold for convergence.

Definition at line 399 of file approximationScheme.h.

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

◆ history_

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

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

Definition at line 396 of file approximationScheme.h.

◆ last_epsilon_

double gum::ApproximationScheme::last_epsilon_
protectedinherited

Last epsilon value.

Definition at line 381 of file approximationScheme.h.

◆ max_iter_

Size gum::ApproximationScheme::max_iter_
protectedinherited

The maximum iterations.

Definition at line 417 of file approximationScheme.h.

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

◆ max_time_

double gum::ApproximationScheme::max_time_
protectedinherited

The timeout.

Definition at line 411 of file approximationScheme.h.

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

◆ meekRules_

gum::MeekRules gum::learning::Miic::meekRules_
protected

Object that can propagates orientations to non-oriented edges.

Definition at line 332 of file Miic.h.

Referenced by learnMixedStructure(), learnPDAG(), and learnStructure().

◆ min_rate_eps_

double gum::ApproximationScheme::min_rate_eps_
protectedinherited

Threshold for the epsilon rate.

Definition at line 405 of file approximationScheme.h.

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

◆ onProgress

◆ onStop

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

Criteria messageApproximationScheme.

Definition at line 83 of file IApproximationSchemeConfiguration.h.

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

◆ onStructuralModification

Signaler4< gum::NodeId, gum::NodeId, std::string, std::string > gum::learning::Miic::onStructuralModification

Definition at line 401 of file Miic.h.

◆ period_size_

Size gum::ApproximationScheme::period_size_
protectedinherited

Checking criteria frequency.

Definition at line 426 of file approximationScheme.h.

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

◆ timer_

◆ verbosity_

bool gum::ApproximationScheme::verbosity_
protectedinherited

If true, verbosity is enabled.

Definition at line 429 of file approximationScheme.h.

Referenced by ApproximationScheme(), and verbosity().


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