36
$\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
    $\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$ – David Waterworth Apr 26 at 3:56

13 Answers 13

32
$\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.

| improve this answer | |
$\endgroup$
  • $\begingroup$ It's why I said "nearly" :) $\endgroup$ – Nikos Kazazakis Apr 24 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 Apr 24 at 18:19
  • $\begingroup$ @fpacaud Doesn't PYOMO use the same ASL AD code as AMPL does? $\endgroup$ – Nikos Kazazakis Apr 25 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 Apr 25 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 May 7 at 7:51
19
$\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.

| improve this answer | |
$\endgroup$
  • 1
    $\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 Apr 26 at 22:29
  • 1
    $\begingroup$ Despite all the advantages of Julia I doubt it. $\endgroup$ – ErlingMOSEK Apr 27 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 May 7 at 7:51
16
$\begingroup$

We use Julia in production for optimization at Invenia.

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

| improve this answer | |
$\endgroup$
14
$\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.

| improve this answer | |
$\endgroup$
13
$\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 :)

| improve this answer | |
$\endgroup$
  • 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 Apr 23 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 May 7 at 7:52
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.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Could you share what else from the Python eco-system which is typically used? e.g. IDE, packages, etc. Thanks. $\endgroup$ – Simon Roed May 7 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 May 22 at 13:56
11
$\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

| improve this answer | |
$\endgroup$
  • 2
    $\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$ – Robert Schwarz Apr 23 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$ – Nikos Kazazakis Apr 23 at 18:09
10
$\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.

| improve this answer | |
$\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.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Could you share what else from the Python eco-system which is typically used? e.g. IDE, packages, etc. Thanks. $\endgroup$ – Simon Roed May 7 at 7:52
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/
| improve this answer | |
$\endgroup$
6
$\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 :)

| improve this answer | |
$\endgroup$
5
$\begingroup$

We work in OR since 20 years and have observed the huge rise of Python in industry the last 10 years. A lot of engineers but also some analysts have moved to Python, especially the ones working in scientific fields like data science and operations research.

At LocalSolver, we observe that 90% of industrial clients use the LocalSolver 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 corresponding to the main stacks used by IT services to build the business applications that embed optimization engines. C++ is still used in some companies, particularly software editors, but becomes very rare.

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

| improve this answer | |
$\endgroup$
1
$\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.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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