IIS infeasible
回答済みHi,
I have a maximization problem, which is infeasible (status: 4) in Python with the Gurobi package. Then, I tried to do IIS infeasible to find out the constraints that make the model infeasible. But it does not show information on infeasibility and just shows LP format. How can I solve this issue. I really appreciate if anyone helps me. My code is as follows:
# Check the status of the optimization
status = model.status
print("Status:", status)
# If the model is infeasible, print infeasible constraints
if status == GRB.INFEASIBLE:
print("Model is infeasible.")
try:
model.computeIIS()
infeasible_constraints = [c.constrName for c in model.getConstrs() if c.IISConstr]
print("Infeasible constraints:", infeasible_constraints)
print("Number of infeasible constraints:", len(infeasible_constraints))
print("Total number of constraints:", model.NumConstrs)
except gp.GurobiError as e:
print("Failed to compute IIS:", e)
# Save the Gurobi log to a file
log_file_path = "gurobi_log.lp" # Path to save the log file with .lp extension
model.write("gurobi_log.lp")
# Read the Gurobi log file
with open(log_file_path, 'r') as log_file:
log_contents = log_file.read()
# Print the log contents
print("Gurobi Optimizer Log:")
print(log_contents)
-
Hi Vida,
It would be worthwhile taking a thorough look at the documentation on computeIIS.
You need to use a .ilp extension to write the IIS. Using a .lp extension will simply write the original model.
- Riley
0 -
Hi Riley,
Thank you for your help. In my case, I could not extract IIS because there was a problem in my linearization with max function. So, I could not see any results for computing IIS.
-Vida
0
サインインしてコメントを残してください。
コメント
2件のコメント