correct error in constraint solver approach

The bug is 1/M = 0 in the constraint solver
Change M from int to double solve the issue