Optimization of circuits with a large number of parameters