Main Content

Analyze Architecture

Perform static analysis on a System Composer™ architecture to evaluate characteristics of the system.

Analysisis a method for quantitatively evaluating an architecture for certain characteristics. Static analysis analyzes the structure of the system. Static analysis uses an analysis function and parametric values of properties captured in the system model.

使用分析来计算系统的总体可靠性,质量汇总,性能或热特性或执行交换分析。

根据元素属性编写静态分析,以执行数据驱动的贸易研究并验证系统要求。考虑一个机电系统,在成本和重量之间进行权衡,较轻的组件往往更高。决策过程涉及根据其元素的属性分析系统的整体成本和权重,以及迭代的属性,以获得从成本和权重的角度来看可以接受的解决方案。

The analysis workflow consists of these steps:

  1. Define a profile containing a set of stereotypes that describe some analyzable properties (for example, cost and weight).

  2. Apply the profile to an architecture model and add stereotypes from that profile to elements of the model (components, ports, or connectors).

  3. Specify values for the properties on those elements.

  4. 编写分析功能以计算贸易研究所需的值。这是系统模型中捕获的参数和相关属性值的静态约束求解器。

  5. Create an instance of the architecture model, which is a tree of elements, corresponding to the model hierarchy with all shared architectures expanded and a variant configuration applied. Use the实例化架构模型工具。

  6. 运行分析功能,然后查看分析计算,并在分析查看器工具。

Set Properties for Analysis

This example shows how to enable analysis by adding stereotypes to model elements and setting property values. The model provides the basis to analyze the trade-off between total cost and weight of the components in a simple architecture model of a robot system.

Open the Model

Open thesystemWithProps体系结构模型。

进口Profile

Enable analysis of properties by first importing a profile. In the toolstrip, navigate to造型>Profiles>进口并浏览配置文件以导入它。

将刻板​​印象应用于模型元素

将刻板​​印象应用于分析一部分的所有模型元素。使用“应用刻板印象”对话框将刻板印象应用于某种类型的所有元素。导航造型>Apply Stereotypes. In Apply Stereotypes, from将刻板​​印象应用于, select成分. From范围, select这个信用证ayer. For more information, seeUse Apply Stereotypes Dialog to Batch Apply Stereotypes.

Tip

Make sure you apply the stereotype to the top-level component if a cumulative value is to be computed.

Set Property Values

Set property values for each model element in the Property Inspector. To open the Property Inspector, navigate to造型>物业检查员.

  1. 选择模型元素。

  2. In the Property Inspector, expand the stereotype name and type values for properties.

Robot component stereotype displayed from the property inspector called Physical Component with properties named: unit cost 3000 dollars, volume 0 meters cubed, and weight 20 kilograms.

Create a Model Instance for Analysis

体系结构的模型,创建一个实例you can use for analysis.

An实例is an occurrence of an architecture model element at a given point in time.

实例在实例模型中冻结了组件的活动变体或模型参考。

An实例model是实例集合。

您可以更新具有更改模型的实例模型,但是实例模型不会随着活动变体或模型引用的更改而更新。您可以使用一个实例模型,保存在file, of a System Composer architecture model for analysis.

导航造型>分析模型to open the实例化架构模型工具。指定创建和查看分析模型所需的所有参数。

实例化架构模型window with stereotypes listed on the left and configure analysis on the right with analysis function, iteration order bottom-up, and instance model name system with props. Options are to cancel or instantiate.

The选择刻板印象tree lists the stereotypes of all profiles that have been loaded in the current session and allows you to select those whose properties should be available in the instance model. You can browse for an analysis function, create a new analysis function, or skip analysis at this point. If the analysis function requires inputs other than elements in the model, such as an exchange rate to compute cost, enter it in函数参数. Select a mode for iterating through model elements, for example,自下而上to move from the leaves of the tree to the root.Strict Modeensures instances get properties only if the corresponding element in the composition model has the stereotype applied.

To view the instance, clickInstantiateand launch the分析查看器工具。

