Automatic Computer-Aided Optimization of Cavities for the Design of Accelerating Structures