scram::core::Pdag
PDAG is a propositional directed acyclic graph. More...
#include <pdag.h>
Inherits from boost::noncopyable
Public Classes
| Name | |
|---|---|
| class | NodeIndexGenerator <br>Generator of unique indices for graph nodes. |
| class | NullGateRegistrar <br>Registers pass-through or Null logic gates belonging to the graph. |
| struct | Substitution <br>Non-declarative substitutions. |
Public Types
| Name | |
|---|---|
| enum | NodeMark { 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 | |
|---|---|
| bool | complement() 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 |
| bool | coherent() const |
| void | coherent(bool flag) |
| bool | normal() const |
| void | normal(bool flag) |
| const GatePtr & | root() |
| const Gate & | root() const |
| void | root(const GatePtr & gate)<br>Sets the root gate. |
| const ConstantPtr & | constant() const |
| bool | HasConstants() const |
| bool | HasNullGates() const |
| bool | IsTrivial() const |
| bool | IsTrivial()<br>Attempts to make the graph trivial if possible. |
| const IndexMap< const mef::BasicEvent * > & | basic_events() const |
| void | Print()<br>Prints the PDAG in the Aralia format. |
| void | Log()<br>Writes PDAG properties into logs. |
| void | RemoveNullGates()<br>Removes gates of Null logic with a single argument (maybe constant). |
| template <NodeMark Mark> <br>void | Clear()<br>Clears marks from graph nodes. |
| template <NodeMark Mark> <br>void | Clear(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 int | kVariableStartIndex <br>The shift value for mapping. |
Detailed Description
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
| Enumerator | Value | Description |
|---|---|---|
| kGateMark | General graph traversal (dirty upon traversal end!). | |
| kVisit | General visit times for graph nodes. | |
| kCount | ||
| kOptiValue | ||
| kDescendant | ||
| kAncestor | ||
| kOrder |
Various kinds of marks applied to the nodes.
using IndexMap
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
inline bool complement() constReturn: true if graph = ~root.
function complement
inline bool & complement()function Pdag
Pdag()Constructs a graph with no root gate ready for general purpose (test) Boolean formulas.
function Pdag
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
inline const std::vector< Substitution > & substitutions() constReturn: Non-declarative substitutions to be applied by analysis.
function coherent
inline bool coherent() constReturn: true if the fault tree is coherent.
function coherent
inline void coherent(
bool flag
)Parameters:
- flag true if fault tree doesn't contain non-coherent gates.
function normal
inline bool normal() constReturn: true if all gates of the fault tree are normalized AND/OR.
function normal
inline void normal(
bool flag
)Parameters:
- flag true if the graph has been normalized.
function root
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
inline const Gate & root() constReturn: The current root gate of the graph.
Precondition: The graph has been constructed with a root gate.
function root
inline void root(
const GatePtr & gate
)Sets the root gate.
Parameters:
- gate Replacement root gate.
This function is helpful for transformations.
function constant
inline const ConstantPtr & constant() constReturn: The single Boolean constant for the whole graph.
function HasConstants
inline bool HasConstants() constReturn: true if the graph contains pass-through gates with a constant.
function HasNullGates
inline bool HasNullGates() constReturn: true if the graph has at least one pass-through logic gate.
function IsTrivial
inline bool IsTrivial() constReturn: 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
bool IsTrivial()Attempts to make the graph trivial if possible.
Return: true if the graph is trivial or made trivial.
function basic_events
inline const IndexMap< const mef::BasicEvent * > & basic_events() constReturn: 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
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
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
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
template <NodeMark Mark>
inline void Clear()Clears marks from graph nodes.
Template Parameters:
- Mark The kind of the mark.
function Clear
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
static const int kVariableStartIndex = 2;The shift value for mapping.
Updated on 2025-11-11 at 16:51:08 +0000
