The Maximize() and Minimize() functions find the factor values that optimize an expression. The expression is assumed to be a continuous function of the factor values.
The form of the call is as follows:
result = Maximize(objectiveExpression,{list of factor names}, <<option(value))
result = Minimize(objectiveExpression,{list of factor names}, <<option(value))
objectiveExpression is the expression whose value is to be optimized, and can either be the expression itself, or the name of a global containing a stored expression.
{list of factor names} is an expression yielding a list of names involved in objectiveExpression.
The name can be followed by limits that bound the permitted values, for example name(lowerBound,upperBound).
If you want to limit the values on one side, make the other side a missing value, for example:
{beta} // unconstrained
{beta (0,1)} // constrained between 0 and 1
{beta (.,1)} // upper limit of 1
{beta (0,.)} or {beta (0)} // lower limit of 0
Factor values can be either numbers or matrices.
Options available, shown with their default value, include:
<< Tolerance(.00000001) // convergence criterion
<< Max Iter( 250) // maximum number of iterations
<< Limits() //
Initial values are assumed to be already supplied the factor values before calling the function.
These functions are not expected to find global optima for functions that have multiple local optima; they are useful only for taking an initial value and moving it to either a local or global optimum.
The return value is currently the value of the objective function, if the optimization was successful, or Empty() if not.
The following example uses Minimize to find the least squares estimates of this exponential model, with data taken from the Nonlinear Example/US Population.jmp sample data table.
xx = [1790, 1800, 1810, 1820, 1830, 1840, 1850, 1860, 1870, 1880, 1890, 1900, 1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990];
yy = [3.929, 5.308, 7.239, 9.638, 12.866, 17.069, 23.191, 31.443, 39.818, 50.155, 62.947, 75.994, 91.972, 105.71, 122.775, 131.669, 151.325, 179.323, 203.211, 226.5, 248.7];
b0 = 3.9;
b1 = .022;
sseExpr = Expr(
Sum( (yy - (b0 * Exp( b1 * (xx - 1790) ))) ^ 2 )
);
sse = Minimize( sseExpr, {b0, b1}, <<Tolerance( .00001 ) );
Show( b0, b1, sse );
b0 = 13.9991388055261;
b1 = 0.0147104409355048;
sse = 1862.14141218875;