Optimization and tensor network methods for quantum optics and quantum circuit analysis