Hey guys,

I need a hint on how to effectivley solve a nonlinear optimization problem with NLopt package when my objective function contains some complex calculations and my nonlinear constraint contains the same complex calculations, something like the following:

```
using NLopt
function myfunc(x::Vector, grad::Vector)
if length(grad) > 0
# gradient calculation
end
Y = SomeComplexCalculations( x)
return UseYForObjective( Y)
end
function myconstraint(x::Vector, grad::Vector)
if length(grad) > 0
# gradient calculation
end
Y = SomeComplexCalculations( x)
return UseYForConstraint( Y)
end
```

Of course, I could do it as shown above, but that looks very unefficient to me.

I also thought about making `Y`

a global variable, but I am not sure if thats possible at all or I might get into trouble during the optimization process.

So I wonder if there is another way of giving data calculated by the objective function to the constraints.

Thanks for any suggestion or comment in advance!