I have a Pyomo model with many constraints and variables. When solving it with Gurobi, I get the message "Model is infeasible or unbounded". Now I would like to find out which constraints cause the problem. Here in this question Finding out reason of Pyomo model infeasibility there is an advice to use the following command
The problem with this approach is that it just prints out every single value of a variable that causes problems. As I have quite many variables the printed out information is too large for the console of Spyder. So basically I have 2 questions:
- Can I print out the information from the log into a txt file? I tried the following but I get an error message:
file = open("Log.txt", "w") file.write(log_infeasible_constraints(model)) file.close()
TypeError: write() argument must be str, not None
- Is there another approach for finding out what is causing the problem in Pyomo? Can I somehow see the values of all variables at the time the infeasibility or unboundedness is found out?
Reminder: Does anyone have an idea how I can get more precise information about the error? Especially seeing the values of the variables would be quite helpful. Any idea?