Create and Manage Allocations Programmatically
This example shows how to create and manage System Composer™ allocations using the Allocation Editor and programmatic interfaces.
In systems engineering, an architectural system is commonly described on different levels. Functional architectures  describe the high-level functions of a system. Logical architectures  describe the logical components of a system and how data is exchanged between them. You can use allocations to establish relationships from functional components to logical components and to indicate deployment strategies.
An allocation establishes a directed relationship from architectural elements — components, ports, and connectors — in one model to architectural elements in another model.
Resource-based allocation allows you to allocate functional architectural elements to logical architectural elements and logical architectural elements to physical architectural elements.
An allocation scenario contains a set of allocations between a source and a target model.
Allocate between model elements in an allocation scenario. The default allocation scenario is called
An allocation set consists of one or more allocation scenarios that describe various allocations between a source and a target model.
Create an allocation set with allocation scenarios in the Allocation Editor. Allocation sets are saved as MLDATX files.
To create allocations interactively, see Create and Manage Allocations Interactively.
To learn more about how System Composer concepts apply to systems engineering design, see System Composer Concepts.
Create and Manage Allocations Using Tire Pressure Monitoring System
This example uses the Tire Pressure Monitoring System (TPMS) project. To open the project, use this command.
Create New Allocation Set
You can create an allocation set using the Allocation Editor. In this example,
TPMS_FunctionalArchitecture.slx is the source model and
TPMS_LogicalArchitecture.slx is the target model.
To create an allocation set for these models, use this command.
allocSet = systemcomposer.allocation.createAllocationSet(... 'FunctionalToLogical', ...% Name of the allocation set 'TPMS_FunctionalArchitecture', ... % Source model 'TPMS_LogicalArchitecture' ... % Target model );
To see the allocation set, open the Allocation Editor by using this command.
Create Allocations Between Two Models
This example shows how to programmatically create allocations between two models in the TPMS project.
systemcomposer.arch.Component objects for the reporting functions in the functional architecture model.
functionalArch = systemcomposer.loadModel('TPMS_FunctionalArchitecture'); reportLevels = functionalArch.lookup('Path',... 'TPMS_FunctionalArchitecture/Report Tire Pressure Levels'); reportLow = functionalArch.lookup('Path',... 'TPMS_FunctionalArchitecture/Report Low Tire Pressure');
systemcomposer.arch.Component object for the TPMS reporting system component in the logical architecture model.
logicalArch = systemcomposer.loadModel('TPMS_LogicalArchitecture'); reportingSystem = logicalArch.lookup('Path',... 'TPMS_LogicalArchitecture/TPMS Reporting System');
Create the allocations in the default scenario that is created.
defaultScenario = allocSet.getScenario('Scenario 1'); alloc = defaultScenario.allocate(reportLevels,reportingSystem); defaultScenario.allocate(reportLow,reportingSystem);
Optionally, you can delete the allocation between reporting low tire pressure and reporting system.
Use Stereotypes on Allocations
This example shows how to programmatically apply stereotypes to allocations and use stereotypes to parameterize allocations.
allocSet.applyProfile("TPMSProfile") alloc.applyStereotype("TPMSProfile.FunctionalAllocation") setProperty(alloc,"TPMSProfile.FunctionalAllocation.IsImplemented","true")
 Carter, Jeffrey. “Functional Architecture.” Guide to the Systems Engineering Body of Knowledge (SEBoK) v. 2.7, released October 31, 2022. https://sebokwiki.org/wiki/Functional_Architecture.
 Faisandier, Alan, Garry Roedler, and Rick Adcock. “Logical Architecture.” Guide to the Systems Engineering Body of Knowledge (SEBoK) v. 2.7, released October 31, 2022. https://sebokwiki.org/wiki/Logical_Architecture.