主要内容

模型度量数据聚合

你可以更好地理解大小、复杂性和可读性分析模型及其组件的聚合模型度量数据。聚合度量数据是可用的AggregatedValueAggregatedMeasures属性的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

聚合度量数据的访问

这个例子展示了如何以编程方式收集度量数据的度量引擎,然后聚合度量数据的访问。

  1. 加载sldemo_auto_climatecontrol模型。

    openExample (“sldemo_auto_climatecontrol”)
  2. 创建一个slmetric.Engine分析根对象并设置。

    metric_engine = slmetric.Engine ();setAnalysisRoot (metric_engine“根”,“sldemo_auto_climatecontrol”,“RootType”,“模型”);

  3. 收集数据的输入输出模型度量。

    执行(metric_engine“mathworks.metrics.IOCount”);
  4. 得到模型度量数据,返回一个数组slmetric.metric.ResultCollection对象,res_col。指定的输入参数AggregationDepth

    res_col = getMetrics (metric_engine,“mathworks.metrics.IOCount”,“AggregationDepth”,“所有”);

    AggregationDepth输入参数有两种选择:所有没有一个。如果你不希望getMetrics聚合方法措施和值,指定没有一个

  5. 显示结果。

    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马克斯。对于每一个组件,AggregatedValueAggregatedMeasures属性的最大数量的输入和输出本身及其子组件。例如,对于sldemo_auto_climatecontrol,AggregatedValue属性是9,这是sldemo_auto_climatecontrol /温度控制图组件值。

另请参阅

|||

相关的话题