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

unsupported operand type(s) for +: 'Constr' and 'Var'

回答済み

コメント

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.
  • Simranjit Kaur
    • Gurobi Staff

    The quicksum() function takes a list of terms as arguments. The correct usage in your case would be

    T = m4.addConstrs( tr[month]  == gp.quicksum( [Ci[month], Cr[month]]) for month in months)
    Alternatively, you can use
    T = m4.addConstrs( tr[month]  == Ci[month] + Cr[month] for month in months)
    This will create a constraint for each month, ensuring that tr[month] equals the sum of Ci[month] and Cr[month].
    0

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