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

Adding Constraints to variables in Excel sheet

回答済み

コメント

3件のコメント

  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    What is your question?

    Are you asking how to read Excel Sheet data? If yes, then you can use pandas for this, see How to Import an Excel File into Pyhton using Pandas?

    0
  • Aadav Srimushnam Sundaranathan
    • Gurobi-versary
    • First Comment
    • First Question

    No. As I look to add constraints to variables in a table (with i rows and j columns), I am getting an error for the following syntax: 

    m.add_constr(Supply[i][j].value <= 400 for i in range(dem_r) for j in range(dem_c))

    Can you please suggest the right method to add constraints to variables in a table.

     

    0
  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    It is hard to help here, because you did neither provide a reproducible example nor the error message you get.

    My guess would be that you are using a wrong method. Instead of \(\texttt{add_constr}\), you should probably use the addConstrs method.

    0

サインインしてコメントを残してください。