Using sparse matrix in NLoptimization

Welcome to JuMP!

Please provide a link if you post the same (or similar) question in multiple places: Function zero() with type"Any".

You should start by reading the performance tips in the Julia manual: Performance Tips · The Julia Language.

The use of Any and global is likely the cause of the poor performance. As one work-around, instead of creating a sparse matrix to then multiply, you could try writing out the multiplication as a scalar expression.

If things are still slow after you’ve fixed the global variable issue, please take a read of Please read: make it easier to help you and simplify your example as much as possible. There are a few other things you could try to speed things up, but first things first.