Single-Objective Optimization

Process Overview

The following sections describe these stages:

  1. Using the Optimization Wizard to choose

  2. Using the Optimization view to choose

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

Using the Optimization Wizard

To create a new optimization,

  1. Select File > New > Optimization.

    This opens the Optimization Wizard.

  2. foptcon is selected by default, and this is the optimization algorithm you will use for this example. Note that this algorithm specifies a single objective in the Objectives column. Click Next.

  3. On the next screen, set the number of constraints to 1, as shown.

    Leave the number of free variables at 1 (spark will be the free variable). Click Next.

  4. On the next screen, choose spark as your free variable for this optimization by clicking SPK in the list on the right, then click the button to match it up with FreeVariable1, as shown. Click Finish.

A new branch named Optimization appears in the Optimization tree. Your CAGE browser should look like the following example. In the Optimization Information pane you can see listed the algorithm name mbcOSfmincon, free variable SPK, and the description Single objective optimization subject to constraints. In the Objectives and Constraints panes there are status messages informing you that you need to specify a model for an objective, and valid constraint settings.

Setting Objectives, Constraints, and Operating Points

  1. Double-click Objective in the Objectives pane.

    The Edit Objective dialog appears.

  2. Click to select TQ_Model and select Maximize from the radio buttons on the right. Click OK.

    You return to the CAGE Browser Optimization view. The Description TQ_Model(SPK,L,N,A,E) appears in the Objectives pane.

  3. Double-click Model in the Constraints pane.

    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. Notice that the Description NOXFLOW_Model(SPK, L, N, A, E) <= 250 appears in the Constraints pane.

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

  4. You can use the Input Variable Values 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).

    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 Input Variable Values 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.

  5. 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.

    This single-objective optimization produces one best solution for each point in the operating point set. Click the cells of the table, or the points in the Results Surface, to view solutions at those operating points.

  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.

For more information, see Analyzing Point-by-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 will see a dialog reporting successful table filling. Switch to the Tables view to 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. Go to the Data Sets view (click the Data Sets button in the Data Objects pane) to see that the table of optimization results is 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. Select the data set and click   (Fill Table From Data Set) in the toolbar.

  4. Clear the check box at the bottom to Show table history after fill.

  5. Choose to fill the spark table with the SPK optimization output by selecting them in the two lists, then click the button Fill Table at the bottom right.

  6. Right-click the display and select Surface to see the filled table surface and the optimization output spark values.

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.

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

  


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