Decision Optimization

 View Only
  • 1.  Docplex to qubo tuple

    Posted Mon December 20, 2021 01:58 PM
    Hi, All,
    I am modelling with docplex and wondering how I can from my docplex model extract my objective function into a QUBO dictionary? I would like to have the variable (qubo_model)  in this form: {(x_0,x_1):2,
    (x_0,x_2):-3,
    ....
    }

    After executing this lines:
    qp = QuadraticProgram()
    qp.from_docplex(mdl)

    conv = InequalityToEquality()
    eq_model = conv.convert(qp)

    conv2 = QuadraticProgramToQubo()
    qubo_model = conv2.convert(eq_model)

    Many thanks



    ------------------------------
    parfait atchadé
    Researcher
    University Ramon Llull - La Salle. DS4DS
    Barcelona
    ------------------------------


  • 2.  RE: Docplex to qubo tuple

    Posted Tue December 21, 2021 03:26 AM
    Are you looking for something like this?
    { (a,b) : coef for a,b,coef in model.objective_expr.iter_quad_triplets() }​


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



  • 3.  RE: Docplex to qubo tuple

    Posted Tue December 21, 2021 03:55 AM
    Dear Vincent, I tried to test what you share in 3 different codes. I'm using this docplex package: from docplex.mp.model import Model. There is some limitation? Many thanks Vincent.
    Parfait




    ------------------------------
    parfait atchadé
    Researcher
    University Ramon Llull - La Salle. DS4DS
    Barcelona
    ------------------------------



  • 4.  RE: Docplex to qubo tuple

    Posted Tue December 21, 2021 04:24 AM
    Are you using an up to date version of docplex? It should be 2.22.x
    It should just create an empty dict {} with diet model as it's not quadratic.

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



  • 5.  RE: Docplex to qubo tuple

    Posted Tue December 21, 2021 05:52 AM
    Thank you very much, Vincent. I just updated my docplex. But I realized that it is not what I am looking for.
    Thanks a lot.

    ------------------------------
    parfait atchadé
    Researcher
    University Ramon Llull - La Salle. DS4DS
    Barcelona
    ------------------------------