General Optimization Example
Overview
To use the General Optimization module, first you have to decide on the function that you need to optimize. The form of this function is problem specific, which can only be derived from the process model you want to optimize. This function must be defined in a Statistica Visual Basic (SVB) file and be accompanied by an active Statistica Spreadsheet that must contain all the necessary information for the optimization process. Following is a step-by-step example that highlights the minimum necessary requirements.
Function StatisticaGeneralOptimization(x() As Double) As Double StatisticaGeneralOptimization = 0.5 + (x(1))*(x(1)) + (x(2))*(x(2)) + x(3) + x(4) End FunctionA copy of this SVB file, GeneralOptimizationSetting.svb, is located in the Statistica Examples > Macros > Analysis Examples folder, accessed by selecting Open Examples from the File menu.
Data File
Open the GeneralOptimizationSettings.sta data file. Should you want to create your own spreadsheet, it must contain all the information necessary to the General Optimization analysis, such variable types (continuous or discrete); minimum, maximum, and starting values for the continuous variables; and number of unique values for the discrete variables.
Specifying the Analysis
- Select General Optimization from the Data Mining - Process Optimization submenu to display the STATISTICA General Optimization Startup Panel.
- Click the SVB file button to locate and load the GeneralOptimizationSetting.svb file (located in the STATISTICA Examples > Macros > Analysis Examples folder). If the parsing of the SVB file and setting spreadsheet is successful, you are ready to start the optimization process. Before that, you can review the settings and change the value of the fields according to your optimization preferences.
- You can change, for example, the minimum of the Simplex search for one or more continuous variables. To do so, select the Simplex option button on the Optimization algorithm tab. This displays the Simplex tab.
- Select the Simplex tab and click the Change/review settings button. This displays a standard STATISTICA spreadsheet.
- You can type in the desired value in the appropriate cell, and click OK. For this example, click Cancel to return to the STATISTICA General Optimization dialog box and use the original spreadsheet.
- Click the Optimize button. This initiates the optimization algorithm. While computation is in progress, you can see a progress bar displaying information about the optimization process such as current function value and iteration number.
- You can click
Cancel to end the optimization and discard the results, and you can click
Finish to end optimization and retain the results. Otherwise, the optimization continues until the stopping criterion is met. A set of outputs are displayed, which you can use to review and examine the optimization results. The results contain a settings spreadsheet particular to the algorithm used (Simplex in this case). Also displayed is a spreadsheet of final values of the variables that yield the minimum of the function defined in the SVB file. For this particular example, the optimized value of the variables are:
Note: These optimal values are applicable to the particular settings (such as minimum and maximum) defined in the settings spreadsheet. If these conditions are changed, so may the optimal solution found by the algorithm. That is because by imposing a minimum and maximum on the variables range, you create what is known as a constrained optimization. Changing these constraints might yield different solutions.
- In addition to these outputs, a spreadsheet of iteration is produced, which displays the function values per iteration. A graph representation of the spreadsheet can also be provided in the form of a two dimensional Statistica graph. Note that you can reprint the results of the optimization by clicking the Results button.