Move gradient convergence test after step update.

The trust region minimizer was detecting convergence due to
the gradient tolerance being reached but was not updating the
step. In the unconstrained test this is usually not a problem,
since we approach this point quite slowly. In the constrained
case however, we may approach this point quite quickly as a
result of the line search.

As a consequence, even though the solver finds the optimal
solution on the boundary, it fails to return this solution
to the user.

Thanks to Rodney Hoskinson for reporting this.

Change-Id: I7b1bcd1310ef0582e05957f43d1700eaabd73241
2 files changed