Products & Services Industries Academia Support User Community Company

Learn more about Model-Based Calibration   

Single-Objective Optimization

Process Overview

The following sections describe these stages:

  1. Using the Create Optimization from Model wizard to choose

    • A model for your objective

    • The optimization settings:

      • Which algorithm to use

      • Maximize or minimize

      • Point or sum objective

      • Operating points for your optimization

      • What free variables to use

  2. Using the Optimization view to choose

    • A model, type, and value for your constraint

  3. Running the optimization, examining the output, exporting to a data set, and using the output to fill a table

Using the Create Optimization from Model Wizard

To create your optimization,

  1. Select Tools > Create Optimization From Model (or use the toolbar button).

    The Create Optimization From Model Wizard appears. If you are viewing a model, then the wizard automatically selects the current model.

  2. Select TQ_Model as the model you want to optimize.

    Click Next.

  3. On this page of the wizard you select the optimization settings.

    1. Select Maximize for the Objective type.

    2. Clear the check boxes for all the Free variables except SPK.

    Leave the other settings at the defaults, and click Finish to create the optimization.

You see the CAGE Browser Optimization view. A new branch named TQ_Optimization appears in the Optimization tree. View the new optimization. Your CAGE browser should look like the following example.

In the Objectives pane you can see the Description TQ_Model(SPK,L,N,A,E) and the Type is Maximize.

In the Optimization Information pane you can see listed the default algorithm name mbcOSfmincon, free variable SPK, and if you hover the mouse you can read the full description Single objective optimization subject to constraints.

The Constraints pane is empty as you have not yet added any constraints.

Note that the toolbar button Run Optimization (   ) is enabled, because your optimization setup has provided enough information to start an optimization.

Your optimization is ready to run, but would run at a single point (the set points of the variables is the default). To finish setting up your optimization you need to specify a constraint and edit the points where you want the optimization to run.

Setting Constraints and Operating Points

  1. Right-click the Constraints pane and select Add Constraint.

    The Edit Constraint dialog appears.

    1. Leave the Constraint type drop-down menu at the default, Model.

    2. Edit the Constraint name to NOX.

    3. Select NOXFLOW_Model from the Input model list.

    4. Make sure the inequality is <=, and enter 250 in the Constant edit box as the maximum value for the constraint, as shown above.

    5. Press Enter.

      You return to the CAGE Browser Optimization view. Make sure the the Description NOXFLOW_Model(SPK, L, N, A, E) <= 250 appears in the Constraints pane.

  2. You can use the Optimization Point Set panes to define a set of operating points for the optimization. Note that you do not have to have an operating point set; if you do not, the optimization will run at a single point of your choosing (the set points of variables is the default).

    You can use the Create Optimization from Model wizard to choose the points where you want to run the optimization, or you can set up points later in the Optimization view. In both cases you can choose to use points from a suitable data set or table grid if they exist in your project.

    Running the optimization requires the selected models to be evaluated (many times over) and hence values are required for all the model input factors (L, N, A, E, and SPK). The defaults of the fixed variables (L, N, A, E) are their set points, as shown in the Fixed Variables pane. You have chosen SPK as a free variable, so the optimization will choose different values for SPK in trying to find the best. The default initial value for a free variable is the set point, as shown in the Free Variables pane.

    To define the set of operating points for the optimization,

    1. In the Optimization Point Set pane, increase the Number of runs to 6. Notice 6 rows appear in both fixed and free variables panes, all containing the default set point values of each variable.

    2. Enter, or copy and paste, these values into the N column of the Fixed Variables pane:

      N

      1000

      1000

      3000

      3000

      6000

      6000

    3. Enter, or copy and paste, these values into the L column of the Fixed Variables pane:

      L

      0.1

      0.8

      0.1

      0.8

      0.1

      0.8

      The Fixed Variables pane should look as shown.

      Leave the other fixed variables and the free variable values at the defaults. If you wished to restrict the range of the free variables, you could select Optimization > Edit Free Variable Ranges. The default is the range of the variable as defined in the Variable Dictionary. For this example, leave the default.

  3. Your CAGE Browser should now look like the following example, with an objective, constraint, and set of operating points. The optimization is ready to run.

