If-else constraints in CVX


(Esdras RUGIRA) #1

t=24;
for i=10:t-4
if ((h_min<=H_t(i)) && (H_t(i)<=h_max))
H_t(i)=(h_max-H_t(i))^2;
else
H_t(i)=0;
end
end

I have this code in matlab inside CVX solver. When I run this script, DCP error appears: constraints may not appear in if/then statements.

Help me to overcome this challenge.


(Michael C. Grant) #2

Please read the FAQ; and the chapter in the documentation on the DCP ruleset; your model is not convex.


(Esdras RUGIRA) #3

I appreciate your quick reply