Soft constraints in JuMP

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

I have tried

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

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

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.

1 Like