Problems with Constraints

32 views
Skip to first unread message

Kaho Suzuki

unread,
Jul 3, 2019, 4:52:03 AM7/3/19
to YALMIP
Hello,I have encountered very simple problem but I am not sure what's wrong.
The constraints of my model as follows:
C = [0.4<=soc(25)<=1.0,-0.02<=soc(1)-soc(25)<=0.02,];
for i=1:24
    C = [C,0.4<=soc(i)<=1.0,];
    C = [C,300.0<=Pc(i)<=1000.0,300.0<=Pt(i)<=1000.0,];
    C = [C,Uc(i)+Ut(i)<=1,];
end
I don't think there is anything wrong. But error occurred:
Error using constraint/horzcat (line 11)
One of the constraints evaluates to a FALSE LOGICAL variable. Your model is infeasible

Error in main1 (line 78)
C = [0.4<=soc(25)<=1.0,-0.02<=soc(1)-soc(25)<=0.02,];
Where soc is a 1*24 sdpvar and soc(1)&&soc(25) were initialized to 0.4. 
Then I changed it to the following shape:
C = [0.4<=soc(25)<=1.0,-0.02<=soc(1)-soc(25),soc(1)-soc(25)<=0.02,];
The program could be run. However, the number of constraints is 97, which should be 99 if current. 
Obviously the constraints -0.02<=soc(1)-soc(25),soc(1)-soc(25)<=0.02 was ignored.
I had thought about everything I could but didn't work. I really need your help. 

Johan Löfberg

unread,
Jul 3, 2019, 5:01:43 AM7/3/19
to YALMIP
You are working with constant data, not sdpvars, so according to matlab -0.02<=soc(1)-soc(25)<=0.02 evaluates to (-0.02<=soc(1)-soc(25)) <=0.02 which evaluates to (1) <= 0.02, which is trivially a false statement

You either skip adding constraints on constant data, or you fix variables by equality instead of assignment

Johan Löfberg

unread,
Jul 3, 2019, 5:04:09 AM7/3/19
to YALMIP
and yes, the trivial statements  [-0.02<=soc(1)-soc(25),soc(1)-soc(25)<=0.02] which evaluate to [-0.02 <= 0, 0 <= 0.02] which evaluates to [true, true] are simply removed from the model.

Kaho Suzuki

unread,
Jul 3, 2019, 5:28:54 AM7/3/19
to YALMIP
I know, thanks a lot !
Reply all
Reply to author
Forward
0 new messages