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

the structural constraint indicating that some arcs shall never be removed or reversed More...

#include <structuralConstraintMandatoryArcs.h>

+ Inheritance diagram for gum::learning::StructuralConstraintMandatoryArcs:
+ Collaboration diagram for gum::learning::StructuralConstraintMandatoryArcs:

Public Member Functions

Constructors / Destructors
 StructuralConstraintMandatoryArcs ()
 default constructor More...
 
 StructuralConstraintMandatoryArcs (const DiGraph &graph)
 constructor starting with a given graph More...
 
 StructuralConstraintMandatoryArcs (const StructuralConstraintMandatoryArcs &from)
 copy constructor More...
 
 StructuralConstraintMandatoryArcs (StructuralConstraintMandatoryArcs &&from)
 move constructor More...
 
virtual ~StructuralConstraintMandatoryArcs ()
 destructor More...
 
Operators
StructuralConstraintMandatoryArcsoperator= (const StructuralConstraintMandatoryArcs &from)
 copy operator More...
 
StructuralConstraintMandatoryArcsoperator= (StructuralConstraintMandatoryArcs &&from)
 move operator More...
 
Specific Accessors / Modifiers
void setArcs (const ArcSet &set)
 assign a set of forbidden arcs More...
 
void addArc (const Arc &arc)
 assign a new forbidden arc More...
 
void eraseArc (const Arc &arc)
 remove a forbidden arc More...
 
const ArcSetarcs () const
 returns the set of mandatory arcs More...
 
void setGraphAlone (const DiGraph &graph)
 sets a new graph from which we will perform checkings More...
 
