optimization search works, albeit slowly, and starting work on faster way to calculate transition matrices