In order to lighten the heavy calculation in the optimal design of binary optical elements, the relation-shap between the number of the independent variables in the optimization and the intensity distributions of the input and/or output pictures is set up mathematically. A general optimization algorithm the ALOPEX is introduced to this area. By tubing these together, a general scheme for the optimal design of binary optical elements, which needs shorter computing time and has a strong ability of resistance to the local extrema is proposed. Some design results by using defferent algorithms are compared.