6
$\begingroup$

No single programming language will meet every need. However, there should be a language that most operations research scientists prefer to master.

I have coded different algorithms in Matlab and Python so far, but they may not be fast enough in comparison to C++ or C#. I would like to learn a new programming language and want to ensure that I choose the most appropriate language. Please note that my expertise revolves around the applications of heuristics, metaheuristics, column generation, Benders decomposition and approximate dynamic programming.

Please share your thought with me.

$\endgroup$
7
  • 6
    $\begingroup$ Julia might be a good choice for you. $\endgroup$ Commented Oct 21, 2022 at 5:01
  • 1
    $\begingroup$ @ErlingMOSEK Julia gets kudos from me for ability to solve quantum relative entropy problems in I think both Convex.jl and JuMP,, I believe using the barrier which was proven this year to be self-concordant. And it looks great for Linear SDP. But as far as I can tell, Julia is currently a wasteland for Nonlinear SDP, even for BMI. Nothing in Julia that can do what YALMIP does for Nonlinear SDP, both local and global optimization (only small or easy (relatively speaking) problems might actually solve to global optimality).. Granted, OP's interest seems far afield from Nonlinear SDP and QRE. $\endgroup$ Commented Oct 21, 2022 at 7:44
  • 3
    $\begingroup$ One important aspect is what do the people around you use; programming is a team sport! What language will you be able to get help with locally, what language is in use in your team, or the teams you want to join? $\endgroup$ Commented Oct 22, 2022 at 0:35
  • 1
    $\begingroup$ "but they may not be fast enough" Have you ran into any speed problems so far? Problems that could not be fixed with an optimized algorithm? $\endgroup$
    – Mast
    Commented Oct 22, 2022 at 5:07
  • 1
    $\begingroup$ What did your search engines throw up, that didn't work for you? $\endgroup$ Commented Oct 23, 2022 at 21:17

8 Answers 8

16
$\begingroup$

For modelling, mainly Python. Julia works too but is much less commonly used in companies.

For dedicated algorithm implementations, mainly C++. C works too but will require more lines of code and development time. Rust works too but is much less commonly used in companies.

In academia, the goal is to develop the most efficient algorithms and it is usually possible to choose which language to use. In industry, the choice of the language might be imposed by the client anyway; or might depend on how easy it will be to find people to develop and maintain the project. In this case, Java is also common.

$\endgroup$
10
$\begingroup$

I am an academic who works on large projects in OR & power systems. This involves a mixture of machine learning (ML), optimization, data-processing, simulations, and more data processing. Our group uses Julia for optimization, simulation, and most of the data processing, and Python for ML. I recently gave a talk about the reasons why we chose Julia for optimization.

Almost everyone I know in the academic world uses either C/C++, Julia or Python (I listed them in alphabetical order). In recent years, C++ seems to lose popularity (at least around me) in favor of Python and, to a large extent, Julia.
Almost no company I know uses Julia; there are a few, but TBH it's still a niche. As far as I know (remember I'm from academia), the more popular choices for in industry, for optimization, are C/C++, Java, and Python (also in alphabetical order). I believe most ML is done in Python nowadays.

In terms of ecosystems, I find Julia (and JuMP in particular) to have the broadest, most performant and best-documented support for (MI)LP, (MI)-conic/convex and (MI)NLP. The fact I don't have to manually install external solvers is a godsend (I wouldn't know how to compile C/C++ code). In Python, you will find a few open-source modeling tools like pyomo, plus each solver's own modeling layer. Commercial solvers have better support for their C++ and python APIs than in Julia (likely because few people both use Julia and pay for the licenses).

$\endgroup$
6
$\begingroup$

This is an interesting debate. And key if you remember Sapir - Whorf theory ("linguistic categories influence perception")

You may use an Algebraic Modeling Language like AMPL or OPL or GAMS or you may choose a GPL General Programming Language like C++ or python.

I discussed pros and cons at

Optimization (aka prescriptive analytics) : Should we write the model in a modeling language or a general programming language ?

To see this on a small example

All options have advantages and issues.

My favourite language to deal with OR problems : OPL that is linked to CPLEX Second choice : python docplex

enter image description here

NB:

I work for IBM

$\endgroup$
1
  • 1
    $\begingroup$ Wow, so if I am getting this right, in this modeling language you have to hard-code the size of vector variables into the name of the variable? How would you ever integrate this into a production pipeline where the size of the array isn't known into runtime? Thank god for Pyomo, JuMP, etc... $\endgroup$
    – Max
    Commented Aug 13, 2023 at 1:55
6
$\begingroup$

Gretzky: Skate to where the puck is going to be. Or in this case, pucks, Julia being one of the pucks..

