# JuMP Support for solver specific methods to create fixed MIP

**URL:** <https://discourse.julialang.org/t/jump-support-for-solver-specific-methods-to-create-fixed-mip/94775>\
**Category:** Optimization (Mathematical)\
**Created:** [February 17, 2023, 8:04am UTC](https://discourse.julialang.org/t/jump-support-for-solver-specific-methods-to-create-fixed-mip/94775 "2023-02-17T08:04:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Di11on](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/di11on/32/6352_2.png) [@Di11on](https://discourse.julialang.org/u/Di11on)\
**Post date:** [February 17, 2023, 8:04am UTC](https://discourse.julialang.org/t/jump-support-for-solver-specific-methods-to-create-fixed-mip/94775/1 "2023-02-17T08:04:28Z")

</div>

It seems that a very common requirement is to get duals from a MIP problem. The traditional way of doing this is to relax the integer variables in the problem and fix them to their MIP solution and obtain the duals from the resulting relaxed LP.

However, doing this manually in JuMP is a little awkward, especially when solving a model in a loop. We have tried copying the model, creating a relaxed LP by removing all the integer costraints and fixing the integer variables and then solving the model in another thread - but this involves quite a bit of overhead.

Many solvers provide their own methods to do this. CPLEX has CPXXchgprobtype/CPXchgprobtype while Gurobi has GRBModel::fixedModel(). Would it not make sense to provide access in a generic way to these methods in JuMP?

@odow ?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [February 17, 2023, 8:36am UTC](https://discourse.julialang.org/t/jump-support-for-solver-specific-methods-to-create-fixed-mip/94775/2 "2023-02-17T08:36:07Z")

</div>

See [Computing the duals of a mixed-integer program · JuMP](https://jump.dev/JuMP.jl/dev/tutorials/linear/mip_duality/). Recently released in JuMP v1.8.0.

---

<div class="post-metadata">

**Author:** ![Di11on](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/di11on/32/6352_2.png) [@Di11on](https://discourse.julialang.org/u/Di11on)\
**Post date:** [February 23, 2023, 3:18pm UTC](https://discourse.julialang.org/t/jump-support-for-solver-specific-methods-to-create-fixed-mip/94775/3 "2023-02-23T15:18:12Z")

</div>

Thanks @odow Does this take advantage of solver-specific routines to do it? E.g. CPLEX’s CPXXchgprobtype/CPXchgprobtype and Gurobi’s GRBModel::fixedModel() or does it just to the job of manually fixing the problem in JuMP more conveniently / efficiently?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [February 23, 2023, 5:01pm UTC](https://discourse.julialang.org/t/jump-support-for-solver-specific-methods-to-create-fixed-mip/94775/4 "2023-02-23T17:01:20Z")

</div>

It modifies the problem at the JuMP level

---

<div class="post-metadata">

**Author:** ![Di11on](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/di11on/32/6352_2.png) [@Di11on](https://discourse.julialang.org/u/Di11on)\
**Post date:** [February 27, 2023, 2:09pm UTC](https://discourse.julialang.org/t/jump-support-for-solver-specific-methods-to-create-fixed-mip/94775/5 "2023-02-27T14:09:06Z")

</div>

Thanks @odow. It would be great if we could support the solver specific routines to do this at JuMP level - I believe there would be significant performance benefits as for large models there are significant overheads in manipulating the problem and restoring it afterwards.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [February 27, 2023, 6:56pm UTC](https://discourse.julialang.org/t/jump-support-for-solver-specific-methods-to-create-fixed-mip/94775/6 "2023-02-27T18:56:14Z")

</div>

It’s actually very hard (if not impossible) to support solver-specific routines at the JuMP level.

For example, rather than modifying the existing model, Gurobi’s `GRBfixmodel` returns a pointer to a new model: [https://www.gurobi.com/documentation/9.5/refman/c\_fixmodel.html](https://www.gurobi.com/documentation/9.5/refman/c_fixmodel.html).

This isn’t something we have the infrastructure to support in JuMP, and even if we could, it would require modifying the variables and constraints in JuMP to stay in sync with the internal model.

All that being said, if the solver-independent way is too slow for you, you can call the solver-specific C API and deal with the complications keeping the two models in sync in your own code.
