Skip to main content

What are common uses of GRBfixmodel()?

Open

Comments

2 comments

  • Ronald van der Velden
    Gurobi Staff Gurobi Staff

    Hi Mike,

    One use case could be, when you have a MIP model but want to calculate dual values (see this question). Those are not available for a MIP model, but when you fix all integer variables, the remaining model is LP and duals can be calculated. 

    Note that while successive solves might be faster when using a fixed model, you're really changing the model by fixing the integer values - so the optimal solution you get for a second solve, might not be the same as what you could get when leaving the model "unfixed". One alternative could be to use the integer values from a previous solve as MIP start or variable hint (see here). While those guide the search, they don't restrict the search space.

    Kind regards,
    Ronald

    1
  • Mike Heinen
    First Comment
    Gurobi-versary
    First Question

    As a followup on https://support.gurobi.com/hc/en-us/articles/360034305272-How-do-I-retrieve-the-dual-Pi-values-for-a-MIP-problem, is it required to call GRBOptimize() on the fixed model before calling GRBgetdblattrarray() to get the "Pi" (dual) values or can the values be retrieved immediately after calling GRBfixmodel()?

    In other words, do I have to do:

    GRBoptimize(model);

    GRBfixmodel(model, &fixed_model);

    GRBoptimize(fixed_model);

    GRBgetdblattrarray(fixed_model, GRB_DBL_ATTR_PI, 0, num_vars, dual_sol);

    Or can I just do

    GRBoptimize(model);

    GRBfixmodel(model, &fixed_model);

    GRBgetdblattrarray(fixed_model, GRB_DBL_ATTR_PI, 0, num_vars, dual_sol);

     

     

    0

Please sign in to leave a comment.