Optimization is a routine process in optical design. The often used DLS optimization algorithm is widely used in physics already. However, due to the lack of correlation between variables (common in optics), the algorithm can diverge quickly, with a dead-end result. Therefore the starting values of the variables must be carefully determined before running the optimization.
Getting the best nominal performance from an optical system requires juggling several dozens of variables, which may or may not affect each other. Graphing the relationships between variables becomes 3-dimensional with just two variables, so it is best to leave calculations to the computer and only define the demerit function... which can get tricky, because the computer does what it is told to do, not what one wants it to do.
Optical designs can carry dozens of variables, so the user cannot be expected to define limits to them all. Most design softwares carry a Default Merit Function (which is actually a type of a demerit function, both henceforth DMF), which can be quickly called on the design. Due to the above-mentioned non-correlation between some optical properties and their effect on the Jacobian Matrix inside the DLS algorithm, the functions themselves are not present in the default merit function, but rather the nominal ray positions and directions (which are related to each other). That can cause some major issues, depending on the number of available variables in the design.
Take for example, an achromatic doublet. The optical designer may require color correction through the visual range, a field angle and a minimum resolution, as one does. The best approach is to realize that an achromat cannot do this, as it has too few free variables available. With its four surfaces, two glasses and one lens separation, an achromat can only correct two wavelengths and fix spherical aberration, coma and distortion, but not a third wavelength nor astigmatism. The DMF does its best to fix everything, since the ray deviations carries no information on which aberration is possible to fix and which is not. Optimization diverges miserably simply for trying to do what it is told to do, and no amount of increase in the weight factors can fix this.
How to fix the achromat optimization is to choose two and only two wavelengths to match, and accept field resolution degradation. Here is where the designers experience comes into rescue: two matched wavelengths do not exclude a third one to be matched as well (a superachromat and effective visual color correction), and one can easily manipulate the median field curvature to trade in excess resolution at the axis for the benefit of the field resolution. The above technique can be applied to other designs as well, but the main point is to provide enough either free variables for the DMF to do its job, or reduce weight factor of the variables that have no actual freedom in the design.
The key to a successful optimization is having sufficiently close starting design for it. But even a successful optimization does not imply that the design has reached the best it can be. An optimization landscape is a topographical presentation of the DMF value with selected variables, and obviously reaches the limit of human visualization with only two of them. But even with 20 variables (21 dimensional topography), it is still there. It is a matter of trust that the minimum DMF value reached is just one of the local minima, and global minimum is out there somewhere. The DLS optimization algorithm will not help one to escape a local minimum, though. That is the designers job.
Escaping a local minima is a well-known optimization problem and software already uses several techniques, such as Global and Hammer optimizations, both of which can be manually performed in a more restricted and controlled environment than Global and Hammer. There is also technique called Saddle Point creation  for temporarily (or permanently, if one can add optical surfaces to the design) alter the optimization landscape in such a way that, without introducing a too drastical alteration to the original design, the previous local minimum will become a saddle point, from where the DLS optimization can slide even lower on one side or the other, along the new dimension. Depending on which point on the design one can add variable freedoms, the deepest minimum can be found (though this might still be just a local minimum, though obviously better than the previous).
Optical optimization is a powerful tool, if one can hold on to it while it grinds. For many instances, a good starting design is all one needs to make alterations to it. But exceeding the starting design could have a bit of a steep (and mathematically very theoretical) learning curve. Still worth it, as a stress-free optimization reduces optical tolerances at the same time.
 Design landscapes of optical systems by Florian Bociort.