Which one is the way to go accroding to you opinion?
The approach that I posted the code example for or the approach with global variables?
I am asking because I am unsure whether global variables will really make it at all. I mean I am not familiar to the internals of NLopt, but I see a potential problem here if I decide to call SomeComplexCalculations( x)
in myfunc
only since this implies that myconstraint
is just called with the same vector x
until myfunc
is called again. However if myconstrained
was called more than once with two different x
during the optimiziation process and myfunc
was only called after a suitable x
that fullfills the condition was found, I would get into trouble.