# Primal/dual optimization scaling for numerical stability

**URL:** <https://discourse.julialang.org/t/primal-dual-optimization-scaling-for-numerical-stability/105083>\
**Category:** Optimization (Mathematical)\
**Tags:** question, gurobi\
**Created:** [October 17, 2023, 4:36pm UTC](https://discourse.julialang.org/t/primal-dual-optimization-scaling-for-numerical-stability/105083 "2023-10-17T16:36:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob-roth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacob-roth/32/1862_2.png) [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Post date:** [October 17, 2023, 4:36pm UTC](https://discourse.julialang.org/t/primal-dual-optimization-scaling-for-numerical-stability/105083/1 "2023-10-17T16:36:18Z")

</div>

I am solving a convex QP via ALM and am using `Gurobi.jl` for benchmarking. I noticed that Gurobi implements some problem scaling [techniques](https://www.gurobi.com/documentation/10.0/refman/scaleflag.html) (slightly more detail here: [https://support.gurobi.com/hc/en-us/community/posts/15330309039633/comments/15341224273681](https://support.gurobi.com/hc/en-us/community/posts/15330309039633/comments/15341224273681)) for improved numerical stability. To make the comparisons more fair, I would like to implement versions of the scaling techniques for a QP of the form

\min\_x \bigl\{\tfrac12 x^\top Q x + q^\top x : Ax\leq b\bigr\}\tag{P}

\min\_y \bigl\{\tfrac12 (A^\top y + q)^\top Q^{\dagger} (A^\top y+q) + b^\top y : y\geq0\bigr\}.\tag{D}

I think that I understand the previous Gurobi post for equilibrium scaling, but I am wondering what is meant by “geometric mean scaling” and (roughly) how to implement it. Is it related to considering new variables x'\gets \frac{x}{\sqrt{\|x^\nu\|\|y^\nu\|}} and y'\gets \frac{y}{\sqrt{\|x^\nu\|\|y^\nu\|}} for given data x^\nu and y^\nu at iteration \nu?

Or are there any `Julia` solvers that implement some form of scaling where the scaling is documented? It seems that `OSQP.jl` does some [scaling](https://github.com/osqp/osqp/blob/master/src/scaling.c), but I didn’t see an explanation in the docs.

Crosslinked [here](https://scicomp.stackexchange.com/q/43367/22292).

---

<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:** [October 17, 2023, 11:51pm UTC](https://discourse.julialang.org/t/primal-dual-optimization-scaling-for-numerical-stability/105083/2 "2023-10-17T23:51:36Z")

</div>

This seems like a question for the Gurobi developers. cc @vasyfa
