How to solve optimization problem with a big sum with given values

Hello,

@Mark_L_Stone: Thank you very much, this helped me a lot.

My “problem” code was quite similar. I just haven’t considered the correct dimensions of the given vector x.
I had to transpose it, then it worked.