Putting on my O.R. hat and viewing language usage as a dynamic system, Julia is on a significant upward trajectory in academia. The increasing number of undergraduate and graduate students using Julia in school seems likely to lead, with some lag, to increasing use in industry. Yes, some of these students who eagerly arrive at their new workplace, bright-eyed and bushy-tailed, wanting to use Julia at work, will confront the harsh reality of being forced to use other language(s). But given the increasing flow of Julia users/enthusiasts into the workplace, they are bound to break through. And once they start to do so in a meaningful way, Julia usage could start to pick up quickly in industry. Knee of the curve, and all that.

I say this as primarily a MATLAB user (yes, I'm a dinosaur). But MATLAB was the new language I increasingly switched to from FORTRAN and various defunct Algol derivatives and other dead languages, and C, which I was forced to use for various things (and back in 1982, I had to grade stochastic simulation homework, with some of the programs written in Pascal, even though I didn't know Pascal). BTW, MATLAB is still heavily used for design analysis and algorithm prototyping at some very large companies in the engineering arena, even though for real-time use, algorithms are generally implemented in an appropriate language (and that's not usually Python).

This answer is meant to be complementary to the existing excellent answers.

$\endgroup$
2
  • $\begingroup$ Python makes for a convenient wrapper around higher-performance tools. It is best-suited to be extended with C, but I have found relatively headache-free ways to extend Python to Rust, C++, and FORTRAN. $\endgroup$
    – Galen
    Commented Oct 22, 2022 at 21:04
  • 2
    $\begingroup$ This. Nothing further need be said. (+1) $\endgroup$ Commented Oct 24, 2022 at 2:06
5
$\begingroup$

Operations research covers a lot of territory. Most of the answers posted are oriented toward optimization, which is fine but a bit limited. For analytics / data analysis, the two most popular languages seem to be Python and R. For simulation, you might use either Python or R, but you might also want to use a dedicated simulation package. So I'm not sure any one language suffices. (For the record, I use Java most things and R for some things.)

One thing to keep in mind is that, regardless of your choice of language, it is likely you will leave the "heavy lifting" to library packages or third party (likely commercial) programs. So the bulk of the computation time will probably be spent in some code that you did not write. If your work involves substantial processing of inputs before running your model or substantial processing of outputs after running it, you may want a language that is fast (many would say C or C++, although Java is I think not too far behind these days). Otherwise, I think it is better to pick a language in which you will be productive (comfortable using it, less prone to coding errors, more likely to adequately document the code, ...) and not worry too much about the computational speed.

$\endgroup$
4
$\begingroup$

Like said in the other answers, first of all, OR covers a big territory. And then you have the business side of things where you are often bounded to certain languages and tools.

I think it is useful to have a default programming language to go to (e.g. Python) and find different OR-problems and how to solve them via that language. Look at the solution of the packages you use and try to find the abstract representation of these solutions. Probably most packages have very similar representations. This way, you get familiar in solving OR-problems in practice and when bounded to a certain language, other then your go-to language, you can probably rapidly find the right package and the way to implement it. At least, that's my experience.

When you have an OR-problem that can't be solved with your go-to language, you can look for other languages. But I feel that languages like Python & Julia have almost everything covered.

$\endgroup$
3
$\begingroup$

Today I'm responsible for the tool chains for 461 engineers, hereof 88 with main focus on OR-like tasks. They cover anything from HPC (20,000 cores) to racks of Nvidia-A100 GPUs to swarms of micro-services.

The glue that makes everything work is python3.10 running on Linux Ubuntu LTS. After that comes specialized packages written in C or nim.

Speed is the key so we use lots of OR to tune our algorithms - from memory management(1) to multiprocessing(2) to calibration of block sizes(3) so we get the optimal balance between the number of IOPS and block size on SSDs during read and write.

With this context there is one central lesson:

All software goes through 4 stages of development and I illustrate the share of lines of code by programming language involved:

  1. Make it work (100% python)
  2. Make it right (100% python, markdown and jupyter notebook)
  3. Make it fast (98% python, 2% C or nim)
  4. Make it cheap (97% python, 3% C or nim)

This progression becomes easy to understand once you see how easy it is to link python with nim have a look here.

$\endgroup$
2
  • $\begingroup$ Why Python? I'm surprised. $\endgroup$ Commented Jun 28, 2023 at 21:32
  • 1
    $\begingroup$ Because the ecosystem of supporting libraries is very large and well maintained. $\endgroup$
    – root-11
    Commented Jun 29, 2023 at 9:23
0
$\begingroup$

FWIW, my experience in the corporate world OR is that most of your time will be in data cleaning, prep, and visualization. And for that R is extremely effective and easy to use. That's the primary reason it's my language of choice. You can also do optimization, simulation, predictive modeling, etc.

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