Analyze Architecture

Write analyses based on element properties to perform data-driven trade studies and verify system requirements. Consider an electromechanical system where there is a trade-off between cost and weight, and lighter components tend to cost more. The decision process involves analyzing the overall cost and weight of the system based on the properties of its elements, and iterating on the properties to arrive at a solution that is acceptable both from the cost and weight perspective.

The analysis workflow consists of these steps:

  • Define a profile containing a set of property sets that describe some analyzable properties (for example, cost and weight)

  • Apply the profile to an architecture model and add property sets from that profile to elements of the model (components, ports, or connectors)

  • Specify values for the properties on those elements

  • 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

  • Write an analysis function to compute values necessary for the study

  • Run the analysis function

Set Tags and Properties for Analysis

Enable analysis by tagging model elements and setting property values. Load this model:

systemWithProps

Import a Profile

Enable analysis of properties by first importing a profile. In the Profiles section of the toolstrip, click Manage > Import and browse to the profile.

Apply Stereotypes to Model Elements

Apply stereotypes to all model elements that are part of the analysis. Use the menu items that apply stereotypes to all elements of a certain type. Select Apply Stereotypes > Apply to and then Components > This layer. 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.

  1. Select the model element.

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

Create a Model Instance for Analysis

Create an instance of the architecture model that you can use for analysis. In the Views section, select Analysis Model > Analysis Model. In this dialog box, specify all the parameters required to create and view an analysis model.

The stereotypes 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 one, 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 Function arguments. Select a mode for iterating through model elements, for example, Bottom-up to move from the leaves of the tree to the root.

To view the instance, click Instantiate.

The Analysis Viewer shows all components, ports, and connectors in the first column. The other columns are properties for all stereotypes chosen for this instance. If a property is not part of a stereotype applied to an element, that field is greyed out. You can use the Filter button to hide properties for certain stereotypes. When you select an element, Instance Properties shows its stereotypes and property values. You can save an instance in a MAT-file, and open it again in the Analysis Viewer. If you make changes in the model while an instance is open, you can synchronize the instance with the model by clicking Update. Unsynchronized changes are shown in a different color.

Write Analysis Function

Write a function to analyze the architecture model using instance API. Analysis functions are MATLAB functions that compute values necessary to evaluate the architecture using properties of each element in the model instance.

You can add an analysis function as you set up the analysis instance. After you select the stereotypes of interest, create a template function by clicking the button next to the Analysis function field. The generated M-file includes the code to obtain all property values from all stereotypes that are subject to analysis. The analysis function operates on a single element — aggregate values are generated by iterating this function over all elements in the model when you run the analysis from Analysis Viewer.

function systemWithProps_1(instance,varargin)
% systemWithProps_1 Example Analysis Function
if instance.isComponent()
    sysComponent_unitPrice = instance.getValue("PhysicalElement.unitCost");
    for child = instance.Components
        comp_price = child.getValue("PhysicalElement.unitCost");
        sysComponent_unitPrice = sysComponent_unitPrice + comp_price;
    end
   instance.setValue("PhysicalElement.unitCost",sysComponent_unitPrice);
end

  

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

  • Access a property of the instance: instance.getValue("<stereotype>.<property>")

  • Set a property of an instance: instance.setValue("<stereotype>.<property>",value)

  • Access the subcomponents of a component: instance.Components

  • Access the connectors in component: instance.Connectors

The getValue function generates an error if the property does not exist. You must use error handling functions such as try-catch statements if it is possible that some elements in the model do not use the stereotypes.

As an example, this code computes the weight of a component as a sum of the weights of its subcomponents.

if instance.isComponent()
  weight = 0;
  for child=instance.Components
    subcomp_weight = child.getValue("PhysicalElement.weight");
    weight = weight + subcomp_weight;
  end
  instance.setValue("PhysicalElement.weight",weight)
end
		

Once the analysis function is complete, add it to the analysis. An analysis function can take additional input arguments, for example, a conversion constant if the weights are in different units in different stereotypes. When this code runs for all components recursively,starting from the deepest components in the hierarchy to the top level, the overall weight of the system is assigned to the weight property of the top-level component.

Run Analysis Function

Run an analysis function using the Analysis Viewer.

  1. Select or change the analysis function using the Analyze menu.

  2. Select the iteration method.

    • Preorder: Start from the top level, move to a child component, process the subcomponents of that component recursively before moving to a sibling component.

    • Topdown — Like pre-order, but process all sibling components before moving to their subcomponents.

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

    • Bottomup — Like post-order, but process all subcomponents at the same depth before moving to their parents.

    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. Click the Analyze button.

System Composer runs the analysis function over each model element and computes results. The computed properties are shown in a different color in the Analysis Viewer.

See Also

Related Topics