Sunday, August 19, 2018

Julia 1.0



Julia 1.0 is out:


Julia 1 console with retro style ascii art

For optimization modeling, the Julia JuMP package is a good tool. The performance of Julia/JuMP is impressive [2]. And the Jupyter [4] notebook interface is really a pleasure to use when playing with the model.

The JuMP models I have seen, used integers for indexing. (Not only from the JuMP documentation and examples but also real models people were working on). This is a major drawback IMHO: there is limited protection against errors (no type/domain checking). Better is to index by strings. It gives better, more descriptive output and also checking for incorrect indices is better. Basically you want a proper error if you say x[j,i] instead of x[i,j]. Similarly when using demand['february','region3'] instead of demand['region3','february']. This is lost when using demand[2,3]. May be I need to create some motivating examples for this. An example of indexing by strings is the Steel model [1], where dicts are used that index data and variables by strings. The model uses integers for the time periods -- I prefer to have those also labeled something like t1,t2,t3,t4. Of course, in practice they will be labeled by something like jan,feb,mar,apr or may be week11,week12,week13,week14. I often use the rule: the way you want labels to appear in your Excel report (say), should also be used in the model. I am not 100% sure why indexing by integers is so popular in JuMP models (or at least the ones I was studying). I suspect that the fact that matrices (arrays) are an important data structure in Julia, plays a role here. Julia has data frames (a concept popularized by R), but I don't think they are often used directly in optimization models.

Warning:  The latest release of JuMP (based on MathProgBase) is not compatible with Julia 0.7 or 1.0. [3]

Update: I fixed my incorrect statement about indexing by integers only. (I will try to expand on this).

References


  1. SteelT3 model translated from the AMPL book, https://github.com/JuliaOpt/JuMP.jl/blob/release-0.18/examples/steelT3.jl
  2. Iain Dunning, Joey Huchette, Miles Lubin, JuMP: A modeling language for mathematical optimization, SIAM Review, 59(2), pp. 295–320, 2017 (preprint at: http://www.optimization-online.org/DB_HTML/2015/04/4891.html).
  3. https://github.com/JuliaOpt/JuMP.jl
  4. http://jupyter.org/

2 comments:

  1. These are good suggestions re indexing in JuMP, Erwin. Have you had a chance to revisit JuMP in its more recent incarnations to evaluate its usability? Like you, I really value GAMS, but I often bemoan its clumsy syntax for general programming operations, and its inability to support any modularity or restricted variable name-spaces when building models and pre-post-processing code. So I'm hoping JuMP takes off. Thanks for all your interesting, and fun, posts.

    ReplyDelete
  2. I fully agree concrrning the indexing.
    Lukily it is easily achievable. Here an example of the gams transport model in JuMP using dictionaries as variables: https://lobianco.org/antonello/personal/blog/2017/0203_jump_for_gams_users

    ReplyDelete