53
$\begingroup$

I am giving a small computer exercise that aims at teaching students the basics of a modelling language to model small optimization problems. So far I have been using the modelling language GAMS as this is used in many companies in industry.

To be totally honest, I have never been a big fan of GAMS mainly because I'd prefer to use a general-purpose programming language for optimization instead of a pure modelling language. Now I am thinking about using either Python or Julia for teaching.

The problem is that I really do not know if Julia or Python are used in the industry for optimization. So the question is not if those programming languages are generally used (of course, I know about the Python hype), it is about whether those languages are also used for operations research in industry. In fact on the webpage of Julia several case studies are listed, however I could not find many case studies from industry for Python.

What is your opinion towards this and what experience have you made? If I choose to use Python or Julia, can I tell students that they are (strongly) used in industry to motivate them? Which of those would you choose (or just proceed with GAMS)?

$\endgroup$
1
  • 2
    $\begingroup$ As an aside whilst I also agree that I'd prefer to use a general purpose language for optimisation, in particular for production use, we (at a previous employer) did a lot of bench marking of a commercial solvers high level api vs GAMS for model generation (in both cases the solve time was identical since it was the same back end solver) and found GAMS generated the low level matrix from the symbolic model many orders of magnitude faster. $\endgroup$ Commented Apr 26, 2020 at 3:56

16 Answers 16

50
$\begingroup$

Despite being a great fan of Julia (and JuMP) I must admit that Python is most widely adopted in industry. I won't recommend PuLP however, which tends to be too slow. As alternatives, I would consider

  • Pyomo is a great package, with various interesting extensions (for stochastic programming, MPEC, bilevel optimization, ...).
  • Cvxpy is a game changer if you are dealing with convex problems, and is fast. As cvxpy is still actively maintained by some students of Boyd, you could expect using state-of-the-art code when using this package (e.g. https://github.com/cvxgrp/cvxpylayers)
  • Most optimization solvers come with a Python interface.

My experience in Artelys, a firm specialized in optimization, is that most people are using Python nowadays, and prefer to stick to this language. We have some prototypes in Julia, but none of them have been industrialized. However, they do provide support for the Julia interface of the solver Knitro (but mostly used by academics so far).

I won't be so definitive as others about Julia, though. JuMP is really a game changer. For non-linear programming, the performance of JuMP AD backend is closed to those of AMPL (between 3x and 5x slower in my experience, which is way better than Pyomo). My bet is that the gap will close in the next years, with the current focus on AD in Julia. That's the reason why I prefer to use Julia for my teachings so far (having built-in linear algebra is gold to me). Also if you choose to use Julia, you could experiment cutting-edge packages developed by the JuliaOpt community. For instance, I do not know any equivalent of Dualization.jl (a package computing automatically the dual of an optimization problem) in other languages.

Nearly no-one outside academia uses Julia in production

I beg to differ on this one. PSR, another firm specialized in optimization, is using Julia extensively for their studies, with success so far.

$\endgroup$
7
  • $\begingroup$ It's why I said "nearly" :) $\endgroup$ Commented Apr 24, 2020 at 14:03
  • $\begingroup$ Very good answer. Note that many people say Python is too slow. But while this is certainly true for Python itself, it is not true if you use the appropriate libraries offering Python interfaces, as this answer mentions. So IMHO you can hardly go wrong with Python. $\endgroup$
    – fpnick
    Commented Apr 24, 2020 at 18:19
  • $\begingroup$ @fpacaud Doesn't PYOMO use the same ASL AD code as AMPL does? $\endgroup$ Commented Apr 25, 2020 at 2:09
  • $\begingroup$ @NikosKazazakis you are right. In my opinion, they did a very good job in interfacing ASL with Pyomo. The thing is that it comes with a non negligible communication cost when writing large NLP problems. I recognize my comment was unclear: I was thinking of the benchmark detailed here, p310, Table 2: mlubin.github.io/pdf/jump-sirev.pdf $\endgroup$
    – fpacaud
    Commented Apr 25, 2020 at 9:40
  • $\begingroup$ Could you share what else from the Python eco-system which is typically used? e.g. IDE, packages, etc. Thanks. $\endgroup$
    – Simon Roed
    Commented May 7, 2020 at 7:51
25
$\begingroup$

We use Julia in production for optimization at Invenia.

We use Convex.jl, and JuMP.jl, and have found them to be excellent.

$\endgroup$
20
$\begingroup$

The feed back we get from our customers at Mosek is Python is used extensively in the financial industry for doing portfolio optimization and lot of other operations.

Those customers like to use Cvxpy or Mosek Fusion to interface the optimizer. You can see some Python notebooks at our Github tutorial page. This portfolio construction framework also provides a good example of what the financial industry are doing with Python and optimization

Our feeling regarding Julia which we also have an interface for is it much less used than Python in industry at this moment time. It is very popular among academics though.

$\endgroup$
3
  • 2
    $\begingroup$ If Julia is very popular among academics now, it's probably going to see a surge in industry in a few years. $\endgroup$
    – pjs
    Commented Apr 26, 2020 at 22:29
  • 1
    $\begingroup$ Despite all the advantages of Julia I doubt it. $\endgroup$ Commented Apr 27, 2020 at 9:08
  • $\begingroup$ Could you share what else from the Python eco-system which is typically used? e.g. IDE, packages, etc. Thanks. $\endgroup$
    – Simon Roed
    Commented May 7, 2020 at 7:51
15
$\begingroup$

Staffjoy was an early user of Julia and JuMP for their start up providing workforce scheduling. They also release all of their internal software as open-source after they shut-down. See for example the autoscheduler based on JuMP.

$\endgroup$
14
$\begingroup$

I personnaly use Python for optimizing industrial problems every day.

I know Polymathian also use Python for their Tropofy platform.

GUROBI has a python API, which I think is quite popular (although I cannot prove it).

I think that since Python is one of the most popular languages out there, mechanically it is used for optimization. However, I think it also depends on what you mean by optimization. Are you talking about software development, an industrial study, consulting, etc ? I think for software development, Python is often used with other low level languages such as C. For consulting or studies, Python is very appropriate in my experience.

I think Julia is promising, but too young to be compared to Python or any other language in fact. This being said, Atoptima solve their optimization problems with a branch and price framework implemented in Julia. I would not be surprised if in the coming years, Julia becomes more and more popular in the optimization community.

So to sum up, I would say that YES, Python is appropriate for what you need. And if someone learns Python, the learning curve for Julia should not be too steep.

PS : this is a personal opinion and I am curious to see some other answers :)

