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

How to get the square root(sum of binary decission variable)

回答済み

コメント

2件のコメント

  • 正式なコメント
    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 Mohd,

    You can decompose √(∑(open)) into two constraints:

    sum_open = model.addVar(ub=ub1, vtype="I")
    sqrt_sum_open = model.addVar(ub=ub2)

    model.addConstr(sum_open == df["open"].sum())
    model.addConstr(sum_open == sqrt_sum_open**2)

    Note that if there is a limit to how many "open" binary variables can be 1 in an optimal solution then you should use this value for ub1, and sqrt(ub1) for ub2.

    Note, if your objective function is simply sqrt_sum_open then you don't actually need the square root, you can use sum_open instead.

    - Riley

    0

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