# Change to improve JuMP compatibility with PackageCompiler

**URL:** <https://discourse.julialang.org/t/change-to-improve-jump-compatibility-with-packagecompiler/15944>\
**Category:** Optimization (Mathematical)\
**Created:** [October 5, 2018, 7:20pm UTC](https://discourse.julialang.org/t/change-to-improve-jump-compatibility-with-packagecompiler/15944 "2018-10-05T19:20:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwveysey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jwveysey/32/5662_2.png) [@jwveysey](https://discourse.julialang.org/u/jwveysey)\
**Post date:** [October 5, 2018, 7:20pm UTC](https://discourse.julialang.org/t/change-to-improve-jump-compatibility-with-packagecompiler/15944/1 "2018-10-05T19:20:40Z")

</div>

Hi, JuMP community -

I have a suggestion for improving the compatibility of JuMP with PackageCompiler. I hope I’m using the right means to convey it; I haven’t contributed to the community before and am trying to follow contribution guidelines. If I’m off base, please redirect me.

Anyway, I’ve found that PackageCompiler doesn’t like the order in which regular and @generated functions are declared in JuMPArray.jl. But I can get it to work and compile a JuMP program I’ve written if the @generated functions are simply moved to the end of JuMPArray.jl. (By the way, I’m using JuMP v0.18.3.)

What do you think about this change? I’m happy to create a pull request for it if people support the idea.

---

<div class="post-metadata">

**Author:** ![ccoffrin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ccoffrin/32/400_2.png) [@ccoffrin](https://discourse.julialang.org/u/ccoffrin)\
**Post date:** [October 5, 2018, 7:51pm UTC](https://discourse.julialang.org/t/change-to-improve-jump-compatibility-with-packagecompiler/15944/2 "2018-10-05T19:51:03Z")

</div>

@miles.lubin, fyi, our team has at least one use case that would significantly benefit from PackageCompiler.

---

<div class="post-metadata">

**Author:** ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)\
**Post date:** [October 5, 2018, 8:09pm UTC](https://discourse.julialang.org/t/change-to-improve-jump-compatibility-with-packagecompiler/15944/3 "2018-10-05T20:09:11Z")

</div>

Sounds like an innocent enough change. Developer time is mostly focused on the 0.19 release but I’ll accept a PR for the `release-0.18` branch. Is there a way to test that JuMP is compatible with PackageCompiler under CI? A one-time fix without tests is likely to break later.

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [October 5, 2018, 8:12pm UTC](https://discourse.julialang.org/t/change-to-improve-jump-compatibility-with-packagecompiler/15944/4 "2018-10-05T20:12:22Z")

</div>

It would be really cool to see JuMP working with package compiler. I sort of assumed that would be difficult since in general JuMP is a big complicated thing that involves C++ dependencies of solvers and all that good stuff. @jwveysey do you actually have a complete working example?

---

<div class="post-metadata">

**Author:** ![jwveysey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jwveysey/32/5662_2.png) [@jwveysey](https://discourse.julialang.org/u/jwveysey)\
**Post date:** [October 6, 2018, 12:24am UTC](https://discourse.julialang.org/t/change-to-improve-jump-compatibility-with-packagecompiler/15944/5 "2018-10-06T00:24:47Z")

</div>

Thanks for the feedback, everyone. Yes, I do have a complete working example, and the performance benefits for the first invocation in a Julia session are pretty substantial. I’ll prepare a pull request next week and see if I can include a reduced form of my example as a test case.

---

<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:** [October 6, 2018, 4:18pm UTC](https://discourse.julialang.org/t/change-to-improve-jump-compatibility-with-packagecompiler/15944/6 "2018-10-06T16:18:45Z")

</div>

Pinging @joaquimg since he has this working as well.

---

<div class="post-metadata">

**Author:** ![joaquimg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joaquimg/32/223_2.png) [@joaquimg](https://discourse.julialang.org/u/joaquimg)\
**Post date:** [October 8, 2018, 3:52am UTC](https://discourse.julialang.org/t/change-to-improve-jump-compatibility-with-packagecompiler/15944/7 "2018-10-08T03:52:51Z")

</div>

I have been using JuMP in a compiled code for almost an year. I have started trying packegecompiler recently, I use my modified version of the static-compile script.  
The only thing I had problems was indeed JuMPArrays. I changed my code not to use them, because it made no difference to use a plain array in my case.  
I am glad you found the problems!  
Compiling JuMP code makes wonders if you are solving a small number of LPs.  
I also had good experience using the nonlinear interface.  
The solvers C++ libraries are not a problem, I compiled com using Xpress, SCS, GLPK, CBC, Mosek and Gurobi.

---

<div class="post-metadata">

**Author:** ![joaquimg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joaquimg/32/223_2.png) [@joaquimg](https://discourse.julialang.org/u/joaquimg)\
**Post date:** [October 8, 2018, 3:54am UTC](https://discourse.julialang.org/t/change-to-improve-jump-compatibility-with-packagecompiler/15944/8 "2018-10-08T03:54:35Z")

</div>

One problem of testing this compiled stuff is travis giving up due to slowness of the compilation process…

---

<div class="post-metadata">

**Author:** ![jwveysey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jwveysey/32/5662_2.png) [@jwveysey](https://discourse.julialang.org/u/jwveysey)\
**Post date:** [October 8, 2018, 2:56pm UTC](https://discourse.julialang.org/t/change-to-improve-jump-compatibility-with-packagecompiler/15944/9 "2018-10-08T14:56:17Z")

</div>

Thanks, Joaquim - I’m glad to hear about others working in the area. I’m going to put together a pull request for my proposed change this week.
