How to convert a branch structure to constraints.

14 views
Skip to first unread message

Kaho Suzuki

unread,
Jul 3, 2019, 11:23:27 PM7/3/19
to YALMIP
Hello, I've encountered a problem. Would you please help me?
Here is a branch structure:
for i=1:24
    a(i)=A1(i)*B1(i)-A2(i)*B2(i);
    if double(a(i))>0
        b(i)=a(i);
        c(i)=0;
    elseif double(a(i))<0
            b(i)=0;
            c(i)=-a(i);
    else 
            b(i)=0;
            c(i)=0;
    end       
end
Where A1,B1,A2 and B2 are all 1*n sdpvars. 
Now I'd like to convert it to constraints. Is there any way to reach it?

Johan Löfberg

unread,
Jul 4, 2019, 2:34:36 AM7/4/19
to YALMIP
https://yalmip.github.io/tutorial/logicprogramming/#constraints
https://yalmip.github.io/modellingif

although it looks like you simply have b = max(a,0) and c = min(a,0)

Johan Löfberg

unread,
Jul 4, 2019, 2:43:34 AM7/4/19
to YALMIP
should be c = max(-a,0)

Kaho Suzuki

unread,
Jul 5, 2019, 10:39:32 AM7/5/19
to YALMIP
Thanks a lot
Reply all
Reply to author
Forward
0 new messages