1 classdef INode < DataTree.INode & Greedy.DataTree.Info
2 % %Interface
class for general data tree nodes storing detailed data returned
3 % by Greedy.Interface.gen_detailed_data()
5 % Usually every Greedy.Interface instance creates a
new node in the detailed
6 % data tree with
new reduced basis functions or a logging information about
7 % the steps taken by the Greedy.Interface node.
12 % storage of history entries (c.f. snapshot() and format_snapshot() )
17 properties (Access = private)
19 history_ids = struct('
id', {},
'id_descr', {},
'map', []);
25 function set_rb(
this, RB)
26 %
function set_rb(
this, RB)
27 % sets the reduced basis space
29 % @todo is
this correct or should it be in a specialization?
33 function RB = get_rb(
this)
34 %
function set_rb(
this, RB)
35 % returns the reduced basis space
37 % @todo is
this correct or should it be in a specialization?
42 %
function data = get_by_description(
this,
id, dmodel)
43 % %
function data = get_by_description(
this,
id, model)
44 % % returns a
leaf in the DataTree
for a specific ID, parameter and time instant.
48 % %
id: a
string specifying an optional ID restriction. (
default = empty)
51 % % data:
leaf element of type Greedy.DataTree.Detailed.ILeafNode.
59 % mu = get_mu(dmodel);
60 % nt = dmodel.descr.nt;
62 % data = get_by_description@DataTree.INode(
this,
id, mu, nt);
65 function snapshot(
this,
id, id_text, snapshot_description)
66 %
function snapshot(
this,
id, id_text, snapshot_description)
67 % creates a copy of the Greedy.Info element of the subtree rooted by
this
68 % node and stores it in a history.
70 % The history is organized by
short ID strings to whom a longer
71 % description text should be attached. Furthermore every history entry
72 % can be decribed by a Matlab
struct. A Date tag is added automatically.
75 % which refines the training parameter space several times. At all these
76 % time instants it creates a new history entry.
79 % id: the id string under which the history entry shall be stored.
80 % id_text: a descriptive text for the id. This is only used at the
81 % first time a history entry for the 'id' is created.
82 % snapshot_description: a description of the history entry with
84 [dummy, index] = intersect({this.history_ids.
id},
id);
85 hist_index = length(this.history) + 1;
87 index = length(this.history_ids) + 1;
88 this.history_ids(index).
id =
id;
89 this.history_ids(index).map = hist_index;
91 this.history_ids(index).map = [this.history_ids(index).map, hist_index];
95 this.history_ids(index).id_descr = id_text;
98 dates = datestr(clock, 'dd.mm.yyyy HH:MM');
100 if ~isempty(this.fields) || ~isempty(this.stop_flags)
101 this.history{hist_index}.description = snapshot_description;
102 this.history{hist_index}.date = dates;
103 if ~isempty(this.fields)
104 this.history{hist_index}.fields = this.fields;
106 if ~isempty(this.stop_flags)
107 this.history{hist_index}.stop_flags = this.stop_flags;
111 snapshot_children(
this,
id, id_text, snapshot_description);
114 function sl = get_snapshot_length(
this,
id)
115 %
function sl = get_snapshot_length(
this,
id)
116 % returns the number of history entries stored
for a specific
id.
122 % sl: number of history entries
123 [dummy, index] = intersect(this.history_ids.id,
id);
127 sl = length(this.history_ids.
id{index});
131 function fs = format_snapshot(
this,
id, indices)
132 %
function fs = format_snapshot(
this,
id, indices)
133 % retuns a formatted structure of a history item
for several indices
136 [dummy, index] = intersect({this.history_ids.id}, id);
141 if nargin == 2 || isempty(indices)
142 indices = 1:length(this.history_ids(index).map);
146 fs.descr = this.history_ids(index).id_descr;
147 fs.history = this.history{this.history_ids(index).map(indices)};
149 children = gather_children_format_snapshot(
this,
id, indices);
150 if ~isempty(children)
151 fs.children = children;
157 methods(Access = protected)
159 function snapshot_children(this,
id, id_text, snapshot_description)
160 % function snapshot_children(this,
id, id_text, snapshot_description)
161 % forward the snapshot generation to the children
162 for i = 1:length(this)
163 snapshot_children(get(this, i),
id, id_text, snapshot_description);
167 function children = gather_children_format_snapshot(this,
id, indices)
168 % function children = gather_children_format_snapshot(this,
id, indices)
169 % helper function called by format_snapshot()
170 children = cell(1, length(this));
171 for i = 1:length(this)
172 children{i} = gather_children_format_snapshot(
get(
this, i),
id, indices);
179 %
function siz = get_rb_size(
this);
180 % returns the size of the reduced basis stored in
this tree.
183 % siz: dimension of stored reduced basis space `{\cal W}_{\text{red}}`
184 siz = get_rb_size(
this);
186 %
function siz = get_ei_size(
this);
187 % returns the size of the collateral reduced basis stored in
this tree.
190 % siz: a tree of nodes which are objects of type DataTree.IdMapNode
191 % of stored collateral reduced basis spaces `{\cal W}^{{\cal
192 % L}_h}_{\text{red}}`
for operators `{\cal L}_h`
193 siz = get_ei_size(
this);
195 %
function [ot1, ot2, ot3] = offtime(
this, rmodel)
196 % returns up to three different offline time measurements
197 [ot1, ot2, ot3] = offtime(
this, rmodel);