Using NaN
is almost certainly going to cause issues (and I’m surprised that it worked), mainly because of this:
julia> 0 <= NaN
false
julia> NaN <= 0
false
julia> NaN == NaN
false
If you have constraints, you should checkout JuMP. Here’s an example of a NLP: https://jump.dev/JuMP.jl/stable/examples/mle/