i am trying an opimization problem in pyomo...i get 'SumExpression' object is not iterable error at line(model.nt[j] = model.ntm1[j] + ....)... as shown in below code R_2_j(), R_1_j() function outputs depend on decision variables...if i make model.nt a parameter it shows because of decision variable involved t is not i real domain so i made model.nt a set now and also can i not do this ""model.ntm1[j] + model.q[j]*R_2_j(model, j, -1)"" like to multiply and add function and model...if so what should i do about it ...and also since model.nt involves decision variables should i keep model.nt a set or a param or a var
model.q = Param(model.l,
initialize={2: 0.235,
4: 0.235,
6: 0.235,
8: 0.235},
doc='q')
model.nt = Set(model.l)
model.ntm1 = Param(model.l,
initialize={2: 0,
4: 0,
6: 0,
8: 0},
doc='queuesmm1')
for j in model.l:
model.nt[j] = model.ntm1[j] + model.q[j]*R_2_j(model, j, -1) + model.q[j]*(R_1_j(model,j, 0) + G_e_j(model,j, 0)) - model.s[j]*G_e_j(model,j, 0)
If I understand what you are trying to do, you are trying to make a set (nt
) depend on the value of some variables through R_2_j
.
This is not a valid formulation, all sets and parameters values must be independent of variables (but can depend on other parameters!).
I think in a couple of instances you are trying to use an implicit product, e.g. model.q[j]R_2_j(model, j, -1)
.
If what you are trying to obtain is a product, you need to write it explicitly:
model.q[j] * R_2_j(model, j, -1)
(notice the *
)
There's at least another case in the same row.