MIPSOL Callback : Is there any way to get solution right after incumbent found?
回答済みHi, I'm trying to use callback function to get solution in the middle of optimization, and add Lazy constraints with using those solution.
Using GRB.Callback.MIPSOL with model.cbGetSolution, I could get solution when all cutting planes added, not right after incumbent found.
Is there any way that I could get solution right after incumbent found, not after all cutting planes added(after all renewing BestBd)? Thanks.
-
Hi Seung Kyu,
Could you please clarify whether you are referring to lazy constraints or user cuts?
https://support.gurobi.com/hc/en-us/articles/360025804471-What-is-the-difference-between-user-cuts-and-lazy-constraints- Riley
0 -
I'm trying to use lazy constraints via cbGetSolution(), not user cuts. Currently I'm using callback function as below. It is called after all 'BestBd' renewed, so I was wondering if I can call callback function right after Incumbent found. Thanks.
def no_crossing_callback(model, where):
global previous_incumbent
if where == GRB.Callback.MIPSOL:
incumbent = model.cbGet(GRB.Callback.MIPSOL_OBJBST)
if incumbent < previous_incumbent:
previous_incumbent = incumbent
solution = model.cbGetSolution(y)0 -
If I understand correctly, you are wanting to obtain infeasible solutions that violate the lazy constraints.
The MIPSOL callback is called when Gurobi finds a new feasible solution. If you are creating lazy constraints using the Lazy attribute, so that they go into a constraint pool that Gurobi manages, then the callback will not be called before violated lazy constraints are added, because if they're violated you don't have a feasible solution.
If you want to be able to obtain an infeasible solution before lazy constraints are added then you can use the MIPSOL callback but you will need to add lazy constraints dynamically from within this callback. See How do I implement lazy constraints in Gurobi for more details, and tsp.py for an example of this.
- Riley
0
サインインしてコメントを残してください。
コメント
3件のコメント