$\endgroup$
2
  • 1
    $\begingroup$ Thanks Kuifje for your answer. With optimization I just mean basically applying the Python or Julia for operations research problems in industry. The reason I ask this question is that I have a hard time finding jobs in Germany where it is explicity required to do optimization with Pyhton or Julia. However, I can easly find job descriptions where GAMS is either required or a plus (e.g., Siemens, ABB, (big) utility companies or transmission grid operators) $\endgroup$
    – PeterBe
    Commented Apr 23, 2020 at 14:18
  • $\begingroup$ Could you share what else from the Python eco-system which is typically used? e.g. IDE, packages, etc. Thanks. $\endgroup$
    – Simon Roed
    Commented May 7, 2020 at 7:52
14
$\begingroup$

Although I personally think Julia is glorious, nearly no-one outside academia uses it for numerous reasons, including:

  1. Missing out on all the Python packages
  2. Julia programmers being much harder to find than Python programmers, and
  3. Julia being much harder than Python to integrate to other things.

JuMP can offer performance benefits, but for commercial use that's rarely an issue as most companies will simply buy an AMPL license if that's a bottleneck and use its Python interface.

When it comes to interfacing, Python is the king, and that is true of optimisation solvers as well.

Apart from our personal experience at Octeract, this is also reflected by the languages' popularities:

the 2019 index ranks Julia 50th, and Python 3rd

$\endgroup$
2
  • 3
    $\begingroup$ While it's true that the Python ecosystem is (older and) richer, the PyCall.jl package makes it really easy to call Python code from Julia, including support for numpy arrays. $\endgroup$ Commented Apr 23, 2020 at 15:59
  • 5
    $\begingroup$ Don't get me wrong, I think Julia is glorious for OR, but fact is that is not adopted industrially in any significant capacity, mostly for the reasons I listed :) $\endgroup$ Commented Apr 23, 2020 at 18:09
13
$\begingroup$

My answer will be focused on teaching, and I'll give you my perspective from Georgia Tech ISyE.

Yes, you should teach your students optimization using Python. For simple models, one simple open-source platform you could introduce is PuLP. It is solver-agnostic, and will work both with commercial solvers as well as open source (including COIN-OR stuff). For more complex stuff, you could teach the gurobipy interface.

Julia is also useful, but I would suggest for now that it is best for research students like those pursuing a Ph.D.

$\endgroup$
2
  • $\begingroup$ Could you share what else from the Python eco-system which is typically used? e.g. IDE, packages, etc. Thanks. $\endgroup$
    – Simon Roed
    Commented May 7, 2020 at 7:52
  • $\begingroup$ I can't speak about what is used in industry, but standard Python things that students should learn include numpy, matplotlib, pandas, etc. Most in academia also find that teaching and research via Jupyter notebooks is also useful. $\endgroup$
    – alerera
    Commented May 22, 2020 at 13:56
11
$\begingroup$

Our, KLM, current optimizer products' codebases are all in python. The main reason for this is python is extremely powerful for fast prototyping. However, when it comes to the necessity of implementing more advanced techniques such as column generation and own branch-and-price algorithm, then python start lacking the performance you're looking for. In that case, python is again powerful since that part of your code can then well be implemented in c++ still within your codebase. Last but not least, the immense support with packages from the community makes it extremely handy.

