DMPC usage example

The main features of the Decentralized MPC class are showed in this file.

Contents

Example description

The following example aims at showing the usage of the class dlincon in a simple but complete control problem in which the plant has some a relevant degree of decoupling between its states.

clear variables
clear globals
close all
clc
%
% The plant we are about to control is the LTI discrete-time system below
Ts=.1;
sys=ss([1.1 .1 0;.2 .3 0;0 .2 1.3],[1 0;0 0.1;0 1],eye(3),zeros(3,2),Ts);
%
% Nx, Nu and Ny are number of states, input and outputs, respectively
[Nx,Nu]=size(sys.B);
Ny=size(sys.c,1);
%
% Engineering insight suggest the following decentralization
dec(1).u=[1 2];
dec(1).x=[1 2];
dec(1).y=[1 2];
dec(1).applied=1;
dec(2).u=[1 2];
dec(2).x=[2 3];
dec(2).y=[2 3];
dec(2).applied=2;

Example setup

Below 4 simulations will be performed to show the potential of the class. In order:

Each simulation shows the behavior of the set of DMPC against the centralized controller that is used as reference for comparison. Both states and inputs are plotted.

Setup simulation parameters

x_c0=[ -0.4286;0.2182;-0.3596];
u_c0=zeros(Nu);
Tsim=1;
for j=1:4
Steup controllers parameters
	if mod(j,2)==0
		type='track'; % even values of j
	else
		type='reg';   % odd values of j
	end
	if strcmp(type,'reg')
	    cost.Q=1e1*eye(Nx);
	    cost.R=eye(Nu);
	else
	    cost.S=1e1*eye(Nx);
	    cost.T=eye(Nu);
	end
	interval.N=10;
	interval.Nu=5;
	[A,B,C,D]=ssdata(sys);
	var_bounds=(j>2);
	if var_bounds

Nullify influence of static constraint on case of variant bounds. This is not mandatory, it is possible to have some bounds to be variant and some others to be fixed, and that is currently supported

		k=inf;
Warning: No gain K specified, assuming K=0 
Hybrid Toolbox v.1.1.12 [February 24, 2009] - (C) 2003-2009 by Alberto Bemporad <bemporad@dii.unisi.it>
Warning: No gain K specified, assuming K=0 
Hybrid Toolbox v.1.1.12 [February 24, 2009] - (C) 2003-2009 by Alberto Bemporad <bemporad@dii.unisi.it>
Warning: No gain K specified, assuming K=0 
Hybrid Toolbox v.1.1.12 [February 24, 2009] - (C) 2003-2009 by Alberto Bemporad <bemporad@dii.unisi.it>
Start simulation
	else
		k=.5;
	end
	limits.umin=-k*ones(Nu,1);
	limits.umax=k*ones(Nu,1);
	limits.ymin=-k*ones(Ny,1);
	limits.ymax=k*ones(Ny,1);

    cost.rho=inf;

	Dcon = dlincon(sys,type,cost,interval,limits,0,dec,var_bounds);

    xx=.1;
    range.xmin=-xx*ones(Nx,1);
    range.xmax=-range.xmin;

    if ~Dcon.var_bounds
        if Dcon.stability_test(range,cost)
            disp('Stability test succeded');
        else
            disp('Stability test failed');
        end
    end

    x_c=x_c0;
    x_d=x_c;
    u_c=u_c0;
    u_d=u_c;
	disp('Start simulation')
Hybrid Toolbox v.1.1.12 [February 24, 2009] - (C) 2003-2009 by Alberto Bemporad <bemporad@dii.unisi.it>
Hybrid Toolbox v.1.1.12 [February 24, 2009] - (C) 2003-2009 by Alberto Bemporad <bemporad@dii.unisi.it>
Hybrid Toolbox v.1.1.12 [February 24, 2009] - (C) 2003-2009 by Alberto Bemporad <bemporad@dii.unisi.it>
Open neighbors / regions found:
----------------------------------------------------------------------------


Analyzing region size ...
-->>Number of regions in the control law: 1

Open neighbors / regions found:
----------------------------------------------------------------------------


Analyzing region size ...
-->>Number of regions in the control law: 1

Closed Loop is stable with this decentralization
 at least around the origin.(feedback method)
The closed loop with this decentralization is stable at
 least around the origin even with a maximum of 0 losses (stability test)!!
