Adding Constraints to variables in Excel sheet
回答済みI am attempting to load data from excel sheet for maximizing profits in supply planning. I have sheets for Demand, Supply, Price and Cost, where I am looking to add capacity constraint of 400 to my variables in Supply sheet with i rows and j columns.
#adding constraints
m.add_constr(Supply[i][j].value <= 400 for i in range(dem_r) for j in range(dem_c))
where dem_r and dem_c are the size of rows and columns in the sheet.
Unfortunately, it shows syntax error. Can you guide on how to add constraints for variables with i rows and j columns?
-
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 -
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 -
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
サインインしてコメントを残してください。
コメント
3件のコメント