1 classdef Uniform < ParameterSampling.IRefineable
2 % Parameter sampling
class with uniformly distributed parameters in the
5 properties (SetAccess =
private, Dependent)
11 %
boolean value determining whether a logarithmic
function shall be
12 % applied on the uniform distribution of the parameter samples.
13 log_distribution =
false;
15 % vector or scalar determining how many equally distant vectors shall be
16 % added to the parameter sample in each direction.
18 % If it is a vector,
for each direction of the parameter space a different
19 % number can be given.
20 init_numintervals = 2;
23 properties (Access =
public)
29 function ups =
Uniform(init_numintervals, log_distribution)
30 %
function ups =
Uniform(init_numintervals, log_distribution)
34 % init_numintervals: vector or scalar determining how many equally
35 % distant vectors shall be added to the parameter
36 % sample in each direction.
37 % log_distribution:
boolean indicator determining whether a
38 % logarithmic
function shall be applied on the
39 % uniform distribution of the parameter samples.
44 ups.log_distribution = log_distribution;
48 function init_sample(
this, dmodel)
49 %
function init_sample(
this, dmodel)
55 if this.log_distribution
56 params.range = cellfun(@log, dmodel.mu_ranges, 'UniformOutput', false);
58 params.range = dmodel.mu_ranges;
60 if isscalar(this.init_numintervals)
61 params.numintervals = ones(1,length(params.range)) * this.init_numintervals;
63 params.numintervals = this.init_numintervals;
68 this.init_done = true;
71 function M = get.sample(this)
73 M = get(this.pgrid, 'vertex');
74 if this.log_distribution
82 function levels = get_refinement_levels(this)
83 % function levels = get_refinement_levels(this)
84 % @copybrief ParameterSampling::
IRefineableget_refinement_levels()
86 % @copydetails ParameterSampling::
IRefineableget_refinement_levels()
87 levels = get(this.pgrid, 'level');
90 function size = size(this)
91 % function size = size(this)
92 % @copybrief ParameterSampling::
Interfacesize()
94 % @copydetails ParameterSampling::
Interfacesize()
95 size = get(this.pgrid, 'nleafelements');
98 function this = refine(this, elems)
99 % function this = refine(this, elems)
100 % @copybrief ParameterSampling::
IRefineablerefine()
102 % @copydetails ParameterSampling::
IRefineablerefine()
104 elems = 1:length(this.pgrid.get_leafgids);
106 this.refined_elements = [this.refined_elements, {elems}];
107 this.sample_history = [this.sample_history, this.sample];
108 refine(this.pgrid, elems);
111 function cogs = cogs(
this)
112 %
function cogs = cogs(
this)
116 cogs = get(this.pgrid, 'leafcogs');
119 function skips = skipped_refinements(this)
120 % function skips = skipped_refinements(this)
121 % @copybrief ParameterSampling::
IRefineableskipped_refinements()
123 % @copydetails ParameterSampling::
IRefineableskipped_refinements()
124 li = get_leafgids(this.pgrid);
125 skips = this.pgrid.refine_steps - this.pgrid.creation_step(li);
128 function max_vertex = elementwise_maximum_of_vertex_values(this, values)
129 % function max_vertex = elementwise_maximum_of_vertex_values(this, values)
130 % @copybrief ParameterSampling::
IRefineableelementwise_maximum_of_vertex_values()
132 % @copydetails ParameterSampling::
IRefineableelementwise_maximum_of_vertex_values()
133 li = get_leafgids(this.pgrid);
134 lv = this.pgrid.vertexindex(li,:);
136 value_vertex = reshape(values(lv(:)), size(lv));
137 max_vertex = max(value_vertex, [], 2);