Hi @Maria95, I’ve moved your question to the “Optimization (Mathematical)” section.
Here’s how I could write your first part, although I don’t understand why C has length(A) instead of N elements:
A = rand(100.0:200.0, 36)
N = Int(length(A) / 12)
# C = rand(0.5:1.0, length(A)) # I don't think this does what you think it does.
C = 0.5 + rand(length(A)) / 2
D = [sum(A[1:(12 * i)]) / C[12 * i] for i = 1:N]
The second part is:
A = rand(36, 4)
C = 0.5 * rand(length(A)) / 2
model = Model()
@variable(model, x[1:4] >= 0)
Ax = A * x
N = Int(length(Ax) / 12)
some_value = 0.0
@constraint(model, [i = 1:N], sum(Ax[1:(12 * i)]) / C[12 * i] >= some_value)
I’m not sure I fully understand your question, but hopefully this provides some insight on where to go next.