模型度量数据聚合
你可以更好地理解大小、复杂性和可读性分析模型及其组件的聚合模型度量数据。聚合度量数据是可用的AggregatedValue
和AggregatedMeasures
属性的slmetric.metric.Result
对象。的AggregatedValue
属性聚合度规标量值。的AggregatedMeasures
财产总量指标措施(即度量值的详细信息)。
模型指标聚合是如何运作的吗
的实现模型度量定义了一个度量集合数据跨组件的层次结构。MathWorks模型度量的slmetric.metric.Metric
类定义了模型指标聚合。这个类包含了AggregationMode
财产,这些选项:
总和
:返回的总和价值
财产和价值
属性的孩子组件在组件层次结构。返回的总和Meaures
财产和措施
属性的孩子组件在组件层次结构。马克斯
:返回的最大价值
财产和价值
属性的孩子组件在组件层次结构。返回的最大措施
财产和措施
属性的孩子组件在组件层次结构。没有一个
:没有度量值的聚合。
你可以找到的描述MathWorks指标及其模型AggregationMode
属性设置模型指标。自定义指标的一部分算法
方法,您可以定义如何度规聚合数据。有关更多信息,请参见创建一个自定义模型度量Nonvirtual块计数。
此图显示了软件总量指标数据在模型层次结构的组成部分。父模型层次结构的顶部。组件可以如下:
模型
子系统块
图表
MATLAB功能块
保护模式
在图中,AggregationMode
是总和
和层次结构模型和组件都有一个价值
和一个AggregatedValue
。的AggregatedValue
为父母模型或组件的总和价值
和AggregatedValue
每一个直接的子组件。例如,在这个图中,AggregatedValue
的父模型75年
。的AggregatedValue
父模型计算的总和价值
父母的模型,6
,加上AggregatedValue
每一个直接的子组件,33
,17
,19
。
聚合度量数据的访问
这个例子展示了如何以编程方式收集度量数据的度量引擎,然后聚合度量数据的访问。
加载
sldemo_auto_climatecontrol
模型。openExample (“sldemo_auto_climatecontrol”)
创建一个
slmetric.Engine
分析根对象并设置。metric_engine = slmetric.Engine ();setAnalysisRoot (metric_engine“根”,…“sldemo_auto_climatecontrol”,“RootType”,“模型”);
收集数据的输入输出模型度量。
执行(metric_engine“mathworks.metrics.IOCount”);
得到模型度量数据,返回一个数组
slmetric.metric.ResultCollection
对象,res_col
。指定的输入参数AggregationDepth
。res_col = getMetrics (metric_engine,“mathworks.metrics.IOCount”,…“AggregationDepth”,“所有”);
的
AggregationDepth
输入参数有两种选择:所有
和没有一个
。如果你不希望getMetrics
聚合方法措施和值,指定没有一个
。显示结果。
metricData = {“MetricID”,“ComponentPath”,“价值”,…“AggregatedValue”,“措施”,“AggregatedMeasures”};问= 1;为n = 1:长度(res_col)如果res_col (n)。状态= = 0的结果= res_col (n) .Results;为m = 1:长度(结果)disp ([“MetricID:”,结果(m) .MetricID]);disp ([“ComponentPath:”,结果(m) .ComponentPath]);disp ([的价值:num2str(结果(m) value)]);disp ([的聚合值:num2str(结果(m) .AggregatedValue)]);disp ([的措施:num2str(结果(m)各行业)]);disp ([的聚合的措施:,…num2str(结果(m) .AggregatedMeasures)]);metricData {cnt + 1, 1} = (m) .MetricID结果;metricData{问+ 1,2}= (m) .ComponentPath结果;metricData{问+ 1,3}=结果(m) value;tdmetricData{问+ 1,4}=结果(m)各行业;metricData{问+ 1,5}= (m) .AggregatedMeasures结果;问=问+ 1;结束其他的disp ([“没有结果:”,res_col (n) .MetricID]);结束disp (' ');结束
这里是结果:
MetricID: mathworks.metrics。IOCount ComponentPath: sldemo_auto_climatecontrol值:0聚合值:9措施:0 0 0 0聚合措施:5 4 0 0 MetricID: mathworks.metrics。IOCount ComponentPath: sldemo_auto_climatecontrol / AC控制价值:6聚合值:6措施:5 1 0 0聚合措施:5 1 0 0 MetricID: mathworks.metrics。IOCount ComponentPath: sldemo_auto_climatecontrol /外部温度在摄氏度值:1聚合值:1措施:0 1 0 0聚合措施:0 1 0 0 MetricID: mathworks.metrics。IOCount ComponentPath: sldemo_auto_climatecontrol /热量从居住者值:1聚合值:1措施:0 1 0 0聚合措施:0 1 0 0 MetricID: mathworks.metrics。IOCount ComponentPath: sldemo_auto_climatecontrol /加热器控制价值:8聚合值:8措施:5 3 0 0聚合措施:5 3 0 0 MetricID: mathworks.metrics。IOCount ComponentPath: sldemo_auto_climatecontrol /室内动态值:3聚合值:3措施:2 1 0 0聚合措施:2 1 0 0 MetricID: mathworks.metrics。IOCount ComponentPath: sldemo_auto_climatecontrol /更多信息值:0聚合值:0措施:0 0 0 0聚合措施:0 0 0 0 MetricID: mathworks.metrics。IOCount ComponentPath: sldemo_auto_climatecontrol /子系统值:2聚合值:2措施:1 1 0 0聚合措施:1 1 0 0 MetricID: mathworks.metrics。IOCount ComponentPath: sldemo_auto_climatecontrol / Subsystem1值:2聚合值:2措施:1 1 0 0聚合措施:1 1 0 0 MetricID: mathworks.metrics。IOCount ComponentPath: sldemo_auto_climatecontrol /温度控制表值:9聚合值:9措施:5 4 0 0聚合措施:5 4 0 0 MetricID: mathworks.metrics。IOCount ComponentPath: sldemo_auto_climatecontrol /用户选点摄氏度值:1聚合值:1措施:0 1 0 0聚合措施:0 1 0 0
输入输出指标,AggregationMode
是马克斯
。对于每一个组件,AggregatedValue
和AggregatedMeasures
属性的最大数量的输入和输出本身及其子组件。例如,对于sldemo_auto_climatecontrol
,AggregatedValue
属性是9
,这是sldemo_auto_climatecontrol /温度控制图
组件值。
另请参阅
slmetric.metric.Metric
|slmetric.Engine
|slmetric.metric.Result
|slmetric.metric.ResultCollection