# How can I get the maximum of an absolute value of an objective

**URL:** https://discourse.julialang.org/t/how-can-i-get-the-maximum-of-an-absolute-value-of-an-objective/101356
**Category:** Optimization (Mathematical)
**Tags:** question, package, jump
**Created:** [July 8, 2023, 5:00pm UTC](https://discourse.julialang.org/t/how-can-i-get-the-maximum-of-an-absolute-value-of-an-objective/101356 "2023-07-08T17:00:42Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![That\_ind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/that_ind/32/51372_2.png) [@That\_ind](https://discourse.julialang.org/u/That_ind)
#### Post date: [July 12, 2023, 11:58am UTC](https://discourse.julialang.org/t/how-can-i-get-the-maximum-of-an-absolute-value-of-an-objective/101356/9 "2023-07-12T11:58:15Z")

</div>

Many thanks! But I tried this and get `status is INFEASIBLE`.

If `l` equals `-2`, then 0\<= `neg` \<=-2? This seems not to be straightforward to me. Also, in the link

> [https://docs.mosek.com/modeling-cookbook/mio.html#exact-absolute-value](https://docs.mosek.com/modeling-cookbook/mio.html#exact-absolute-value)

you posted, there seems should be

```julia
@constraint(model, pos <= M * z)
@constraint(model, neg <= M * (1 - z))

```

and the constant `M` is an a priori known upper bound on |x|, which should be positive.

And indeed in my case the objective to be optimized is of type `AffExpr`, so I added a line

```julia
@constraint(model, x == x_AffExpr)

```

where `x_AffExpr` is a known expression.

It would be great if you can explain a little bit more. Thanks!

---

_[View the full topic](https://discourse.julialang.org/t/how-can-i-get-the-maximum-of-an-absolute-value-of-an-objective/101356)._
