# Constraints tolerance IPNewton in Optim.jl

**URL:** <https://discourse.julialang.org/t/constraints-tolerance-ipnewton-in-optim-jl/92038>\
**Category:** Optimization (Mathematical)\
**Tags:** optim\
**Created:** [December 23, 2022, 8:56am UTC](https://discourse.julialang.org/t/constraints-tolerance-ipnewton-in-optim-jl/92038 "2022-12-23T08:56:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shce](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@shce](https://discourse.julialang.org/u/shce)\
**Post date:** [December 23, 2022, 8:56am UTC](https://discourse.julialang.org/t/constraints-tolerance-ipnewton-in-optim-jl/92038/1 "2022-12-23T08:56:01Z")

</div>

Hello,

I was wondering if it is possible to specify up to which tolerance the equality constraints are satisfied in Optim.jl using IPNewton method.

Currently, the optimization stops because `x_tol` or `f_tol` are satisfied, but not because `g_tol` is satisfied. If I manually check the value of the constraints, they are satisfied within a tolerance of `1e-2`. Is it possible to set a parameter to force higher precision?

I have tried setting `x_tol=NaN` and f`_tol=NaN` to force the algorithm to stop by `g_tol`, but then it stagnates:

```julia
Iter Lagrangian value Function value Gradient norm |==constr.| μ
     0 3.332750e+01 1.746610e+00 3.438553e+01 1.901604e+01 1.00e+00
 * time: 1.67178566274176e9
     1 1.353145e+01 1.702241e+00 3.543331e+01 1.048336e+01 1.00e-01
 * time: 1.671785662797074e9
     2 4.377825e+00 1.699334e+00 7.754110e+02 3.833958e-01 9.76e-02
 * time: 1.671785662809908e9
     3 2.529626e+00 1.699267e+00 5.851341e+01 3.768007e-01 2.01e-02
 * time: 1.671785662883332e9
     4 2.278308e+00 1.703248e+00 8.222396e+00 1.410696e-01 1.99e-02
 * time: 1.671785662899112e9
     5 1.965445e+00 1.712061e+00 2.599936e+00 1.133042e-03 1.12e-02
 * time: 1.67178566292044e9
     6 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.67178566309099e9
     7 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785663162644e9
     8 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785663237643e9
     9 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785663344027e9
    10 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785663460111e9
    11 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785663539827e9
    12 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785663623636e9
    13 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785663723319e9
    14 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785663871442e9
    15 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785663952723e9
    16 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785664022078e9
    17 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785664093651e9
    18 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785664163002e9
    19 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785664231979e9
    20 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785664306802e9
    21 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785664431646e9
    22 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785664514846e9
    23 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.671785664598036e9
    24 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.67178566466456e9
    25 1.766109e+00 1.712061e+00 4.019143e+00 1.133042e-03 2.35e-03
 * time: 1.67178566474315e9

```

Why doesn’t it try to reduce the value of `μ` and see if it can improve the norm of the gradient?

I apologize for not posting the code (it is a research code and it has not been published yet).

Thank you very much,

SHCE
