Manage Model Complexity and Maintainability with Dashboards
Learn how to assess the size, architecture, and complexity of your design by using the metric data in the new Model Maintainability Dashboard. The metrics measure different aspects of model maintainability from model design artifacts such as Simulink® models, Stateflow® charts, and MATLAB® code. The model maintainability metrics help you determine if parts of a design are too complex and need to be refactored. A less complex design is easier to read, maintain, and test.
Published: 14 Oct 2022
Teams incrementally develop, maintain, and collaborate on complex models using Simulink. Everyone who has been working on large models and projects has seen situations like this, where the model has become very hard to understand and modify over time. But how can you objectively measure the maintainability of such a model? And when is the cost of maintaining a model too high, so that it should be refactored or reimplemented?
With the new Model Maintainability dashboard, you can quickly see metric data to assess the size, architecture, and complexity of your project. Like the Model Testing dashboard, this new dashboard monitors your work to provide immediate feedback and insight. The dashboard consists of three main areas of content.
On the left, the Project Architecture panel shows you the classified units and component models. Below that is the artifact panel, which shows all the related artifacts for the calculation of the metrics on the currently open dashboard. On the right side is a dashboard with widgets for key metrics.
The Architecture panel shows the hierarchy of component and unit models. Components and units are verified as a whole and define the scope of the dashboard. The unit and component boundaries define how the metrics are aggregated, for example, that you get the correct overall block count for your component. What is displayed here can be customized in the options.
The Component Structure section of the dashboard shows aggregated metrics for the cyclomatic complexity and structure of the whole component. For example, these metrics will aggregate information from all references, including models, link libraries, and MATLAB files. The layer depth shows the maximum call stock of the model. It counts how subsystems, StateFlow charts, and MATLAB functions are nested. The breadth shows the maximum number of subsystems per layer.
To understand the definition of any metric, you can access the help with the three dots. The component interface section summarize the input and output ports and signals for the component interface. The cyclomatic complexity is displayed here for Simulink, StateFlow, and MATLAB.
The Architecture sections provide key size metrics as an aggregated number for the whole component and a distribution across the model layers. For Simulink, there are the number of signal lines, blocks, go-tos per subsystem. And you can drill down into any of these metrics to get a granular view of how they are computed. For MATLAB, the lines of code per MATLAB function, method, or function block. And for StateFlow, the number of states and transitions per StateFlow chart.
You can see right away that the overall complexity is very high on this component. And StateFlow is the main contributor. The distribution of complexity can be used to identify that this StateFlow chart is the cause of the high complexity.
You can use the links to navigate to the problem chart, where you quickly can see that the chart is indeed very complex. One option is to break the parallel states into separate charts that can be verified independently. Let's take a look at the maintainability of the EV powertrain controller component.
Here, we can see an outlier in the signal count and block count metric. This model layer looks quite messy and unstructured. It is very difficult to understand what is going on. Grouping the blocks into subsystems could help give structure and make the signal flow easier to digest.
And in addition to reviewing results on a desktop, results can be generated in CI systems. Results can be programmatically queried or generated into a human-readable report. The results are persisted in a database, which can be pushed into Artifactory, for example, and integrated into local projects.
So that was a quick overview of the Model Maintainability dashboard. In summary, the dashboard provides an objective quantification of the maintainability for your models and helps satisfy requirements from safety standards like ISO 26262.