You don’t have to change nls_obj, just make the anonymous function capture the first output, like here
optimize(x->foo(x, a)[1], ...)
Note the [1]
You don’t have to change nls_obj, just make the anonymous function capture the first output, like here
optimize(x->foo(x, a)[1], ...)
Note the [1]