Running the Optimization

  1. Click Run Optimization (   ) in the toolbar.

    The optimization runs, showing progress messages as each point is evaluated until the optimization is complete. On completion of the optimization, a new node appears in the Optimization tree.

  2. The view switches to the new node Optimization_Output where you can view the optimization results.

  3. The optimization output view retains a memory of previous layout. If you have not used these views before, try the buttons and right-click context menus in the view title bars to add Constraint Graphs to examine your results.

  4. This single-objective optimization produces one best solution for each point in the operating point set. To view solutions at particular operating points, either:

    • Click the cells of the table, or

    • Click the points in the Results Surface plot.

    , .

  5. Select Run 6 and examine the results.

For more information, see Analyzing Point Optimization Output in the CAGE User's Guide documentation.

Using Optimization Results to Fill Tables

As an example, to use these optimization results to fill a table, first create a new table as follows:

  1. Build a SPK table in N and L. Select File > New > 2-D Table.

  2. Leave 10 in the Rows and Columns edit boxes and 0 in the Initial Value edit box.

  3. Use the drop-down menus to select L and N for the Y and X inputs.

  4. Rename the table to SPK_Table.

  5. Click OK. Your CAGE browser switches to the Tables view. CAGE has automatically initialized the normalizers to space breakpoints evenly over the ranges of N and L.

There are two methods for filling tables with optimization results.

  1. Click the Optimization button in the Processes pane to return to the Optimization view

  2. Click the plus to expand the Optimization node, and select the Optimization_Output node.

  3. Select Solution > Fill Tables (or the toolbar button Fill tables using optimal settings).

    The Table Filling wizard appears.

  4. Select the SPK_Table table and click the button to add it to the list of tables to be filled. Click Next.

  5. Select the SPK_Table table, and double-click SPK in the list of optimization results to select it to fill the table, as shown.

  6. Click Finish.

    You see a dialog reporting successful table filling.

  7. Leave the View check box selected to switch to the Tables view when you click Close. Examine the new spark table.

The other method of filling tables with optimization output uses Data Sets.

  1. From the Optimization_Output optimization output node, click Export to Data Set (   ) in the toolbar (or select Solution > Export to Data Set). Click OK in the Export to Data Set dialog box to accept the defaults.

  2. CAGE displays the Data Sets view. Click View Data in the toolbar to see the table of optimization results contained in the new data set New_Dataset.

    You can now use this data set (or any optimization results) to fill tables, as you can with any data set.

  3. Click   (Fill Table From Data Set) in the toolbar.

  4. Choose to fill the spark table with the SPK optimization output by selecting them in the two lists:

    1. Select SPK_Table in the Table to fill list.

    2. Select the SPK optimization output in the Factor to fill table list.

    3. Click the button Fill Table at the bottom right.

  5. The Table History dialog box appears to show you that CAGE filled the table from the data set. Click Close to dismiss the dialog box.

  6. To see the filled table surface and the optimization output spark values, right-click the display and select Surface. Recall you already filled the spark table from the optimization results with the table filling wizard, so the table should look unchanged.

See also Tutorial: Filling Tables from Data for more details on using data sets to fill tables.

In the next section you will use a custom fill routine to fill the table.

Using a Custom Fill Routine to Fill Tables

It can be useful to create your own custom fill function to fill tables from the results of an optimization. Some example situations are:

You can use a custom fill routine to fill the SPK_Table table from the optimization results.

  1. Create a custom fill function. For this example, you can use the supplied example, griddataTableFill.m, which can be found in the mbctraining directory. Copy griddataTableFill.m to a directory away from the MATLAB root directory, and make sure this directory is on the MATLAB path (or change the current directory to the location where you copied the file).

  2. At the optimization output node, select Solution > Fill Tables.

  3. The wizard retains a memory so the SPK_Table table is already selected to be filled. Click Next.

  4. Similarly, SPK is already selected from the list of optimization results to fill the table.

  5. Select Custom from the Fill Method drop down menu. Use the file selector, or enter the name of the fill function you wish to use to fill your tables. In this case, select or enter griddataTableFill. Note that this function must be on the MATLAB path.

  6. Click Finish to fill the SPK_Table table.

  7. You see a dialog reporting successful table filling. Click Close.

In the next section you will add a multiobjective optimization to this project.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS