Hi, I’m trying to implement a model with constraints based on an NCP-function (continuous & differentiable) and put it into an NLP solver such as IPOPT:

```
@constraint(m, f(x,y) <= 0)
```

where

```
f(x,y) := xy if x+y >= 0
-0.5(x^2 + y^2 ) if x+y < 0
```

Can I get some hints on how to implement such constraints on JuMP if it’s possible?

You could write a normal Julia function for `f`

, and then call `JuMP.register`

and `@NLconstraint`

, see http://www.juliaopt.org/JuMP.jl/v0.13/nlp.html#user-defined-functions

`@constraint(model, ifelse(x + y >= 0, x*y, -0.5*(x^2 + y^2)) <= 0)`

is another way. If you can avoid user-defined functions, it’s better to do so because registering multivariate user-defined functions disables hessian computations.

This works great. Thank you very much!