# Abs in JuMP

**URL:** <https://discourse.julialang.org/t/abs-in-jump/90811>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [November 25, 2022, 2:06pm UTC](https://discourse.julialang.org/t/abs-in-jump/90811 "2022-11-25T14:06:17Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [November 26, 2022, 4:51am UTC](https://discourse.julialang.org/t/abs-in-jump/90811/3 "2022-11-26T04:51:02Z")

</div>

> [@Salvador\_Catsis](#):
>
> I’m fairly new to Julia and new to JuMP

Hi!

> I haven’t asked many programming questions before so please forgive the formatting if it’s not appropriate.

It’s a good question. You can make it a little better by providing the `S` and `x` matrices. Currently, I can’t run your example.

To model `abs`, you can use:

```julia
# To model: sum(abs.(y .- x))
@variable(model, t[1:length(x)] >= 0)
@constraint(model, t .>= y .- x)
@constraint(model, t .>= x .- y)
@objective(model, Min, sum(t))

```

But JuMP actually has special support for this with the NormOneCone:

> **[Standard form · JuMP](https://jump.dev/JuMP.jl/stable/moi/reference/standard_form/#MathOptInterface.NormOneCone)**
>
> Documentation for JuMP.

```julia
# To model: sum(abs.(y .- x))
@variable(model, t)
@constraint(model, [t; y .- x] in MOI.NormOneCone(1 + length(x)))
@objective(model, Min, t)

```

---

_[View the full topic](https://discourse.julialang.org/t/abs-in-jump/90811)._