The Analysis Viewer shows all elements in the first column. The other columns show properties for all stereotypes chosen for the current instance. If a property is not part of a stereotype applied to an element, that field is greyed out. You can use the筛选按钮以隐藏某些刻板印象的属性。选择一个元素时,实例属性显示了元素的刻板印象和属性值。您可以将实例保存在垫子中,然后在分析查看器中再次打开。

Select an element in the Analysis Viewer to see the drop down option under Update to Update Element.

如果在打开实例时对模型进行更改,则可以将实例与模型同步。更新推动从实例到模型的更改。刷新从模型中提取对实例的更改。非同步变化以不同的颜色显示。选择一个元素可以使选项更新Element.

写分析功能

Write a function to analyze the architecture model using instances. An analysis function quantitatively evaluates an architecture for certain characteristics.

Ananalysis functionis a MATLAB®function that computes values necessary to evaluate the architecture using the properties of each element in the model instance.

使用分析功能来计算分析结果。

有关更多信息,请参阅分析功能构造.

您可以在设置分析实例模型时添加分析功能。选择感兴趣的刻板印象后,通过单击创建模板功能旁边Analysis function场地。生成的M文件包括从所有刻板印象中获取所有属于分析的代码。分析函数在单个元素上运行 - 当您使用该函数在模型中的所有元素上迭代该函数时,当您使用该元素进行分析,从而生成聚合值分析查看器工具。

functionsystemWithProps_1(instance,varargin)如果实例.isComponent() && ~isempty(instance.Components)...&& instance.hasValue('System -Profile.physicalelement.unitcost') sysComponent_unitPrice = 0;为了child = instance.com如果child.hasvalue('System -Profile.physicalelement.unitcost') comp_price = child.getValue('System -Profile.physicalelement.unitcost'); sysComponent_unitPrice = sysComponent_unitPrice + comp_price;结尾结尾实例.setValue('System -Profile.physicalelement.unitcost', sysComponent_unitPrice);结尾

In the generated file,实例is the instance of the element on which the analysis function runs currently. You can perform these operations for analysis:

  • 访问实例的属性:实例.getValue("..")

  • 设置实例的属性:实例.setValue("..",value)

  • Access the subcomponents of a component:实例.Components

  • Access the connectors in component:实例.Connectors

ThegetValuefunction generates an error if the property does not exist. You can usehasvalue查询在获取值之前,模型中的元素是否具有属性。

例如,此代码将组件的权重计算为其子组件的权重之和。

如果实例.isComponent() && ~isempty(instance.Components)...&& instance.hasValue('SystemProfile.PhysicalElement.weight') weight = 0;为了child = instance.com如果child.hasvalue('SystemProfile.PhysicalElement.weight') subcomp_weight = child.getValue('SystemProfile.PhysicalElement.weight'); weight = weight + subcomp_weight;结尾结尾实例.setValue('SystemProfile.PhysicalElement.weight',weight);结尾

Once the analysis function is complete, add it to the analysis under theAnalysis function盒子。分析函数可以采用其他输入参数,例如,如果权重在不同的刻板印象中,则转换常数。当此代码递归为所有组件运行时,从层次结构中的最深组件开始到最高级别,系统的整体权重分配给了weight顶级组件的属性。

运行分析功能

使用分析查看器.

  1. 选择或更改分析功能Analyzemenu.

  2. Select the iteration method.

    • Pre-order— Start from the top level, move to a child component, and process the subcomponents of that component recursively before moving to a sibling component.

    • 自顶向下- 像预订一样,但是在转到其子组件之前处理所有同胞组件。

    • Post-order— Start from components with no subcomponents, process each sibling, and then move to parent.

    • 自下而上- 像后订单一样,但是在移交给父母之前,请处理所有子组件。

    The iteration method depends on what kind of analysis is to be run. For example, for an analysis where the component weight is the sum of the weights of its components, you must make sure the subcomponent weights are computed first, so the iteration method must be bottom-up.

  3. 点击Analyze按钮。

System Composer runs the analysis function over each model element and computes results. The computed properties are highlighted yellow in the分析查看器.

The unit cost is computed and shown in yellow.

Here, the total cost of the system is5100美元and the total weight is55 kg.

See Also

|||||||||||

Related Topics