This problem is a very general and important one, with many applications. To see some of these applications and download code to solve this problem, visit the Georgia Tech site.