Solve Optimization Problems with Speculative Parallelism
Mathematica 7 lets you run a command with a number of different inputs, stopping when a result is obtained. In the following a minimization command is run using several different methods. The first one to finish is used and the others are canceled. The computation is then repeated using all the methods; a table shows all the results along with the result of the speculative result.
 In:= ```methods = {"Newton", "QuasiNewton", "ConjugateGradient", "InteriorPoint"}; try = ParallelTry[ {#, FindMinimum[ E^Sin[5 x] + Sin[5 E^y] + Sin[5 Sin[x]] + Sin[Sin[5 y]] - Sin[5 (x + y)] + 1/4 (x^2 + y^2), {x, y}, Method -> #]} &, methods];```
 In:= ```data = ParallelMap[ {#, FindMinimum[ E^Sin[5 x] + Sin[5 E^y] + Sin[5 Sin[x]] + Sin[Sin[5 y]] - Sin[5 (x + y)] + 1/4 (x^2 + y^2), {x, y}, Method -> #]} &, methods];```
 In:= ```data = Map[ {#[], #[[2, 1]], If[#[] === First[try], "Speculative Result", ""]} &, data]; data = Prepend[data, {"Method", "Minimum"}]; Text[Grid[data, Frame -> All , Spacings -> {1, 1}]]```
 Out=  