Hi @fdekerme, I’ve moved this to the “Optimization (Mathematical)” section.
Can you provide a reproducible example?
The answer depends one what detector_response is doing. But a simple fix might be:
using JuMP, Ipopt
model = Model(Ipopt.Optimizer)
set_silent(model)
@variable(model, 0 <= L₁[i = 1:x, j = 1:y], start = start_values.mat1[i, j])
@variable(model, 0 <= L₂[i = 1:x, j = 1:y], start = start_values.mat2[i, j])
@objective(
model,
Min,
sum(
(detector_response(spectra.top[i,j, :], L₁[i,j], L₂[i,j]) - top_image[i, j])^2 +
(detector_response(spectra.bottom[i,j,:], L₁[i,j], L₂[i,j]) - bottom_image[i, j])^2
for i in 1:x, j in 1:y
)
)
optimize!(model)