I've been using CPLEX through AMPL for a couple of years but I'm finding it limiting and want to try CPLEX through either C++ or Python. I know plenty of people who use Concert with C++ but no one that uses Python. I find programming Python a lot easier and faster than C++, but I don't want to be limited again. Does anyone have experience using the CPLEX Python API and Concert with C++ and comment on the difference?


asked 02 Sep '10, 17:37

AnORStudent's gravatar image

accept rate: 0%

retagged 26 Nov '11, 14:43

fbahr's gravatar image

fbahr ♦

In general Python is very good for prototyping or used in an application which changes a lot over time. You get the benefit of the large amount of easy to use Python functionality such as database connection etc.

Most software vendors now have python interfaces and I think we will see more OR Python users in the future.

Regarding the CPLEX Python API vs. Concert C++ and where they differ, I would recommend asking here :


I think they have improved their support much and you will get fast quality answers. My guess would be that if you keep away of very fancy MIP stuff, then you should be able to do exactly the same, with a small extra cost for the Python layer.

Actually I think there is also stuff which you can not do in the C++ API, but only in the C API. But you better ask them to get a correct answer.


answered 02 Sep '10, 18:12

Bo%20Jensen's gravatar image

Bo Jensen ♦
accept rate: 14%

The Python API provides nearly all of the functionality that is possible with the Callable Library interface (a.k.a. the C API) to CPLEX, including callbacks and access to simplex tableaux. The Python API also provides some convenient tools previously only accessible from the Interactive Optimizer, such as methods that return a summary of the solution quality or a histogram of nonzero counts in the constraint matrix.The only thing that comes to mind that is part of the Callable Library interface but is not available in Python is access to the presolved model within a callback.

There is one place where the overhead from Python is very different from the other CPLEX APIs. If a control callback (e.g., branching callback or solve callback) is in use then the performance of parallel MIP will be slower when compared to the equivalent program written in C or C++. This is due to the way that Python handles multithreaded applications. Otherwise you should not see much difference in the performance overhead incurred with calling CPLEX from Python compared to using Concert.


answered 07 Sep '10, 18:15

Philip%20Starhill's gravatar image

Philip Starhill
accept rate: 0%

Thanks for the detailed follow up, Philip. Nice to see cplex people here, you are more than welcome, we can always use expert insight on optimization software.

(07 Sep '10, 19:02) Bo Jensen ♦

I haven't used the Python API, but I just looked at the docs, and they list a full set of callbacks. I generally use callbacks as the measure of completeness of the API. If there are any limitations of the Python API not shared by the C++ API (other than stability), I suspect you'll be using it for quite a while before you bump into them. As far as stability goes, the Python API is newer, so I wouldn't be shocked if it had a bug or two not shared by C++, but I haven't seen any particular griping on the IBM CPLEX forum(s).

Bo is right that there are a few (but only a few) things you can only do with C and not with any of the higher level APIs. I'd characterize them as operating at the tableau level (although that's probably not entirely accurate). I've been using the Java API for years (and the C++ API, albeit a bit reluctantly, before that), and I have not bumped into any limitations that made me regret my choice. I don't think you'll find the Python API limiting.


answered 02 Sep '10, 20:12

Paul%20Rubin's gravatar image

Paul Rubin ♦♦
accept rate: 19%

One of the thinks present in the C callable library but missing both in the Concert and Python APIs are the methods to get the inverse basis matrix. This is useful, for instance, if you want to experiment yourself with Gomory cuts from the optimal basis.


answered 30 Nov '11, 04:36

Stefano%20Gualandi's gravatar image

Stefano Gual...
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 02 Sep '10, 17:37

Seen: 6,261 times

Last updated: 30 Nov '11, 04:36

OR-Exchange! Your site for questions, answers, and announcements about operations research.