FeasRelax with smart choice of cons to drop
I'm attempting to use the FeasRelax function on a minimization problem. My problem has some constraints that conflict with each other. FeasRelax successfully drops some of the conflictors. However, I need it to do something slightly more advanced: I need it to drop constraints such that my minimization problem is maximized. I want it to keep the constraints that push up the resulting minimum the most. Is this possible with FeasRelax?
If it's not possible directly, I was considering an iterative approach where I manually adjust the penalty of the constraints given to FeasRelax to force it to keep constraints that were ignored until I can't push up the result any further. How can I tell which constraints were ignored? Do you think something like the code below should work? (It doesn't work.) Can I repeatedly use FeasRelax on the same problem like in the code below?
for _ in range(10): # wanted loop until done
# model.reset() # need this?
model.feasRelax(0, False, None, None, None, disj, penalties) # won't work
model.optimize()
if model.status == gp.GRB.OPTIMAL:
if model.objVal == last_score:
longests = [v.X for v in vars]
return longests
last_score = max(model.objVal, last_score)
chgd = False
for c, con in enumerate(disj):
if abs(con.Slack) > 1e-5:
penalties[c] *= 100
chgd = True
if not chgd:
print(" no penalties updated.")
longests = [v.X for v in vars]
return longests
else:
handle_infeasible(model)
print("Model not optimal")
return None
サインインしてコメントを残してください。
コメント
0件のコメント