Regarding Julia, I personally started experimenting and it seems quite nice. However, having no community support as much as python is an important fallback. Moreover, most commercial solvers do not have an official API for it. Maybe not a showstopper but certainly an issue to be thoroughly discussed.

$\endgroup$
9
$\begingroup$

Yes, Python is used in the industry is the simple answer.

We are Optimeering Aqua and our sister company Optimeering use Python and the (Fico) Xpress Python- API. We were alpha and beta users. For us this has been working well. We very early on used Fico's Mosel language, but found moving to a general programming language to have lots of advantages, with few disadvantages. I think there has been many debates on general purpose languages vs domain specific languages, so will not repeat that here.

$\endgroup$
1
  • $\begingroup$ Could you share what else from the Python eco-system which is typically used? e.g. IDE, packages, etc. Thanks. $\endgroup$
    – Simon Roed
    Commented May 7, 2020 at 7:52
8
$\begingroup$

Interesting that you ask - I've actually seen both julia and python used in industry. On the python side, I'd highly recommend cvxpy (for convex optimization). It was pretty easy to get started with, and it integrates well with other popular python numerical libraries. The stuff I've seen in julia was custom work, so I can't really comment on ease of use.

edit: I will say, though, that Julia makes linear algebra easy and, dare I say even beautiful :)

$\endgroup$
6
$\begingroup$

Python is well ahead of specific modelling languages. Many of solvers such as Gurobi, Cplex etc. have python interface. You can encounter small problems. For example for modelling problems, which package you will teach. You will have alternatives pyomo, pulp, python-mip or solver interface. I prefer pyomo which can be used with lots of commercial or free solvers. Also you can find heuristic and constraint programming packages for python such as google OR tools.

Additionally, you should examine following links, they will give idea.

  1. python wiki for OR packages: https://wiki.python.org/moin/PythonForOperationsResearch
  2. Famous scipy package optimization module: https://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html
  3. Python PSO package: https://pyswarms.readthedocs.io/en/latest/
$\endgroup$
5
$\begingroup$

The main reason why Pyomo is being used in industry and JuMP is not is that JuMP is a version 0.21.6 package whereas Pyomo is v5.7.3. Naturally, most businesses are not going to use a package with version less than 1.

Also, according to the following discussion, first-class nonlinear optimization support is something for v2.0 (two or three years away): https://github.com/jump-dev/JuMP.jl/issues/2355 This (and other related links) provide excellent and open discussion that in and of itself is a testament to JuMP's potential.

V1.0 and solid support for Conic and Linear-Quadratic problems should be on the cards for the near future. It seems like they are preparing the documentation for its release. https://arxiv.org/pdf/2002.03447.pdf

But the OP is concerned with teaching students who will go into industry. In the future when JuMP reaches v1.0, it will be competitive with Pyomo because: Julia is beautiful.

The students will probably enjoy Julia more than Python (at least I did when I started).

$\endgroup$
1
  • $\begingroup$ I have to say, that python is so much better tooled than Julia though. I don't use Pyomo, but I have now deserted Julia/jump for python/CasADi. En route, I experimented with Python/(cyipopt + sklearn). Then with Python/(cyipopt+JAX) and learnt about pure functions which is "when the penny dropped". The above were slow / hard to optimise compared to GAMS. But CasADi rules. I have also fallen in love with the organised style of coding that Python enforces via indenting. $\endgroup$ Commented Mar 10, 2022 at 3:35
5
$\begingroup$

We have worked in OR for 20 years and have observed the huge rise of Python in the industry over the last 10 years. Many engineers and analysts have moved to Python, especially in scientific fields like data science and operations research.

At Hexaly, 90% of our industrial clients use the Hexaly Python API to develop optimization solutions. Especially during the early, prototyping phases, but also more and more for deployment as well.

Until now, the preferred languages of our clients were Java and C# because they were the main stacks used by IT services to build business applications that embed optimization engines. C++ is still used in some companies, particularly software editors, but it has become rare.

Until now, we have observed no demand for Julia in the industry.

$\endgroup$
4
$\begingroup$

The latest JuMP.jl website gives a few examples of its use in industry:

I personally find JuMP.jl, by far, the most user-friendly and flexible optimization interface I ever used. By far.

$\endgroup$
3
$\begingroup$

Since Python is dominant in the industry, pyomo gained its popularity. I personally prefer the JuMP's implementation. Check these Constrction Speed R and Python Modeling.

For R users, I recently used a package OMPR with CBC solver in the production environment.

It works well if your model is relatively small. The author is trying to make it faster.

$\endgroup$
0
$\begingroup$

We have been using both Python and Julia (with JuMP) in our company for various projects. Our clients are generally happier using Python with gurobipy or cvxpy because Python is a more widely adopted language for production level code so it is easier for companies to have their technical teams deploy those models in their environments. On the other hand, from personal experience, I think writing optimization models using JuMP is way easier and that is why in many internal projects we have written the code handling optimization in Julia. We use Gurobi with both Python and Julia so I have not seen any significant difference in performance with either.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.