# Soft constraints in JuMP

**URL:** <https://discourse.julialang.org/t/soft-constraints-in-jump/89373>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [October 27, 2022, 1:53pm UTC](https://discourse.julialang.org/t/soft-constraints-in-jump/89373 "2022-10-27T13:53:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielw2904](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielw2904/32/10890_2.png) [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Post date:** [October 27, 2022, 1:53pm UTC](https://discourse.julialang.org/t/soft-constraints-in-jump/89373/1 "2022-10-27T13:53:15Z")

</div>

I am completely new to the JuMP.jl package. I am trying to set soft constraints with different weights but only getting errors for any constraints I set. I would like something similar to this link

> **[Soft Constraints | Online Z3 Guide](https://microsoft.github.io/z3guide/docs/optimization/softconstraints/)**
>
> The (assert-soft formula \[id id\]) command asserts a weighted soft constraint. The weight must be a positive natural number, but is optional. If omitted, the weight is set to 1.

I have tried

```julia
using JuMP
using HiGHS
using NLopt
model = Model(NLopt.Optimizer)
set_optimizer_attribute(model, "algorithm", :LN_COBYLA)

@variable(model, x)
@constraint(model, x > 0 )

```

but getting this error

```julia
`@constraint(model, x > 0)`: Unrecognized sense >

```

---

<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:** [October 27, 2022, 4:04pm UTC](https://discourse.julialang.org/t/soft-constraints-in-jump/89373/2 "2022-10-27T16:04:14Z")

</div>

I think many solvers do not accept a strictly less `<` (or greater `>`) relationship in constraints. Seemingly this is also not supported by JuMP.  
Use `>=`. If for some reason you need a strictly greater than zero relation, you could use `x >= eps` where `eps` is an arbitrary small number.
