rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes
DataTree.IdMapNode Class Reference

Detailed Description

Data Tree element which can be filtered by ids

The children branches of this data tree node are all tagged with one or several "Id"s.

The branches can then be accessed via the id argument of the get_index() method.

Note: If one branch is tagged with a list of several "Id"s, any of these "Id"s in the last can be used to access the tagged branch.

Definition at line 18 of file IdMapNode.m.

Inheritance diagram for DataTree.IdMapNode:
Inheritance graph
[legend]
Collaboration diagram for DataTree.IdMapNode:
Collaboration graph
[legend]

Public Member Functions

 IdMapNode (idmap, initvalues, mergefun)
 constructor for an IdMapNode mapping the children nodes with "Id" tags. More...
 
function data = get (index)
 Access to a child of the current node. More...
 
function index = get_index (id, mu, nt)
 Obtains the leaf index vector that best fits the child description given by the three arguments. More...
 
function tree = create_tree (creator, ids, mu_cube, tslice, basepath)
 Creates a new tree from a subtree specified by ids, parameter and time index regions. More...
 
function this = set (i, value, mergefun)
 sets a new value at a specific child branch More...
 
function scalar = scalar (mergefun)
 reduces the data tree values with help of the mergefun More...
 
function ids = get_all_ids ()
 returns all "Id" strings in this IdMapNode. More...
 
function st = get_flat_struct ()
 makes a struct from the data tree with field names equal to the "Id" names. More...
 
function str = num2str ()
 converts the data tree into a string More...
 
function this = minus (scalar)
 substracts a scalar from each of the values in the data tree. More...
 
function  display ()
 prints out a string representation of the data tree.
 
- Public Member Functions inherited from DataTree.DefaultNode
function
children = 
length ()
 Returns the number of children of the node. More...
 
function this = set (index, value)
 Sets a child at the given path in the tree hierarchy. More...
 
- Public Member Functions inherited from DataTree.INode
virtual function DataTree.INode tree = create_tree (DataTree.ICreator creator, ids, mu_cube, tslice, basepath)
 Creates a new tree from a subtree specified by ids, parameter and time index regions. More...
 
function  leaf_func (funcptr, ids, mu_cube, tslice)
 applies a function to all leafs of a DataTree More...
 
function tree = create_scalar_tree (funcptr, ids, mu_cube, tslice)
 copies the current trees with different leafs. These leafs are computes by a function returning scalar values. More...
 
function
start_index = 
traverse_start ()
 Start iterator for a full traverse of the DataTree. More...
 
function
next_index = 
traverse_next (this_index)
 iterator for a full traverse of the DataTree. More...
 
function
description = 
get_active_leaf_description (IModel model, ids)
 returns an enumeration of all leaves' basepath index vectors with a description of their parents. More...
 
function
description = 
get_leaf_description (ids, mu_cube, tslice)
 returns an enumeration of all leaves' basepath index vectors with a description of their parents. More...
 
function tstop = index_valid_till (index)
 Returns the last valid time step index of a time slice. More...
 
function INode data = get_by_description (id, mu, nt)
 A combination of get_index() and get() More...
 
function
active_leaf_index = 
get_active_leaf_index (IModel model, id)
 retuns the leaf element index for the current IDetailedModel configuration. More...
 
function DataTree.LeafNode
active_leaf = 
get_active_leaf (IModel model, id)
 retuns the leaf element for the current IDetailedModel configuration. More...
 
function  display (fn, basepath, name)
 overwrites the standard display method for DataTree objects More...
 
function lines = disp_node (basepath, fn)
 returns a cell array of strings with information on the node. More...
 

Static Public Member Functions

static function flatca = flatten_cell_array (ca)
 flattens a cell array, i.e. returns a cell without cell entries which are cell arrays by itself. More...
 
static function idname = name_from_idmap (idmap)
 creates a string representation of an "Id"-map More...
 

Public Attributes

 idmap
 cell array of "Id" strings More...
 
