CAGE User's Guide Previous page   Next Page

Creating an Optimization from Your Own Algorithm

The CAGE optimization feature allows you to use your own optimization algorithms as alternatives to the library routines foptcon and NBI.

Using an example, this tutorial illustrates how to take an existing optimization algorithm and implement it as an optimization function for use in CAGE optimization.

The problem to be solved is the worked example problem:

Maximize torque (TQ) over the free variables (SPK, AFR) over a specified set of (N, L) points. These points are defined in the data set New_Dataset, which can be found in the CAGE session optimworkedexample.cag.

The torque model to be used is that in /mbctraining/Holliday.mat.

Process Overview

  1. Start with your own algorithm. We provide an example.
  2. Create a CAGE optimization function.
  3. Define the attributes of your optimization in the CAGE optimization function.
  4. Add your algorithm to the CAGE optimization function.
  5. Register your completed optimization function with CAGE.
  6. Verify the optimization.

The steps of this tutorial lead you through a series of examples illustrating how to construct the code to incorporate your own algorithm into an optimization in CAGE.

Before you begin you must create a working directory.

  1. Create a new folder (for example, C:\Optimization_Work). We recommend that you place this directory outside your MATLAB folders to avoid interfering with toolbox files.
  2. Copy the following six files from the mbctraining directory into your new working folder:
  3. Make sure your new working directory is on the MATLAB path.
    1. Select File -> Set Path.
    2. Click Add Folder and browse to your working directory.
    3. Click OK.
    4. Click Save.

Step 1: Examine the Algorithm

  1. Open currtutoptim.m from the mbctraining directory. currtutoptim.m is an optimization algorithm that solves the worked example problem in the MATLAB workspace. You should see the following code in the MATLAB editor.

  2. Verify that this algorithm solves the worked example problem by typing the following commands at the MATLAB prompt:

The workspace output should resemble

The matrix bestX contains the optimal SPK and AFR values that maximize the MBC model torque (exported from Holliday.mat) at the speed and load points defined in the matrix data.

currtutoptim.m is the example optimization algorithm that you want to transfer to the CAGE optimization feature.

This tutorial shows how to make currtutoptim.m available for use in the CAGE optimization feature.


Previous page  Using the Worked Example Optimization Step 2: Create a CAGE Optimization Function Next page

Learn more about the latest releases of MathWorks products:

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