# Most efficient way of retrieving dual solutions iteratively

**URL:** <https://discourse.julialang.org/t/most-efficient-way-of-retrieving-dual-solutions-iteratively/122790>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump, dual\
**Created:** [November 18, 2024, 9:26pm UTC](https://discourse.julialang.org/t/most-efficient-way-of-retrieving-dual-solutions-iteratively/122790 "2024-11-18T21:26:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BMI\_OR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bmi_or/32/213496_2.png) [@BMI\_OR](https://discourse.julialang.org/u/BMI_OR)\
**Post date:** [November 18, 2024, 9:26pm UTC](https://discourse.julialang.org/t/most-efficient-way-of-retrieving-dual-solutions-iteratively/122790/1 "2024-11-18T21:26:14Z")

</div>

I have implemented an algorithm where at each iteration I need to solve an optimization model and retrieve its dual solution. Currently, I am using `dual.()` to get the solution, and I am seeing that this function is also the bottleneck of my algorithm. I am considering implementing the dual version of the problem directly and then retrieving its primal solution using `value.()`. Is there a significant difference? Are there more efficient ways of retrieving the dual solution if the only thing changing between iterations are some of the right-hand-side values in the constraints?  
Thanks in advance for the help.

---

<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:** [November 18, 2024, 9:38pm UTC](https://discourse.julialang.org/t/most-efficient-way-of-retrieving-dual-solutions-iteratively/122790/2 "2024-11-18T21:38:03Z")

</div>

Can you provide a minimal reproducible example of your problem?

Querying the dual should not be a bottleneck. What solver and what type of constraint?

It is possible to very efficiently implement algorithms that use dual solutions. See:

- [Benders decomposition · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/algorithms/benders_decomposition/)
- [Column generation · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/algorithms/cutting_stock_column_generation/)

It is also the core component of SDDP.jl, [https://sddp.dev](https://sddp.dev), and if you use an LP solver like HiGHS or Gurobi, JuMP will automatically efficiently restart the problem if the RHS is the only thing that changed.
