Design and optimization of active photonic devices