Read Using A Genetic Algorithm For Table Seating, exact algorithm used in swift-geometrize. The app is interesting for its 20 years history.