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

the structural constraint imposing a partial order over nodes More...

#include <structuralConstraintSliceOrder.h>

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

Public Member Functions

Constructors / Destructors
 StructuralConstraintSliceOrder ()
 default constructor More...
 
 StructuralConstraintSliceOrder (const NodeProperty< NodeId > &order)
 constructor starting with an empty graph with a given number of nodes More...
 
 StructuralConstraintSliceOrder (const DiGraph &graph, const NodeProperty< NodeId > &order)
 constructor starting with a given graph More...
 
 StructuralConstraintSliceOrder (const StructuralConstraintSliceOrder &from)
 copy constructor More...
 
 StructuralConstraintSliceOrder (StructuralConstraintSliceOrder &&from)
 move constructor More...
 
virtual ~StructuralConstraintSliceOrder ()
 destructor More...
 
Operators
StructuralConstraintSliceOrderoperator= (const StructuralConstraintSliceOrder &from)
 copy operator More...
 
StructuralConstraintSliceOrderoperator= (StructuralConstraintSliceOrder &&from)
 move operator More...
 
Specific Accessors / Modifiers
void setSliceOrder (const NodeProperty< NodeId > &slice)
 sets the time slices of all the nodes in the property More...
 
const NodeProperty< NodeId > & sliceOrder () const
 returns the current slice order More...
 
void addNode (NodeId node, NodeId slice)
 adds a new node in the slice order More...
 
void setDefaultSlice (NodeId slice)
 assign a given slice to all the nodes specified in the partial order 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 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...
 
bool checkModificationAlone (const GraphChange &change) const
 checks whether the constraints enable to perform a graph change More...
 

Protected Attributes

NodeProperty< NodeId_SliceOrder_order_
 slices to which belong the nodes More...
 

Protected Member Functions

Accessors / Modifiers
void setGraph (const DiGraph &graph)
 sets a new graph from which we will perform checkings More...
 
