The example file (which can be downloaded from the zip file at the end of the last page of this article) shows a derivative of the Cooke triplet, optimized for best RMS wavefront error. All radii and thicknesses are variable, except the last radius of curvature which is controlled by an f/# solve and maintains the lens as f/5 during optimization.

The merit function for this design was build using the default merit function tool, and consists of RMS wavefront error and lens center/edge thickness boundary constraints. Five rings were used by the Gaussian Quadrature pupil sampling algorithm. Since n rings allows aberrations of order r
2n - 1 to be controlled exactly, this gives control of wavefront aberrations up to r
9. The highest order aberration in the design currently is r
6, higher order spherical aberration.

The current value of the merit function is 0.102. We then run Tools...Optimization...Find Best Asphere:

The tool allows us to choose start and stop surfaces, and the maximum order of the selected polynomial. Each surface within the range is evaluated to see if it is a candidate asphere. To be considered, the surface must be of type Standard, have no conic value, define a boundary between air and glass (cemented surfaces usually make poor aspheres), and have a curvature that is either variable or controlled by a marginal ray angle or F/# solve. Surfaces that do not meet this test are ignored.
When a candidate surface is identified, the surface is converted into an asphere of the user-selected type. The aspheric terms are set as variables for optimization. The local damped-least squares optimizer is then called to optimize the modified system. If the resulting system has the lowest merit function yet found, the system is retained. The procedure repeats until all surfaces have been tested. Finally, the tool reports which surface, when converted to an asphere, provided the lowest merit function. For example:

Changing the desired order of asphere and pressing Run Again yields these results:
Initial Design: 0.102
Conic asphere: 0.086
4th order: 0.088
6th order: 0.084
8th order: 0.084
10th order: 0.083
12th order 0.082
The user can then choose what degree of asphere provides the most effective improvement in performance.