Skip to main content

Float exponent of a variable

Ongoing

Comments

4 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • Zed Dean
    • Gurobi Staff

    Hello Biswajit,

    I would try to introduce two  auxiliary variables:

    \begin{array}{l}
    a=x^{0.2} \\
    b=y^{0.4}
    \end{array}

    $$
    \text { min } a+b
    $$

    Then add the two constraints using Model.addGenConstrPow() (gurobi.com) as follow: 

    model.addGenConstrPow(x, a, 0.2)
    model.addGenConstrPow(y, b, 0.4)

    PWL  piecewise-linear constraints are an approximation, it affects the model's accuracy. Including a non-convex, piecewise linear may significantly increase the cost of solving the model. The Graph below illustrates the non-convex nature of your equation.

    Best Regards

    Zed

     

    0
  • BISWAJIT KAR
    • Gurobi-versary
    • Curious
    • Conversationalist

    Dear Zed Dean, Thanks a lot for your response. The above question is just an example. I am solving similar questions.

    I am still getting a bit confused. So, is the following how the code is supposed to be written?

    import gurobipy as gp
    m.gp.Model('float')

    x=m.addVar(vtype=GRB.CONTINUOUS, name='x')
    y=m.addVar(vtype=GRB.CONTINUOUS, name='y')

    #Auxilary verb
    a=m.addVar(vtype=GRB.CONTINUOUS, name='a')
    b=m.addVar(vtype=GRB.CONTINUOUS, name='b')

    m.addGenConstrPow(x, a, 0.2)
    m.addGenConstrPow(y, b, 0.4)


    0
  • Zed Dean
    • Gurobi Staff

    Hello Biwajit,

    Seems correct so far, you need to add the objective and then you should be fine 

    Yours

    Zed

     

    0

Post is closed for comments.