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.
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:
It is also the core component of SDDP.jl, 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.