Skip to main content

Modeling square root of squared variable

Answered

Comments

2 comments

  • 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

Please sign in to leave a comment.