Hi, Johan,
I have a conditionnal constraint which poses different relations to two of 9 states: if x(8)<=const1., x(4) - x(3) == const.2; if x(8) >= const.1, x(4) - x(3) == const.3. I use function implies to code this condition as (in MPC framework):
b_switch = binvar(1, Np);
for i=...Np
constraints = [constraints, ...
implies(b_switch(i),[x(8,i+1) <= const1., x(3,i+1) == x(4,i+1) - const2.]),...
implies(~b_switch(i), [x(8,i+1) >= const1., x(3,i+1) == x(4,i+1) - const3.])];
(constraints bounding all the variables)
end
Is there a problem writing so? why am I getting b_switch =ones(1, Np) all the time? and the stored data for x(8) are stuck at const.1. I just cannot figure out why it doesn't work. Thank you!
Best,
Huarong