Warning: Parameter 1 to SyntaxHighlight_GeSHi::configureParser() expected to be a reference, value given in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/Hooks.php on line 207

Warning: Parameter 1 to SyntaxHighlight_GeSHi::resourceLoaderRegisterModules() expected to be a reference, value given in /var/www/vhosts/rave.gatech.edu/httpdocs/help/includes/Hooks.php on line 207
Coding Optimizers for use in Rave - Rave Documentation

Coding Optimizers for use in Rave

From Rave Documentation
Revision as of 15:24, 23 November 2012 by Matt (Talk | contribs) (optimizersettingsKEYWORD.m)

Jump to: navigation, search


This page contains some guidelines for how to code optimizers for use in Rave. Like other Rave plugins, optimizers require you to follow certain code structures in a few places, but for the most part you can code the actual optimization part of it however you want.

Required Files

Just like workspace objects, each optimizer has a keyword that serves as its unique identifier in Rave. Keywords appear in the name of the folder that contains the files for your optimizer, and in the filenames themselves. There is no min/max length requirement for the keyword, and it can contain letters and numbers. Keywords are case sensitive, so if you use capitalization, be sure to use it everywhere.

In this example, the optimizer described has the keyword "KEYWORD".

All files related to this optimizer must be placed in a folder named KEYWORD, which in turn must be placed in one of the three subfolders in the rave\optimizers directory. The subfolders are rave\optimizers\single, rave\optimizers\multi, and rave\optimizers\ranking. Put single objective optimizers in the single directory, multiobjective optimizers in the multi directory, and ranking functions in the ranking directory. Ranking functions are any functions that act only on the data set already loaded in Rave without requiring new function calls to generate new data. (They might, for example, select some rows in the data set based on some definition of optimality.)

The choice of which directory you place your optimizer in determines where it appears in the Algorithm menu on the Optimize tab. Also, if you place it in the single directory, Rave will only allow one objective to be selected from the Objective list on the Optimize tab. If you place it in the multi or ranking directories, the user may be allowed to select multiple objectives from the Objective list, as defined by settings.maxobjectives (described below).

Once you've made your KEYWORD directory, you must put three required files in it, plus any other helper files that your optimizer uses. The three required files are:

  • optimizerinfo.txt - A two line plain text file. (Note that the file name does not contain KEYWORD). The first line of this file is the name of your optimizer as you want it to appear in Rave. The second line is a short description of the optimizer that will appear in the infobar when this optimizer is selected from the Algorithm menu.
  • optimizersettingsKEYWORD.m - This is a script that defines any user-specified parameters that your optimizer needs, and a few required parameters that Rave needs.
  • raveKEYWORD.m - This is the main function that actually runs your optimizer

The required files are describe in more detail below.


This is a simple two+ line plain text file. It doesnt contain any code, just plain english text. The first line contains the name of the optimizer as it will appear in the Algorithm menu on the Optimize Tab. Because the menu is only 200 pixels wide, try to keep this to around 40 characters or less. The second line of the file contains a slightly longer description. This should contain critical identifying information about the optimizer, not a description of how it works. If the optimizer requires any MATLAB toolboxes (or other files that must be downloaded etc) you should note it here. You might also want to put your name here.

In the remainder of this file (lines 3+), you can put any instructions or additional information about the optimizer. Future versions of Rave will offer a method for the user to view this information from the Optimize Tab.


This file defines the parameters that will appear in the Settings table on the Optimize Tab when this optimizer is selected from the Algorithm menu, and also defines values for few parameters Rave uses to control other aspects of the Optimize Tab when this algorithm is selected from the Algorithms Menu. This file is just a list of lines (i.e. a MATLAB script, not a function) where each line defines one setting. The settings should be listed in the order that you wish them to appear in the Settings Table. The required Rave parameter settings do not appear in the Table, so you can put them wherever you want in this file. Because this is a MATLAB script, you can optionally include comments describing the settings.

The format for the required Rave parameters is: settings.PARAMETERNAME=PARAMETERVALUE;

