Automatic Dip-picking by Non-linear Optimization