test for failed optimization from linprog
catch singular matrix error from linalg.solve and use lstsq instead
fix indices for constraints