The required parameters must be included in this file. If these are missing, your Optimizer will not run. Each of these parameters controls only how the Optimize Tab user interface should act. It is up to you to actually code your optimizer to match whatever behavior you define using these parameters. The required parameters are:

  • settings.enforcesideconstraints = 0 or 1 or 2 This parameter identifies whether the optimizer will enforce the upper/lower bounds on each independent variable defined by handles.maxlimit and handles.minlimit. If = 0, the bounds will not be enforced. If = 1, the bounds will be enforced. If = 2, the optimizer supports both approaches and the user can specify whether or not to enforce them by checking the "Enforce side constraints" box on the optimize tab.
    • The value you specify here only controls the appearance of the "Enforce side constraints" check box on the Optimize Tab. It is up to you to code the actual enforcing (or ignoring) of the side constraints in the raveKEYWORD.m file.
    • Note: If you set this value = 2 in this file, then when the user runs this optimizer its settings structure will have settings.enforcesideconstraints = 0 or 1 depending on whether the user checked the box or not. Thus you use this same parameter within the raveKEYWORD.m file to determine whether to enforce the side constraints for each run.
  • settings.allowconstraints = 0 or 1 This parameter identifies whether your optimizer supports general constraints that the user may define on the constrain tab and select for enforcement on the Optimize Tab. If = 0, constraints are not supported and the constraint menu on the Optimize Tab will be made inactive. If = 1, constraints are supported and the user can select them on the list in the Optimize tab.
    • The value you specify here only controls the appearance of the Constraint Menu on the Optimize Tab. It is up to you to code the actual enforcing of constraints in your raveKEYWORD.m file.
  • settings.numberofobjectives = a two-element vector of a positive integers or inf This paramter controls the maximum number of objectives the user is allowed to select from the Objective Menu on the Optimize Tab. This parameter is only used by multi and ranking optimizers (i.e. optimizers located in the multi or ranking subdirectories of rave\optimizers). The first element of this vector defines the minimum allowable number of objectives, and the second element defines the maximum. For example, if this = [1 inf], then the optimizer supports any number of objectives. If this = [2 4], then the optimizer only supports two, three, or four objectives. If this = [2 2] then the optimizer requires exactly two objectives. If the user selects a number of objectives from the Objective Menu outside of this range, they will see an error dialog box when the try to run the optimizer telling them that they have selected too few or too many objectives, and the optimizer will not run.
    • The value you specify here only controls the limits that rave enforces before your optimizer begins running. It is up to you to actually code support for whatever number of objectives you specify here in your raveKEYWORD.m file.

In addition to these required parameters, you can include user-specified parameters that will appear in the Settings Table.

The format for user-specified parameters is:


Here, PARAMETERNAME is the variable name that you will use to refer to this parameter in the raveKEYWORD.m file. This is not displayed in Rave, but you will use it in your code. FORMATTEDNAME is the name as it will appear to the user. This must be a string and may contains spaces or any other formatting you like. INITIALVALUE is the initial value that will appear as the default value in the settings table. This may be either a string or a scalar number. If you enter a string here, and the user changes it in the table, whatever they enter in the table will also be treated as a string. If you enter a number here, and the user changes it in the table, whatever they enter will be converted to a number. Because all numbers can be converted to strings, but not all strings can be converted to numbers, any parameter that can take string or numerical values should be listed in this file as a string.

Here are some examples:



Required Function Parts

At the end of the file, your function must send certain data back to Rave. At a minimum, you must include two lines:


This line saves the settings structure from this optimizer run. You can include this line at any point in your function, just make sure you put it after any changes to the settings structure that are made while the optimizer runs


Here, X is whatever data you want your optimizer to return as its "answer." X must be an array with the same number of columns as settings.x where the value in each column is the value of the corresponding independent variable as indexed by settings.x. If the optimizer only returns a single optimal designs, X will have one row. If your optimizer returns multiple designs, X will have multiple rows. You should sort the rows of X in the order that you desired them to appear in Rave (if it matters).

You don't need to save the corresponding values of the objective functions; Rave will do that automatically.

You may also include any other relevant outputs from your optimizer as additional fields below handles.optimizerresults(end+1). Rave will not use these directly, but it will save them and export them so that you can refer to them in other programs. For example, suppose your optimizer also generates a matrix called A that you want to save. You can do this by adding the line: