Tartalomjegyzék

Teljes Matlab script kiegészítő függvényekkel.

function [pLFR_reduced] = P_LFR_reduction_for_LFR_simplified(syslfr,varargin)

P_LFR_reduction_for_LFR

File: P_LFR_reduction_for_LFR.m
Directory: 1_PhD_projects/00_my_toolboxes/FinslerTools/v11
Author: Peter Polcz (ppolcz@gmail.com)
Created on 2019. March 11.
Modified on 2019. March 29. (simplified version)

Initialization

Output:
 
┌ <a href="matlab:edit('/home/ppolcz/_/1_PhD_projects/00_my_toolboxes/FinslerTools/v11/P_LFR_reduction_for_LFR_simplified.m')">P_LFR_reduction_for_LFR_simplified</a> called from instrumentAndRun:109

Collect LFR model matrices

pLFR = syslfr;
if isa(pLFR,'lfr')
    pLFR = plfr(syslfr);
end

[A,B,C,D,Delta,bounds,blk] = pLFR.data;

s1 = pLFR.ny;
s2 = pLFR.nu;
m1 = pLFR.m1;
m = s2+m1;

Generate PI and compute its constant left kernel

[M11,M12] = pcz_split_matrix(eye(m),m,[s2 m1]);

PI_lfr = plfr(M11,M12,C,D,blk);
Ker = P_constKer_for_LFR(PI_lfr')';

Theta = null(Ker);

% Dimensions
[~,K] = size(Theta);
wh_m = rank(Theta);
wh_m1 = wh_m - s2;

pcz_display(s1,s2, wh_m,wh_m1,K);

Generate permutation matrix

[~,Irows] = rref(Theta');
Jrows = setdiff(1:m,Irows);
sigma_b = [Irows Jrows]
Is_right = pcz_permat(sigma_b)';
Is1 = Is_right(s2+1:end,s2+1:end);
Is_left = blkdiag(eye(s1),Is1);

assert(all(sigma_b(1:s2) == 1:s2), ...
    'The first n elements of sigma_b must be identity permutation (in theory)');

pcz_display(Irows,Jrows,sigma_b,Is_right,Is1)

Generate transformation matrix

V = Theta(Irows,:);
W = Theta(Jrows,:);
Gamma = W*V'/(V*V');

if args.Round
    Gamma = round(Gamma, args.Round);
end

% Model reduction transformation
S = Is_right' * [
    eye(wh_m)
    Gamma
    ];

% pcz_display(V,W,Gamma,S)

Model reduction transformationsz

M = [A B ; C D];

pcz_display(Is_left,M,Is_right,S)

[A,B,C,D] = pcz_split_matrix(Is_left*[A B ; C D]*Is_right'*S, [s1 wh_m1],[s2 wh_m1]);
Delta = pcz_split_matrix(Is1 * Delta * Is1',wh_m1,wh_m1);

pLFR_reduced = plfr(A,B,C,D,Delta,bounds);
end


function lfr = empty_lfr(lfr,A,x)
    lfr.A = A;
    lfr.B = zeros(size(A,1),0);
    lfr.C = zeros(0,size(A,2));
    lfr.D = zeros(0,0);
    lfr.Delta = zeros(0,0);
    lfr.Pi = zeros(0,1);
    lfr.Pib = x;
end


function test1
    pcz_generateSymStateVector(3,'x');

    A = [ (x1^2 + x2 + 1)/(x3^4 + 3*x1^3 + 4*x3 + 2) + x2 1 1 ];

    warning off
    pLFR = plfr(sym2lfr(A));
    warning on

    [~,~,C,D,Delta] = pLFR.data;
    Pi_original = simplify((eye(size(Delta)) - Delta*D)\Delta*C)

    pLFR_test = P_LFR_reduction_for_LFR_simplified(pLFR);
    pLFR_reduced_regi = P_LFR_reduction(A,x);

    [~,~,C,D,Delta] = pLFR_test.data;
    Pi = simplify((eye(size(Delta)) - Delta*D)\Delta*C)

    Pi_regi = pLFR_reduced_regi.LFR_reduced.Pi

%     pLFR.LFR_reduced.M
%     pLFR_test.LFR_reduced.M
%
%     pLFR.LFR_reduced.D
%     pLFR_test.LFR_reduced.D
end