Main Content

Programmatically Create Procedural-Based Configurations

You can create a procedural-based configuration that allows you to specify the order in which you make changes to your model. You organize checks into procedures using the procedures API. A check in a procedure does not run until the previous check passes. A procedural-based configuration runs until a check fails, requiring you to modify the model to pass the check and proceed to the next check. Changes you make to your model to pass the checks therefore follow a specific order.

To create a procedural-based configuration, perform the following tasks:

  1. Review the information in Customize the Configuration of the Model Advisor Overview.

  2. Decide on order of changes to your model.

  3. Identify checks that provide information about the modifications you want to make to your model. For example, if you want to modify your model optimization settings, the Check optimization settings check provides information about the settings. You can use custom checks and checks provided by MathWorks®.

  4. (Optional) Author custom checks in a customization file. See Create Model Advisor Checks.

  5. Organize the checks into procedures for a procedural-based configuration:

    1. Create procedures by using the procedure API. For detailed information, see Create Procedural-Based Configurations.

    2. Create the custom configuration Use Model Advisor Configuration Editor to Customize Model Advisor.

  6. (Optional) Deploy the custom configurations to your users. For detailed information, see Deploy Custom Configurations.

  7. Verify that models comply with modeling guidelines. For detailed information, see Run Model Advisor Checks and Review Results.

Create Procedural-Based Configurations

Create Procedures Using the Procedures API

You create procedures with the ModelAdvisor.Procedure class API. You first add the checks to tasks, which are wrappers for the checks. The tasks are added to procedures.

Note

When creating procedural checks, be aware of potential conflicts with the checks. Verify that it is possible to pass both checks.

You use the ModelAdvisor.Procedure class to create procedural checks.

  1. Add each check to a task using the ModelAdvisor.Task.setCheck method. The task is a wrapper for the check. You cannot add checks directly to procedures.

  2. Add each task to a procedure using the ModelAdvisor.Procedure.addTask method.

Define Procedures

You define procedures in a procedure definition function that specifies the properties of each instance of the ModelAdvisor.Procedure class. Define one instance of the procedure class for each procedure that you want to add to the Model Advisor. Then register the procedure using the ModelAdvisor.Root.register method.

You can add subprocedures or tasks to a procedure. The tasks are wrappers for checks.

  • Use the ModelAdvisor.Procedure.addProcedure method to add a subprocedure to a procedure.

  • Use the ModelAdvisor.Procedure.addTask method to add a task to a procedure.

The following code example adds subprocedures to a procedure:

%Create a procedure
MAP = ModelAdvisor.Procedure('com.mathworks.example.Procedure');

%Create 3 sub procedures
MAP1=ModelAdvisor.Procedure('com.mathworks.example.procedure_sub1');
MAP2=ModelAdvisor.Procedure('com.mathworks.example.procedure_sub2');
MAP3=ModelAdvisor.Procedure('com.mathworks.example.procedure_sub3');

%Add sub procedures to procedure
addProcedure(MAP, MAP1);
addProcedure(MAP, MAP2);
addProcedure(MAP, MAP3);

%register the procedures
mdladvRoot = ModelAdvisor.Root;
mdladvRoot.register(MAP);
mdladvRoot.register(MAP1);
mdladvRoot.register(MAP2);
mdladvRoot.register(MAP3);

The following code example adds tasks to a procedure:

%Create three tasks
MAT1=ModelAdvisor.Task('com.mathworks.tasksample.myTask1');
MAT2=ModelAdvisor.Task('com.mathworks.tasksample.myTask2');
MAT3=ModelAdvisor.Task('com.mathworks.tasksample.myTask3');

%Create a procedure
MAP = ModelAdvisor.Procedure('com.mathworks.tasksample.myProcedure');

%Add the three tasks to the procedure
addTask(MAP, MAT1);
addTask(MAP, MAT2);
addTask(MAP, MAT3);

%register the procedure and tasks
mdladvRoot = ModelAdvisor.Root;
mdladvRoot.register(MAP);
mdladvRoot.register(MAT1);
mdladvRoot.register(MAT2);
mdladvRoot.register(MAT3);

You can specify where the Model Advisor places a procedure using the ModelAdvisor.Group.addProcedure method. The following code example adds procedures to a group:

%Create three procedures
MAP1=ModelAdvisor.Procedure('com.mathworks.sample.myProcedure1');
MAP2=ModelAdvisor.Procedure('com.mathworks.sample.myProcedure2');
MAP3=ModelAdvisor.Procedure('com.mathworks.sample.myProcedure3');

%Create a group
MAG = ModelAdvisor.Group('com.mathworks.sample.myGroup');

%Add the three procedures to the group
addProcedure(MAG, MAP1);
addProcedure(MAG, MAP2);
addProcedure(MAG, MAP3);

%register the group and procedures
mdladvRoot = ModelAdvisor.Root;
mdladvRoot.register(MAG);
mdladvRoot.register(MAP1);
mdladvRoot.register(MAP2);
mdladvRoot.register(MAP3);

See Also

|

Related Topics