%
% Macro to test saa.m
% (c) Marc Bodson, June 18, 2020
% The test macro produces the plots in the paper
% J. Petersen & M. Bodson, “Fast Implementation of Direct Allocation
% with Extension to Coplanar Controls,”  AIAA Journal of Guidance,
% Control, and Dynamics, vol. 25, no. 3, pp. 464-473, 2002.
%
fprintf('sys = 1: 16-dim C-17 model \n');
fprintf('sys = 2: 12-dim Tailless aircraf model \n');
sys = input('Choose system:  sys = ');
if sys==1
    cb=zeros(3,16);
    cb(1,:)=[-0.5158 -0.8129 -0.8129 -0.5158 -0.1224 -0.1224 0.0144...
        0.0169 0.0361 0.0116 -0.0192 -0.0338 0.0361 0.0116 -0.0192 -0.0338];
    cb(2,:)=[0.2077 0.1126 -0.1126 -0.2077 0.4812 -0.4812 0.3044...
        0.3137 0.1056 0.2130 0.2723 0.3045 -0.1056 -0.2130 -0.2723 -0.3045];
    cb(3,:)=[0.0188 0.0102 -0.0102 -0.0188 0.0241 -0.0241 -0.3428...
        -0.5118 0.0465 0.0460 0.0457 0.0397 -0.0465 -0.0460 -0.0457 -0.0397];
    umax=[15 15 15 15 26 26 5 5 0 0 0 0 0 0 0 0]';
    umin=[-15 -15 -15 -15 -39 -39 -5 -5 -30 -30 -30 -30 -30 -30 -30 -30]';
    upref=zeros(16,1);
else
    cb=zeros(3,11);
    cb(1,:)=[-2.5114 -2.5115 -1.9042 -0.9494 -0.9494 -1.1329 0 ...
        1.5046 1.5046 -0.0003 -0.0004];
    cb(2,:)=[3.7450 -3.7450 0 1.7718 -1.7718 0 -0.0455 ...
        -2.0751 2.0752 -0.2887 0.2887];
    cb(3,:)=[-0.5319 0.5319 0 -0.4893 0.4893 0 -0.8174 ...
        0.2875 -0.2875 0.1418 -0.1418];
    umax=[30 30 30 60 60 10.61 10.61 60 60 40 40]';
    umin=[-30 -30 -30 -60 -60 -10.61 -10.61 0 0 0 0]';
    upref=zeros(11,1);
end
%
saa