| CAGE User's Guide | ![]() |
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
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.
C:\Optimization_Work). We recommend that you place this directory outside your MATLAB folders to avoid interfering with toolbox files.
currtutoptim.m mbcOStemplate.m mbcOStutoptimfunc.m mbcOStutoptimfunc_s1.m optimtut.mat optimtuteg.mat
Step 1: Examine the Algorithm
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.
The workspace output should resemble
BestX = 23.768 12.78 18.179 12.78 14.261 12.78 12.014 12.78 11.439 12.78 12.535 12.78 27.477 12.78 21.887 12.78 17.969 12.78 15.722 12.78 15.147 12.78 16.243 12.78 31.185 12.78 25.595 12.78 21.677 12.78 19.43 12.78 18.855 12.78 19.951 12.78 34.893 12.78 29.303 12.78 25.385 12.78 23.138 12.78 22.563 12.78 23.659 12.78 38.601 12.78 33.012 12.78 29.093 12.78 26.847 12.78 26.271 12.78 27.368 12.78 42.309 12.78 36.72 12.78 32.802 12.78 30.555 12.78 29.979 12.78 31.075 12.78
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.
| Using the Worked Example Optimization | Step 2: Create a CAGE Optimization Function | ![]() |
Learn more about the latest releases of MathWorks products: |
| © 1994-2009 The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |