INTERFACE RanMin; PROCEDURE Minimize( f: GoalFunc; VAR x: ARRAY OF REAL; (* In: guess. Out: best point found. *) VAR y: REAL; (* Out: "f(x)" *) READONLY dx: ARRAY OF REAL; (* Coordinate scale factors. *) maxRadius: REAL; (* Maximum relative probe radius *) minRadius: REAL; (* Minimum relative probe radius. *) maxCalls: CARDINAL; (* Maximum number of function probes. *) 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. *) ); (* Minimizes "f" by random probes near the current minimum. The client must given in the array "x" an initial guess for the minimum of "f". The routine will probe "f" along a random walk. The first probe will be at the given "x"; subsequent probes will be uniformly distributed in an axis-aligned box of variable size centered on the current minimum. The size of the box along the "k"th coordinate is "2*step*dx[k]", where "step" is a variable step size (choosen by the routine after each iteration) between "minRadius" and "maxRadius". 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 after 2M consecutive probes at distance "minRadius" from the current minimum have failed to produce a new minimum. Upon return return, "xm" will be the best point found, and ym will be its value. *) 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 RanMin.