# Scalling both primal and dual feasibility tolerance according to the size of the problem

**URL:** https://discourse.julialang.org/t/scalling-both-primal-and-dual-feasibility-tolerance-according-to-the-size-of-the-problem/97455
**Category:** Optimization (Mathematical)
**Tags:** jump
**Created:** [April 14, 2023, 6:04am UTC](https://discourse.julialang.org/t/scalling-both-primal-and-dual-feasibility-tolerance-according-to-the-size-of-the-problem/97455 "2023-04-14T06:04:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ErwanMeunier](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erwanmeunier/32/47054_2.png) [@ErwanMeunier](https://discourse.julialang.org/u/ErwanMeunier)
#### Post date: [April 14, 2023, 6:04am UTC](https://discourse.julialang.org/t/scalling-both-primal-and-dual-feasibility-tolerance-according-to-the-size-of-the-problem/97455/1 "2023-04-14T06:04:37Z")

</div>

Hi,

I have JuMP (MILP) models usually solved by HiGHS. Since some of my models were pretty constrained and had a lot of variables, some numerical issues arose and made some problems infeasible. I hence had to cross swords with the tolerance settings. Actually, I use the `primal_feasibility_tolerance` described [here](https://ergo-code.github.io/HiGHS/dev/options/definitions/#dual_feasibility_tolerance).

Then, the following questions come to my mind :

1. Should the `dual_feasibility_tolerance` attribute should be set to the same value as `primal_feasibily_tolerance`?
2. **Is there a way to scale tolerance prior to the solving process by using the information from the problem / the data?**

Thanks in advance

Erwan

---

<div class="post-metadata">

### Author: ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)
#### Post date: [April 14, 2023, 10:06am UTC](https://discourse.julialang.org/t/scalling-both-primal-and-dual-feasibility-tolerance-according-to-the-size-of-the-problem/97455/2 "2023-04-14T10:06:43Z")

</div>

Regarding your second question:  
You could set the tolerance with something like

```julia
set_optimizer_attribute( model, "primal_feasibily_tolerance", my_tolerance )

```

after adding variables and constraints to the model, but before solving it. Variable `my_tolerance` could be set via some function taking number of added variables/constraints as arguments (or whatever problem data you want to consider).

It seems, however, strange to me that the tolerance setting causes infeasibility in a “normal” solving process.

---

<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: [April 15, 2023, 12:44am UTC](https://discourse.julialang.org/t/scalling-both-primal-and-dual-feasibility-tolerance-according-to-the-size-of-the-problem/97455/3 "2023-04-15T00:44:17Z")

</div>

1. Not necessarily. But if you’re modifying the tolerances you should have a good understanding of what they represent and why the new value is okay.
2. In general, needing to change the tolerances is a sign that your model has numerical issues. You’re almost always better off fixing the model, rather than changing the solver.

See [https://www.gurobi.com/documentation/10.0/refman/guidelines\_for\_numerical\_i.html](https://www.gurobi.com/documentation/10.0/refman/guidelines_for_numerical_i.html) for lots of tips and suggestions.

Common sources are very large or small coefficients in your model. Try to minimize the difference between the magnitude of the coefficients in your model, for example by changing the units of the input data and decision variables.
