Skip to main content

Modeling square root of squared variable

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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.
  • Riley Clement
    • Gurobi Staff

    Hi DR,

    I cannot reproduce the exact issue you might be seeing because there are several definitions in your code which are not provided, e.g. i_max, j_max, k_max, a, b, etc

    However I can see an error where you are using z2 as an argument in

    c = m.addGenConstrLogA(z2, z3, 0.5, "c")

    Both the first two arguments need to be Gurobi variables.  You initially define z2 to be a Gurobi variable but then you overwrite on the next line, resulting in it being an expression.  You are probably wanting to do the following instead.

    z2 = m.addVar(vtype=GRB.CONTINUOUS, name='z2')
    m.addConstr(z2 == gp.quicksum( z[k,0] * z[k,0] for k in range(0, k_max) )

    - Riley

    1
  • DR
    • Gurobi-versary
    • First Comment
    • First Question

    Thanks a lot, Riley! 

    0

Post is closed for comments.