I have a problem that involves combining several matrices with a weighted average to optimize for a given feature, such as the average value of over the data in the resulting matrix.

The setup is essentially like this.

```
weights =(1,2,8)
matrixA =[1 2
5 8]
matrixB =[5 7
9 0]
matrixC =[4 5
7 8]
averageMatrix = (matrixA*weights[1] + matrixB*weights[2] + matrixC*weights[3])/3
matrixAveragePre = accumulate(+, averageMatrix[i,j] for i in 1:2, j in 1:2)
matrixAveragePost = matrixAveragePre[4]/4
```

With these dummy values the output is the expected:

20.833333333333332

an output which I would like to optimize by adjusting the weights to produce either a specific number such as, say, 30 or to maximize.

This is a fairly straightforward thing to do using Excelâ€™s built-in Solver tool, but I am not sure what the most convenient equivalent here is. I have looked and JuMP and Optim, but they donâ€™t seem to be solving this sort of problem, unless I am mistaken?