Advisor.authoring.CompositeConstraint class

Package: Advisor.authoring

Create a Model Advisor constraint that checks for multiple constraints

Description

Instances of Advisor.authoring.CompositeConstraint class contain multiple constraints. Depending on the instance definition, the Model Advisor reports a violation if a model does not meet one or all of the constraints.

Construction

cc = Advisor.authoring.CompositeConstraint() creates an instance of this class

Properties

expand all

IDs of constraints that compose an Advisor.authoring.CompositeConstraint object. This property is read-only. Use the addConstraintID method to create a CompositeConstraint.

Use and operator to specify that the Model Advisor reports a violation if a model does not meet all of the check constraints. Use or operator to specify that the Model Advisor reports a violation if a model does not meet at least one of the check constraints. This property is read/write.

Methods

addConstraintID Add constraint to composite constraint

Examples

collapse all

These commands specify a composite constraint for Multi-Port Switch blocks.

Create three PositiveBlockParameter constraint objects.

c1 = Advisor.authoring.PositiveBlockParameterConstraint(); 
c1.ID = 'ID_A2'; 
c1.BlockType = 'MultiPortSwitch'; 
c1.ParameterName = 'DataPortOrder'; 
c1.SupportedParameterValues = {'Specify indices'}; 
c1.ValueOperator = 'eq'; 

c2 = Advisor.authoring.PositiveBlockParameterConstraint(); 
c2.ID = 'ID_A3'; 
c2.BlockType = 'MultiPortSwitch'; 
c2.ParameterName = 'DataPortForDefault'; 
c2.SupportedParameterValues = {'Additional data port'}; 
c2.ValueOperator = 'eq'; 

c3 = Advisor.authoring.PositiveBlockParameterConstraint(); 
c3.ID = 'ID_A4'; 
c3.BlockType = 'MultiPortSwitch'; 
c3.ParameterName = 'DiagnosticForDefault'; 
c3.SupportedParameterValues = {'None'}; 
c3.ValueOperator = 'eq'; 

Use the addPreRequisiteConstraintID method to make c1 a prerequisite to checking constraints c2 and c3.

c2.addPreRequisiteConstraintID('ID_A2'); 
c3.addPreRequisiteConstraintID('ID_A2'); 

Create a composite constraint that specifies that if a Rate Transition block does not meet both constraints c2 and c3, the block is in violation of this check.

CC = Advisor.authoring.CompositeConstraint(); 
CC.addConstraintID('ID_A3');
CC.addConstraintID('ID_A4'); 
CC.CompositeOperator = 'and'; 

Introduced in R2018a