- Public Attributes inherited from DataTree.DefaultNode
 values = "[]"
 cell array of DataTree.INode elements, holding the childrens of this DataTree.INode. More...
 

Static Public Attributes

static const  data_node_type = "IdMap"
 Data node type identifier. More...
 

Constructor & Destructor Documentation

DataTree.IdMapNode.IdMapNode (   idmap,
  initvalues,
  mergefun 
)

constructor for an IdMapNode mapping the children nodes with "Id" tags.

This constructor can be run in two modes
  1. Flat-mode: This creates exactly one IdMapNode, such that it is possible that one child is tagged with more than one "Id" string.
  2. Recursive-mode: This creates a tree of IdMapNode nodes, such that the leafs of this tree are tagges with exactly one "Id" string.

The constructor runs in Flat-mode, if a mergefun is given or if initvalues is a cell array. Otherwise, it runs in Recursive-mode.

See also
test_indexed_node() for example usage of this constructor.
Note
that the values given by initvalues are wrapped by a DataTree.DummyLeafNode if they are not derived from a DataTree.INode.
Parameters
idmapa cell array of "Id" strings that are tagged to the children of this node. These "Id"s can also be nested, which either leads to a child tagged with more than one "Id"s or a recursively build tree of IdMapNode nodes. See the explanation of Flat-mode and Recursive-Mode for details.
initvaluesThis can be
  1. a scalar,
  2. a cell array,
  3. a struct or
  4. an IdMapNode
  • In the first case every child of this node is set to this scalar.
  • In the second case the i-th child is set to initvalues{i}.
  • In the third and fourth case, a child tagged with id is set to initvalues.(id) respectively get(initvalues, get_index(initvalues, id, [], [])). In Flat-mode, the mergefun might apply here, too.
mergefunThis is a function pointer to a function expecting a cell array of values as an argument and returning an arbitrary value. This function pointer is used, in case the constructor runs in Flat-mode and the initvalues are given as an IdMapNode or a struct. For children tagged with several "Id"s id1, ..., idn, mergefun can be used to compute a value for this child from the cell array {initvalues.id1,..., initvalues.idn}. If mergefun is set to [], a default function
@(x) x{1};
is used.

Definition at line 74 of file IdMapNode.m.

Here is the call graph for this function:

Member Function Documentation

function tree = DataTree.IdMapNode.create_tree (   creator,
  ids,
  mu_cube,
  tslice,
  basepath 
)

Creates a new tree from a subtree specified by ids, parameter and time index regions.

The method creates a new DataTree for all nodes tagged by an id in ids, lying in the time slice given by tslice and inside the parameter space region given by mu_rect. At each of these nodes a method from a creator is called to build the tree.

Parameters
creatoran object creating the new tree.
idsa cell array of ids which shall be filtered. An empty cell array means that all ids are accepted. (default = [])
mu_cubea 1x2-cell array of vectors { lower_left, upper_right } specifying the lower left and the upper right corner of a cube in the parameter space for filtering parameter vectors. An empty array disables the filtering (default = []).
tslicea 2D vector specifying an interval of time step indices for time slicing. An empty vector disables the filtering (default = [])
basepatha vector specifying the relation of the current node to the parent node at which the merge began.
Return values
treethe newly created tree

Calls DataTree.Creator.create_idmap_node() to build new elements.

Definition at line 243 of file IdMapNode.m.

Here is the call graph for this function:

function flatca = DataTree.IdMapNode.flatten_cell_array (   ca)
static

flattens a cell array, i.e. returns a cell without cell entries which are cell arrays by itself.

Parameters
caa cell array
Return values
flatcathe flattended cell array

Definition at line 531 of file IdMapNode.m.

Here is the call graph for this function:

Here is the caller graph for this function:

function data = DataTree.IdMapNode.get (   index)
virtual

Access to a child of the current node.

Access a children node by an index which is usually retrieved by a call to get_index()

Parameters
indexvector describing the father-child relation
Return values
datathe children node

Reimplemented from DataTree.DefaultNode.

