Optimization

From Rave Documentation
Revision as of 09:48, 13 September 2013 by Admin (Talk | contribs) (Run the optimizer)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

Rave offers an easy-to use interface for running optimizers from the Optimization Toolbox and the Global Optimization Toolbox, as well as some custom optimizers that do not require additional toolboxes.

This page presents an overview to the optimization process, with an emphasis on the steps you need to take before and after setting up and running optimizations.

For more detailed information about setting up and running optimizations, see Optimize tab.

For more detailed information about the available optimization algorithms, see List of optimization algorithms.

Using Optimization

The steps for running optimization in Rave are:

  1. Load a data set
  2. Load/create functional variable(s)
  3. Create constraints (if applicable)
  4. Set up optimization runs using the Optimize tab
  5. Run the optimizer
  6. Collect results

These steps are described below. Follow the links for more detailed descriptions.

Load a Data Set

Although optimization does not directly rely on the data contained in a data set, Rave still requires you to load a data set as the first step. This is because Rave uses the data set to determine what your independent variables are and what their ranges are. Consequently, the data set you load must contain, at a minimum, one column for each independent variable, with the first row of the data set containing the names of these variables, and two rows of numerical data such that the values in these two rows contain the minimum and maximum feasible values for each independent variable.

For example, consider the optimization problem:

 min y = x1^2 + x2^2
s.t. -1 < x1 < 1
     -2 < x2 < 3
     x1+x2 > 1

In this case there are two independent variables, x1 and x2, and one function variable, y. The data file that you load in Rave should thus look like:

x1     x2
-1     -2
1      3

This is the bare-minimum allowable data set: it contains all the independent variables and two rows of data that span the allowable ranges of the independent variables. Note that the order of the data rows does not matter, nor is it requires that the minimum/maximum values all appear in the same row. You could also include additional rows of data for use in other Rave functions, but they would not affect optimization.

  • Note: Rave currently always enforces upper and lower limits for all independent variables during optimization. You cannot yet run optimizers that do not have constraints of the form a < x < b for every independent variable, x. Future versions of Rave will allow completely unconstrained optimization, however even in these future cases you will still need to load a two-line data set to start.


Also important: Note that the data set we load does not contain a column for y. Since y is a functional variable it must be added later, after the data set is loaded. Similarly the data set does not contain information about the constraint x1+x1 < 1. This will also be added later. Both of these topics are described below.

Load/Create Functions

Next you must load or create functions for each functional variable that appears in the optimization problem. Continuing the example above, we have only one function variable: y = x1^2 + x2^2. If we had a more complicated objective function that involved multiple intermediate variables, you could either create a function variable in Rave that calculates each intermediate variable, and then another function of those intermediate variables that calculates the overall objective, y, or you could simply create a function that directly calculates y with the intermediate variables appearing within the source code of that function but not explicitly appearing in Rave.

For this example, we will create a MATLAB function to calculate y using the "variable-names-as-inputs" format. This function looks like:

function y = myObjective(x1,x2)
y=x1.^2+x2.^2;

Note that the function is vectorized, meaning that we use .^ as the exponent operator instead of just ^ . This enables MATLAB to evaluate the function at multiple points without using a for loop. See vectorized functions for more info.

Next we must load this function in Rave to create the functional variable y.

See the page Working with Functions for more information about importing a function into Rave.

Create Constraints (If Applicable)

If your optimization problem involves constraints other than those of the form a < x < b for each independent variable, you must create these constraints on the Constrain tab.

For the example above, we would need to create the constraint:

x1+x2 > 1 

since it is the only constraint that is not of the form a < x < b.

Note that Rave currently ALWAYS enforces constraints of the form a < x < b for your independent variables. You can change the values of a and b in these constraints from the Manage analyses GUI. See variable ranges and allowable values for more information.


See the Constrain tab page for more information.

Set Up Visualizations (Optional)

If you would like to watch the progress of your optimizer, you need to create a suitable visualization. Visualization works best when your optimizer only involves two or three variables.

Currently the following visualizations support optimizer animations:

  • Contour Plot
  • Scatter Plot
  • 3D Scatter Plot
  • Line Plot

See the page: Visualizing optimization runs for more information

Set up optimization runs using the Optimize tab

Optimization runs are set up and executed from the Optimize tab. See that page for information on how to set up and execute optimizations.

Run the optimizer

After setting up optimization runs on the Optimize tab, the runs are executed by clicking the "Start" button at the bottom of the tab. See the Optimize tab page for more information.

Collect results