Skip to main content

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



1 comment

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

Please sign in to leave a comment.