By using iterative algorithm,Least Pth-norm algorithm and AMPSO algorithm in the Matlab environment,an optimal method is presented to design the gain flattening filter based on cascaded Mach-Zehnder Interferometer(MZI),and the method is applied to design the filter for flattening ASE source.An example is given to verify that the designed optical filter can effectively improve the flatness of ASE source,the flatness of the flattened spectrum (1 525 nm-1 540 nm) can reach ±0.73 dB,the 3 dB bandwid...