Intra-cavity gain has been analyzed using exponential descending method.
Optimization of OC-FBG has been analyzed using greedy algorithm.
The method improved the efficiency compared with using filters outside the cavity.
A new possible solution for adjusting output spectrum of fiber laser was proposed.