Products & Services Solutions Academia Support User Community Company

Learn more about Model-Based Calibration   

Creating an Optimization

Setting Up Optimizations

For any optimization, you need one or more models. Import the model or models you want to optimize into your project. See CAGE Import Tool. After you import your models, you can create an optimization.

Use the following process to set up an optimization:

  1. Use the wizard for Creating Optimizations from Models to create your optimization.

    You can use the wizard to set up any type of optimization: point or sum, single or multiobjective. See About Point and Sum Optimizations.

  2. Add constraints. You can add a boundary model constraint in the wizard. Use the Optimization view to apply other types of constraints (model constraints, linear, ellipsoid, 1–D table, 2–D table, and range). See Edit Constraint for details of all these constraints.

  3. Choose the points where you want to run the optimization. To do so, you can use the wizard or the Optimization view. In the wizard you can select a suitable table grid, data set, or point-by-point models, or use the variable set points. In the Optimization view you can select the points manually or import them from data sets, tables, or the output of existing optimizations. See Editing Variable Values.

  4. Run the optimization. See Running Optimizations.

  5. View the results. See Optimization Analysis.

About Point and Sum Optimizations

You can set up either point or sum optimizations using the Create Optimization From Model wizard.

You can start a common CAGE calibration workflow by creating a point optimization. What is a point optimization? For a point optimization problem, CAGE can determine optimal control parameter values at a single operating point per optimization run. A run is a single call to the optimization algorithm. To optimize control parameters for a set of operating points, CAGE can run an optimization for each point.

You can use a point optimization workflow to find good initial values for a sum optimization. In a sum optimization, a single optimization run can determine the optimal value of control parameters at several operating points simultaneously. For information on the different steps required for setting up sum optimizations, see Setting Up Sum Optimizations.

Some optimization problems require optimizing more than one objective simultaneously. For information on the different steps required for setting up multiobjective optimizations, see Setting Up Multiobjective Optimizations.

For more information on point, sum, single-objective, and multiobjective optimization problems, see Optimization Problems You Can Solve with CAGE

Creating Optimizations from Models

You can use the Create Optimization from Model wizard to set up any type of optimization: point or sum, single or multiobjective. To set up an optimization using a model in your project, from any view in CAGE, use this procedure:

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

    The Create Optimization From Model Wizard appears.

  2. Select a model to minimize or maximize in the optimization.

    If you are viewing a model, then the wizard automatically selects the current model. If you are viewing an optimization or an optimization output node, then the wizard automatically selects the model in the first objective.

    If you have point-by-point models as shown in this example, you can optionally select the check box to Create operating point data set.

    Click Next.

  3. Select the optimization type (algorithm, maximize or minimize, point or sum), data source for optimization, free variables, and boundary constraint.

    • Algorithm:

      • Use the default foptcon for gradient-based single-objective optimizations.

      • Use NBI for multiobjective optimizations. You can set up your additional optimization objectives after you finish the wizard. See Setting Up Multiobjective Optimizations.

      • Use ga or patternsearch for nongradient-based single-objective optimizations. These algorithms are only available if you have the Global Optimization Toolbox product installed.

      • Use Modal optimization with a composite model for selecting the best operating mode for each operating point. For an overview, see Using Composite Models and for instructions see Creating Modal Optimizations, both in the Getting Started documentation.

      • If you have a suitable user-defined optimization routine in CAGE, it can appear here. See Writing User-Defined Optimizations.

    • Objective type: Choose whether you want to Maximize or Minimize your model, and select a Point or Sum objective.

      CAGE automatically configures your variable values correctly: a run per point if you select Point, a single run for Sum. See Setting Up Sum Optimizations.

    • Data Source: Choose the points where you want to run the optimization. You can also set up points in the Optimization view. If you choose to set up points in the wizard, the options depend on the contents of your project and your model type. You can choose to use the variable set points, a data set, a table grid, model operating points (the default for point-by-point models), or unique operating points (for a composite model combining point-by-point models).

    • Free variables: Select the check boxes of the variables you want to optimize from the set of model inputs. If you select a table grid as the Data source, as shown in the preceding figure, CAGE automatically removes the table normalizer variables from the selection of free variables.

    • Add a model boundary constraint: Select the check box if you want to constrain the optimization within the boundary model associated with your model.

    Click Finish to create the optimization.

