aGrUM  0.13.2
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 64 of file structuralConstraintSliceOrder.h.

Member Typedef Documentation

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

Definition at line 429 of file structuralConstraintSetStatic.h.

Constructor & Destructor Documentation

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

default constructor

Definition at line 49 of file structuralConstraintSliceOrder.cpp.

49  {
50  GUM_CONSTRUCTOR(StructuralConstraintSliceOrder);
51  }
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 54 of file structuralConstraintSliceOrder.cpp.

References _SliceOrder__order, gum::HashTable< Key, Val, Alloc >::cbegin(), and gum::HashTable< Key, Val, Alloc >::cend().

55  {
56  for (auto iter = order.cbegin(); iter != order.cend(); ++iter) {
57  _DiGraph__graph.addNodeWithId(iter.key());
58  }
59  _SliceOrder__order = order;
60 
61  GUM_CONSTRUCTOR(StructuralConstraintSliceOrder);
62  }
NodeProperty< NodeId > _SliceOrder__order
slices to which belong the nodes

+ Here is the call graph for this function:

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

constructor starting with a given graph

Definition at line 65 of file structuralConstraintSliceOrder.cpp.

66  :
67  StructuralConstraintDiGraph(graph),
68  _SliceOrder__order(order) {
69  GUM_CONSTRUCTOR(StructuralConstraintSliceOrder);
70  }
NodeProperty< NodeId > _SliceOrder__order
slices to which belong the nodes
gum::learning::StructuralConstraintSliceOrder::StructuralConstraintSliceOrder ( const StructuralConstraintSliceOrder from)

copy constructor

Definition at line 73 of file structuralConstraintSliceOrder.cpp.

74  :
75  StructuralConstraintDiGraph(from),
76  _SliceOrder__order(from._SliceOrder__order) {
77  GUM_CONS_CPY(StructuralConstraintSliceOrder);
78  }
NodeProperty< NodeId > _SliceOrder__order
slices to which belong the nodes
gum::learning::StructuralConstraintSliceOrder::StructuralConstraintSliceOrder ( StructuralConstraintSliceOrder &&  from)

move constructor

Definition at line 81 of file structuralConstraintSliceOrder.cpp.

82  :
83  StructuralConstraintDiGraph(std::move(from)),
84  _SliceOrder__order(std::move(from._SliceOrder__order)) {
85  GUM_CONS_MOV(StructuralConstraintSliceOrder);
86  }
NodeProperty< NodeId > _SliceOrder__order
slices to which belong the nodes
gum::learning::StructuralConstraintSliceOrder::~StructuralConstraintSliceOrder ( )
virtual

destructor

Definition at line 89 of file structuralConstraintSliceOrder.cpp.

References operator=().

89  {
90  GUM_DESTRUCTOR(StructuralConstraintSliceOrder);
91  }

+ Here is the call graph for this function:

Member Function Documentation

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

adds a new node in the slice order

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

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

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.

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

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

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.

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

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

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.

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

checks whether the constraints enable to add an arc

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

checks whether the constraints enable to remove an arc

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

checks whether the constraints enable to reverse an arc

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

checks whether the constraints enable to perform a graph change

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.

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.

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.

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.

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

indicates whether a change will always violate the constraint

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.

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

notify the constraint of a modification of the graph

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

notify the constraint of a modification of the graph

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

notify the constraint of a modification of the graph

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

notify the constraint of a modification of the graph

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.
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.
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.
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.
StructuralConstraintSliceOrder & gum::learning::StructuralConstraintSliceOrder::operator= ( const StructuralConstraintSliceOrder from)

copy operator

Definition at line 95 of file structuralConstraintSliceOrder.cpp.

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

Referenced by ~StructuralConstraintSliceOrder().

95  {
96  if (this != &from) {
98  _SliceOrder__order = from._SliceOrder__order;
99  }
100  return *this;
101  }
NodeProperty< NodeId > _SliceOrder__order
slices to which belong the nodes
StructuralConstraintDiGraph & operator=(const StructuralConstraintDiGraph &from)
copy operator

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

move operator

Definition at line 105 of file structuralConstraintSliceOrder.cpp.

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

105  {
106  if (this != &from) {
108  _SliceOrder__order = std::move(from._SliceOrder__order);
109  }
110  return *this;
111  }
NodeProperty< NodeId > _SliceOrder__order
slices to which belong the nodes
StructuralConstraintDiGraph & operator=(const StructuralConstraintDiGraph &from)
copy operator

+ Here is the call graph for this function:

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

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

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

sets a new graph from which we will perform checkings

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

sets a new graph from which we will perform checkings

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

sets the time slices of all the nodes in the property

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

returns the current slice order

Member Data Documentation

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

slices to which belong the nodes

Definition at line 231 of file structuralConstraintSliceOrder.h.

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


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