How to constrain the switching variable of a PWA-Model for Model Predictive Control

46 views
Skip to first unread message

Steffen Mann

unread,
Oct 18, 2018, 11:34:27 AM10/18/18
to YALMIP
Dear All,

I am using a PWA Model to switch between my working points of my linearized model. I implemented 
my model like in the example Model predictive control - Hybrid models from the Yalmip wiki. 
Unfortunately when I control my plant with my MPC the controller switches to fast between 
the linearized models.
Is there any way to constrain the decision variable? The decision variable is a binary array, whose
element switches to one for the active model. I thought maybe one can left and right shift the decision variable array,
so that the controller only have the possibilty to choose the next two models.
Below is the code I use for modelling. 
Second question: Is it possible to use QPoases as a solver for a PWA model (at the moment I am using Mosek)?
  
 
%% Setup the optimization problem
u
= sdpvar(repmat(nu,1,N),repmat(1,1,N));
x
= sdpvar(repmat(nx,1,N+1),repmat(1,1,N+1));
r
= sdpvar(ny,1);
d
= binvar(repmat(10,1,N+1),repmat(1,1,N+1));


constraints
= [];
objective
= 0;
for k = 1:N
    objective
= objective + (r-Cd{1}*x{k})'*Q*(r-Cd{1}*x{k})+u{k}*R*u{k};
    Model1 = [x{k+1} == Ad{1}*x{k}+Bd{1}*u{k}, x{k}(4) <= ix(1)];
    Model2 = [x{k+1} == Ad{2}*x{k}+Bd{2}*u{k}, ix(1) <= x{k}(4) <= ix(2)];
    Model3 = [x{k+1} == Ad{3}*x{k}+Bd{3}*u{k}, ix(2) <= x{k}(4) <= ix(3)];
    Model4 = [x{k+1} == Ad{4}*x{k}+Bd{4}*u{k}, ix(3) <= x{k}(4) <= ix(4)];
    Model5 = [x{k+1} == Ad{5}*x{k}+Bd{5}*u{k}, ix(4) <= x{k}(4) <= ix(5)];
    Model6 = [x{k+1} == Ad{6}*x{k}+Bd{6}*u{k}, ix(5) <= x{k}(4) <= ix(6)];
    Model7 = [x{k+1} == Ad{7}*x{k}+Bd{7}*u{k}, ix(6) <= x{k}(4) <= ix(7)];
    Model8 = [x{k+1} == Ad{8}*x{k}+Bd{8}*u{k}, ix(7) <= x{k}(4) <= ix(8)];
    Model9 = [x{k+1} == Ad{9}*x{k}+Bd{9}*u{k}, ix(8) <= x{k}(4) <= ix(9)];
    Model10 = [x{k+1} == Ad{10}*x{k}+Bd{10}*u{k}, ix(9) <= x{k}(4)];
    constraints = [constraints,...
                    implies(d{k}(1), Model1),...
                    implies(d{k}(2), Model2),...
                    implies(d{k}(3), Model3),...
                    implies(d{k}(4), Model4),...
                    implies(d{k}(5), Model5),...
                    implies(d{k}(6), Model6),...
                    implies(d{k}(7), Model7),...
                    implies(d{k}(8), Model8),...
                    implies(d{k}(9), Model9),...
                    implies(d{k}(10), Model10),...
                    sum(d{k}) == 1];
    constraints = [constraints,...
        [umin] <= u{k}<= [umax],...
        xmin <= x{k} <= xmax];
end
constraints = [constraints, xmin <= x{k+1} <= xmax];

Thanks for any help,
Steffen

Johan Löfberg

unread,
Oct 18, 2018, 12:46:29 PM10/18/18
to YALMIP
Of course you can constrain it. It's a decision variable like any other.

qpoases does not solve MIQPs as far as I know

Steffen Mann

unread,
Oct 19, 2018, 2:57:48 AM10/19/18
to YALMIP
Dear Johan, 

1. I want to constrain it in a way like this:
        constraints = [constraints,...
            [0;d{k}(2:end)] == d{k+1}(:)...
            | d{k} == d{k+}...
            | [d{k}(1:end-1);0] == d{k+1}(:)];

So I want my PWA model constrain in a way that it can only choose the same, next or previous model.

2. Which other solver can solve the MIQPs and also has an embedded c interface? 

Regards
Steffen 

Johan Löfberg

unread,
Oct 19, 2018, 9:38:12 AM10/19/18
to YALMIP
I have no idea what that constraint  supposed to do. Are you saying

if d{k}(5) then d{k+1}(4) or d{k+1}(5) or d{k+1}(6)
if d{k}(6) then d{k+1}(5) or d{k+1}(6) or d{k+1}(7)
etc

The commercial ones most likely have C APIs



Reply all
Reply to author
Forward
0 new messages