I am trying to solve a non-linear system re-writing it in a way that I can use optimization (basically the objective function is 1.0 and the constraints are the equations of the system).

However, these equations use user-defined function that have objects of type mutable structure as arguments. When I try to run the model I get the error “Unexpected stuct_params of type struct_params in non-linear expression”, where “struct_params” is the structure that I am talking about. A snippet of the code is provided below

```
function v_zeros_UI_exogeno!(pars,Psi,UI)
pars::struct_params
Psi::struct_smm
UI::Float64
b = (UI^(1-pars.sigma))/(1-pars.sigma)
n = 0.5*b
model = Model(Ipopt.Optimizer)
@variable(model, v_ni >= 0)
@variable(model, v_nf >= 0)
@variable(model, v_bi >= 0)
@variable(model, v_bf >= 0)
register(model, :gauss_cheby_integral_f, 4, gauss_cheby_integral_f, autodiff=true)
register(model, :gauss_cheby_integral_i, 6, gauss_cheby_integral_i, autodiff=true)
register(model, :complementar_cdf_f, 3, complementar_cdf_f, autodiff=true)
register(model, :complementar_cdf_i, 5, complementar_cdf_i, autodiff=true)
@objective(model, Min, 1.0)
@NLconstraint(model, c1, v_ni == n + (Psi.alpha_f/(pars.r+pars.lambda_f))*gauss_cheby_integral_f(v_nf,v_max,pars,Psi) +
(Psi.alpha_i/(pars.r+pars.lambda_i))*gauss_cheby_integral_i(v_ni,v_max,pars,Psi,false,UI) +
(Psi.alpha_f/(pars.r+pars.lambda_f))*(v_nf - v_ni + (pars.lambda_f/pars.r)*(v_bf-v_ni))*complementar_cdf_f(pars,Psi,v_nf))
@NLconstraint(model, c2, v_nf == ((pars.r+pars.lambda_f)/pars.r)*v_ni - (pars.lambda_f/pars.r)*v_bf)
@NLconstraint(model, c3, v_bi == ((pars.r+pars.theta)/pars.r)*v_bf - (pars.theta/pars.r)*v_ni)
@NLconstraint(model, c4, v_bf == b - (pars.theta/pars.r)*(v_bf - v_ni) + (Psi.alpha_f/(pars.r+pars.lambda_f))*gauss_cheby_integral_f(v_bf,v_max,pars,Psi) +
(Psi.alpha_i/(pars.r+pars.lambda_i+pars.theta))*gauss_cheby_integral_i(v_bi,v_max,pars,Psi,true,UI) +
(complementar_cdf_i(pars,Psi,true,v_bi,UI))*(((pars.theta*pars.lambda_i)/(pars.r+pars.lambda_i))*(v_ni/pars.r) - pars.theta*(v_bf/pars.r)) +
((Psi.alpha_i*pars.theta)/((pars.r+pars.lambda_i+pars.theta)*(pars.r+pars.lambda_i)))*(gauss_cheby_integral_i(v_ni,v_max,pars,Psi,false,UI) + ((complementar_cdf_i(pars,Psi,true,v_ni,UI))-(complementar_cdf_i(pars,Psi,true,v_bi,UI)))*v_ni))
optimize!(model)
return [value(v_ni),value(v_nf),value(v_bi),value(v_bf)]
end
```