The function I want to maximize is
function L(params::Vector{Real}, df::DataFrame, mm::MMParams)
θ1, α1, β1, D1, N1, ϵ1, θ2, α2, β2, D2, N2, ϵ2, ρ, pA, pF, σ, constant = params
Π = mm.Π
y_star_1 = y_start((θ1, α1, β1, D1, N1, ϵ1, ρ, pA, pF))
y_star_2 = y_start((θ2, α2, β2, D2, N2, ϵ2, ρ, pA, pF))
lists = unique(df[:, :list])
L = 0.0
for firm in lists
dt = df[df[:, :list] .== firm, :]
for row in eachrow(dt)
s = row[:s]
j = row[:LS]
i = row[:S]
if j in 0:2 && i in 1:2
y_star = (i == 1 ? y_star_1 : y_star_2)
f_value = logf(s, y_star, σ, constant)
π_value = Π[j + 1, i + 1]
L += f_value + log(π_value)
end
end
end
return L
end
I try to register this function
L_closure = (params...) -> L(collect(params), df, mm)
# Register the function
JuMP.register(
model,
:L,
length(initial_params), # Number of parameters
L_closure,
autodiff = true # Enable automatic differentiation
)
But I got the error
Unable to register the function
Anyone knows how to solve this?