INTERFACE UniMinTest; IMPORT UniMin, Random, PSPlot; TYPE Function = PROCEDURE (x: LONGREAL): LONGREAL; GoodProc = PROCEDURE (x, fx: LONGREAL): BOOLEAN; Problem = OBJECT name: TEXT; (* Problem's name *) xMin, xMax: LONGREAL; (* Nominal range of "x". *) yMin, yMax: LONGREAL; (* Range of "f(x)", for plotting. *) xStart: LONGREAL; (* Starting "x" value *) tol: LONGREAL; (* Required precision *) dist: LONGREAL; (* Estimated distance from "xStart" to minimum *) maxCalls: CARDINAL; (* Maximum number of calls to "f" *) METHODS eval (x: LONGREAL; VAR f, df: LONGREAL); (* Function to minimize. *) error (x, fx: LONGREAL): REAL; (* Solution error in bits. *) END; Performance = RECORD nTests: CARDINAL; (* Number of tests run *) (* The standard deviations are significative only if "nTests >= 2". *) avgCalls: LONGREAL; (* Average number of function calls per test *) devCalls: LONGREAL; (* Standard deviation of function calls per test *) maxCalls: CARDINAL; (* Max number of function calls per test. *) (* Negative error is interpreted as zero error: *) avgError: LONGREAL; (* Average solution error per test *) devError: LONGREAL; (* Standard deviation of solution error per test *) maxError: REAL; (* Max solution error among all tests *) nFailures: CARDINAL; (* Number of times that error was positive. *) END; PROCEDURE SingleTest ( psf: PSPlot.PSFile; (* Postscript file *) minimizer: UniMin.T; (* The minimization tool *) problem: Problem; (* Function and parameters *) debug: BOOLEAN; (* Passed to the minimizer *) ): Performance; (* Cost and accuracy statistics. *) (* Runs the "minimizer" on the "problem" and prints the results. Also appends to "psf" a new page with a plot of the function, showing the "minimizer"'s probes. *) PROCEDURE MultipleTests ( minimizer: UniMin.T; problem: Problem; nTests: CARDINAL; coins: Random.T; ): Performance; (* Runs "nTests" tests with random starting points. Prints averages etc. *) END UniMinTest.