Skip to content

scram::core::Pdag

PDAG is a propositional directed acyclic graph. More...

#include <pdag.h>

Inherits from boost::noncopyable

Public Classes

Name
classNodeIndexGenerator <br>Generator of unique indices for graph nodes.
classNullGateRegistrar <br>Registers pass-through or Null logic gates belonging to the graph.
structSubstitution <br>Non-declarative substitutions.

Public Types

Name
enumNodeMark { kGateMark, kVisit, kCount, kOptiValue, kDescendant, kAncestor, kOrder}<br>Various kinds of marks applied to the nodes.
template <typename T > <br>using ext::index_map< kVariableStartIndex, T >IndexMap <br>Sequential mapping of Variable indices to other data of type T.

Public Functions

Name
boolcomplement() const
bool &complement()
Pdag()<br>Constructs a graph with no root gate ready for general purpose (test) Boolean formulas.
Pdag(const mef::Gate & root, bool ccf =false, const mef::Model * model =nullptr)<br>Constructs a PDAG starting from the top gate of a fault tree.
const std::vector< Substitution > &substitutions() const
boolcoherent() const
voidcoherent(bool flag)
boolnormal() const
voidnormal(bool flag)
const GatePtr &root()
const Gate &root() const
voidroot(const GatePtr & gate)<br>Sets the root gate.
const ConstantPtr &constant() const
boolHasConstants() const
boolHasNullGates() const
boolIsTrivial() const
boolIsTrivial()<br>Attempts to make the graph trivial if possible.
const IndexMap< const mef::BasicEvent * > &basic_events() const
voidPrint()<br>Prints the PDAG in the Aralia format.
voidLog()<br>Writes PDAG properties into logs.
voidRemoveNullGates()<br>Removes gates of Null logic with a single argument (maybe constant).
template <NodeMark Mark> <br>voidClear()<br>Clears marks from graph nodes.
template <NodeMark Mark> <br>voidClear(const GatePtr & gate)<br>Determines the proper "clear" state for the graph node mark, and set the clear mark to nodes starting from the given gate.

Public Attributes

Name
const intkVariableStartIndex <br>The shift value for mapping.

Detailed Description

cpp
class scram::core::Pdag;

PDAG is a propositional directed acyclic graph.

Precondition: There are no shared pointers to any other graph gate except for the root gate of the graph upon graph transformations. Extra reference count will prevent automatic deletion of the node and management of the structure of the graph. Moreover, the graph may become a multi-root graph, which is not the assumption of all the other preprocessing and analysis algorithms.

This class provides a simpler representation of a fault tree that takes into account the indices of events instead of IDs and pointers. This graph can also be called an indexed fault tree.

This class is designed to help preprocessing and other graph transformation functions.

Public Types Documentation

enum NodeMark

EnumeratorValueDescription
kGateMarkGeneral graph traversal (dirty upon traversal end!).
kVisitGeneral visit times for graph nodes.
kCount
kOptiValue
kDescendant
kAncestor
kOrder

Various kinds of marks applied to the nodes.

using IndexMap

cpp
template <typename T >
using scram::core::Pdag::IndexMap =  ext::index_map<kVariableStartIndex, T>;

Sequential mapping of Variable indices to other data of type T.

Public Functions Documentation

function complement

cpp
inline bool complement() const

Return: true if graph = ~root.

function complement

cpp
inline bool & complement()

function Pdag

cpp
Pdag()

Constructs a graph with no root gate ready for general purpose (test) Boolean formulas.

function Pdag

cpp
explicit Pdag(
    const mef::Gate & root,
    bool ccf =false,
    const mef::Model * model =nullptr
)

Constructs a PDAG starting from the top gate of a fault tree.

Parameters:

  • root The top gate of the fault tree.
  • ccf Incorporation of CCF gates and events for CCF groups.
  • model The Model containing substitutions if any.

Precondition: No new Variable nodes are introduced after the construction.

