aGrUM 2.3.2
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
 StructuralConstraintSliceOrder (const NodeProperty< NodeId > &order)
 constructor starting with an empty graph with a given number of nodes
 StructuralConstraintSliceOrder (const DiGraph &graph, const NodeProperty< NodeId > &order)
 constructor starting with a given graph
 StructuralConstraintSliceOrder (const StructuralConstraintSliceOrder &from)
 copy constructor
 StructuralConstraintSliceOrder (StructuralConstraintSliceOrder &&from)
 move constructor
virtual ~StructuralConstraintSliceOrder ()
 destructor
Operators
StructuralConstraintSliceOrderoperator= (const StructuralConstraintSliceOrder &from)
 copy operator
StructuralConstraintSliceOrderoperator= (StructuralConstraintSliceOrder &&from)
 move operator
Specific Accessors / Modifiers
void setSliceOrder (const NodeProperty< NodeId > &slice)
 sets the time slices of all the nodes in the property
const NodeProperty< NodeId > & sliceOrder () const
 returns the current slice order
void addNode (NodeId node, NodeId slice)
 adds a new node in the slice order
void setDefaultSlice (NodeId slice)
 assign a given slice to all the nodes specified in the partial order
void setGraphAlone (const DiGraph &graph)
 sets a new graph from which we will perform checkings
void modifyGraphAlone (const ArcAddition &change)
 notify the constraint of a modification of the graph
void modifyGraphAlone (const ArcDeletion &change)
 notify the constraint of a modification of the graph
void modifyGraphAlone (const ArcReversal &change)
 notify the constraint of a modification of the graph
void modifyGraphAlone (const GraphChange &change)
 notify the constraint of a modification of the graph
bool isAlwaysInvalidAlone (const GraphChange &change) const
 indicates whether a change will always violate the constraint
bool checkArcAdditionAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to add arc (x,y)
bool checkArcDeletionAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to remove arc (x,y)
bool checkArcReversalAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to reverse arc (x,y)
bool checkModificationAlone (const ArcAddition &change) const
 checks whether the constraints enable to add an arc
bool checkModificationAlone (const ArcDeletion &change) const
 checks whether the constraints enable to remove an arc
bool checkModificationAlone (const ArcReversal &change) const
 checks whether the constraints enable to reverse an arc
bool checkModificationAlone (const GraphChange &change) const
 checks whether the constraints enable to perform a graph change

Protected Types

using constraints

Protected Member Functions

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

Protected Attributes

NodeProperty< NodeId_SliceOrder_order_
 slices to which belong the nodes

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 86 of file structuralConstraintSliceOrder.h.

Member Typedef Documentation

◆ constraints

using gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph, OTHER_CONSTRAINTS >::constraints
inherited

Definition at line 425 of file structuralConstraintSetStatic.h.

Constructor & Destructor Documentation

◆ StructuralConstraintSliceOrder() [1/5]

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

default constructor

Definition at line 71 of file structuralConstraintSliceOrder.cpp.

71 {
72 GUM_CONSTRUCTOR(StructuralConstraintSliceOrder);
73 }

References StructuralConstraintSliceOrder().

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

Here is the call graph for this function:
Here is the caller 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 76 of file structuralConstraintSliceOrder.cpp.

77 {
78 for (auto iter = order.cbegin(); iter != order.cend(); ++iter) {
79 _DiGraph_graph_.addNodeWithId(iter.key());
80 }
81 _SliceOrder_order_ = order;
82
83 GUM_CONSTRUCTOR(StructuralConstraintSliceOrder);
84 }
NodeProperty< NodeId > _SliceOrder_order_
slices to which belong the nodes

References StructuralConstraintSliceOrder(), _SliceOrder_order_, gum::HashTable< Key, Val >::cbegin(), and gum::HashTable< Key, Val >::cend().

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 87 of file structuralConstraintSliceOrder.cpp.

89 :
90 StructuralConstraintDiGraph(graph), _SliceOrder_order_(order) {
91 GUM_CONSTRUCTOR(StructuralConstraintSliceOrder);
92 }

References StructuralConstraintSliceOrder(), and _SliceOrder_order_.

Here is the call graph for this function:

◆ StructuralConstraintSliceOrder() [4/5]

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

copy constructor

Definition at line 95 of file structuralConstraintSliceOrder.cpp.

96 :
97 StructuralConstraintDiGraph(from), _SliceOrder_order_(from._SliceOrder_order_) {
99 }

References StructuralConstraintSliceOrder(), and _SliceOrder_order_.

Here is the call graph for this function:

◆ StructuralConstraintSliceOrder() [5/5]

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

move constructor

Definition at line 102 of file structuralConstraintSliceOrder.cpp.

103 :
104 StructuralConstraintDiGraph(std::move(from)),
105 _SliceOrder_order_(std::move(from._SliceOrder_order_)) {
106 GUM_CONS_MOV(StructuralConstraintSliceOrder);
107 }

References StructuralConstraintSliceOrder(), and _SliceOrder_order_.

Here is the call graph for this function:

◆ ~StructuralConstraintSliceOrder()

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

destructor

Definition at line 110 of file structuralConstraintSliceOrder.cpp.

110 {
111 GUM_DESTRUCTOR(StructuralConstraintSliceOrder);
112 }

References StructuralConstraintSliceOrder().

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

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

checks whether the constraints enable to add an arc

◆ 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()

void gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph, OTHER_CONSTRAINTS >::modifyGraph ( const ArcAddition & 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 116 of file structuralConstraintSliceOrder.cpp.

116 {
117 if (this != &from) {
119 _SliceOrder_order_ = from._SliceOrder_order_;
120 }
121 return *this;
122 }
StructuralConstraintDiGraph & operator=(const StructuralConstraintDiGraph &from)
copy operator

References StructuralConstraintSliceOrder(), _SliceOrder_order_, and gum::learning::StructuralConstraintDiGraph::operator=().

Here is the call graph for this function:

◆ operator=() [2/2]

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

move operator

Definition at line 126 of file structuralConstraintSliceOrder.cpp.

126 {
127 if (this != &from) {
129 _SliceOrder_order_ = std::move(from._SliceOrder_order_);
130 }
131 return *this;
132 }

References StructuralConstraintSliceOrder(), _SliceOrder_order_, and gum::learning::StructuralConstraintDiGraph::operator=().

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

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