INTERFACE SimMin; PROCEDURE Minimize( f: GoalFunc; VAR x: ARRAY OF ARRAY OF REAL; (* In/Out: the probe simplex. *) VAR y: ARRAY OF REAL; (* Out: values of "f" at simplex vertices. *) VAR lo, hi: CARDINAL; (* Out: lowest and highest vertices. *) minSize: REAL; (* Minimum simplex size. *) maxCalls: CARDINAL; (* Maximum number of calls. *) report: ReportProc := NIL; (* Called when a new minimum is found. *) normalize: NormalizeProc := NIL; (* Called to modify point before applying "f". *) verbose: BOOLEAN := FALSE; (* TRUE to mumble while working. *) Alpha: REAL := 1.0; (* Reflecton coefficient. *) Beta: REAL := 0.5; (* Interpolation coefficient. *) Gamma: REAL := 1.0; (* Extrapolation coefficient. *) Delta: REAL := 0.0; (* Min-bias coefficient. *) ); (* Minimizes "f" by the Nadler-Mead simplex method, with coefficients Alpha, Beta, Gamma, Delta. The client must initialize the array "x" with a simplex whose affine span contains the minimum point. The array "x" must have "M" rows and "N" columns, with "M <= N+1". If "report" is not NIL, it is called whenever a new minimum is found. If "normalize" is not NIL, it is applied to every generated point, before evaluating "f" on it. This feature allows minimization inside bounded domains, or over curved subspaces of "R^N". The procedure stops when "report" returns TRUE, or after "maxCalls" calls to "f", or if it decides to shrink the simplex and its radius (measured from the lowest vertex) is less than or equal to "minSize". Upon return return, we will have "y[i] = f(x[i])" for every "i"; and the minimum and maximum elements will be "y[lo]" and "y[hi]", respectively. *) TYPE GoalFunc = PROCEDURE (READONLY x: ARRAY OF REAL): REAL; ReportProc = PROCEDURE (READONLY x: ARRAY OF REAL; y: REAL): BOOLEAN; NormalizeProc = PROCEDURE (VAR x: ARRAY OF REAL); END SimMin.