Skip to main content

Float exponent of a variable

Ongoing

Comments

3 comments

  • Zed Dean
    • Gurobi Staff 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
    • Conversationalist
    • Investigator

    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 Gurobi Staff

    Hello Biwajit,

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

    Yours

    Zed

     

    0

Please sign in to leave a comment.