# Using sparse matrix in NLoptimization

**URL:** <https://discourse.julialang.org/t/using-sparse-matrix-in-nloptimization/27046>\
**Category:** Optimization (Mathematical)\
**Tags:** question\
**Created:** [July 31, 2019, 5:27pm UTC](https://discourse.julialang.org/t/using-sparse-matrix-in-nloptimization/27046 "2019-07-31T17:27:01Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [August 1, 2019, 6:09am UTC](https://discourse.julialang.org/t/using-sparse-matrix-in-nloptimization/27046/4 "2019-08-01T06:09:21Z")

</div>

Welcome to JuMP!

Please provide a link if you post the same (or similar) question in multiple places: [Function zero() with type"Any"](https://discourse.julialang.org/t/function-zero-with-type-any/27007).

You should start by reading the performance tips in the Julia manual: [Performance Tips · The Julia Language](https://docs.julialang.org/en/v1/manual/performance-tips/index.html).

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](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757) 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.

---

_[View the full topic](https://discourse.julialang.org/t/using-sparse-matrix-in-nloptimization/27046)._