Postcondition:

  • All declarative substitutions are applied, and all non-declarative substitutions are collected for application.
  • The PDAG is stable as long as the argument fault tree and its underlying containers are stable. If the fault tree has been manipulated (event addition, etc.), its PDAG representation is not guaranteed to be the same.
  • The index assignment for variables is special: index in [kVariableStartIndex, num of vars + kVariableStartIndex). This indexing technique helps preprocessing and analysis algorithms optimize their work with basic events.
  • All Gate indices >= (num of vars + kVariableStartIndex).

Upon construction, features of the fault tree are recorded to help preprocessing and analysis functions.

function substitutions

cpp
inline const std::vector< Substitution > & substitutions() const

Return: Non-declarative substitutions to be applied by analysis.

function coherent

cpp
inline bool coherent() const

Return: true if the fault tree is coherent.

function coherent

cpp
inline void coherent(
    bool flag
)

Parameters:

  • flag true if fault tree doesn't contain non-coherent gates.

function normal

cpp
inline bool normal() const

Return: true if all gates of the fault tree are normalized AND/OR.

function normal

cpp
inline void normal(
    bool flag
)

Parameters:

  • flag true if the graph has been normalized.

function root

cpp
inline const GatePtr & root()

Return: The shared pointer to current root gate of the graph. nullptr iff the graph has been constructed root-less.

function root

cpp
inline const Gate & root() const

Return: The current root gate of the graph.

Precondition: The graph has been constructed with a root gate.

function root

cpp
inline void root(
    const GatePtr & gate
)

Sets the root gate.

Parameters:

  • gate Replacement root gate.

This function is helpful for transformations.

function constant

cpp
inline const ConstantPtr & constant() const

Return: The single Boolean constant for the whole graph.

function HasConstants

cpp
inline bool HasConstants() const

Return: true if the graph contains pass-through gates with a constant.

function HasNullGates

cpp
inline bool HasNullGates() const

Return: true if the graph has at least one pass-through logic gate.

function IsTrivial

cpp
inline bool IsTrivial() const

Return: true if the graph represents a trivial Boolean function; that is, graph = Constant or graph = Variable. The only gate is the root pass-through to the simple arg.

Note: The root gate may be swapped with a new one.

function IsTrivial

cpp
bool IsTrivial()

Attempts to make the graph trivial if possible.

Return: true if the graph is trivial or made trivial.

function basic_events

cpp
inline const IndexMap< const mef::BasicEvent * > & basic_events() const

Return: Original basic event as initialized in this indexed fault tree. The Variable indices map directly to the original basic events.

Precondition: No new Variable nodes are introduced after the construction.

function Print

cpp
void Print()

Prints the PDAG in the Aralia format.

Warning: Node visits are used.

This is a helper for logging and debugging. The output is the standard error.

function Log

cpp
void Log()

Writes PDAG properties into logs.

Warning: Gate marks are manipulated.

Precondition:

  • The graph is valid and well formed.
  • Logging cutoff level is Debug 4 or higher.

Postcondition: Gate marks are clear.

function RemoveNullGates

cpp
void RemoveNullGates()

Removes gates of Null logic with a single argument (maybe constant).

Warning: Gate marks will get cleared by this function.

Postcondition:

  • If there's still a Null logic gate, then it's the root of the graph with a single variable/constant, and no further processing is required.
  • If there's still a constant, it belongs to the root gate, and the whole graph is constant, so no further processing is required.

That one child arg is transferred to the parent gate, and the original argument gate is removed from the parent gate.

All Boolean constants from the PDAG are removed according to the Boolean logic of the gates upon passing these args to parent gates.

function Clear

cpp
template <NodeMark Mark>
inline void Clear()

Clears marks from graph nodes.

Template Parameters:

  • Mark The kind of the mark.

function Clear

cpp
template <NodeMark Mark>
void Clear(
    const GatePtr & gate
)

Determines the proper "clear" state for the graph node mark, and set the clear mark to nodes starting from the given gate.

Parameters:

  • gate The root gate to start the traversal and cleaning.

Template Parameters:

  • Mark The kind of the mark.

Precondition: The gate marks are usable for traversal (clear, continuous, etc.).

Public Attributes Documentation

variable kVariableStartIndex

cpp
static const int kVariableStartIndex = 2;

The shift value for mapping.


Updated on 2025-11-11 at 16:51:08 +0000