メインコンテンツへスキップ

MIPSOL Callback : Is there any way to get solution right after incumbent found?

回答済み

コメント

3件のコメント

  • Riley Clement
    Gurobi Staff Gurobi Staff

    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
  • Yoon Seung Kyu
    First Comment
    First Question

    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
  • Riley Clement
    Gurobi Staff Gurobi Staff

    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

サインインしてコメントを残してください。