# Nonlinear objective with both splatted variable and vector parameters

**URL:** <https://discourse.julialang.org/t/nonlinear-objective-with-both-splatted-variable-and-vector-parameters/97791>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [April 22, 2023, 4:17pm UTC](https://discourse.julialang.org/t/nonlinear-objective-with-both-splatted-variable-and-vector-parameters/97791 "2023-04-22T16:17:12Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)\
**Post date:** [April 23, 2023, 4:19pm UTC](https://discourse.julialang.org/t/nonlinear-objective-with-both-splatted-variable-and-vector-parameters/97791/5 "2023-04-23T16:19:07Z")

</div>

If the parameters are used **exclusively** in the registered function, you have the option of hiding them from JuMP via a closure:

```julia
using JuMP, Ipopt
function myfunc()
    model = Model(Ipopt.Optimizer)
    nvar = 3
    @variable(model, x[1:nvar])
    a = zeros(nvar)
    f(x...) = sum((x .- a).^2)
    register(model, :f, nvar, f; autodiff = true)
    @NLobjective(model, Min, f(x...))
    optimize!(model)
    @show value.(x)

	a[1] = 10.0
    optimize!(model)
    @show value.(x)

end
myfunc()

```

In this case it’s on you to be aware of the subtleties around how to update the parameter outside the closure.

---

_[View the full topic](https://discourse.julialang.org/t/nonlinear-objective-with-both-splatted-variable-and-vector-parameters/97791)._