void modifyGraphAlone (const ArcAddition &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraphAlone (const ArcDeletion &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraphAlone (const ArcReversal &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraphAlone (const GraphChange &change)
 notify the constraint of a modification of the graph More...
 
bool isAlwaysInvalidAlone (const GraphChange &change) const
 indicates whether a change will always violate the constraint More...
 
bool checkArcAdditionAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to add arc (x,y) More...
 
bool checkArcDeletionAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to remove arc (x,y) More...
 
bool checkArcReversalAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to reverse arc (x,y) More...
 
bool checkModificationAlone (const GraphChange &change) const
 checks whether the constraints enable to perform a graph change More...
 
bool checkModificationAlone (const ArcAddition &change) const
 checks whether the constraints enable to add an arc More...
 
bool checkModificationAlone (const ArcDeletion &change) const
 checks whether the constraints enable to remove an arc More...
 
bool checkModificationAlone (const ArcReversal &change) const
 checks whether the constraints enable to reverse an arc More...
 

Public Types

using allConstraints = _ConstraintSet_< void >
 

Protected Attributes

ArcSet _MandatoryArcs_mandatory_arcs_
 the MandatoryArcs on which we perform checks More...
 

Detailed Description

the structural constraint indicating that some arcs shall never be removed or reversed

Definition at line 45 of file structuralConstraintMandatoryArcs.h.

Member Typedef Documentation

◆ allConstraints

using gum::learning::StructuralConstraintEmpty::allConstraints = _ConstraintSet_< void >
inherited

Definition at line 41 of file structuralConstraint.h.

Constructor & Destructor Documentation

◆ StructuralConstraintMandatoryArcs() [1/4]

gum::learning::StructuralConstraintMandatoryArcs::StructuralConstraintMandatoryArcs ( )

default constructor

Definition at line 41 of file structuralConstraintMandatoryArcs.cpp.

References gum::learning::genericBNLearner::Database::Database().

41  {
42  GUM_CONSTRUCTOR(StructuralConstraintMandatoryArcs);
43  }
+ Here is the call graph for this function:

◆ StructuralConstraintMandatoryArcs() [2/4]

gum::learning::StructuralConstraintMandatoryArcs::StructuralConstraintMandatoryArcs ( const DiGraph graph)

constructor starting with a given graph

Definition at line 46 of file structuralConstraintMandatoryArcs.cpp.

References gum::learning::genericBNLearner::Database::Database().

46  {
47  setGraph(graph);
48  GUM_CONSTRUCTOR(StructuralConstraintMandatoryArcs);
49  }
+ Here is the call graph for this function:

◆ StructuralConstraintMandatoryArcs() [3/4]

gum::learning::StructuralConstraintMandatoryArcs::StructuralConstraintMandatoryArcs ( const StructuralConstraintMandatoryArcs from)

copy constructor

Definition at line 52 of file structuralConstraintMandatoryArcs.cpp.

References gum::learning::genericBNLearner::Database::Database().

53  :
54  _MandatoryArcs_mandatory_arcs_(from._MandatoryArcs_mandatory_arcs_) {
56  }
ArcSet _MandatoryArcs_mandatory_arcs_
the MandatoryArcs on which we perform checks
+ Here is the call graph for this function:

◆ StructuralConstraintMandatoryArcs() [4/4]

gum::learning::StructuralConstraintMandatoryArcs::StructuralConstraintMandatoryArcs ( StructuralConstraintMandatoryArcs &&  from)

move constructor

Definition at line 59 of file structuralConstraintMandatoryArcs.cpp.

References gum::learning::genericBNLearner::Database::Database().

60  :
61  _MandatoryArcs_mandatory_arcs_(std::move(from._MandatoryArcs_mandatory_arcs_)) {
63  }
ArcSet _MandatoryArcs_mandatory_arcs_
the MandatoryArcs on which we perform checks
+ Here is the call graph for this function:

◆ ~StructuralConstraintMandatoryArcs()

gum::learning::StructuralConstraintMandatoryArcs::~StructuralConstraintMandatoryArcs ( )
virtual

destructor

Definition at line 66 of file structuralConstraintMandatoryArcs.cpp.

References gum::learning::genericBNLearner::Database::Database().

66  {
67  GUM_DESTRUCTOR(StructuralConstraintMandatoryArcs);
68  }
+ Here is the call graph for this function:

Member Function Documentation

◆ addArc()

void gum::learning::StructuralConstraintMandatoryArcs::addArc ( const Arc arc)

assign a new forbidden arc

◆ arcs()

const ArcSet& gum::learning::StructuralConstraintMandatoryArcs::arcs ( ) const

returns the set of mandatory arcs

◆ checkArcAdditionAlone()

bool gum::learning::StructuralConstraintMandatoryArcs::checkArcAdditionAlone ( NodeId  x,
NodeId  y 
) const

checks whether the constraints enable to add arc (x,y)

an arc can be added if and only if its extremal nodes belong to the graph and the arc does not already exist.

◆ checkArcDeletionAlone()

bool gum::learning::StructuralConstraintMandatoryArcs::checkArcDeletionAlone ( NodeId  x,
NodeId  y 
) const

checks whether the constraints enable to remove arc (x,y)

an arc can be removed if and only if the arc exists.

◆ checkArcReversalAlone()

bool gum::learning::StructuralConstraintMandatoryArcs::checkArcReversalAlone ( NodeId  x,
NodeId  y 
) const

checks whether the constraints enable to reverse arc (x,y)

an arc can be reversed if and only if it exists and arc (y,x) does not.

◆ checkModificationAlone() [1/4]

bool gum::learning::StructuralConstraintMandatoryArcs::checkModificationAlone ( const GraphChange change) const

checks whether the constraints enable to perform a graph change

An arc can be added if and only if its extremal nodes belong to the graph and the arc does not already exist. An arc can be removed if and only if the arc exists. An arc (x,y) can be reversed if and only if it exists and arc (y,x) does not.

◆ checkModificationAlone() [2/4]

bool gum::learning::StructuralConstraintMandatoryArcs::checkModificationAlone ( const ArcAddition change) const

checks whether the constraints enable to add an arc

an arc can be added if and only if its extremal nodes belong to the graph and the arc does not already exist.

◆ checkModificationAlone() [3/4]

bool gum::learning::StructuralConstraintMandatoryArcs::checkModificationAlone ( const ArcDeletion change) const

checks whether the constraints enable to remove an arc

an arc can be removed if and only if the arc exists.

◆ checkModificationAlone() [4/4]

bool gum::learning::StructuralConstraintMandatoryArcs::checkModificationAlone ( const ArcReversal change) const

checks whether the constraints enable to reverse an arc

an arc (x,y) can be reversed if and only if it exists and arc (y,x) does not.

◆ eraseArc()

void gum::learning::StructuralConstraintMandatoryArcs::eraseArc ( const Arc arc)

remove a forbidden arc

◆ isAlwaysInvalidAlone()

bool gum::learning::StructuralConstraintMandatoryArcs::isAlwaysInvalidAlone ( const GraphChange change) const

indicates whether a change will always violate the constraint

Some learning algorithms need examine several times whether a given graph change can be applied. For instance, the first time arc (X,Y) addition is considered, the learning algorithm may discard this change because it violates the structural constraint (e.g., if the latter enforces a DAG structure, this arc addition might induce a directed cycle), but, later on, other arc removal may induce that the arc addition is now possible. Such change is thus not always invalid. Conversely, there are changes that can be discarded once and for all. For instance, in a 2TBN structure, it is always impossible to add a backward-time arc. Such graph changes are always invalid and are therefore tagged as such by the isAlwaysInvalid method.

◆ modifyGraphAlone() [1/4]

void gum::learning::StructuralConstraintMandatoryArcs::modifyGraphAlone ( const ArcAddition change)

notify the constraint of a modification of the graph

Warning
If an already existing arc is added nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeexception is thrown if an arc (x,y) is added and x or y does not belong to the graph nodes

◆ modifyGraphAlone() [2/4]

void gum::learning::StructuralConstraintMandatoryArcs::modifyGraphAlone ( const ArcDeletion change)

notify the constraint of a modification of the graph

Warning
If a nonexisting arc is removed, nothing is done. In particular, no exception is raised.

◆ modifyGraphAlone() [3/4]

void gum::learning::StructuralConstraintMandatoryArcs::modifyGraphAlone ( const ArcReversal change)

notify the constraint of a modification of the graph

Warning
If an already existing arc is added, or if a nonexisting arc is removed, nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeexception is thrown if at least one extremity of the arc does not belong to the graph nodes

◆ modifyGraphAlone() [4/4]

void gum::learning::StructuralConstraintMandatoryArcs::modifyGraphAlone ( const GraphChange change)

notify the constraint of a modification of the graph

Warning
If an already existing arc is added, or if a nonexisting arc is removed, nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeexception is thrown if an arc (x,y) is added and x or y does not belong to the graph nodes

◆ operator=() [1/2]

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

copy operator

Definition at line 72 of file structuralConstraintMandatoryArcs.cpp.

References gum::learning::genericBNLearner::Database::Database().

72  {
73  if (this != &from) { _MandatoryArcs_mandatory_arcs_ = from._MandatoryArcs_mandatory_arcs_; }
74  return *this;
75  }
ArcSet _MandatoryArcs_mandatory_arcs_
the MandatoryArcs on which we perform checks
+ Here is the call graph for this function:

◆ operator=() [2/2]

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

move operator

Definition at line 79 of file structuralConstraintMandatoryArcs.cpp.

References gum::learning::genericBNLearner::Database::Database().

79  {
80  if (this != &from) {
81  _MandatoryArcs_mandatory_arcs_ = std::move(from._MandatoryArcs_mandatory_arcs_);
82  }
83  return *this;
84  }
ArcSet _MandatoryArcs_mandatory_arcs_
the MandatoryArcs on which we perform checks
+ Here is the call graph for this function:

◆ setArcs()

void gum::learning::StructuralConstraintMandatoryArcs::setArcs ( const ArcSet set)

assign a set of forbidden arcs

◆ setGraphAlone()

void gum::learning::StructuralConstraintMandatoryArcs::setGraphAlone ( const DiGraph graph)

sets a new graph from which we will perform checkings

Member Data Documentation

◆ _MandatoryArcs_mandatory_arcs_

ArcSet gum::learning::StructuralConstraintMandatoryArcs::_MandatoryArcs_mandatory_arcs_
protected

the MandatoryArcs on which we perform checks

Definition at line 193 of file structuralConstraintMandatoryArcs.h.


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