Algorithm-driven paradigms for the optimization and simulation of photonic devices