メインコンテンツへスキップ

How to get squre root of QuadExpr

回答済み

コメント

3件のコメント

  • 正式なコメント
    Simranjit Kaur
    Gurobi Staff 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 why not try our AI Gurobot?.
  • wang xiang
    Gurobi-versary
    First Comment
    First Question

    is put as

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    The addGenConstrPow method requires a single variable as xvar argument and not a QuadExpr object. Thus, you need to introduce an additional optimization variable and an additional equality constraint.

    aux_var = m.addVar(vtype=GRB.CONTINUOUS, name="aux_var")
    m.addConstr(om_risk == add_var, name="aux_eq")
    m.addGenConstrPow(aux_var, vars_risk, 0.5)

    Best regards,
    Jaromił

    0

投稿コメントは受け付けていません。