Decision Optimization

 View Only
Expand all | Collapse all

Accessing Python cplex.Cplex object

  • 1.  Accessing Python cplex.Cplex object

    Posted Fri January 21, 2022 10:35 AM
    Hi,

    What is the difference between instantiating a cplex.Cplex object in Python via:
    a. the Cplex API
    import cplex
    cpx = cplex.Cplex()​

    b. Docplex 

    from docplex.mp.model import Model
    mdl = Model()
    cpx = mdl.cplex


    In particular, I would like to get the extreme ray of an unbounded LP problem. Would constructing the LP model via one of these methods make a difference?

    Thanks,
    Louis



    ------------------------------
    Louis Luo
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Accessing Python cplex.Cplex object

    Posted Fri January 21, 2022 10:53 AM
    There is no difference: at the end you will end up with a CPLEX object.
    * With cplex package, you create and manipulate a problem via indexes and coefficients. So it is very mathematical.
    * docplex is built on top of docplex and provides an object layer with variables, expressions, aggregate functions... which is easier to manipulate and maintain. It covers most CPLEX standard functionalities. Once your Model is built, you can use the get_cplex method to get the hand on the cplex object and use the cplex package functions if you need access to more expert methods such as the extreme ray.

    ------------------------------
    Vincent Beraudier
    ------------------------------