Definition at line 188 of file IdMapNode.m.

Here is the call graph for this function:

function ids = DataTree.IdMapNode.get_all_ids ( )

returns all "Id" strings in this IdMapNode.

Note
that a flat cell array is returned, such that this might unequal to the idmap.
Return values
idsa cell array of strings with the "Id"s in this data tree.

Definition at line 382 of file IdMapNode.m.

Here is the call graph for this function:

Here is the caller graph for this function:

function st = DataTree.IdMapNode.get_flat_struct ( )

makes a struct from the data tree with field names equal to the "Id" names.

Return values
stflat struct as described above

Definition at line 397 of file IdMapNode.m.

Here is the call graph for this function:

Here is the caller graph for this function:

function index = DataTree.IdMapNode.get_index (   id,
  mu,
  nt 
)
virtual

Obtains the leaf index vector that best fits the child description given by the three arguments.

Parameters
idid string filtered by this node or another IdMapNode instance.
mua parameter vector filtered through a DataTree.PpartNode instance in the tree hierarchy.
ntan integer corresponding to a time step index filtered through a DataTree.TpartNode instance in the tree hierarchy.
Return values
indexindex vector for the element which is filter by the argument triple. If none such element exists, empty vector.

Reimplemented from DataTree.DefaultNode.

Definition at line 210 of file IdMapNode.m.

Here is the caller graph for this function:

function this = DataTree.IdMapNode.minus (   scalar)

substracts a scalar from each of the values in the data tree.

This function assumes, that the IdMapNode has only leaf children.

Parameters
scalarThe scalar to substract from the leaf values.
Return values
thishandle to the changed IdMapNode.

Definition at line 434 of file IdMapNode.m.

Here is the call graph for this function:

function idname = DataTree.IdMapNode.name_from_idmap (   idmap)
static

creates a string representation of an "Id"-map

Parameters
idmapa cell array of strings
Return values
idnamea string of all "Id"s concatenated with the _ character.

Definition at line 598 of file IdMapNode.m.

Here is the call graph for this function:

Here is the caller graph for this function:

function str = DataTree.IdMapNode.num2str ( )

converts the data tree into a string

Return values
stra string representation of the data tree

Definition at line 414 of file IdMapNode.m.

Here is the call graph for this function:

function scalar = DataTree.IdMapNode.scalar (   mergefun)

reduces the data tree values with help of the mergefun

Parameters
mergefunThis is a function pointer to a function expecting a cell array of values as an argument and returning an arbitrary value. For children tagged with several "Id"s id1, ..., idn, mergefun can be used to compute a single value for all thes children values. It gathers the values { values1, ..., valuesn } in a cell array and applies the mergefun on it. The result is returned. The algorithm is run recursively, such that the leaf-level is reduced first, and the upper level's values are reduced. If mergefun is set to [], a default function
@(x) x{1};
is used.
Return values
scalarscalar

Definition at line 350 of file IdMapNode.m.

Here is the call graph for this function:

function this = DataTree.IdMapNode.set (   i,
  value,
  mergefun 
)

sets a new value at a specific child branch

Note
only direct children can be set.
Parameters
iscalar index of the child to be set or vector of indices. In the latter case, set() is called recursively.
valuea scalar, a struct or a tree of IdMapNode nodes as described in the constructor IdMapNode.IdMapNode().
mergefun(optional) If given, the function runs in Flat-mode as described in the constructor description IdMapNode.IdMapNode(). Then value needs to be a struct or a tree of IdMapNode nodes.
Return values
thishandle to the changed IdMapNode.

Definition at line 302 of file IdMapNode.m.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

DataTree.IdMapNode.data_node_type = "IdMap"
static

Data node type identifier.


Default: "IdMap"

Definition at line 52 of file IdMapNode.m.

DataTree.IdMapNode.idmap

cell array of "Id" strings

Note
This property has non-standard access specifiers: SetAccess = Private, GetAccess = Public
Matlab documentation of property attributes.

Definition at line 39 of file IdMapNode.m.


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