12
$\begingroup$

There are many great technologies/libraries out there to improve the speed and quality of implementing and deploying OR applications. However in my experience I "stumbled" upon many of them often by accident and they greatly improved the workflow.

What are your favourites and why?

Some which I found very beneficial:

  • version control like git
  • json/xml for writing data to disk

I am mainly interested in stuff that works with Python. However if it is not applicable feel free to add it too.

$\endgroup$
11
$\begingroup$

I like Stuart Mitchell's (maintainer of Pulp) tips, especially tip number 2 : use a profiler to track your bottlenecks. Quoting him:

I can't tell you the number of times I have assumed the slow code was for one reason and then found it was another.

I agree with him and use line_profiler to optimize the code (for Python). I have been able to drastically reduce computation times with this amazing tool many times.

Check out this post for some other useful Python libraries.

$\endgroup$
6
$\begingroup$

In addition to profiler (mentioned by Kuifje), Python has quite a few unit testing libraries that can be used to test your application (unittest and pytest are both common).

As in any commercial application, real-world OR applications should be flexible, maintainable and modularized. It is common to change some modelling objects (variables, constraints, etc), the way they are constructed, the way your algorithm gets data, etc (as a result of customer requests, addition of new features or product improvement in general). It is important that your changes do not break other parts of the code such as your solution representation or even the correctness of your algorithm. That's where unit testing plays an important role.

Your unit test in an OR application could include small problem instances that are different in some way (become infeasible in some case, become unbounded in some case, produce an expected solution in some case, etc). If your tests fail, you will find the cause of the issue a lot easier compared to the case with no unit testing.

$\endgroup$
6
$\begingroup$

One useful package that I've been using for optimization modeling is ticdat, which is great for validating the input data and performing sanity and integrity checks. Because the data we receive in applications are almost never clean and a lot needs to be written to ensure they are correctly handled by either throwing an error or fixing what needs to be fixed (e.g., assigning a default value when a value is null in a certain column of a certain table).

I found out that Gurobi recently added an example on how to use ticdat (diet example) in their library of beginner models.

$\endgroup$
2
  • 1
    $\begingroup$ Interesting ! I agree with the fact that pandas is great for data manipulation, but for writing models dicts are more convenient. In your experience, is there a lot of added value using ticdat, instead of creating your own dictionaries (and data checks) from pandas ? $\endgroup$
    – Kuifje
    Jul 21 at 13:46
  • $\begingroup$ Absolutely! Ticdat has two main classes depending on what you are comfortable with, one based on pandas (PanDatFactory) and one based on dict of dicts (TicDatFactory). There are a lot of checks that it does for you and you only need to set it up (check of logical relation between columns or rows, check of correct data types or values, reading from different sources without the need to write separate subroutines for them, etc). Assuming one can write all those checks themselves using their own dictionaries and data checks in pandas, essentially, they are creating a new ticdat package. $\endgroup$
    – EhsanK
    Jul 21 at 13:57
4
$\begingroup$

I'll start with the lowest hanging fruit in the orchard: an IDE (with a good built-in debugger), to facilitate code development.

Regarding reading/writing "data", I use XML libraries to save and retrieve things like the parameter settings used in runs. For applications where either the input date is complicated or I'm running multiple instances with the intent of doing some statistical analysis of the run times, results etc., I prefer to use an open source SQL database to input model parameters and save model results. (I've been using SQLite in recent years, but previously had good luck with MySQL.)

For inhaling data / model parameters from an outside source, it's useful to have an open source library that reads (and possibly writes) CSV and XLSX files. Again, depending on the nature of the work, I might prefer to turn the input files into an SQLite database and work with that.

In many cases, I want my application to have a GUI. I work mainly with Java, so I typically use Swing, but in other cases a browser-based user interface may be best. (For instance, for R applications I will unsurprisingly use Shiny.)

I don't have a lot of experience with deployment (since I don't tend to do anything useful), but for those who do need to worry about it, another technology that may be helpful is containers (such as Docker).

$\endgroup$
3
$\begingroup$

In the vein of version control — continuous integration/deployment strategies. This, in addition to an integrated testing suite has made significant improvements to deployment cycles and could be completed through unittest and Github Actions.

As prubin mentions, interfaces control for the application can also play a critical role. While he seems to prefer GUIs (and if it's client facing, this is obviously superior), I prefer command-line interfaces — specifically through Python's argparse.

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