Can I have different constraints in a loop?

(saeed ) #1

in a constraint, a paremeter gets different values. indeed this constraint
itself involves different constraints each of one is related to a distinct value of the
parameter. So I have written it in a, the question is that since for each
cycle of the loop the constraint is different, does the whole loop involve all constraints?
in other words, are all constraints effect on variables kept and saved to give the correct
value of variables or not? if not, does it mean that I have to write the constraint
for each parameter separately? the loop is as below
z, v and q are cvx variables which should be optimized

for k=1:K
    for kk=1:K
        if k~=kk

for each k, sum_ve and g(k) are different. are all constraints effects on variables kept?
note that if we use sum_ve(k) instead of sum_ve, we will have an error as below

> The following error occurred converting from cvx to double:
> Error using double
> Conversion to double from cvx is not possible.

(Mark L. Stone) #2

Prior to the first for loop, add the statement
expression sum_ve(K)
and use sum_ve(k) instead of sum_ve.

(saeed ) #3

thank you very much.