Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Cplex Concert Technology with Python

    Posted Mon April 30, 2018 09:34 AM

    Originally posted by: ashley20


    Hi all, I am a user for Cplex concert technology with C++ for several years. Now I am trying to start using Python with Cplex Concert Technology in a new project. I have a couple questions:

    1. Comparing to concert technology with C++, is there any limitation for using concert technology with Python? (in terms of performance, stability, limitation of functionalities)

    2. Can you share some links for tutorial/document/examples for using concert technology with Python?

    Thank you!

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Cplex Concert Technology with Python

    Posted Mon April 30, 2018 09:56 AM

    There is no Concert technology for Python. I am not sure what you are referring to. There is the CPLEX Python API and there is docplex. Which of the two are you using? Maybe show a short example then we can tell.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Cplex Concert Technology with Python

    Posted Mon April 30, 2018 10:32 AM

    Originally posted by: ashley20


    Hi Daniel,

     

    Thanks for your reply. I have not started anything yet in using (cplex + python).

     

    A little background is: I am a Cplex Concert Technology C++ user, and I am asked to use (cplex + python) in a new project. So I am at the phase of evaluating this combination (cplex + python).

     

    So let me change my questions:

    1. Would you please talk about Cplex Python API vs. DoCplex? What is the pro and con? and what is the suitable scope for each of them? why Cplex offers two?

    2. Comparing to Cplex concert technology with C++, is there any drawback for using Cplex with Python, in terms of performance, stability, limitation of functionalities? 

     

    Thank you!

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Cplex Concert Technology with Python

    Posted Mon May 07, 2018 04:11 PM

    OK, I got it now. CPLEX+Python is in any case different from Concert.

    The CPLEX Python API is a direct wrapper around the CPLEX callable library. With this API modeling is matrix based. A variable is just a column index and a constraint is just a row index. The advantage is that you have more or less direct access to the C API and almost anything you can do in C you can also do with the Python API. The disadvantage is that you don't have object oriented modeling. Whether this is a problem or not depends on your preferences/skills/experience.

    docplex is built on top of the CPLEX Python API. It provides object oriented modeling that is similar to Concert. Right now it does not support everything that the CPLEX Python API supports but depending on what you plan to do it may well be sufficient. The advantage is the object oriented modeling, the disadvantage is that it adds yet another wrapping layer and does not support everything from the Python API (the latter may not be a problem in your project).

    Performance and stability: Usually you create your model one way or the other and eventually call some sort of solve() functions. At this point the Python code will trap into the native CPLEX code and the actual solve will happen in this native code. This is the same for C++ by the way. So the only point at which performance and stability depend on Python here is model building. I am not aware of any significant problems here for either of the two variants.

    Limitation of functionalities: The CPLEX Python API gives access to almost everything from the callable library, i.e., almost everything you can do with CPLEX. Since docplex builds on this Python API it will in general not offer more functionality, more likely less.

    One big difference between the two is logical constraints: The only logical constraint that the callable library supports is Concert's equivalent of IloIfThen() (these constraints are known as indicator constraints). The same is true for the CPLEX Python API. docplex instead supports things like logical AND and OR between constraints. It does this by transforming them to indicator constraints under the hood. So it does not offer more functionality here but merely more convenience.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Cplex Concert Technology with Python

    Posted Wed May 09, 2018 11:37 AM

    Originally posted by: ashley20


    Hi Daniel,

     

    Thank you so much for your detail answer. I think docplex probably is a good choice for my project. My project is just a MIP problem which will be solved directly by Cplex. It is not expected to have any customized decomposition algorithm. 

     

    I still have one question on docplex. Comparing to build model using Python API or C++ or Java API, do you see any noticeable performance issue for docplex during model building phase? I heard OPL is slower in model building phase for large model, and I just hope this is not the case for docplex.

     

    Thank you!

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Cplex Concert Technology with Python

    Posted Fri May 11, 2018 03:24 AM

    The more wrappers you involve, the slower things will get. However, if you only want to build up the model and then solve it, I doubt you will see any measurable performance difference between docplex and C. If model building turns out to be the bottleneck in your project then there are probably ways to do things differently/faster. Then you should come back here and ask for further help :-)


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Cplex Concert Technology with Python

    Posted Tue May 15, 2018 10:49 AM

    Originally posted by: ashley20


    Hi Daniel,

     

    Thank you for your responses and answering all my questions!


    #CPLEXOptimizers
    #DecisionOptimization