Optimizing entanglement generation and distribution using genetic algorithms