# Easy way to scale model in JuMP?

**URL:** <https://discourse.julialang.org/t/easy-way-to-scale-model-in-jump/96212>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [March 16, 2023, 9:48pm UTC](https://discourse.julialang.org/t/easy-way-to-scale-model-in-jump/96212 "2023-03-16T21:48:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shakedregev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shakedregev/32/45821_2.png) [@shakedregev](https://discourse.julialang.org/u/shakedregev)\
**Post date:** [March 16, 2023, 9:48pm UTC](https://discourse.julialang.org/t/easy-way-to-scale-model-in-jump/96212/1 "2023-03-16T21:48:10Z")

</div>

I’m developing a linear solver for an optimization solver that requires a scaled constraint matrix. I am solving an LP, so the constraint matrix is constant. I would like to be able to scale the constraints within the optimization solver, so each row in the matrix has norm 1. Currently I’m doing it within the linear solver

```julia
foreach(normalize!,eachrow(A))

```

I would like to be doing this in JuMP instead so it only needs to be done once. Is there an efficient way to do this?

---

<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:** [March 16, 2023, 11:35pm UTC](https://discourse.julialang.org/t/easy-way-to-scale-model-in-jump/96212/2 "2023-03-16T23:35:45Z")

</div>

No, there is no efficient way to do this in JuMP. Doing it in the solver is probably the best approach.

You might also want to look at other normalization approaches. Here’s a paper you might be interested in  
[https://optimization-online.org/2020/12/8166/](https://optimization-online.org/2020/12/8166/)

---

<div class="post-metadata">

**Author:** ![shakedregev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shakedregev/32/45821_2.png) [@shakedregev](https://discourse.julialang.org/u/shakedregev)\
**Post date:** [March 17, 2023, 5:34pm UTC](https://discourse.julialang.org/t/easy-way-to-scale-model-in-jump/96212/3 "2023-03-17T17:34:20Z")

</div>

Thanks, I have already done some tests with some “offline” linear systems pulled from optimization problems, and this seemed best.

Normalizing in JuMP seemed most natural, because I’m not actually changing the underlying optimization problem (as long as I divide the RHS as well). I’ll do it within the solver then
