Hi there,

I’m trying to use the max function in one of my NLconstraint. Following @ **odow**’s advice, I use auto-differentiation to allow max into the constraint. The problem is that the length of the array that I want to take max over is not fixed and depend on problem instances, so ideally I want to be able to write

```
m = Model(solver=IpoptSolver(print_level=0))
f(array) = maximum(array)
JuMP.register(m, :f, 1, f, autodiff=true)
...
@variable(m, x[1:T])
@variable(m, y)
@NLconstraint(m, y == f(x))
```

However, due to the restriction to scalar operation in NLconstraint, right now I’m forced to write, e.g. when L = 2:

```
m = Model(solver=IpoptSolver(print_level=0))
f(a,b) = max(a,b)
JuMP.register(m, :f, 2, f, autodiff=true)
...
@variable(m, x[1:T])
@variable(m, y)
@NLconstraint(m, y == f(x[1],x[2]))
```

and for different L, the code will have to change. Any idea to help me write proper code?

Thanks!!!