Stability test succeded
Start simulation
Hybrid Toolbox v.1.1.12 [February 24, 2009] - (C) 2003-2009 by Alberto Bemporad <bemporad@dii.unisi.it>
Hybrid Toolbox v.1.1.12 [February 24, 2009] - (C) 2003-2009 by Alberto Bemporad <bemporad@dii.unisi.it>
Hybrid Toolbox v.1.1.12 [February 24, 2009] - (C) 2003-2009 by Alberto Bemporad <bemporad@dii.unisi.it>
Open neighbors / regions found:
----------------------------------------------------------------------------


Analyzing region size ...
-->>Number of regions in the control law: 1

Open neighbors / regions found:
----------------------------------------------------------------------------


Analyzing region size ...
-->>Number of regions in the control law: 1

Closed Loop is stable with this decentralization
 at least around the origin.(feedback method)
The closed loop with this decentralization is stable at
 least around the origin even with a maximum of 0 losses (stability test)!!
Stability test succeded
Start simulation
Warning: No gain K specified, assuming K=0 
Hybrid Toolbox v.1.1.12 [February 24, 2009] - (C) 2003-2009 by Alberto Bemporad <bemporad@dii.unisi.it>
Warning: No gain K specified, assuming K=0 
Hybrid Toolbox v.1.1.12 [February 24, 2009] - (C) 2003-2009 by Alberto Bemporad <bemporad@dii.unisi.it>
Warning: No gain K specified, assuming K=0 
Hybrid Toolbox v.1.1.12 [February 24, 2009] - (C) 2003-2009 by Alberto Bemporad <bemporad@dii.unisi.it>
Start simulation
	% Setup variant bounds
	bounds=[-.2;.2];
	for i=2:Dcon.M
    		bounds=[bounds; [-.2;.2]];
    end
	% Reference signal
	r=[3,3]';

	for i=1:Tsim/Ts
	    x_c(:,i+1) = A*x_c(:,i) + B*u_c(:,i);
	    x_d(:,i+1) = A*x_d(:,i) + B*u_d(:,i);

	    if var_bounds
            if mod(j,2)==1
                r=zeros(Nx+2*Nu,1);
            else

There are only two inputs, hence only 1st and 3rd state components can achieve zero-error convergence. 2*Nu zeros are added because of the variant bound that are mapped as fake outputs.

                r=[-.1;0;-.1;zeros(2*Nu,1)];
            end
            [u_c(:,i+1) Dcon] = Deval(Dcon,'global',[x_c(:,i+1) ; bounds],r);
            [u_d(:,i+1) Dcon] = Deval(Dcon,'Dglobal',[x_d(:,i+1) ; bounds],r);
		  if  i==ceil(Tsim/Ts/2)
			  % Vary the variant bounds
		      bounds=bounds+.1;
		  end
        else
            if mod(j,2)==1
                r=zeros(Nx,1);
            else

There are only two inputs, hence only 1st and 3rd state components can achieve zero-error convergence.

                r=[-.1;0;-.1];
            end
	        [u_c(:,i+1) Dcon] = Deval(Dcon,'global',x_c(:,i+1),r);
	        [u_d(:,i+1) Dcon] = Deval(Dcon,'Dglobal',x_d(:,i+1),r);
	    end
    end
	% Plot showing in red, green and blue color the first, second and third
	% state components, respectively. Continuous lines depicts centralized
	% controller trajectories while dash ones show decentralized set of
    % controllers behavior.
    figure;
	t=0:Ts:Tsim;
	subplot(2,1,1)
	plot(t,x_c);
	hold on
	plot(t,x_d,'--');
	hold off
	title('States: cent(-), dec(--)');
	subplot(2,1,2)
	plot(t,u_c);
	hold on
	plot(t,u_d,'--');
	hold off
	title('Inputs: cent(-), dec(--)');

	if j<4
		disp('Press any key to test next configuration');
		pause();
	end
Press any key to test next configuration
Press any key to test next configuration
Press any key to test next configuration
end

Comment to the results

Figures 1 and 3 depicts the regulator configuration with fixed and time varying bounds, respectively. Convergence in the second case is slower due to the more restrictive bound imposed. However in both cases convergence is achieved by both the centralized and set of decentralized controllers.

Figure 2 and 4 depicts the reference tracking configuration with fixed and time varying bounds, respectively. The more restrictive variant bounds make the latter case to need more time to achieve convergence with respect to the fixed bounds case. In particular figure 4 show the main difference between the centralized and decentralized controllers, that is the longer transient in the decentralized case.