void modifyGraph (const ArcAddition &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraph (const ArcDeletion &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraph (const ArcReversal &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraph (const GraphChange &change)
 notify the constraint of a modification of the graph More...
 
bool isAlwaysInvalid (const GraphChange &change) const
 indicates whether a change will always violate the constraint More...
 
bool checkArcAddition (NodeId x, NodeId y) const
 checks whether the constraints enable to add arc (x,y) More...
 
bool checkArcDeletion (NodeId x, NodeId y) const
 checks whether the constraints enable to remove arc (x,y) More...
 
bool checkArcReversal (NodeId x, NodeId y) const
 checks whether the constraints enable to reverse arc (x,y) More...
 
bool checkModification (const ArcAddition &change) const
 checks whether the constraints enable to add an arc More...
 
bool checkModification (const ArcDeletion &change) const
 checks whether the constraints enable to remove an arc More...
 
bool checkModification (const ArcReversal &change) const
 checks whether the constraints enable to reverse an arc More...
 
bool checkModification (const GraphChange &change) const
 checks whether the constraints enable to perform a graph change More...
 

Protected Types

using constraints = typename _StructuralConstraintSetStatic_< StructuralConstraintDiGraph, OTHER_CONSTRAINTS... >::minConstraints
 

Detailed Description

the structural constraint imposing a partial order over nodes

In DBNs, it is forbidden to add arcs from nodes at time slice t to nodes at time slice s, where s < t. This class allows for taking this kind of constraint into account by imposing a partial order over the nodes: arcs (X,Y) can then only be added if X <= Y in the partial order.

Warning
: there may exist free variables, that is variables whose order w.r.t. the other variables is unspecified. In this case, arcs adjacent to them can be constructed. The partial order is specified by assigning numbers to nodes (through a NodeProperty). Nodes without number (i.e., that do not belong to the property) are free.

Definition at line 66 of file structuralConstraintSliceOrder.h.

Member Typedef Documentation

◆ constraints

using gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::constraints = typename _StructuralConstraintSetStatic_< StructuralConstraintDiGraph , OTHER_CONSTRAINTS... >::minConstraints
inherited

Definition at line 408 of file structuralConstraintSetStatic.h.

Constructor & Destructor Documentation

◆ StructuralConstraintSliceOrder() [1/5]

gum::learning::StructuralConstraintSliceOrder::StructuralConstraintSliceOrder ( )

default constructor

Definition at line 51 of file structuralConstraintSliceOrder.cpp.

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

51  {
52  GUM_CONSTRUCTOR(StructuralConstraintSliceOrder);
53  }
+ Here is the call graph for this function:

◆ StructuralConstraintSliceOrder() [2/5]

gum::learning::StructuralConstraintSliceOrder::StructuralConstraintSliceOrder ( const NodeProperty< NodeId > &  order)

constructor starting with an empty graph with a given number of nodes

param order the partial order

Definition at line 56 of file structuralConstraintSliceOrder.cpp.

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

57  {
58  for (auto iter = order.cbegin(); iter != order.cend(); ++iter) {
59  _DiGraph_graph_.addNodeWithId(iter.key());
60  }
61  _SliceOrder_order_ = order;
62 
63  GUM_CONSTRUCTOR(StructuralConstraintSliceOrder);
64  }
NodeProperty< NodeId > _SliceOrder_order_
slices to which belong the nodes
+ Here is the call graph for this function:

◆ StructuralConstraintSliceOrder() [3/5]

gum::learning::StructuralConstraintSliceOrder::StructuralConstraintSliceOrder ( const DiGraph graph,
const NodeProperty< NodeId > &  order 
)

constructor starting with a given graph

Definition at line 67 of file structuralConstraintSliceOrder.cpp.

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

69  :
70  StructuralConstraintDiGraph(graph),
71  _SliceOrder_order_(order) {
72  GUM_CONSTRUCTOR(StructuralConstraintSliceOrder);
73  }
NodeProperty< NodeId > _SliceOrder_order_
slices to which belong the nodes
+ Here is the call graph for this function:

◆ StructuralConstraintSliceOrder() [4/5]

gum::learning::StructuralConstraintSliceOrder::StructuralConstraintSliceOrder ( const StructuralConstraintSliceOrder from)

copy constructor

Definition at line 76 of file structuralConstraintSliceOrder.cpp.

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

77  :
78  StructuralConstraintDiGraph(from),
79  _SliceOrder_order_(from._SliceOrder_order_) {
80  GUM_CONS_CPY(StructuralConstraintSliceOrder);
81  }
NodeProperty< NodeId > _SliceOrder_order_
slices to which belong the nodes
+ Here is the call graph for this function:

◆ StructuralConstraintSliceOrder() [5/5]

gum::learning::StructuralConstraintSliceOrder::StructuralConstraintSliceOrder ( StructuralConstraintSliceOrder &&  from)

move constructor

Definition at line 84 of file structuralConstraintSliceOrder.cpp.

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

85  :
86  StructuralConstraintDiGraph(std::move(from)),
87  _SliceOrder_order_(std::move(from._SliceOrder_order_)) {
88  GUM_CONS_MOV(StructuralConstraintSliceOrder);
89  }
NodeProperty< NodeId > _SliceOrder_order_
slices to which belong the nodes
+ Here is the call graph for this function:

◆ ~StructuralConstraintSliceOrder()

gum::learning::StructuralConstraintSliceOrder::~StructuralConstraintSliceOrder ( )
virtual

destructor

Definition at line 92 of file structuralConstraintSliceOrder.cpp.

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

92  {
93  GUM_DESTRUCTOR(StructuralConstraintSliceOrder);
94  }
+ Here is the call graph for this function:

Member Function Documentation

◆ addNode()

void gum::learning::StructuralConstraintSliceOrder::addNode ( NodeId  node,
NodeId  slice 
)

adds a new node in the slice order

◆ checkArcAddition()

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkArcAddition ( NodeId  x,
NodeId  y 
) const
inherited

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

◆ checkArcAdditionAlone()

bool gum::learning::StructuralConstraintSliceOrder::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 and is not a backward-time arc.

◆ checkArcDeletion()

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkArcDeletion ( NodeId  x,
NodeId  y 
) const
inherited

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

◆ checkArcDeletionAlone()

bool gum::learning::StructuralConstraintSliceOrder::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.

◆ checkArcReversal()

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkArcReversal ( NodeId  x,
NodeId  y 
) const
inherited

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

◆ checkArcReversalAlone()

bool gum::learning::StructuralConstraintSliceOrder::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 and is not a backward-time arc.

◆ checkModification() [1/4]

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkModification ( const ArcAddition change) const
inherited

checks whether the constraints enable to add an arc

◆ checkModification() [2/4]

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkModification ( const ArcDeletion change) const
inherited

checks whether the constraints enable to remove an arc

◆ checkModification() [3/4]

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkModification ( const ArcReversal change) const
inherited

checks whether the constraints enable to reverse an arc

◆ checkModification() [4/4]

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkModification ( const GraphChange change) const
inherited

checks whether the constraints enable to perform a graph change

◆ checkModificationAlone() [1/4]

bool gum::learning::StructuralConstraintSliceOrder::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 and is not a backward-time arc.

◆ checkModificationAlone() [2/4]

bool gum::learning::StructuralConstraintSliceOrder::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() [3/4]

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

checks whether the constraints enable to reverse an arc

an arc can be reversed if and only if it exists and arc (y,x) does not and is not a backward-time arc.

◆ checkModificationAlone() [4/4]

bool gum::learning::StructuralConstraintSliceOrder::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 and is not a backward-time arc. 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 and is not a backward-time arc.

◆ isAlwaysInvalid()

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::isAlwaysInvalid ( const GraphChange change) const
inherited

indicates whether a change will always violate the constraint

◆ isAlwaysInvalidAlone()

bool gum::learning::StructuralConstraintSliceOrder::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.

◆ modifyGraph() [1/4]

void gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::modifyGraph ( const ArcAddition change)
inherited

notify the constraint of a modification of the graph

◆ modifyGraph() [2/4]

void gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::modifyGraph ( const ArcDeletion change)
inherited

notify the constraint of a modification of the graph

◆ modifyGraph() [3/4]

void gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::modifyGraph ( const ArcReversal change)
inherited

notify the constraint of a modification of the graph

◆ modifyGraph() [4/4]

void gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::modifyGraph ( const GraphChange change)
inherited

notify the constraint of a modification of the graph

◆ modifyGraphAlone() [1/4]

void gum::learning::StructuralConstraintSliceOrder::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
InvalidArcexception is thrown if any time-backward arc is created by the arc addition.

◆ modifyGraphAlone() [2/4]

void gum::learning::StructuralConstraintSliceOrder::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::StructuralConstraintSliceOrder::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 an arc (x,y) is added and x or y does not belong to the graph nodes
InvalidArcexception is thrown if any time-backward arc is created by the arc reversal.

◆ modifyGraphAlone() [4/4]

void gum::learning::StructuralConstraintSliceOrder::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 or reversed and x or y does not belong to the graph nodes
InvalidArcexception is thrown if any time-backward arc is created by an arc addition or reversal.

◆ operator=() [1/2]

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

copy operator

Definition at line 98 of file structuralConstraintSliceOrder.cpp.

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

98  {
99  if (this != &from) {
101  _SliceOrder_order_ = from._SliceOrder_order_;
102  }
103  return *this;
104  }
StructuralConstraintDiGraph & operator=(const StructuralConstraintDiGraph &from)
copy operator
NodeProperty< NodeId > _SliceOrder_order_
slices to which belong the nodes
+ Here is the call graph for this function:

◆ operator=() [2/2]

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

move operator

Definition at line 108 of file structuralConstraintSliceOrder.cpp.

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

108  {
109  if (this != &from) {
111  _SliceOrder_order_ = std::move(from._SliceOrder_order_);
112  }
113  return *this;
114  }
StructuralConstraintDiGraph & operator=(const StructuralConstraintDiGraph &from)
copy operator
NodeProperty< NodeId > _SliceOrder_order_
slices to which belong the nodes
+ Here is the call graph for this function:

◆ setDefaultSlice()

void gum::learning::StructuralConstraintSliceOrder::setDefaultSlice ( NodeId  slice)

assign a given slice to all the nodes specified in the partial order

◆ setGraph()

void gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::setGraph ( const DiGraph graph)
inherited

sets a new graph from which we will perform checkings

◆ setGraphAlone()

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

sets a new graph from which we will perform checkings

◆ setSliceOrder()

void gum::learning::StructuralConstraintSliceOrder::setSliceOrder ( const NodeProperty< NodeId > &  slice)

sets the time slices of all the nodes in the property

◆ sliceOrder()

const NodeProperty< NodeId >& gum::learning::StructuralConstraintSliceOrder::sliceOrder ( ) const

returns the current slice order

Member Data Documentation

◆ _SliceOrder_order_

NodeProperty< NodeId > gum::learning::StructuralConstraintSliceOrder::_SliceOrder_order_
protected

slices to which belong the nodes

Definition at line 229 of file structuralConstraintSliceOrder.h.


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