When you return to the Optimization view you can edit or add constraints and settings and run the optimization.

After you create the optimization, you cannot change the free variables or the algorithm type.

Tools for Common Optimization Tasks

Common tasks are available in the toolbar:

Optimization Wizard

For most optimizations, you should use the wizard for Creating Optimizations from Models because it simplifies the setup process.

If your user-defined optimization script defines operating point sets and/or a fixed number of free variables, you must use the Optimization Wizard instead. This is common with Version 2.0 scripts.

For example you may have advanced operating point set requirements, so you need to match the data set variables as part of setting up the free variables; or your optimization problem may involve free variables that are not part of the objective model (e.g., some feasibility problems).

You can use the Optimization Wizard to:

  1. Choose algorithm

  2. Set up free variables, objectives, and constraints options — Optimization Wizard Step 2

  3. Select free variables — Optimization Wizard Step 3

    The last 3 steps you can do in the wizard or in the Optimization view:

  4. Set up objectives — Optimization Wizard Step 4

  5. Set up model constraints — Optimization Wizard Step 5

  6. Set up data sets (user-defined optimizations only) — Optimization Wizard Step 6

To use the Optimization Wizard, select File > New > Optimization.

This takes you to the Optimization Wizard, which leads you through the steps of choosing the optimization to run, specifying the number of variables to optimize over (unless this is predefined by the function), and linking the variables referenced in the optimization to CAGE variables.

Step 1. First you must choose your algorithm. The first screen of the Optimization Wizard is shown below.

The first four algorithm choices in the list are standard routines you can use for constrained single and multiobjective optimization.

In many cases these standard routines are sufficient to allow you to solve your optimization problem. Sometimes, however, you might need to write a customized optimization algorithm; to do this you can use the supplied template to modify for your needs. Any optimization functions that you have checked into CAGE appear in this list. See Writing User-Defined Optimizations for information. The Worked Example option is designed to show you how to use the modified template. For step-by-step instructions, see the optimization tutorial section Worked Example Optimization in the Getting Started documentation.

Optimization Wizard Step 2

Here you select algorithm options for numbers of free variables, objectives, and constraints. The optimization tries to find the best values of the free variables. The options available depend on your selected algorithm.

Click Next to proceed to setting up free variables.

Optimization Wizard Step 3

You must select variables to link with the free variables used in your optimization.

Use this screen to associate the variables from your CAGE session with the free variable(s) you want to use in the optimization. Select the correct pair in the right and left lists by clicking, then click the large button as indicated in the figure.

Once you have assigned your free variables here you can either click Next or Finish. This also applies to all later steps in the Optimization Wizard.

Optimization Wizard Step 4

You can set up your objectives here or you can set them up at the Optimization view in CAGE. See Edit Objective.

Here you can select which models from your session you want to use for the optimization, and whether you want to maximize or minimize the model output. The foptcon algorithm is for single objectives, so you can only maximize or minimize one model. The NBI algorithm can evaluate multiple objectives. For example, you might want to maximize torque while minimizing NOX emissions. Remember you can also define constraints later, for example, using emissions requirements.

You can also include 'helper' models in your user-defined optimizations, so you can view other useful information to help you make optimization decisions (this is not enabled for NBI or foptcon).

Optimization Wizard Step 5

You can use models to define constraint regions that restrict free variables. If you want to use constraints you can select them here, or add them in the Optimization view in CAGE. You can also add other types of constraints in the Optimization view. See Edit Constraint.

Select a model for each constraint by selecting a CAGE model and a model constraint and clicking the button to match them up.

For each constraint, either:

Optimization Wizard Step 6

If your user-defined optimization allows you to add a data set you can select it on step 6 of the Optimization Wizard. You can use data sets to evaluate models over a different set of operating points during an optimization run. As an example, you could run an optimization at the points (N1, L1), (N2, L2), but an important quantity to monitor and possibly act upon is, say, temperature at points (N3, L3), (N4, L4). You can monitor the temperature at these points by using data sets, to help you select optimization results. You can set up data sets in Step 6 of the wizard or in the Optimization view in CAGE (select Optimization > Edit Data Sets).

Data sets are not enabled for foptcon and NBI optimizations.

Click Finish to return to the Optimization view in CAGE. Your new optimization appears as a new node in the tree pane on the left, and the setup details appear on the right.

  


Recommended Products

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

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