- optimagic version used, if any: 0.5.2
What would you like to enhance and why? Is it related to an issue/problem?
If the Jacobian value is invalid (infinite or NaN) at the starting parameters, an error should be thrown. Currently, no error is thrown, and the optimization simply fails.
MRE
import numpy as np
import optimagic as om
from optimagic.optimization.optimize import minimize
def fun(x):
return np.sum(x ** 2)
def jac(x):
return np.full_like(x, np.nan)
# the following runs without error
minimize(
fun,
np.arange(2),
jac=jac,
algorithm=om.algos.scipy_lbfgsb,
)