# User-defined vector input function in JuMP 0.18.6

**URL:** <https://discourse.julialang.org/t/user-defined-vector-input-function-in-jump-0-18-6/44956>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 14, 2020, 7:56pm UTC](https://discourse.julialang.org/t/user-defined-vector-input-function-in-jump-0-18-6/44956 "2020-08-14T19:56:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ken\_Lin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ken_lin/32/14367_2.png) [@Ken\_Lin](https://discourse.julialang.org/u/Ken_Lin)\
**Post date:** [August 14, 2020, 7:56pm UTC](https://discourse.julialang.org/t/user-defined-vector-input-function-in-jump-0-18-6/44956/1 "2020-08-14T19:56:51Z")

</div>

Is it possible to have user-defined functions with vector input in JuMP 0.18.6? Or is there a way to do similar things? I would like to use the NLopt solver ([GitHub - JuliaOpt/NLopt.jl: Package to call the NLopt nonlinear-optimization library from the Julia language](https://github.com/JuliaOpt/NLopt.jl)) and it seems that this solver is not supported after JuMP 0.18.

For example, is it possible to do something like

```julia
function f(x)
return dot(x,x)
end

function g(x)
return dot(x,x)
end
Model = (model, solver=NLoptSolver(algorithm=:LD_MMA))
@variable(model, x[1:n])
@objective(model, Min, f(x))
@constraint(model, g(x)<=0)
solve(model)

```

For n large, it will be very time-consuming to list x[1],…,x[n] as scalar one by one.

It seems that we can do the vector input by Julia’s splatting syntax in JuMP0.21.3, as shown below:

 ![JuMPuser-defined](https://global.discourse-cdn.com/julialang/original/3X/d/5/d539569a0a08bb3be2c9199f1d82f92db7545510.png)

I tried this in JuMP 0.18.6 but got an error.

Another question is, if the solver I use doesn’t require derivative, do I need to set `autodiff=false`?
