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

Leveraging Gurobi Callbacks to Incorporate Expensive Heuristics into Optimization

回答済み

コメント

3件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • Riley Clement
    • Gurobi Staff

    Hi Mohammad,

    I think it would be a good idea to closely read the API doc for cbSetSolution.

    When you use 

    model.cbSetSolution(z_var,new_z_val)

    You are telling the solver you have a new solution, and that z_var = new_z_val, but this is then only a partial solution consisting of 1 variable - and Gurobi must try and complete the solution, which involves solving your model with fixed z.  Unless this solve is trivial then Gurobi would almost certainly abandon trying to complete the solution and ignore your attempt.

    However, I think the larger issue here is that this approach does not do what you want it to.  I will explain it with a simpler example:  minimize x, x >= 0, x is integer

    Solver: "I have a solution of x = 0"
    Callback: "Ok, now I have calculated that x should equal 2, so I will give you a solution with x = 2"
    Solver: "I have accepted your solution.  But x=0 is better, so I will now ignore your solution".

    The problem you are trying to solve might be better approached with gurobi-machinelearning where you first train a ML model to approximate g(x) - either with your data provided by your heuristic, or the data that the heuristic was trying to approximate - then embed the trained model in the optimization model.  There would be no use of callbacks in this approach.

    - Riley

    1
  • Mohammad Rohani Nezhad
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Riley

    Thank you for your thorough explanation, and I appreciated how you simplified the answer :). It appears I may have overestimated the callback, so I'll explore alternative approaches, particularly the one you suggested.

    Regards

    -M

    1

投稿コメントは受け付けていません。