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

Help with a conditional constraint!

回答済み

コメント

3件のコメント

  • 正式なコメント
    Simranjit Kaur
    • 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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Eli Towle
    • Gurobi Staff

    Is \( \texttt{yieldpersqft} \) fixed data that is known beforehand? If so, you can add a conditional statement to your \( \texttt{for} \) loop so you only sum terms for which \( \texttt{yieldpersqft[p, o]} \) is strictly positive:

    for i in locations:
        for o in facilityoptions:
            m.addConstr(
                gp.quicksum(
                    ProductionQty[p, i, o] / yieldpersqft[p, o]
                    for p in setproduce
                    if yieldpersqft[p, o] > 0
                )
                <= sqft[o] * LocationSelect[i, o],
                "SqftConstraint",
            )
    0
  • Abhishek Solomon
    • Gurobi-versary
    • Curious
    • Conversationalist

    Thank you Eli Towle ! Yes, yieldpersqft is fixed data. I will try this and come back if there's any other issue.

    0

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