  In this article, we present a general mode-conversion algorithm allowing to
build an optical system composed of an alternation of phase masks and free
propagations. The originality of our approach lies in the introduction of free
parameters that can be used to perform an optimization regarding some
properties of interest. Here, we apply this algorithm to overlap balancing, for
the conversion of an important number of modes with limited phase resources.
Moreover, we discuss about the convergence and the limitations of such an
algorithm, notably concerning the loss of unitarity that tends to occur in a
practical implementation.
