Define a function in global scope inside another function

This is generally not a good idea and won’t work out of the box because the already compiled code won’t see the redefined method until you hit global scope. You’d need to use Base.invokelatest inside the solve which is not performant. See documentation.

You could try is pass that function as another parameter into the problem or define some sort of struct where you can then change the values later on.

1 Like