Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

python interface?

  • 1.  python interface?

    Posted 10/20/10 08:24 AM

    Originally posted by: BKE


    Hello,

    Is there a Python interface to CP optimizer? I would like to write a fast hybrid (CPLEX+CP) prototype preferably in Python. (I am not very comfortable with C++ or Java and other prototypes related to this project have been written in Python.)
    There is a Python interface for CPLEX, but I found nothing on CP. Sorry if I have missed something obvious.

    Any suggestions are welcome.

    Thanks
    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: python interface?

    Posted 10/22/10 04:56 AM

    Originally posted by: SystemAdmin


    Hello,

    Unfortunately, there is no Python interface to CP Optimizer, you must rely on Java, C++, .net DDLs or the OPL langage to design you model.

    Regards,

    Philippe
    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: python interface?

    Posted 06/12/15 02:30 AM

    Originally posted by: saeed62s


    Hi Philippe

    I saw your post now, but it was for 2010, I was wondering still there is no Python interface to CP Optimizer? I wrote my code in OPL, ILOG using CP and now I want to convert it to Python, is there any way?

    Thanks

    Mahmood

     


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: python interface?

    Posted 06/12/15 09:04 AM

    Originally posted by: GGR


    Hi Mahmood

    we actually seriously think about the python interface. Unfortunately it is not available for now.

     

    Cheer

     


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: python interface?

    Posted 06/14/15 12:56 PM

    Hi

    in Python you may also call an OPL execution that will descrive a CPO model as described at

    https://www.ibm.com/developerworks/community/forums/html/topic?id=0b6cacbe-4dda-4da9-9282-f527c3464f47

    regards


    #CPOptimizer
    #DecisionOptimization


  • 6.  Re: python interface?

    Posted 10/11/16 09:22 AM

    Originally posted by: P_Rein


    Hello..

    Did the serious thinking on the topic give any results?

    I was unable to find a python interface for CP. Is there one already?

    Regards


    #CPOptimizer
    #DecisionOptimization


  • 7.  Re: python interface?

    Posted 10/11/16 11:43 AM

    Originally posted by: ChrisBr


    Hello Petar,

    You might have a look at The IBM Decision Optimization CPLEX Modeling for Python, where you'll find details about Python API for CPLEX and CP Optimizer using IBM Decision Optimization on Cloud service or on your computer with IBM ILOG CPLEX Optimization Studio.
    Please note that solving with CP Optimizer locally is not (yet) available with CPLEX Optimization Studio v12.6.3.

    Regards,

    Chris.


    #CPOptimizer
    #DecisionOptimization


  • 8.  Re: python interface?

    Posted 12/02/16 03:44 AM

    Originally posted by: AndyTum


    Hi Chris,

     

    Is solving with CP Optimizer locally possible using CPLEX Optimization Studio v12.7.0.0? If so, can you briefly explain?

     

    Regards,

    Andy


    #CPOptimizer
    #DecisionOptimization


  • 9.  Re: python interface?

    Posted 12/02/16 05:41 AM

    Originally posted by: Olivier OUDOT


    Hi Andy,

     

    Once you have installed COS 12.7.0, you just have to edit your local cpo_config.py configuration file (that should be visible in your Python path) and set the following line:

    set_default(LOCAL_CONTEXT)
    

    If you have already some local settings, you can keep them after this line.

    Note 1: local solving assume that the installation has been completed correctly and that the "CP Optimizer Interactive" process is already put in the system path. You can check this by invoking "cpoptimizer(.exe)" in a command prompt.

    Note 2: I recommand you update your docplex Python stuff using "pip update docplex"

    Note 3: docplex documentation available on Internet at http://rawgit.com/IBMDecisionOptimization/docplex-doc/master/docs/index.html will be updated soon to better describe this new type of deployment.

     

    Olivier


    #CPOptimizer
    #DecisionOptimization


  • 10.  Re: python interface?

    Posted 12/02/16 07:02 AM

    Originally posted by: AndyTum


    Hi Olivier,

     

    Is the cpo_config.py file something I have to create on my own? Does this file only contain a single line, i.e. "set_default(LOCAL_CONTEXT)""?

    When typing cpoptimizer in a command prompt, I get a message that the program could not be started because MSVCP120D.dll is missing on my computer. Do you know why this problem happens?

     

    Thanks in advance for your reply

    Andy


    #CPOptimizer
    #DecisionOptimization


  • 11.  Re: python interface?

    Posted 03/05/19 05:28 AM

    Originally posted by: beyondzhao


    Hi Oliver,

     

    I have installed COS 12.8 on ubuntn 18.04. And I also run "pip install docplex" to install docplex. The obvious two steps all are succeed.

    But when I run "cpoptimizer" in command line, it didn't work.

    Another problem is that there is no cpo_config.py file in my computer and I'm not very clear about the "Python Path" you said. Can you explain it , namely the exact destion folder?

    Appreciate for your reply.

     

    Zhao 


    #CPOptimizer
    #DecisionOptimization


  • 12.  Re: python interface?

    Posted 03/07/19 04:14 AM

    Originally posted by: rdumeur


    Dear beyondzhao,

     

    Please note that the 'cpoptimizer' command has nothing to do with the Python interface of CPO. It is an executable that can be found in the <cos install dir>/cpoptimizer/bin/<arch> directory.

    Is your PATH correctly set so that the 'cpoptimizer' can be found by the shell?

    By 'python path', I think Olivier referred to the PYTHONPATH variable which must be set so that the cpo_config.py file can be loaded by the python interpreter.

    About 'cpo_config.py' please refer to http://ibmdecisionoptimization.github.io/docplex-doc/cp/docplex.cp.config.py.html to determine what parameter you want to set in it.

    I hope this helps,

     

             Cheers,

     

    Edit: "nothing to do" is  excessive. It is used as a back-end to solve models built using the python modeling API, of course.

     

     

     

     


    #CPOptimizer
    #DecisionOptimization


  • 13.  Re: python interface?

    Posted 03/12/19 03:53 AM

    Originally posted by: beyondzhao


    Hi, rdumeur,

    Thank you very much for your reply. And I have solved the problem.

    I reinstalled cplex again, and I set the absolute path of cpoptimizer in the config.py of under the folder docplex/cp.


    #CPOptimizer
    #DecisionOptimization


  • 14.  Re: python interface?

    Posted 10/26/10 06:06 AM

    Originally posted by: BKE


    Thanks a lot for the answer.

    I need to do something similar to what's described in ch.22. of the manual, Advanced Modeling With Set Variables. I would prefer not to use C++ if possible, but I the documentation seems to be missing the elements I need (IloNumSetVar, IloEqSum etc). Could someone point me to a similar example in C# or Java?
    #CPOptimizer
    #DecisionOptimization


  • 15.  Re: python interface?

    Posted 12/02/16 09:59 AM

    Originally posted by: Olivier OUDOT


    Hi Andy,

     

    For your first question: yes, cpo_config.py is the way to customize the default configuration to adapt it to your own environment. You can find more details in the documentation here: http://rawgit.com/IBMDecisionOptimization/docplex-doc/master/docs/cp/creating_model.html#advanced-configuration. This documentation will be updated soon to integrate the new case of local solve.

     

    Four your second question, in COS 12.7, the cpoptimizer.exe binary has a dependency on the debug libraries of VS2013 that are not currently supplied in the redistributable package of VS2013. You can fix this by installing VS2013 Express Edition https://www.microsoft.com/en-US/download/details.aspx?id=44914

     

    Olivier


    #CPOptimizer
    #DecisionOptimization