CAGE User's Guide Previous page   Next Page

About the Worked Example Optimization Algorithm

mbcweoptimizer is an example of a user-specified optimization that solves the following problem:

max TQ over (AFR, SPK) at a given (N, L) point.

[bestafr,bestspk]=mbcweoptimizer(TQ, speed, load) finds a maximum (bestafr,bestspk) to the function TQ.

TQ must be a function (or a function handle) that depends on AFR, SPK, SPEED, and LOAD only. The function must depend on the variables in that order. This routine does no variable matching.

optimstore is passed to this function when it is called from the Evaluate section subroutine of your optimization function. In this case, TQ must be a function handle that takes the inputs AFR, SPK, SPEED, LOAD, and OPTIMSTORE, in that order.

The Structure of the Worked Example

The best way to understand how to implement an external optimizer in a CAGE optimization function is to study the details of the example.

The following code section is taken from the Evaluate section of the worked example file as an example.

The line of code labeled A above calls the worked example optimization algorithm external to the optimization function. As with functions in the Optimization Toolbox, the first argument to the call to the optimizer is a function handle that evaluates the objectives at a given input point. We recommend you place the function pointed at by the function handle in the optimization file. If you do not place them in the same file you must make sure the evaluate function M-file is on the MATLAB path. As an example, the optimization evaluation function in the worked example optimization is shown in the code fragment following.

The first four inputs to this function are the torque (in this case) model inputs. The final input is the optimstore object, where information about the optimization is stored. To evaluate objectives, there are two possible functions from the optimstore object that can be used -- evaluate or gridevaluate. In the above example, the line of code referenced by B evaluates the torque model in the worked example at the (afr, spk, speed, load) input points.

The two subfunctions presented above are an example of how to implement an external optimizer in a CAGE optimization M-file.

See also the tutorial section Creating an Optimization from Your Own Algorithm. This example describes in detail the steps involved in incorporating an example algorithm into a CAGE optimization M-file.


Previous page  Checking User-Defined Optimizations into CAGE Optimization Template 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