**Min/Max**

Min/Max is used to find the minimum or maximum of an undetermined variable in an equation set for which there is one or more (limited to 10 for the Annual license, 20 for the Commercial license, and 80 for the Professional license) degrees of freedom. EES will first check the syntax of the equations. If no errors are found, a dialog window will appear presenting the undetermined variables in two lists.

Click the Minimize or Maximize radio button above the left list. The variable that is to be minimized/maximized is selected from the list on the left by clicking on its name or using the up/down arrow keys. If many array variables are included in the list, uncheck the Show array variables check box to hide the array variables and thereby make it easier to find the variable that is to be optimized.

The independent variable(s) whose value(s) will be changed in searching for the optimum are selected from the list on the right. It is necessary to select as many independent variables as there are degrees of freedom (i.e., the difference between the number of variables and the number of equations). The number of independent variables that must be selected is indicated above the right-hand list. To select (or deselect) a variable using the mouse, click on its name in the list. Using the keyboard, move the cursor to the variable name and press the space bar to toggle to the selection. When there are many array variables in the list, it make be difficult to find the desired independent variables. In this case, unselect the Expand array variables check box. This will cause all arrays for which no member is selected to be collapsed into one entry in the list, shown as arrayname[]. If one or more variables in an array have been selected, that array will not be collapsed. Selecting a collapsed array name will expand the array in the list allowing one or more of the array members to be selected. Note that the button at the upper right of the this list will unselect all variables.

If a $DOLAST directive is used in the Equations window, only the variables within the $DOLAST - $ENDDOLAST clause will be available for the optimization process.

If there is one degree of freedom, EES will minimize/maximize the selected variable using either a Golden Section search or a Quadratic Approximations method, depending on the settings of the radio buttons below the left list. The Quadratic Approximation method is usually faster, but the Golden Section method may be more reliable. Multidimensional optimization may be done with the Annual and Commercial licenses using the Conjugate directions method, or the Variable metric method. The Variable Metric method, which uses numerical derivatives, seems to be the most efficient method (when it works). The Conjugate Directions is best for problems in which the optimum is constrained to be on a bound or when numerical derivatives are not reliable.

The Professional license provides three additional optimization algorithms: the Nelder-Mead Simplex method, the DIRECT algorithm and the Genetic method. The Genetic method is the most robust method in the sense that is able to find a global optimum even if there are local optima, but it is also the slowest. The DIRECT algorithm is also designed to find a global optimum when local optima are present, and it can be much faster than the Genetic method.

EES requires finite lower and upper bounds to be set for each independent variable. Careful selection of the bounds and the guess value(s) of the independent variables will improve the likelihood of finding an optimum. You can view or change the bounds and guess value for each selected independent variable by clicking the Bounds button. This will bring up an abbreviated Variable Info dialog containing just the selected independent variables. See the description of the Variable Info command or the $VarInfo directive for additional information on setting the bounds.

For all methods except the genetic method, the maximum number of times in which the equations are solved (i.e., the number of iterations) may be specified, along with the relative convergence tolerance. Calculations will stop if: 1) the relative change in the independent variable(s) between two successive steps is less than the specified relative tolerance; or 2) the number of steps exceeds the specified maximum. EES will also stop the calculations if the equations cannot be solved with the specified value(s) of the independent variables within the tolerance and allowable number of iterations specified with the Stop Criteria command in the Options menu and the "Stop if error occurs" check box is checked. In some cases, the error occurs because the values of independent variable(s) chosen by the optimization algorithm are not valid and you do not wish the stop the optimization process. In this case, uncheck the "Stop if error occurs" check box.

The Professional license provides an option to conduct a Sensitivity Analysis to determine the sensitivity of the optimum value to changes in the independent variables. The results of the sensitivity analysis are displayed in the Solution window.

The Professional license provides an option to log the optimization results to a specified file. Clicking the check box in the Log Results group box will toggle through three options: no logging, logging of the best points as they are found or logging of all points. The values of other variables in the problem may also be selected for logging by clicking in the check box preceding the variable name. Each entry in the log file includes the value of the dependent variable (objective function), the value(s) of the independent variables, the value(s) of the additional selected variables and the number of function calls at this time. The generation number is also logged for the genetic method. The manner these variables are written to the disk file depends of the file name extension. If the file name extension is .csv, the results are written with a comma (or semi-colon in the EU system) delimited file that can be directly opened by Excel. If the file name extension is .dat, these results are written as a tab-delimited text file that can be read into Word, Excel or other similar programs. If the file name extension is .txt, the results are written in a format that can be read directly into an EES Lookup table using the Open Lookup Table menu command.

Note: The Min/Max command can be used for other purposes, such as to find limits of integration.

The optimization calculations will begin after the OK button is clicked. A dialog, similar to that shown below, will indicate the progress of the optimization process. The current optimum value of the dependent variable (Gibbs in the example below) is shown below the elapsed time. The values of the independent variables (c and g in the example below) are also displayed. Both the current values, i.e., the values that are being tested at this time, and the best values, i.e., the values the produced the optimum shown below the elapsed time, are displayed.

While the calculations are in progress, the button caption will show Abort. When calculations are completed, the caption will change to Continue. Clicking the Abort button will terminate the calculations. If the optimization calculation is successful, the values of the independent variable(s) will be set to the those values which resulted in the optimum value of the dependent variable.