From: <par...@us...> - 2012-02-22 19:42:59
|
Revision: 9661 http://octave.svn.sourceforge.net/octave/?rev=9661&view=rev Author: paramaniac Date: 2012-02-22 19:42:49 +0000 (Wed, 22 Feb 2012) Log Message: ----------- move finished functions from package "control-devel" to "control" Added Paths: ----------- trunk/octave-forge/main/control/inst/__conred_check_feedback_sign__.m trunk/octave-forge/main/control/inst/__conred_sb16ad__.m trunk/octave-forge/main/control/inst/__modred_ab09id__.m trunk/octave-forge/main/control/inst/__modred_check_alpha__.m trunk/octave-forge/main/control/inst/__modred_check_alpha_gram__.m trunk/octave-forge/main/control/inst/__modred_check_equil__.m trunk/octave-forge/main/control/inst/__modred_check_gram__.m trunk/octave-forge/main/control/inst/__modred_check_order__.m trunk/octave-forge/main/control/inst/__modred_check_tol__.m trunk/octave-forge/main/control/inst/__modred_check_weight__.m trunk/octave-forge/main/control/inst/__modred_default_alpha__.m trunk/octave-forge/main/control/inst/__opt2cell__.m trunk/octave-forge/main/control/inst/bstmodred.m trunk/octave-forge/main/control/inst/btaconred.m trunk/octave-forge/main/control/inst/btamodred.m trunk/octave-forge/main/control/inst/cfconred.m trunk/octave-forge/main/control/inst/fitfrd.m trunk/octave-forge/main/control/inst/fwcfconred.m trunk/octave-forge/main/control/inst/hnamodred.m trunk/octave-forge/main/control/inst/options.m trunk/octave-forge/main/control/inst/spaconred.m trunk/octave-forge/main/control/inst/spamodred.m trunk/octave-forge/main/control/src/slab09hd.cc trunk/octave-forge/main/control/src/slab09id.cc trunk/octave-forge/main/control/src/slab09jd.cc trunk/octave-forge/main/control/src/slsb10yd.cc trunk/octave-forge/main/control/src/slsb16ad.cc trunk/octave-forge/main/control/src/slsb16bd.cc trunk/octave-forge/main/control/src/slsb16cd.cc Removed Paths: ------------- trunk/octave-forge/extra/control-devel/inst/__conred_check_feedback_sign__.m trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m trunk/octave-forge/extra/control-devel/inst/__modred_check_alpha__.m trunk/octave-forge/extra/control-devel/inst/__modred_check_alpha_gram__.m trunk/octave-forge/extra/control-devel/inst/__modred_check_equil__.m trunk/octave-forge/extra/control-devel/inst/__modred_check_gram__.m trunk/octave-forge/extra/control-devel/inst/__modred_check_order__.m trunk/octave-forge/extra/control-devel/inst/__modred_check_tol__.m trunk/octave-forge/extra/control-devel/inst/__modred_check_weight__.m trunk/octave-forge/extra/control-devel/inst/__modred_default_alpha__.m trunk/octave-forge/extra/control-devel/inst/__opt2cell__.m trunk/octave-forge/extra/control-devel/inst/bstmodred.m trunk/octave-forge/extra/control-devel/inst/btaconred.m trunk/octave-forge/extra/control-devel/inst/btamodred.m trunk/octave-forge/extra/control-devel/inst/cfconred.m trunk/octave-forge/extra/control-devel/inst/fitfrd.m trunk/octave-forge/extra/control-devel/inst/fwcfconred.m trunk/octave-forge/extra/control-devel/inst/hnamodred.m trunk/octave-forge/extra/control-devel/inst/options.m trunk/octave-forge/extra/control-devel/inst/spaconred.m trunk/octave-forge/extra/control-devel/inst/spamodred.m trunk/octave-forge/extra/control-devel/src/slab09hd.cc trunk/octave-forge/extra/control-devel/src/slab09id.cc trunk/octave-forge/extra/control-devel/src/slab09jd.cc trunk/octave-forge/extra/control-devel/src/slsb10yd.cc trunk/octave-forge/extra/control-devel/src/slsb16ad.cc trunk/octave-forge/extra/control-devel/src/slsb16bd.cc trunk/octave-forge/extra/control-devel/src/slsb16cd.cc Deleted: trunk/octave-forge/extra/control-devel/inst/__conred_check_feedback_sign__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__conred_check_feedback_sign__.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/__conred_check_feedback_sign__.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,40 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## check the feedback sign. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: December 2011 -## Version: 0.1 - -function negfb = __conred_check_feedback_sign__ (fbsign, key = "feedback") - - if (! ischar (fbsign)) - error ("conred: key '%s' requires string value", key); - endif - - switch (fbsign) - case "+" - negfb = false; - case "-" - negfb = true; - otherwise - error ("conred: key '%s' has an invalid value", key); - endswitch - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,191 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn{Function File} {[@var{Kr}, @var{info}] =} __conred_sb16ad__ (@var{method}, @dots{}) -## Backend for btaconred and spaconred. -## @end deftypefn - -## Author: Lukas Reichlin <luk...@gm...> -## Created: December 2011 -## Version: 0.1 - -function [Kr, info] = __conred_sb16ad__ (method, varargin) - - if (nargin < 3) - print_usage (); - endif - - if (method != "bta" && method != "spa") - error ("modred: invalid method"); - endif - - G = varargin{1}; - K = varargin{2}; - varargin = varargin(3:end); - - if (! isa (G, "lti")) - error ("%sconred: first argument must be an LTI system", method); - endif - - if (! isa (K, "lti")) - error ("%sconred: second argument must be an LTI system", method); - endif - - if (nargin > 3) # *conred (G, K, ...) - if (is_real_scalar (varargin{1})) # *conred (G, K, nr) - varargin = horzcat (varargin(2:end), {"order"}, varargin(1)); - endif - if (isstruct (varargin{1})) # *conred (G, K, opt, ...), *conred (G, K, nr, opt, ...) - varargin = horzcat (__opt2cell__ (varargin{1}), varargin(2:end)); - endif - ## order placed at the end such that nr from *conred (G, K, nr, ...) - ## and *conred (G, K, nr, opt, ...) overrides possible nr's from - ## key/value-pairs and inside opt struct (later keys override former keys, - ## nr > key/value > opt) - endif - - nkv = numel (varargin); # number of keys and values - - if (rem (nkv, 2)) - error ("%sconred: keys and values must come in pairs", method); - endif - - [a, b, c, d, tsam, scaled] = ssdata (G); - [ac, bc, cc, dc, tsamc, scaledc] = ssdata (K); - [p, m] = size (G); - [pc, mc] = size (K); - dt = isdt (G); - - if (p != mc || m != pc) - error ("%sconred: dimensions of controller (%dx%d) and plant (%dx%d) don't match", \ - method, pc, mc, p, c); - endif - - - ## default arguments - alpha = __modred_default_alpha__ (dt); - tol1 = 0.0; - tol2 = 0.0; - jobc = jobo = 0; - bf = true; # balancing-free - weight = 3; - equil = scaled && scaledc; - ordsel = 1; - ncr = 0; - negfb = false; # positive feedback controller - - - ## handle keys and values - for k = 1 : 2 : nkv - key = lower (varargin{k}); - val = varargin{k+1}; - switch (key) - case "weight" - switch (lower (val(1))) - case "n" # none - weight = 0; - case {"l", "o"} # left, output - weight = 1; - case {"r", "i"} # right, input - weight = 2; - case {"b", "p"} # both, performance - weight = 3; - otherwise - error ("%sconred: '%s' is an invalid value for key weight", method, val); - endswitch - - case {"order", "ncr", "nr"} - [ncr, ordsel] = __modred_check_order__ (val, rows (ac)); - - case "tol1" - tol1 = __modred_check_tol__ (val, "tol1"); - - case "tol2" - tol2 = __modred_check_tol__ (val, "tol2"); - - case "alpha" - alpha = __modred_check_alpha__ (val, dt); - - case "method" - switch (tolower (val)) - case "sr" - bf = false; - case "bfsr" - bf = true; - otherwise - error ("modred: '%s' is an invalid approach", val); - endswitch - - case {"jobc", "gram-ctrb"} - jobc = __modred_check_gram__ (val, "gram-ctrb"); - - case {"jobo", "gram-obsv"} - jobo = __modred_check_gram__ (val, "gram-obsv"); - - case {"equil", "equilibrate", "equilibration", "scale", "scaling"} - scaled = __modred_check_equil__ (val); - - case "feedback" - negfb = __conred_check_feedback_sign__ (val); - - otherwise - warning ("%sconred: invalid property name '%s' ignored", method, key); - endswitch - endfor - - - ## handle model reduction approach - if (method == "bta" && ! bf) # 'B': use the square-root Balance & Truncate method - jobmr = 0; - elseif (method == "bta" && bf) # 'F': use the balancing-free square-root Balance & Truncate method - jobmr = 1; - elseif (method == "spa" && ! bf) # 'S': use the square-root Singular Perturbation Approximation method - jobmr = 2; - elseif (method == "spa" && bf) # 'P': use the balancing-free square-root Singular Perturbation Approximation method - jobmr = 3; - else - error ("%smodred: invalid jobmr option"); # this should never happen - endif - - ## handle negative feedback controllers - if (negfb) - [ac, bc, cc, dc] = ssdata (-K); - endif - - - ## perform model order reduction - [acr, bcr, ccr, dcr, ncr, hsvc, ncs] = slsb16ad (a, b, c, d, dt, equil, ncr, ordsel, alpha, jobmr, \ - ac, bc, cc, dc, \ - weight, jobc, jobo, tol1, tol2); - - ## assemble reduced order controller - Kr = ss (acr, bcr, ccr, dcr, tsamc); - - ## handle negative feedback controllers - if (negfb) - Kr = -Kr; - endif - - ## assemble info struct - info = struct ("ncr", ncr, "ncs", ncs, "hsvc", hsvc); - -endfunction - - - - Deleted: trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,178 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} __modred_ab09id__ (@var{method}, @dots{}) -## Backend for btamodred and spamodred. -## @end deftypefn - -## Author: Lukas Reichlin <luk...@gm...> -## Created: November 2011 -## Version: 0.1 - -function [Gr, info] = __modred_ab09id__ (method, varargin) - - if (nargin < 2) - print_usage (); - endif - - if (method != "bta" && method != "spa") - error ("modred: invalid method"); - endif - - G = varargin{1}; - varargin = varargin(2:end); - - if (! isa (G, "lti")) - error ("%smodred: first argument must be an LTI system", method); - endif - - if (nargin > 2) # *modred (G, ...) - if (is_real_scalar (varargin{1})) # *modred (G, nr) - varargin = horzcat (varargin(2:end), {"order"}, varargin(1)); - endif - if (isstruct (varargin{1})) # *modred (G, opt, ...), *modred (G, nr, opt, ...) - varargin = horzcat (__opt2cell__ (varargin{1}), varargin(2:end)); - endif - ## order placed at the end such that nr from *modred (G, nr, ...) - ## and *modred (G, nr, opt, ...) overrides possible nr's from - ## key/value-pairs and inside opt struct (later keys override former keys, - ## nr > key/value > opt) - endif - - nkv = numel (varargin); # number of keys and values - - if (rem (nkv, 2)) - error ("%smodred: keys and values must come in pairs", method); - endif - - [a, b, c, d, tsam, scaled] = ssdata (G); - [p, m] = size (G); - dt = isdt (G); - - ## default arguments - alpha = __modred_default_alpha__ (dt); - av = bv = cv = dv = []; - jobv = 0; - aw = bw = cw = dw = []; - jobw = 0; - alphac = alphao = 0.0; - tol1 = 0.0; - tol2 = 0.0; - jobc = jobo = 0; - bf = true; # balancing-free - weight = 1; - equil = 0; - ordsel = 1; - nr = 0; - - ## handle keys and values - for k = 1 : 2 : nkv - key = lower (varargin{k}); - val = varargin{k+1}; - switch (key) - case {"left", "output", "v"} - [av, bv, cv, dv, jobv] = __modred_check_weight__ (val, dt, p, []); - - case {"right", "input", "w"} - [aw, bw, cw, dw, jobw] = __modred_check_weight__ (val, dt, [], m); - - case {"order", "n", "nr"} - [nr, ordsel] = __modred_check_order__ (val, rows (a)); - - case "tol1" - tol1 = __modred_check_tol__ (val, "tol1"); - - case "tol2" - tol2 = __modred_check_tol__ (val, "tol2"); - - case "alpha" - alpha = __modred_check_alpha__ (val, dt); - - case "method" - switch (tolower (val)) - case "sr" - bf = false; - case "bfsr" - bf = true; - otherwise - error ("modred: '%s' is an invalid approach", val); - endswitch - - case {"jobc", "gram-ctrb"} - jobc = __modred_check_gram__ (val, "gram-ctrb"); - - case {"jobo", "gram-obsv"} - jobo = __modred_check_gram__ (val, "gram-obsv"); - - case {"alphac", "alpha-ctrb"} - alphac = __modred_check_alpha_gram__ (val, "alpha-ctrb"); - - case {"alphao", "alpha-obsv"} - alphao = __modred_check_alpha_gram__ (val, "alpha-obsv"); - - case {"equil", "equilibrate", "equilibration", "scale", "scaling"} - scaled = __modred_check_equil__ (val); - - otherwise - warning ("%smodred: invalid property name '%s' ignored", method, key); - endswitch - endfor - - ## handle type of frequency weighting - if (jobv && jobw) - weight = 3; # 'B': both left and right weightings V and W are used - elseif (jobv) - weight = 1; # 'L': only left weighting V is used (W = I) - elseif (jobw) - weight = 2; # 'R': only right weighting W is used (V = I) - else - weight = 0; # 'N': no weightings are used (V = I, W = I) - endif - - ## handle model reduction approach - if (method == "bta" && ! bf) # 'B': use the square-root Balance & Truncate method - job = 0; - elseif (method == "bta" && bf) # 'F': use the balancing-free square-root Balance & Truncate method - job = 1; - elseif (method == "spa" && ! bf) # 'S': use the square-root Singular Perturbation Approximation method - job = 2; - elseif (method == "spa" && bf) # 'P': use the balancing-free square-root Singular Perturbation Approximation method - job = 3; - else - error ("modred: invalid job option"); # this should never happen - endif - - - ## perform model order reduction - [ar, br, cr, dr, nr, hsv, ns] = slab09id (a, b, c, d, dt, equil, nr, ordsel, alpha, job, \ - av, bv, cv, dv, \ - aw, bw, cw, dw, \ - weight, jobc, jobo, alphac, alphao, \ - tol1, tol2); - - ## assemble reduced order model - Gr = ss (ar, br, cr, dr, tsam); - - ## assemble info struct - info = struct ("nr", nr, "ns", ns, "hsv", hsv); - -endfunction - - - - Deleted: trunk/octave-forge/extra/control-devel/inst/__modred_check_alpha__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_alpha__.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_alpha__.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,40 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## check alpha for model reduction commands - -## Author: Lukas Reichlin <luk...@gm...> -## Created: November 2011 -## Version: 0.1 - -function alpha = __modred_check_alpha__ (alpha, dt) - - if (! is_real_scalar (alpha)) - error ("modred: argument alpha must be a real scalar"); - endif - if (dt) # discrete-time - if (alpha < 0 || alpha > 1) - error ("modred: require 0 <= ALPHA <= 1"); - endif - else # continuous-time - if (alpha > 0) - error ("modred: require ALPHA <= 0"); - endif - endif - -endfunction Deleted: trunk/octave-forge/extra/control-devel/inst/__modred_check_alpha_gram__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_alpha_gram__.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_alpha_gram__.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,35 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## check alpha for combination methods of grammians - -## Author: Lukas Reichlin <luk...@gm...> -## Created: December 2011 -## Version: 0.1 - -function alpha = __modred_check_alpha_gram__ (alpha, key) - - if (! is_real_scalar (alpha)) - error ("modred: argument '%s' must be a real scalar", key); - endif - - if (abs (alpha) > 1) - error ("modred: require -1 <= %s <= 1", key); - endif - -endfunction Deleted: trunk/octave-forge/extra/control-devel/inst/__modred_check_equil__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_equil__.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_equil__.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,33 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## check equilibration for model reduction commands - -## Author: Lukas Reichlin <luk...@gm...> -## Created: November 2011 -## Version: 0.1 - -function scaled = __modred_check_equil__ (equil) - - if (isscalar (equil)) - scaled = ! logical (equil); - else - error ("modred: property 'equil' must be a logical value"); - endif - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/extra/control-devel/inst/__modred_check_gram__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_gram__.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_gram__.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,40 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## check choice of frequency-weighted grammians. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: December 2011 -## Version: 0.1 - -function job = __modred_check_gram__ (choice, key) - - if (! ischar (choice)) - error ("modred: key '%s' requires string value", key); - endif - - switch (tolower (choice (1))) - case "s" # standard - job = 0; - case "e" # enhanced - job = 1; - otherwise - error ("modred: key '%s' has an invalid value", key); - endswitch - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/extra/control-devel/inst/__modred_check_order__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_order__.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_order__.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,38 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## check order for model reduction commands - -## Author: Lukas Reichlin <luk...@gm...> -## Created: November 2011 -## Version: 0.1 - -function [nr, ordsel] = __modred_check_order__ (nr, n) - - if (! issample (nr, 0) || nr != round (nr)) - error ("modred: order of reduced model must be an integer >= 0"); - endif - - if (nr > n) - error ("modred: order of reduced model (%d) can't be larger than the original one (%d)", \ - nr, n); - endif - - ordsel = 0; - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/extra/control-devel/inst/__modred_check_tol__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_tol__.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_tol__.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,31 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## check tolerance for model reduction commands - -## Author: Lukas Reichlin <luk...@gm...> -## Created: November 2011 -## Version: 0.1 - -function tol = __modred_check_tol__ (tol, str = "") - - if (! is_real_scalar (tol)) - error ("modred: argument %s must be a real scalar", str); - endif - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/extra/control-devel/inst/__modred_check_weight__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_weight__.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_weight__.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,49 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## check weightings for model reduction commands - -## Author: Lukas Reichlin <luk...@gm...> -## Created: November 2011 -## Version: 0.1 - -function [a, b, c, d, job] = __modred_check_weight__ (sys, dt, p = [], m = []) - - sys = ss (sys); # could be non-lti, therefore ssdata would fail - - if (dt != isdt (sys)) - error ("modred: ct/dt"); # TODO: error message - endif - - [pw, mw] = size (sys); - - if (! isempty (p) && mw != p) - error ("modred: left weight requires %d inputs", p); - endif - - if (! isempty (m) && pw != m) - error ("modred: right weight requires %d outputs", m); - endif - - [a, b, c, d] = ssdata (sys); - - job = 1; - - ## TODO: check system size - -endfunction Deleted: trunk/octave-forge/extra/control-devel/inst/__modred_default_alpha__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_default_alpha__.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/__modred_default_alpha__.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,33 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## default alpha for model reduction commands - -## Author: Lukas Reichlin <luk...@gm...> -## Created: November 2011 -## Version: 0.1 - -function alpha = __modred_default_alpha__ (dt) - - if (dt) # discrete-time - alpha = 1; # ALPHA <= 0 - else # continuous-time - alpha = 0; # 0 <= ALPHA <= 1 - endif - -endfunction Deleted: trunk/octave-forge/extra/control-devel/inst/__opt2cell__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__opt2cell__.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/__opt2cell__.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,37 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Convert option struct to a cell with field names as keys and -## field values as values. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: November 2011 -## Version: 0.1 - -function c = __opt2cell__ (opt) - - if (! isstruct (opt)) - error ("opt2cell: argument must be a struct"); - endif - - key = fieldnames (opt); - val = struct2cell (opt); - - c = [key.'; val.'](:).'; # reshape to {key1, val1, key2, val2, ...} - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,370 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} bstmodred (@var{G}, @dots{}) -## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} bstmodred (@var{G}, @var{nr}, @dots{}) -## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} bstmodred (@var{G}, @var{opt}, @dots{}) -## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} bstmodred (@var{G}, @var{nr}, @var{opt}, @dots{}) -## -## Model order reduction by Balanced Stochastic Truncation (BST) method. -## The aim of model reduction is to find an LTI system @var{Gr} of order -## @var{nr} (nr < n) such that the input-output behaviour of @var{Gr} -## approximates the one from original system @var{G}. -## -## BST is a relative error method which tries to minimize -## @iftex -## @tex -## $$ || G^{-1} (G-G_r) ||_{\\infty} = min $$ -## @end tex -## @end iftex -## @ifnottex -## @example -## -1 -## ||G (G-Gr)|| = min -## inf -## @end example -## @end ifnottex -## -## -## -## @strong{Inputs} -## @table @var -## @item G -## LTI model to be reduced. -## @item nr -## The desired order of the resulting reduced order system @var{Gr}. -## If not specified, @var{nr} is chosen automatically according -## to the description of key @var{'order'}. -## @item @dots{} -## Optional pairs of keys and values. @code{"key1", value1, "key2", value2}. -## @item opt -## Optional struct with keys as field names. -## Struct @var{opt} can be created directly or -## by command @command{options}. @code{opt.key1 = value1, opt.key2 = value2}. -## @end table -## -## @strong{Outputs} -## @table @var -## @item Gr -## Reduced order state-space model. -## @item info -## Struct containing additional information. -## @table @var -## @item info.n -## The order of the original system @var{G}. -## @item info.ns -## The order of the @var{alpha}-stable subsystem of the original system @var{G}. -## @item info.hsv -## The Hankel singular values of the phase system corresponding -## to the @var{alpha}-stable part of the original system @var{G}. -## The @var{ns} Hankel singular values are ordered decreasingly. -## @item info.nu -## The order of the @var{alpha}-unstable subsystem of both the original -## system @var{G} and the reduced-order system @var{Gr}. -## @item info.nr -## The order of the obtained reduced order system @var{Gr}. -## @end table -## @end table -## -## @strong{Option Keys and Values} -## @table @var -## @item 'order', 'nr' -## The desired order of the resulting reduced order system @var{Gr}. -## If not specified, @var{nr} is the sum of NU and the number of -## Hankel singular values greater than @code{MAX(TOL1,NS*EPS)}; -## @var{nr} can be further reduced to ensure that -## @code{HSV(NR-NU) > HSV(NR+1-NU)}. -## -## @item 'method' -## Approximation method for the H-infinity norm. -## Valid values corresponding to this key are: -## @table @var -## @item 'sr-bta', 'b' -## Use the square-root Balance & Truncate method. -## @item 'bfsr-bta', 'f' -## Use the balancing-free square-root Balance & Truncate method. Default method. -## @item 'sr-spa', 's' -## Use the square-root Singular Perturbation Approximation method. -## @item 'bfsr-spa', 'p' -## Use the balancing-free square-root Singular Perturbation Approximation method. -## @end table -## -## @item 'alpha' -## Specifies the ALPHA-stability boundary for the eigenvalues -## of the state dynamics matrix @var{G.A}. For a continuous-time -## system, ALPHA <= 0 is the boundary value for -## the real parts of eigenvalues, while for a discrete-time -## system, 0 <= ALPHA <= 1 represents the -## boundary value for the moduli of eigenvalues. -## The ALPHA-stability domain does not include the boundary. -## Default value is 0 for continuous-time systems and -## 1 for discrete-time systems. -## -## @item 'beta' -## Use @code{[G, beta*I]} as new system @var{G} to combine -## absolute and relative error methods. -## BETA > 0 specifies the absolute/relative error weighting -## parameter. A large positive value of BETA favours the -## minimization of the absolute approximation error, while a -## small value of BETA is appropriate for the minimization -## of the relative error. -## BETA = 0 means a pure relative error method and can be -## used only if rank(G.D) = rows(G.D) which means that -## the feedthrough matrice must not be rank-deficient. -## Default value is 0. -## -## @item 'tol1' -## If @var{'order'} is not specified, @var{tol1} contains the tolerance for -## determining the order of reduced system. -## For model reduction, the recommended value of @var{tol1} lies -## in the interval [0.00001, 0.001]. @var{tol1} < 1. -## If @var{tol1} <= 0 on entry, the used default value is -## @var{tol1} = NS*EPS, where NS is the number of -## ALPHA-stable eigenvalues of A and EPS is the machine -## precision. -## If @var{'order'} is specified, the value of @var{tol1} is ignored. -## -## @item 'tol2' -## The tolerance for determining the order of a minimal -## realization of the phase system (see METHOD) corresponding -## to the ALPHA-stable part of the given system. -## The recommended value is TOL2 = NS*EPS. TOL2 <= TOL1 < 1. -## This value is used by default if @var{'tol2'} is not specified -## or if TOL2 <= 0 on entry. -## -## @item 'equil', 'scale' -## Boolean indicating whether equilibration (scaling) should be -## performed on system @var{G} prior to order reduction. -## Default value is true if @code{G.scaled == false} and -## false if @code{G.scaled == true}. -## @end table -## -## -## For the H-infinity norm, the best approximation problem is -## unsolved so far. Nevertheless, balanced truncation and related -## methods can be used to obtain good approximations using this measure. -## -## Available approximation methods are the accuracy-enhancing square-root (SR) -## or the balancing-free square-root (BFSR) versions of -## the Balance & Truncate (BTA) or Singular Perturbation Approximation (SPA) -## model reduction methods for the ALPHA-stable part of the system. -## -## Unstable models are handled by separating the stable and unstable -## parts additively, applying the model reduction only to the stable -## part and by joining the reduced stable with the original unstable part. -## The order of the reduced system can be selected by the user or -## can be determined automatically on the basis of the computed -## Hankel singular values. -## -## For MIMO models, proper scaling of input-output channels is of -## utmost importance. This can @strong{not} be done by the equilibration -## option or the @command{prescale} command because these perform state -## transformations only. While enhancing numerics, state transformations -## have no influence on the input-output behaviour and the magnitude of -## the corresponding signals. Since the algorithm calculates the -## H-infinity norm of these signals, important behaviour of @var{G} -## could be neglected just because the corresponding signals have smaller -## numbers than those of other, less important effects of @var{G}. -## -## BST is often suitable to perform model reduction in order to obtain -## low order design models for controller synthesis. -## -## Approximation Properties: -## @itemize @bullet -## @item -## Guaranteed stability of reduced models -## @item -## Approximates simultaneously gain and phase -## @item -## Preserves non-minimum phase zeros -## @item -## Guaranteed a priori error bound -## @iftex -## @tex -## $$ || G^{-1} (G-G_r) ||_{\\infty} \\leq 2 \\sum_{j=r+1}^{n} \\frac{1+\\sigma_j}{1-\\sigma_j} - 1 $$ -## @end tex -## @end iftex -## @end itemize -## -## @strong{Algorithm}@* -## Uses SLICOT AB09HD by courtesy of -## @uref{http://www.slicot.org, NICONET e.V.} -## @end deftypefn - -## Author: Lukas Reichlin <luk...@gm...> -## Created: October 2011 -## Version: 0.1 - -function [Gr, info] = bstmodred (G, varargin) - - if (nargin == 0) - print_usage (); - endif - - if (! isa (G, "lti")) - error ("bstmodred: first argument must be an LTI system"); - endif - - if (nargin > 1) # bstmodred (G, ...) - if (is_real_scalar (varargin{1})) # bstmodred (G, nr) - varargin = horzcat (varargin(2:end), {"order"}, varargin(1)); - endif - if (isstruct (varargin{1})) # bstmodred (G, opt, ...), bstmodred (G, nr, opt, ...) - varargin = horzcat (__opt2cell__ (varargin{1}), varargin(2:end)); - endif - ## order placed at the end such that nr from bstmodred (G, nr, ...) - ## and bstmodred (G, nr, opt, ...) overrides possible nr's from - ## key/value-pairs and inside opt struct (later keys override former keys, - ## nr > key/value > opt) - endif - - nkv = numel (varargin); # number of keys and values - - if (rem (nkv, 2)) - error ("bstmodred: keys and values must come in pairs"); - endif - - [a, b, c, d, tsam, scaled] = ssdata (G); - dt = isdt (G); - - ## default arguments - alpha = __modred_default_alpha__ (dt); - beta = 0; - tol1 = 0; - tol2 = 0; - ordsel = 1; - nr = 0; - job = 1; - - ## handle keys and values - for k = 1 : 2 : nkv - key = lower (varargin{k}); - val = varargin{k+1}; - switch (key) - case {"order", "nr"} - [nr, ordsel] = __modred_check_order__ (val, rows (a)); - - case "tol1" - tol1 = __modred_check_tol__ (val, "tol1"); - - case "tol2" - tol2 = __modred_check_tol__ (val, "tol2"); - - case "alpha" - alpha = __modred_check_alpha__ (val, dt); - - case "beta" - if (! issample (val, 0)) - error ("bstmodred: argument %s must be BETA >= 0", varargin{k}); - endif - beta = val; - - case "method" # approximation method - switch (tolower (val)) - case {"sr-bta", "b"} # 'B': use the square-root Balance & Truncate method - job = 0; - case {"bfsr-bta", "f"} # 'F': use the balancing-free square-root Balance & Truncate method - job = 1; - case {"sr-spa", "s"} # 'S': use the square-root Singular Perturbation Approximation method - job = 2; - case {"bfsr-spa", "p"} # 'P': use the balancing-free square-root Singular Perturbation Approximation method - job = 3; - otherwise - error ("bstmodred: '%s' is an invalid approximation method", val); - endswitch - - case {"equil", "equilibrate", "equilibration", "scale", "scaling"} - scaled = __modred_check_equil__ (val); - - otherwise - warning ("bstmodred: invalid property name '%s' ignored", key); - endswitch - endfor - - ## perform model order reduction - [ar, br, cr, dr, nr, hsv, ns] = slab09hd (a, b, c, d, dt, scaled, job, nr, ordsel, alpha, beta, \ - tol1, tol2); - - ## assemble reduced order model - Gr = ss (ar, br, cr, dr, tsam); - - ## assemble info struct - n = rows (a); - nu = n - ns; - info = struct ("n", n, "ns", ns, "hsv", hsv, "nu", nu, "nr", nr); - -endfunction - - -%!shared Mo, Me, Info, HSVe -%! A = [ -0.04165 0.0000 4.9200 -4.9200 0.0000 0.0000 0.0000 -%! -5.2100 -12.500 0.0000 0.0000 0.0000 0.0000 0.0000 -%! 0.0000 3.3300 -3.3300 0.0000 0.0000 0.0000 0.0000 -%! 0.5450 0.0000 0.0000 0.0000 -0.5450 0.0000 0.0000 -%! 0.0000 0.0000 0.0000 4.9200 -0.04165 0.0000 4.9200 -%! 0.0000 0.0000 0.0000 0.0000 -5.2100 -12.500 0.0000 -%! 0.0000 0.0000 0.0000 0.0000 0.0000 3.3300 -3.3300 ]; -%! -%! B = [ 0.0000 0.0000 -%! 12.500 0.0000 -%! 0.0000 0.0000 -%! 0.0000 0.0000 -%! 0.0000 0.0000 -%! 0.0000 12.500 -%! 0.0000 0.0000 ]; -%! -%! C = [ 1.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 -%! 0.0000 0.0000 0.0000 1.0000 0.0000 0.0000 0.0000 -%! 0.0000 0.0000 0.0000 0.0000 1.0000 0.0000 0.0000 ]; -%! -%! D = [ 0.0000 0.0000 -%! 0.0000 0.0000 -%! 0.0000 0.0000 ]; -%! -%! G = ss (A, B, C, D, "scaled", true); -%! -%! [Gr, Info] = bstmodred (G, "beta", 1.0, "tol1", 0.1, "tol2", 0.0); -%! [Ao, Bo, Co, Do] = ssdata (Gr); -%! -%! Ae = [ 1.2729 0.0000 6.5947 0.0000 -3.4229 -%! 0.0000 0.8169 0.0000 2.4821 0.0000 -%! -2.9889 0.0000 -2.9028 0.0000 -0.3692 -%! 0.0000 -3.3921 0.0000 -3.1126 0.0000 -%! -1.4767 0.0000 -2.0339 0.0000 -0.6107 ]; -%! -%! Be = [ 0.1331 -0.1331 -%! -0.0862 -0.0862 -%! -2.6777 2.6777 -%! -3.5767 -3.5767 -%! -2.3033 2.3033 ]; -%! -%! Ce = [ -0.6907 -0.6882 0.0779 0.0958 -0.0038 -%! 0.0676 0.0000 0.6532 0.0000 -0.7522 -%! 0.6907 -0.6882 -0.0779 0.0958 0.0038 ]; -%! -%! De = [ 0.0000 0.0000 -%! 0.0000 0.0000 -%! 0.0000 0.0000 ]; -%! -%! HSVe = [ 0.8803 0.8506 0.8038 0.4494 0.3973 0.0214 0.0209 ].'; -%! -%! Mo = [Ao, Bo; Co, Do]; -%! Me = [Ae, Be; Ce, De]; -%! -%!assert (Mo, Me, 1e-4); -%!assert (Info.hsv, HSVe, 1e-4); Deleted: trunk/octave-forge/extra/control-devel/inst/btaconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btaconred.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/btaconred.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,274 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn{Function File} {[@var{Kr}, @var{info}] =} btaconred (@var{G}, @var{K}, @dots{}) -## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} btaconred (@var{G}, @var{K}, @var{ncr}, @dots{}) -## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} btaconred (@var{G}, @var{K}, @var{opt}, @dots{}) -## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} btaconred (@var{G}, @var{K}, @var{ncr}, @var{opt}, @dots{}) -## -## Controller reduction by frequency-weighted Balanced Truncation Approximation (BTA). -## Given a plant @var{G} and a stabilizing controller @var{K}, determine a reduced -## order controller @var{Kr} such that the closed-loop system is stable and closed-loop -## performance is retained. -## -## The algorithm tries to minimize the frequency-weighted error -## @iftex -## @tex -## $$ || V \\ (K - K_r) \\ W ||_{\\infty} = min $$ -## @end tex -## @end iftex -## @ifnottex -## @example -## ||V (K-Kr) W|| = min -## inf -## @end example -## @end ifnottex -## where @var{V} and @var{W} denote output and input weightings. -## -## -## @strong{Inputs} -## @table @var -## @item G -## LTI model of the plant. -## It has m inputs, p outputs and n states. -## @item K -## LTI model of the controller. -## It has p inputs, m outputs and nc states. -## @item ncr -## The desired order of the resulting reduced order controller @var{Kr}. -## If not specified, @var{ncr} is chosen automatically according -## to the description of key @var{'order'}. -## @item @dots{} -## Optional pairs of keys and values. @code{"key1", value1, "key2", value2}. -## @item opt -## Optional struct with keys as field names. -## Struct @var{opt} can be created directly or -## by command @command{options}. @code{opt.key1 = value1, opt.key2 = value2}. -## @end table -## -## @strong{Outputs} -## @table @var -## @item Kr -## State-space model of reduced order controller. -## @item info -## Struct containing additional information. -## @table @var -## @item info.ncr -## The order of the obtained reduced order controller @var{Kr}. -## @item info.ncs -## The order of the alpha-stable part of original controller @var{K}. -## @item info.hsvc -## The Hankel singular values of the alpha-stable part of @var{K}. -## The @var{ncs} Hankel singular values are ordered decreasingly. -## @end table -## @end table -## -## @strong{Option Keys and Values} -## @table @var -## @item 'order', 'ncr' -## The desired order of the resulting reduced order controller @var{Kr}. -## If not specified, @var{ncr} is chosen automatically such that states with -## Hankel singular values @var{info.hsvc} > @var{tol1} are retained. -## -## @item 'method' -## Order reduction approach to be used as follows: -## @table @var -## @item 'sr', 'b' -## Use the square-root Balance & Truncate method. -## @item 'bfsr', 'f' -## Use the balancing-free square-root Balance & Truncate method. Default method. -## @end table -## -## @item 'weight' -## Specifies the type of frequency-weighting as follows: -## @table @var -## @item 'none' -## No weightings are used (V = I, W = I). -## -## @item 'left', 'output' -## Use stability enforcing left (output) weighting -## @iftex -## @tex -## $$ V = (I - G K)^{-1} G, \\qquad W = I $$ -## @end tex -## @end iftex -## @ifnottex -## @example -## -1 -## V = (I-G*K) *G , W = I -## @end example -## @end ifnottex -## -## @item 'right', 'input' -## Use stability enforcing right (input) weighting -## @iftex -## @tex -## $$ V = I, \\qquad W = (I - G K)^{-1} G $$ -## @end tex -## @end iftex -## @ifnottex -## @example -## -1 -## V = I , W = (I-G*K) *G -## @end example -## @end ifnottex -## -## @item 'both', 'performance' -## Use stability and performance enforcing weightings -## @iftex -## @tex -## $$ V = (I - G K)^{-1} G, \\qquad W = (I - G K)^{-1} $$ -## @end tex -## @end iftex -## @ifnottex -## @example -## -1 -1 -## V = (I-G*K) *G , W = (I-G*K) -## @end example -## @end ifnottex -## Default value. -## @end table -## -## @item 'feedback' -## Specifies whether @var{K} is a positive or negative feedback controller: -## @table @var -## @item '+' -## Use positive feedback controller. Default value. -## @item '-' -## Use negative feedback controller. -## @end table -## -## @item 'alpha' -## Specifies the ALPHA-stability boundary for the eigenvalues -## of the state dynamics matrix @var{K.A}. For a continuous-time -## controller, ALPHA <= 0 is the boundary value for -## the real parts of eigenvalues, while for a discrete-time -## controller, 0 <= ALPHA <= 1 represents the -## boundary value for the moduli of eigenvalues. -## The ALPHA-stability domain does not include the boundary. -## Default value is 0 for continuous-time controllers and -## 1 for discrete-time controllers. -## -## @item 'tol1' -## If @var{'order'} is not specified, @var{tol1} contains the tolerance for -## determining the order of the reduced controller. -## For model reduction, the recommended value of @var{tol1} is -## c*info.hsvc(1), where c lies in the interval [0.00001, 0.001]. -## Default value is info.ncs*eps*info.hsvc(1). -## If @var{'order'} is specified, the value of @var{tol1} is ignored. -## -## @item 'tol2' -## The tolerance for determining the order of a minimal -## realization of the ALPHA-stable part of the given -## controller. TOL2 <= TOL1. -## If not specified, ncs*eps*info.hsvc(1) is chosen. -## -## @item 'gram-ctrb' -## Specifies the choice of frequency-weighted controllability -## Grammian as follows: -## @table @var -## @item 'standard' -## Choice corresponding to standard Enns' method [1]. Default method. -## @item 'enhanced' -## Choice corresponding to the stability enhanced -## modified Enns' method of [2]. -## @end table -## -## @item 'gram-obsv' -## Specifies the choice of frequency-weighted observability -## Grammian as follows: -## @table @var -## @item 'standard' -## Choice corresponding to standard Enns' method [1]. Default method. -## @item 'enhanced' -## Choice corresponding to the stability enhanced -## modified Enns' method of [2]. -## @end table -## -## @item 'equil', 'scale' -## Boolean indicating whether equilibration (scaling) should be -## performed on @var{G} and @var{K} prior to order reduction. -## Default value is false if both @code{G.scaled == true, K.scaled == true} -## and true otherwise. -## @end table -## -## @strong{Algorithm}@* -## Uses SLICOT SB16AD by courtesy of -## @uref{http://www.slicot.org, NICONET e.V.} -## @end deftypefn - -## Author: Lukas Reichlin <luk...@gm...> -## Created: December 2011 -## Version: 0.1 - -function [Kr, info] = btaconred (varargin) - - [Kr, info] = __conred_sb16ad__ ("bta", varargin{:}); - -endfunction - - -%!shared Mo, Me, Info, HSVCe -%! A = [ -1. 0. 4. -%! 0. 2. 0. -%! 0. 0. -3. ]; -%! -%! B = [ 1. -%! 1. -%! 1. ]; -%! -%! C = [ 1. 1. 1. ]; -%! -%! D = [ 0. ]; -%! -%! G = ss (A, B, C, D, "scaled", true); -%! -%! AC = [ -26.4000, 6.4023, 4.3868; -%! 32.0000, 0, 0; -%! 0, 8.0000, 0 ]; -%! -%! BC = [ -16 -%! 0 -%! 0 ]; -%! -%! CC = [ 9.2994 1.1624 0.1090 ]; -%! -%! DC = [ 0 ]; -%! -%! K = ss (AC, BC, CC, DC, "scaled", true); -%! -%! [Kr, Info] = btaconred (G, K, 2, "weight", "input", "feedback", "+"); -%! [Ao, Bo, Co, Do] = ssdata (Kr); -%! -%! Ae = [ 9.1900 0.0000 -%! 0.0000 -34.5297 ]; -%! -%! Be = [ -11.9593 -%! 86.3137 ]; -%! -%! Ce = [ 2.8955 -1.3566 ]; -%! -%! De = [ 0.0000 ]; -%! -%! HSVCe = [ 3.8253 0.2005 ].'; -%! -%! Mo = [Ao, Bo; Co, Do]; -%! Me = [Ae, Be; Ce, De]; -%! -%!assert (Mo, Me, 1e-4); -%!assert (Info.hsvc, HSVCe, 1e-4); Deleted: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m 2012-02-22 19:21:08 UTC (rev 9660) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2012-02-22 19:42:49 UTC (rev 9661) @@ -1,300 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @dots{}) -## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{nr}, @dots{}) -## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{opt}, @dots{}) -## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} btamodred (@var{G}, @var{nr}, @var{opt}, @dots{}) -## -## Model order reduction by frequency weighted Balanced Truncation Approximation (BTA) method. -## The aim of model reduction is to find an LTI system @var{Gr} of order -## @var{nr} (nr < n) such that the input-output behaviour of @var{Gr} -## approximates the one from original system @var{G}. -## -## BTA is an absolute error method which tries to minimize -## @iftex -## @tex -## $$ || G - G_r ||_{\\infty} = min $$ -## $$ || V \\ (G - G_r) \\ W ||_{\\infty} = min $$ -## @end tex -## @end iftex -## @ifnottex -## @example -## ||G-Gr|| = min -## inf -## -## ||V (G-Gr) W|| = min -## inf -## @end example -## @end ifnottex -## where @var{V} and @var{W} denote output and input weightings. -## -## -## @strong{Inputs} -## @table @var -## @item G -## LTI model to be reduced. -## @item nr -## The desired order of the resulting reduced order system @var{Gr}. -## If not specified, @var{nr} is chosen automatically according -## to the description of key @var{'order'}. -## @item @dots{} -## Optional pairs of keys and values. @code{"key1", value1, "key2", value2}. -## @item opt -## Optional struct with keys as field names. -## Struct @var{opt} can be created directly or -## by command @command{options}. @code{opt.key1 = value1, opt.key2 = value2}. -## @end table -## -## @strong{Outputs} -## @table @var -## @item Gr -## Reduced order state-space model. -## @item info -## Struct containing additional information. -## @table @var -## @item info.n -## The order of the original system @var{G}. -## @item info.ns -## The order of the @var{alpha}-stable subsystem of the original system @var{G}. -## @item info.hsv -## The Hankel singular values of the @var{alpha}-stable part of -## the original system @var{G}, ordered decreasingly. -## @item info.nu -## The order of the @var{alpha}-unstable subsystem of both the original -## system @var{G} and the reduced-order system @var{Gr}. -## @item info.nr -## The order of the obtained reduced order system @var{Gr}. -## @end table -## @end table -## -## -## @strong{Option Keys and Values} -## @table @var -## @item 'order', 'nr' -## The desired order of the resulting reduced order system @var{Gr}. -## If not specified, @var{nr} is chosen automatically such that states with -## Hankel singular values @var{info.hsv} > @var{tol1} are retained. -## -## @item 'left', 'output' -## LTI model of the left/output frequency weighting @var{V}. -## Default value is an identity matrix. -## -## @item 'right', 'input' -## LTI model of the right/input frequency weighting @var{W}. -## Default value is an identity matrix. -## -## @item 'method' -## Approximation method for the L-infinity norm to be used as follows: -## @table @var -## @item 'sr', 'b' -## Use the square-root Balance & Truncate method. -## @item 'bfsr', 'f' -## Use the balancing-free square-root Balance & Truncate method. Default method. -## @end table -## -## @item 'alpha' -## Specifies the ALPHA-stability boundary for the eigenvalues -## of t... [truncated message content] |