From: <par...@us...> - 2011-11-07 15:36:40
|
Revision: 9018 http://octave.svn.sourceforge.net/octave/?rev=9018&view=rev Author: paramaniac Date: 2011-11-07 15:36:30 +0000 (Mon, 07 Nov 2011) Log Message: ----------- control-devel: add draft code for BTA and SPA model reduction Added Paths: ----------- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m trunk/octave-forge/extra/control-devel/inst/btamodred.m trunk/octave-forge/extra/control-devel/inst/spamodred.m Added: trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-07 15:36:30 UTC (rev 9018) @@ -0,0 +1,136 @@ +## 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{sysr}, @var{nr}] =} __ab09id_modred__ (@var{method}, @dots{}) +## Backend for btamodred and spamodred. +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: November 2011 +## Version: 0.1 + +function [sysr, nr] = __ab09id_modred__ (method, varargin) + + if (nargin < 2) + print_usage (); + endif + + if (method != "bta" && method != "spa") + error ("modred: invalid method"); + endif + + sys = varargin{1}; + varargin = varargin(2:end); + npv = nargin - 2; # number of properties and values + + if (! isa (sys, "lti")) + error ("%smodred: first argument must be an LTI system", method); + endif + + if (rem (npv, 2)) + error ("%smodred: properties and values must come in pairs", method); + endif + + [a, b, c, d, tsam, scaled] = ssdata (sys); + dt = isdt (sys); + + ## default arguments + alphac = alphao = 0.0; + tol1 = 0.0; + tol2 = 0.0; + dico = 0; + jobc = jobo = 0; + job = 1; + weight = 1; + equil = 0; + ordsel = 1; + nr = 0; + + if (dt) # discrete-time + alpha = 1; # ALPHA <= 0 + else # continuous-time + alpha = 0; # 0 <= ALPHA <= 1 + endif + + ## handle properties and values + for k = 1 : 2 : npv + prop = lower (varargin{k}); + val = varargin{k+1}; + switch (prop) + case {"order", "n", "nr"} + if (! issample (val, 0) || val != round (val)) + error ("%smodred: argument %s must be an integer >= 0", method, varargin{k}); + endif + nr = val; + ordsel = 0; + + case "tol1" + if (! is_real_scalar (val)) + error ("%smodred: argument %s must be a real scalar", method, varargin{k}); + endif + tol1 = val; + + case "tol2" + if (! is_real_scalar (val)) + error ("%smodred: argument %s must be a real scalar", method, varargin{k}); + endif + tol2 = val; + + case "alpha" + if (! is_real_scalar (val)) + error ("bstmodred: argument %s must be a real scalar", varargin{k}); + endif + if (dt) # discrete-time + if (val < 0 || val > 1) + error ("bstmodred: argument %s must be 0 <= ALPHA <= 1", varargin{k}); + endif + else # continuous-time + if (val > 0) + error ("bstmodred: argument %s must be ALPHA <= 0", varargin{k}); + endif + endif + alpha = val; + + case "beta" + if (! issample (val, 0)) + error ("bstmodred: argument %s must be BETA >= 0", varargin{k}); + endif + beta = val; + + otherwise + error ("hnamodred: invalid property name"); + endswitch + endfor + + ## TODO: handle job + + ## perform model order reduction + [ar, br, cr, dr] = slab09id (a, b, c, d, dico, equil, nr, ordsel, alpha, job, \ + av, bv, cv, dv, \ + aw, bw, cw, dw, \ + weight, jobc, jobo, alphac, alphao, \ + tol1, tol2) + + ## assemble reduced order model + sysr = ss (ar, br, cr, dr, tsam); + +endfunction + + + + Added: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-11-07 15:36:30 UTC (rev 9018) @@ -0,0 +1,98 @@ +## 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{sysr}, @var{nr}] =} btamodred (@var{sys}, @dots{}) +## Model order reduction by frequency weighted optimal Hankel-norm approximation method. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI model to be reduced. +## @item @dots{} +## Pairs of properties and values. +## TODO: describe options. +## @end table +## +## @strong{Outputs} +## @table @var +## @item sysr +## Reduced order state-space model. +## @item nr +## The order of the obtained system @var{sysr}. +## @end table +## +## @strong{Algorithm}@* +## Uses SLICOT AB09ID by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: November 2011 +## Version: 0.1 + +function [sysr, nr] = btamodred (varargin) + + [sysr, nr] = __ab09id_modred__ ("bta", varargin{:}); + +endfunction + + +%!shared Mo, Me +%! A = [ -26.4000, 6.4023, 4.3868; +%! 32.0000, 0, 0; +%! 0, 8.0000, 0 ]; +%! +%! B = [ 16 +%! 0 +%! 0 ]; +%! +%! C = [ 9.2994 1.1624 0.1090 ]; +%! +%! D = [ 0 ]; +%! +%! sys = ss (A, B, C, D); % "scaled", false +%! +%! AV = [ 0.2000 -1.0000 +%! 1.0000 0 ]; +%! +%! BV = [ 1 +%! 0 ]; +%! +%! CV = [ -1.8000 0 ]; +%! +%! DV = [ 1 ]; +%! +%! sysv = ss (AV, BV, CV, DV); +%! +%! sysr = btamodred (sys, "left", sysv, "tol1", 0.1, "tol2", 0.0); +%! [Ao, Bo, Co, Do] = ssdata (sysr); +%! +%! Ae = [ 9.1900 0.0000 +%! 0.0000 -34.5297 ]; +%! +%! Be = [ 11.9593 +%! 16.9329 ]; +%! +%! Ce = [ 2.8955 6.9152 ]; +%! +%! De = [ 0.0000 ]; +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [Ae, Be; Ce, De]; +%! +%!assert (Mo, Me, 1e-4); \ No newline at end of file Added: trunk/octave-forge/extra/control-devel/inst/spamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/spamodred.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-11-07 15:36:30 UTC (rev 9018) @@ -0,0 +1,54 @@ +## 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{sysr}, @var{nr}] =} spamodred (@var{sys}, @dots{}) +## Model order reduction by frequency weighted optimal Hankel-norm approximation method. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI model to be reduced. +## @item @dots{} +## Pairs of properties and values. +## TODO: describe options. +## @end table +## +## @strong{Outputs} +## @table @var +## @item sysr +## Reduced order state-space model. +## @item nr +## The order of the obtained system @var{sysr}. +## @end table +## +## @strong{Algorithm}@* +## Uses SLICOT AB09ID by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: November 2011 +## Version: 0.1 + +function [sysr, nr] = spamodred (varargin) + + [sysr, nr] = __ab09id_modred__ ("spa", varargin{:}); + +endfunction + +## TODO: add a test \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-11-08 13:48:36
|
Revision: 9029 http://octave.svn.sourceforge.net/octave/?rev=9029&view=rev Author: paramaniac Date: 2011-11-08 13:48:29 +0000 (Tue, 08 Nov 2011) Log Message: ----------- control-devel: update draft code Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m trunk/octave-forge/extra/control-devel/inst/btamodred.m Modified: trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-08 11:35:49 UTC (rev 9028) +++ trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-08 13:48:29 UTC (rev 9029) @@ -50,21 +50,25 @@ dt = isdt (sys); ## default arguments + av = bv = cv = dv = []; + jobv = 0; + aw = bw = cw = dw = []; + jobw = 0; alphac = alphao = 0.0; tol1 = 0.0; tol2 = 0.0; dico = 0; jobc = jobo = 0; - job = 1; + job = 1; # 'F': balancing-free square-root Balance & Truncate method weight = 1; equil = 0; ordsel = 1; nr = 0; - if (dt) # discrete-time - alpha = 1; # ALPHA <= 0 - else # continuous-time - alpha = 0; # 0 <= ALPHA <= 1 + if (dt) # discrete-time + alpha = 1; # ALPHA <= 0 + else # continuous-time + alpha = 0; # 0 <= ALPHA <= 1 endif ## handle properties and values @@ -72,6 +76,17 @@ prop = lower (varargin{k}); val = varargin{k+1}; switch (prop) + case {"left", "v"} + val = ss (val); # val could be non-lti, therefore ssdata would fail + [av, bv, cv, dv, tsamv] = ssdata (val); + jobv = 1; + + case {"right", "w"} + val = ss (val); + [aw, bw, cw, dw, tsamw] = ssdata (val); + jobw = 1; + ## TODO: check ct/dt + case {"order", "n", "nr"} if (! issample (val, 0) || val != round (val)) error ("%smodred: argument %s must be an integer >= 0", method, varargin{k}); @@ -106,16 +121,22 @@ endif alpha = val; - case "beta" - if (! issample (val, 0)) - error ("bstmodred: argument %s must be BETA >= 0", varargin{k}); - endif - beta = val; + ## TODO: alphac, alphao, jobc, jobo otherwise error ("hnamodred: invalid property name"); endswitch endfor + + 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 ## TODO: handle job Modified: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-11-08 11:35:49 UTC (rev 9028) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-11-08 13:48:29 UTC (rev 9029) @@ -79,7 +79,7 @@ %! %! sysv = ss (AV, BV, CV, DV); %! -%! sysr = btamodred (sys, "left", sysv, "tol1", 0.1, "tol2", 0.0); +%! sysr = btamodred (sys, "nr", 2, "left", sysv, "tol1", 0.1, "tol2", 0.0); %! [Ao, Bo, Co, Do] = ssdata (sysr); %! %! Ae = [ 9.1900 0.0000 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-11-08 13:53:00
|
Revision: 9030 http://octave.svn.sourceforge.net/octave/?rev=9030&view=rev Author: paramaniac Date: 2011-11-08 13:52:51 +0000 (Tue, 08 Nov 2011) Log Message: ----------- control-devel: get btamodred test working Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m trunk/octave-forge/extra/control-devel/inst/btamodred.m Modified: trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-08 13:48:29 UTC (rev 9029) +++ trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-08 13:52:51 UTC (rev 9030) @@ -145,7 +145,7 @@ av, bv, cv, dv, \ aw, bw, cw, dw, \ weight, jobc, jobo, alphac, alphao, \ - tol1, tol2) + tol1, tol2); ## assemble reduced order model sysr = ss (ar, br, cr, dr, tsam); Modified: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-11-08 13:48:29 UTC (rev 9029) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-11-08 13:52:51 UTC (rev 9030) @@ -67,15 +67,23 @@ %! %! sys = ss (A, B, C, D); % "scaled", false %! -%! AV = [ 0.2000 -1.0000 -%! 1.0000 0 ]; +%! AV = [ -1.0000, 0, 4.0000, -9.2994, -1.1624, -0.1090; +%! 0, 2.0000, 0, -9.2994, -1.1624, -0.1090; +%! 0, 0, -3.0000, -9.2994, -1.1624, -0.1090; +%! 16.0000, 16.0000, 16.0000, -26.4000, 6.4023, 4.3868; +%! 0, 0, 0, 32.0000, 0, 0; +%! 0, 0, 0, 0, 8.0000, 0 ]; %! -%! BV = [ 1 -%! 0 ]; +%! BV = [ 1 +%! 1 +%! 1 +%! 0 +%! 0 +%! 0 ]; %! -%! CV = [ -1.8000 0 ]; +%! CV = [ 1 1 1 0 0 0 ]; %! -%! DV = [ 1 ]; +%! DV = [ 0 ]; %! %! sysv = ss (AV, BV, CV, DV); %! This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-11-09 19:44:51
|
Revision: 9039 http://octave.svn.sourceforge.net/octave/?rev=9039&view=rev Author: paramaniac Date: 2011-11-09 19:44:44 +0000 (Wed, 09 Nov 2011) Log Message: ----------- control-devel: work on argument checking of model reduction commands Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m trunk/octave-forge/extra/control-devel/inst/bstmodred.m trunk/octave-forge/extra/control-devel/inst/hnamodred.m Added Paths: ----------- trunk/octave-forge/extra/control-devel/inst/__check_alpha__.m trunk/octave-forge/extra/control-devel/inst/__check_order__.m trunk/octave-forge/extra/control-devel/inst/__check_weight__.m Modified: trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-09 09:53:57 UTC (rev 9038) +++ trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-09 19:44:44 UTC (rev 9039) @@ -77,21 +77,15 @@ val = varargin{k+1}; switch (prop) case {"left", "v"} - val = ss (val); # val could be non-lti, therefore ssdata would fail - [av, bv, cv, dv, tsamv] = ssdata (val); + [av, bv, cv, dv] = __check_weight__ (val, dt); jobv = 1; case {"right", "w"} - val = ss (val); - [aw, bw, cw, dw, tsamw] = ssdata (val); + [aw, bw, cw, dw] = __check_weight__ (val, dt); jobw = 1; - ## TODO: check ct/dt case {"order", "n", "nr"} - if (! issample (val, 0) || val != round (val)) - error ("%smodred: argument %s must be an integer >= 0", method, varargin{k}); - endif - nr = val; + nr = __check_order__ (val); ordsel = 0; case "tol1" @@ -107,19 +101,7 @@ tol2 = val; case "alpha" - if (! is_real_scalar (val)) - error ("bstmodred: argument %s must be a real scalar", varargin{k}); - endif - if (dt) # discrete-time - if (val < 0 || val > 1) - error ("bstmodred: argument %s must be 0 <= ALPHA <= 1", varargin{k}); - endif - else # continuous-time - if (val > 0) - error ("bstmodred: argument %s must be ALPHA <= 0", varargin{k}); - endif - endif - alpha = val; + alpha = __check_alpha__ (val, dt); ## TODO: alphac, alphao, jobc, jobo Added: trunk/octave-forge/extra/control-devel/inst/__check_alpha__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__check_alpha__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__check_alpha__.m 2011-11-09 19:44:44 UTC (rev 9039) @@ -0,0 +1,40 @@ +## 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 = __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 Added: trunk/octave-forge/extra/control-devel/inst/__check_order__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__check_order__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__check_order__.m 2011-11-09 19:44:44 UTC (rev 9039) @@ -0,0 +1,30 @@ +## 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 + +function nr = __check_order__ (nr) + + if (! issample (nr, 0) || nr != round (nr)) + error ("modred: order of reduced model must be an integer >= 0"); + endif + +endfunction \ No newline at end of file Added: trunk/octave-forge/extra/control-devel/inst/__check_weight__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__check_weight__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__check_weight__.m 2011-11-09 19:44:44 UTC (rev 9039) @@ -0,0 +1,35 @@ +## 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] = __check_weight__ (sys, dt) + + sys = ss (sys); # could be non-lti, therefore ssdata would fail + + if (dt != isdt (sys)) + error ("modred: ct/dt"); # TODO: error message + endif + + [a, b, c, d] = ssdata (sys); + +endfunction Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-09 09:53:57 UTC (rev 9038) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-09 19:44:44 UTC (rev 9039) @@ -82,10 +82,7 @@ val = varargin{k+1}; switch (prop) case {"order", "n", "nr"} - if (! issample (val, 0) || val != round (val)) - error ("bstmodred: argument %s must be an integer >= 0", varargin{k}); - endif - nr = val; + nr = __check_order__ (val); ordsel = 0; case "tol1" @@ -101,19 +98,7 @@ tol2 = val; case "alpha" - if (! is_real_scalar (val)) - error ("bstmodred: argument %s must be a real scalar", varargin{k}); - endif - if (dt) # discrete-time - if (val < 0 || val > 1) - error ("bstmodred: argument %s must be 0 <= ALPHA <= 1", varargin{k}); - endif - else # continuous-time - if (val > 0) - error ("bstmodred: argument %s must be ALPHA <= 0", varargin{k}); - endif - endif - alpha = val; + alpha = __check_alpha__ (val, dt); case "beta" if (! issample (val, 0)) Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-09 09:53:57 UTC (rev 9038) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-09 19:44:44 UTC (rev 9039) @@ -84,21 +84,15 @@ val = varargin{k+1}; switch (prop) case {"left", "v"} - val = ss (val); # val could be non-lti, therefore ssdata would fail - [av, bv, cv, dv, tsamv] = ssdata (val); + [av, bv, cv, dv] = __check_weight__ (val, dt); jobv = 1; case {"right", "w"} - val = ss (val); - [aw, bw, cw, dw, tsamw] = ssdata (val); + [aw, bw, cw, dw] = __check_weight__ (val, dt); jobw = 1; - ## TODO: check ct/dt case {"order", "n", "nr"} - if (! issample (val, 0) || val != round (val)) - error ("hnamodred: argument %s must be an integer >= 0", varargin{k}); - endif - nr = val; + nr = __check_order__ (val); ordsel = 0; case "tol1" @@ -114,19 +108,7 @@ tol2 = val; case "alpha" - if (! is_real_scalar (val)) - error ("hnamodred: argument %s must be a real scalar", varargin{k}); - endif - if (dt) # discrete-time - if (val < 0 || val > 1) - error ("hnamodred: argument %s must be 0 <= ALPHA <= 1", varargin{k}); - endif - else # continuous-time - if (val > 0) - error ("hnamodred: argument %s must be ALPHA <= 0", varargin{k}); - endif - endif - alpha = val; + alpha = __check_alpha__ (val, dt); otherwise error ("hnamodred: invalid property name"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-11-09 20:18:47
|
Revision: 9040 http://octave.svn.sourceforge.net/octave/?rev=9040&view=rev Author: paramaniac Date: 2011-11-09 20:18:40 +0000 (Wed, 09 Nov 2011) Log Message: ----------- control-devel: work on argument checking of model reduction commands (2) Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m trunk/octave-forge/extra/control-devel/inst/bstmodred.m trunk/octave-forge/extra/control-devel/inst/hnamodred.m Added Paths: ----------- trunk/octave-forge/extra/control-devel/inst/__check_tol__.m Modified: trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-09 19:44:44 UTC (rev 9039) +++ trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-09 20:18:40 UTC (rev 9040) @@ -89,16 +89,10 @@ ordsel = 0; case "tol1" - if (! is_real_scalar (val)) - error ("%smodred: argument %s must be a real scalar", method, varargin{k}); - endif - tol1 = val; + tol1 = __check_tol__ (val, "tol1"); case "tol2" - if (! is_real_scalar (val)) - error ("%smodred: argument %s must be a real scalar", method, varargin{k}); - endif - tol2 = val; + tol2 = __check_tol__ (val, "tol2"); case "alpha" alpha = __check_alpha__ (val, dt); Added: trunk/octave-forge/extra/control-devel/inst/__check_tol__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__check_tol__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__check_tol__.m 2011-11-09 20:18:40 UTC (rev 9040) @@ -0,0 +1,30 @@ +## 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 + +function tol = __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 Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-09 19:44:44 UTC (rev 9039) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-09 20:18:40 UTC (rev 9040) @@ -86,20 +86,14 @@ ordsel = 0; case "tol1" - if (! is_real_scalar (val)) - error ("hnamodred: argument %s must be a real scalar", varargin{k}); - endif - tol1 = val; + tol1 = __check_tol__ (val, "tol1"); case "tol2" - if (! is_real_scalar (val)) - error ("hnamodred: argument %s must be a real scalar", varargin{k}); - endif - tol2 = val; + tol2 = __check_tol__ (val, "tol2"); case "alpha" alpha = __check_alpha__ (val, dt); - + case "beta" if (! issample (val, 0)) error ("bstmodred: argument %s must be BETA >= 0", varargin{k}); Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-09 19:44:44 UTC (rev 9039) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-09 20:18:40 UTC (rev 9040) @@ -96,16 +96,10 @@ ordsel = 0; case "tol1" - if (! is_real_scalar (val)) - error ("hnamodred: argument %s must be a real scalar", varargin{k}); - endif - tol1 = val; + tol1 = __check_tol__ (val, "tol1"); case "tol2" - if (! is_real_scalar (val)) - error ("hnamodred: argument %s must be a real scalar", varargin{k}); - endif - tol2 = val; + tol2 = __check_tol__ (val, "tol2"); case "alpha" alpha = __check_alpha__ (val, dt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-11-09 20:27:57
|
Revision: 9041 http://octave.svn.sourceforge.net/octave/?rev=9041&view=rev Author: paramaniac Date: 2011-11-09 20:27:50 +0000 (Wed, 09 Nov 2011) Log Message: ----------- control-devel: work on argument checking of model reduction commands (3) Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m trunk/octave-forge/extra/control-devel/inst/bstmodred.m trunk/octave-forge/extra/control-devel/inst/hnamodred.m Added Paths: ----------- trunk/octave-forge/extra/control-devel/inst/__default_alpha__.m Modified: trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-09 20:18:40 UTC (rev 9040) +++ trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-09 20:27:50 UTC (rev 9041) @@ -50,6 +50,7 @@ dt = isdt (sys); ## default arguments + alpha = __default_alpha__ (dt); av = bv = cv = dv = []; jobv = 0; aw = bw = cw = dw = []; @@ -64,12 +65,6 @@ equil = 0; ordsel = 1; nr = 0; - - if (dt) # discrete-time - alpha = 1; # ALPHA <= 0 - else # continuous-time - alpha = 0; # 0 <= ALPHA <= 1 - endif ## handle properties and values for k = 1 : 2 : npv Added: trunk/octave-forge/extra/control-devel/inst/__default_alpha__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__default_alpha__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__default_alpha__.m 2011-11-09 20:27:50 UTC (rev 9041) @@ -0,0 +1,33 @@ +## 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 = __default_alpha__ (dt) + + if (dt) # discrete-time + alpha = 1; # ALPHA <= 0 + else # continuous-time + alpha = 0; # 0 <= ALPHA <= 1 + endif + +endfunction Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-09 20:18:40 UTC (rev 9040) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-09 20:27:50 UTC (rev 9041) @@ -63,6 +63,7 @@ dt = isdt (sys); ## default arguments + alpha = __default_alpha__ (dt); beta = 1; # ? tol1 = 0; tol2 = 0; @@ -70,13 +71,8 @@ nr = 0; job = 1; ## ? - - if (dt) # discrete-time - alpha = 1; # ALPHA <= 0 - else # continuous-time - alpha = 0; # 0 <= ALPHA <= 1 - endif + ## handle properties and values for k = 1 : 2 : (nargin-1) prop = lower (varargin{k}); val = varargin{k+1}; Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-09 20:18:40 UTC (rev 9040) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-09 20:27:50 UTC (rev 9041) @@ -63,6 +63,7 @@ dt = isdt (sys); ## default arguments + alpha = __default_alpha__ (dt); av = bv = cv = dv = []; jobv = 0; aw = bw = cw = dw = []; @@ -72,13 +73,8 @@ tol2 = 0; ordsel = 1; nr = 0; - - if (dt) # discrete-time - alpha = 1; # ALPHA <= 0 - else # continuous-time - alpha = 0; # 0 <= ALPHA <= 1 - endif + ## handle properties and values for k = 1 : 2 : (nargin-1) prop = lower (varargin{k}); val = varargin{k+1}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-11-09 20:49:17
|
Revision: 9042 http://octave.svn.sourceforge.net/octave/?rev=9042&view=rev Author: paramaniac Date: 2011-11-09 20:49:10 +0000 (Wed, 09 Nov 2011) Log Message: ----------- control-devel: work on argument checking of model reduction commands (4) Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m trunk/octave-forge/extra/control-devel/inst/__check_order__.m trunk/octave-forge/extra/control-devel/inst/__check_tol__.m trunk/octave-forge/extra/control-devel/inst/__check_weight__.m trunk/octave-forge/extra/control-devel/inst/bstmodred.m trunk/octave-forge/extra/control-devel/inst/hnamodred.m Modified: trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-09 20:27:50 UTC (rev 9041) +++ trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-09 20:49:10 UTC (rev 9042) @@ -72,16 +72,13 @@ val = varargin{k+1}; switch (prop) case {"left", "v"} - [av, bv, cv, dv] = __check_weight__ (val, dt); - jobv = 1; + [av, bv, cv, dv, jobv] = __check_weight__ (val, dt); case {"right", "w"} - [aw, bw, cw, dw] = __check_weight__ (val, dt); - jobw = 1; + [aw, bw, cw, dw, jobw] = __check_weight__ (val, dt); case {"order", "n", "nr"} - nr = __check_order__ (val); - ordsel = 0; + [nr, ordsel] = __check_order__ (val); case "tol1" tol1 = __check_tol__ (val, "tol1"); Modified: trunk/octave-forge/extra/control-devel/inst/__check_order__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__check_order__.m 2011-11-09 20:27:50 UTC (rev 9041) +++ trunk/octave-forge/extra/control-devel/inst/__check_order__.m 2011-11-09 20:49:10 UTC (rev 9042) @@ -20,11 +20,14 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2011 +## Version: 0.1 -function nr = __check_order__ (nr) +function [nr, ordsel] = __check_order__ (nr) if (! issample (nr, 0) || nr != round (nr)) error ("modred: order of reduced model must be an integer >= 0"); endif + + ordsel = 0; endfunction \ No newline at end of file Modified: trunk/octave-forge/extra/control-devel/inst/__check_tol__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__check_tol__.m 2011-11-09 20:27:50 UTC (rev 9041) +++ trunk/octave-forge/extra/control-devel/inst/__check_tol__.m 2011-11-09 20:49:10 UTC (rev 9042) @@ -20,6 +20,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2011 +## Version: 0.1 function tol = __check_tol__ (tol, str = "") Modified: trunk/octave-forge/extra/control-devel/inst/__check_weight__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__check_weight__.m 2011-11-09 20:27:50 UTC (rev 9041) +++ trunk/octave-forge/extra/control-devel/inst/__check_weight__.m 2011-11-09 20:49:10 UTC (rev 9042) @@ -22,7 +22,7 @@ ## Created: November 2011 ## Version: 0.1 -function [a, b, c, d] = __check_weight__ (sys, dt) +function [a, b, c, d, job] = __check_weight__ (sys, dt) sys = ss (sys); # could be non-lti, therefore ssdata would fail @@ -31,5 +31,7 @@ endif [a, b, c, d] = ssdata (sys); + + job = 1; endfunction Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-09 20:27:50 UTC (rev 9041) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-09 20:49:10 UTC (rev 9042) @@ -78,8 +78,7 @@ val = varargin{k+1}; switch (prop) case {"order", "n", "nr"} - nr = __check_order__ (val); - ordsel = 0; + [nr, ordsel] = __check_order__ (val); case "tol1" tol1 = __check_tol__ (val, "tol1"); Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-09 20:27:50 UTC (rev 9041) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-09 20:49:10 UTC (rev 9042) @@ -80,16 +80,13 @@ val = varargin{k+1}; switch (prop) case {"left", "v"} - [av, bv, cv, dv] = __check_weight__ (val, dt); - jobv = 1; + [av, bv, cv, dv, jobv] = __check_weight__ (val, dt); case {"right", "w"} - [aw, bw, cw, dw] = __check_weight__ (val, dt); - jobw = 1; + [aw, bw, cw, dw, jobw] = __check_weight__ (val, dt); case {"order", "n", "nr"} - nr = __check_order__ (val); - ordsel = 0; + [nr, ordsel] = __check_order__ (val); case "tol1" tol1 = __check_tol__ (val, "tol1"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-11-10 17:48:11
|
Revision: 9047 http://octave.svn.sourceforge.net/octave/?rev=9047&view=rev Author: paramaniac Date: 2011-11-10 17:48:04 +0000 (Thu, 10 Nov 2011) Log Message: ----------- control-devel: rename functions Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/bstmodred.m trunk/octave-forge/extra/control-devel/inst/btamodred.m trunk/octave-forge/extra/control-devel/inst/hnamodred.m trunk/octave-forge/extra/control-devel/inst/spamodred.m Added Paths: ----------- 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_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 Removed Paths: ------------- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m trunk/octave-forge/extra/control-devel/inst/__check_alpha__.m trunk/octave-forge/extra/control-devel/inst/__check_order__.m trunk/octave-forge/extra/control-devel/inst/__check_tol__.m trunk/octave-forge/extra/control-devel/inst/__check_weight__.m trunk/octave-forge/extra/control-devel/inst/__default_alpha__.m Deleted: trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-10 17:30:57 UTC (rev 9046) +++ trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -1,125 +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{sysr}, @var{nr}] =} __ab09id_modred__ (@var{method}, @dots{}) -## Backend for btamodred and spamodred. -## @end deftypefn - -## Author: Lukas Reichlin <luk...@gm...> -## Created: November 2011 -## Version: 0.1 - -function [sysr, nr] = __ab09id_modred__ (method, varargin) - - if (nargin < 2) - print_usage (); - endif - - if (method != "bta" && method != "spa") - error ("modred: invalid method"); - endif - - sys = varargin{1}; - varargin = varargin(2:end); - npv = nargin - 2; # number of properties and values - - if (! isa (sys, "lti")) - error ("%smodred: first argument must be an LTI system", method); - endif - - if (rem (npv, 2)) - error ("%smodred: properties and values must come in pairs", method); - endif - - [a, b, c, d, tsam, scaled] = ssdata (sys); - dt = isdt (sys); - - ## default arguments - alpha = __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; - dico = 0; - jobc = jobo = 0; - job = 1; # 'F': balancing-free square-root Balance & Truncate method - weight = 1; - equil = 0; - ordsel = 1; - nr = 0; - - ## handle properties and values - for k = 1 : 2 : npv - prop = lower (varargin{k}); - val = varargin{k+1}; - switch (prop) - case {"left", "v"} - [av, bv, cv, dv, jobv] = __check_weight__ (val, dt); - - case {"right", "w"} - [aw, bw, cw, dw, jobw] = __check_weight__ (val, dt); - - case {"order", "n", "nr"} - [nr, ordsel] = __check_order__ (val); - - case "tol1" - tol1 = __check_tol__ (val, "tol1"); - - case "tol2" - tol2 = __check_tol__ (val, "tol2"); - - case "alpha" - alpha = __check_alpha__ (val, dt); - - ## TODO: alphac, alphao, jobc, jobo - - otherwise - error ("hnamodred: invalid property name"); - endswitch - endfor - - 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 - - ## TODO: handle job - - ## perform model order reduction - [ar, br, cr, dr] = slab09id (a, b, c, d, dico, equil, nr, ordsel, alpha, job, \ - av, bv, cv, dv, \ - aw, bw, cw, dw, \ - weight, jobc, jobo, alphac, alphao, \ - tol1, tol2); - - ## assemble reduced order model - sysr = ss (ar, br, cr, dr, tsam); - -endfunction - - - - Deleted: trunk/octave-forge/extra/control-devel/inst/__check_alpha__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__check_alpha__.m 2011-11-10 17:30:57 UTC (rev 9046) +++ trunk/octave-forge/extra/control-devel/inst/__check_alpha__.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -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 = __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/__check_order__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__check_order__.m 2011-11-10 17:30:57 UTC (rev 9046) +++ trunk/octave-forge/extra/control-devel/inst/__check_order__.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -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 order for model reduction commands - -## Author: Lukas Reichlin <luk...@gm...> -## Created: November 2011 -## Version: 0.1 - -function [nr, ordsel] = __check_order__ (nr) - - if (! issample (nr, 0) || nr != round (nr)) - error ("modred: order of reduced model must be an integer >= 0"); - endif - - ordsel = 0; - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/extra/control-devel/inst/__check_tol__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__check_tol__.m 2011-11-10 17:30:57 UTC (rev 9046) +++ trunk/octave-forge/extra/control-devel/inst/__check_tol__.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -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 = __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/__check_weight__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__check_weight__.m 2011-11-10 17:30:57 UTC (rev 9046) +++ trunk/octave-forge/extra/control-devel/inst/__check_weight__.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -1,39 +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] = __check_weight__ (sys, dt) - - sys = ss (sys); # could be non-lti, therefore ssdata would fail - - if (dt != isdt (sys)) - error ("modred: ct/dt"); # TODO: error message - endif - - [a, b, c, d] = ssdata (sys); - - job = 1; - - ## TODO: check system size - -endfunction Deleted: trunk/octave-forge/extra/control-devel/inst/__default_alpha__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__default_alpha__.m 2011-11-10 17:30:57 UTC (rev 9046) +++ trunk/octave-forge/extra/control-devel/inst/__default_alpha__.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -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 = __default_alpha__ (dt) - - if (dt) # discrete-time - alpha = 1; # ALPHA <= 0 - else # continuous-time - alpha = 0; # 0 <= ALPHA <= 1 - endif - -endfunction Copied: trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m (from rev 9046, trunk/octave-forge/extra/control-devel/inst/__ab09id_modred__.m) =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -0,0 +1,125 @@ +## 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{sysr}, @var{nr}] =} __modred_ab09id__ (@var{method}, @dots{}) +## Backend for btamodred and spamodred. +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: November 2011 +## Version: 0.1 + +function [sysr, nr] = __modred_ab09id__ (method, varargin) + + if (nargin < 2) + print_usage (); + endif + + if (method != "bta" && method != "spa") + error ("modred: invalid method"); + endif + + sys = varargin{1}; + varargin = varargin(2:end); + npv = nargin - 2; # number of properties and values + + if (! isa (sys, "lti")) + error ("%smodred: first argument must be an LTI system", method); + endif + + if (rem (npv, 2)) + error ("%smodred: properties and values must come in pairs", method); + endif + + [a, b, c, d, tsam, scaled] = ssdata (sys); + dt = isdt (sys); + + ## 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; + dico = 0; + jobc = jobo = 0; + job = 1; # 'F': balancing-free square-root Balance & Truncate method + weight = 1; + equil = 0; + ordsel = 1; + nr = 0; + + ## handle properties and values + for k = 1 : 2 : npv + prop = lower (varargin{k}); + val = varargin{k+1}; + switch (prop) + case {"left", "v"} + [av, bv, cv, dv, jobv] = __modred_check_weight__ (val, dt); + + case {"right", "w"} + [aw, bw, cw, dw, jobw] = __modred_check_weight__ (val, dt); + + case {"order", "n", "nr"} + [nr, ordsel] = __modred_check_order__ (val); + + case "tol1" + tol1 = __modred_check_tol__ (val, "tol1"); + + case "tol2" + tol2 = __modred_check_tol__ (val, "tol2"); + + case "alpha" + alpha = __modred_check_alpha__ (val, dt); + + ## TODO: alphac, alphao, jobc, jobo + + otherwise + error ("hnamodred: invalid property name"); + endswitch + endfor + + 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 + + ## TODO: handle job + + ## perform model order reduction + [ar, br, cr, dr] = slab09id (a, b, c, d, dico, equil, nr, ordsel, alpha, job, \ + av, bv, cv, dv, \ + aw, bw, cw, dw, \ + weight, jobc, jobo, alphac, alphao, \ + tol1, tol2); + + ## assemble reduced order model + sysr = ss (ar, br, cr, dr, tsam); + +endfunction + + + + Copied: trunk/octave-forge/extra/control-devel/inst/__modred_check_alpha__.m (from rev 9046, trunk/octave-forge/extra/control-devel/inst/__check_alpha__.m) =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_alpha__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_alpha__.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -0,0 +1,40 @@ +## 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 Copied: trunk/octave-forge/extra/control-devel/inst/__modred_check_order__.m (from rev 9046, trunk/octave-forge/extra/control-devel/inst/__check_order__.m) =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_order__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_order__.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -0,0 +1,33 @@ +## 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) + + if (! issample (nr, 0) || nr != round (nr)) + error ("modred: order of reduced model must be an integer >= 0"); + endif + + ordsel = 0; + +endfunction \ No newline at end of file Copied: trunk/octave-forge/extra/control-devel/inst/__modred_check_tol__.m (from rev 9046, trunk/octave-forge/extra/control-devel/inst/__check_tol__.m) =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_tol__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_tol__.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -0,0 +1,31 @@ +## 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 Copied: trunk/octave-forge/extra/control-devel/inst/__modred_check_weight__.m (from rev 9046, trunk/octave-forge/extra/control-devel/inst/__check_weight__.m) =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_weight__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_weight__.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -0,0 +1,39 @@ +## 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) + + sys = ss (sys); # could be non-lti, therefore ssdata would fail + + if (dt != isdt (sys)) + error ("modred: ct/dt"); # TODO: error message + endif + + [a, b, c, d] = ssdata (sys); + + job = 1; + + ## TODO: check system size + +endfunction Copied: trunk/octave-forge/extra/control-devel/inst/__modred_default_alpha__.m (from rev 9046, trunk/octave-forge/extra/control-devel/inst/__default_alpha__.m) =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_default_alpha__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__modred_default_alpha__.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -0,0 +1,33 @@ +## 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 Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-10 17:30:57 UTC (rev 9046) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -63,7 +63,7 @@ dt = isdt (sys); ## default arguments - alpha = __default_alpha__ (dt); + alpha = __modred_default_alpha__ (dt); beta = 1; # ? tol1 = 0; tol2 = 0; @@ -78,16 +78,16 @@ val = varargin{k+1}; switch (prop) case {"order", "n", "nr"} - [nr, ordsel] = __check_order__ (val); + [nr, ordsel] = __modred_check_order__ (val); case "tol1" - tol1 = __check_tol__ (val, "tol1"); + tol1 = __modred_check_tol__ (val, "tol1"); case "tol2" - tol2 = __check_tol__ (val, "tol2"); + tol2 = __modred_check_tol__ (val, "tol2"); case "alpha" - alpha = __check_alpha__ (val, dt); + alpha = __modred_check_alpha__ (val, dt); case "beta" if (! issample (val, 0)) Modified: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-11-10 17:30:57 UTC (rev 9046) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -47,7 +47,7 @@ function [sysr, nr] = btamodred (varargin) - [sysr, nr] = __ab09id_modred__ ("bta", varargin{:}); + [sysr, nr] = __modred_ab09id__ ("bta", varargin{:}); endfunction Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-10 17:30:57 UTC (rev 9046) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -63,7 +63,7 @@ dt = isdt (sys); ## default arguments - alpha = __default_alpha__ (dt); + alpha = __modred_default_alpha__ (dt); av = bv = cv = dv = []; jobv = 0; aw = bw = cw = dw = []; @@ -80,22 +80,22 @@ val = varargin{k+1}; switch (prop) case {"left", "v"} - [av, bv, cv, dv, jobv] = __check_weight__ (val, dt); + [av, bv, cv, dv, jobv] = __modred_check_weight__ (val, dt); case {"right", "w"} - [aw, bw, cw, dw, jobw] = __check_weight__ (val, dt); + [aw, bw, cw, dw, jobw] = __modred_check_weight__ (val, dt); case {"order", "n", "nr"} - [nr, ordsel] = __check_order__ (val); + [nr, ordsel] = __modred_check_order__ (val); case "tol1" - tol1 = __check_tol__ (val, "tol1"); + tol1 = __modred_check_tol__ (val, "tol1"); case "tol2" - tol2 = __check_tol__ (val, "tol2"); + tol2 = __modred_check_tol__ (val, "tol2"); case "alpha" - alpha = __check_alpha__ (val, dt); + alpha = __modred_check_alpha__ (val, dt); otherwise error ("hnamodred: invalid property name"); Modified: trunk/octave-forge/extra/control-devel/inst/spamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-11-10 17:30:57 UTC (rev 9046) +++ trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-11-10 17:48:04 UTC (rev 9047) @@ -47,7 +47,7 @@ function [sysr, nr] = spamodred (varargin) - [sysr, nr] = __ab09id_modred__ ("spa", varargin{:}); + [sysr, nr] = __modred_ab09id__ ("spa", varargin{:}); endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-11-10 18:52:00
|
Revision: 9049 http://octave.svn.sourceforge.net/octave/?rev=9049&view=rev Author: paramaniac Date: 2011-11-10 18:51:53 +0000 (Thu, 10 Nov 2011) Log Message: ----------- control-devel: check size of weights Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m trunk/octave-forge/extra/control-devel/inst/__modred_check_weight__.m Modified: trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-11-10 18:47:54 UTC (rev 9048) +++ trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-11-10 18:51:53 UTC (rev 9049) @@ -47,6 +47,7 @@ endif [a, b, c, d, tsam, scaled] = ssdata (sys); + [p, m] = size (sys); dt = isdt (sys); ## default arguments @@ -72,10 +73,10 @@ val = varargin{k+1}; switch (prop) case {"left", "v"} - [av, bv, cv, dv, jobv] = __modred_check_weight__ (val, dt); + [av, bv, cv, dv, jobv] = __modred_check_weight__ (val, dt, p, []); case {"right", "w"} - [aw, bw, cw, dw, jobw] = __modred_check_weight__ (val, dt); + [aw, bw, cw, dw, jobw] = __modred_check_weight__ (val, dt, [], m); case {"order", "n", "nr"} [nr, ordsel] = __modred_check_order__ (val); Modified: trunk/octave-forge/extra/control-devel/inst/__modred_check_weight__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_weight__.m 2011-11-10 18:47:54 UTC (rev 9048) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_weight__.m 2011-11-10 18:51:53 UTC (rev 9049) @@ -22,7 +22,7 @@ ## Created: November 2011 ## Version: 0.1 -function [a, b, c, d, job] = __modred_check_weight__ (sys, dt) +function [a, b, c, d, job] = __modred_check_weight__ (sys, dt, p = [], m = []) sys = ss (sys); # could be non-lti, therefore ssdata would fail @@ -30,6 +30,16 @@ 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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-11-19 20:44:48
|
Revision: 9140 http://octave.svn.sourceforge.net/octave/?rev=9140&view=rev Author: paramaniac Date: 2011-11-19 20:44:42 +0000 (Sat, 19 Nov 2011) Log Message: ----------- control-devel: work on option structs Modified Paths: -------------- 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/btamodred.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/spamodred.m Modified: trunk/octave-forge/extra/control-devel/inst/__opt2cell__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__opt2cell__.m 2011-11-19 18:01:27 UTC (rev 9139) +++ trunk/octave-forge/extra/control-devel/inst/__opt2cell__.m 2011-11-19 20:44:42 UTC (rev 9140) @@ -1,3 +1,28 @@ +## 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)) Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-19 18:01:27 UTC (rev 9139) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-19 20:44:42 UTC (rev 9140) @@ -16,7 +16,9 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{sysr}, @var{nr}] =} bstmodred (@var{sys}, @dots{}) +## @deftypefn{Function File} {[@var{sysr}, @var{nr}] =} bstmodred (@var{sys}) +## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} bstmodred (@var{sys}, @dots{}) +## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} bstmodred (@var{sys}, @var{opt}) ## Model order reduction by Balanced Stochastic Truncation method. ## Uses the stochastic balancing approach in conjunction with the square-root or ## the balancing-free square-root Balance & Truncate (B&T) Modified: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-11-19 18:01:27 UTC (rev 9139) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-11-19 20:44:42 UTC (rev 9140) @@ -16,7 +16,9 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{sysr}, @var{nr}] =} btamodred (@var{sys}, @dots{}) +## @deftypefn{Function File} {[@var{sysr}, @var{nr}] =} btamodred (@var{sys}) +## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} btamodred (@var{sys}, @dots{}) +## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} btamodred (@var{sys}, @var{opt}) ## Model order reduction by frequency weighted optimal Hankel-norm approximation method. ## ## @strong{Inputs} Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-19 18:01:27 UTC (rev 9139) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-19 20:44:42 UTC (rev 9140) @@ -16,7 +16,9 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{sysr}, @var{info}] =} hnamodred (@var{sys}, @dots{}) +## @deftypefn{Function File} {[@var{sysr}, @var{info}] =} hnamodred (@var{sys}) +## @deftypefnx{Function File} {[@var{sysr}, @var{info}] =} hnamodred (@var{sys}, @dots{}) +## @deftypefnx{Function File} {[@var{sysr}, @var{info}] =} hnamodred (@var{sys}, @var{opt}) ## Model order reduction by frequency weighted optimal Hankel-norm approximation method. ## ## @strong{Inputs} Modified: trunk/octave-forge/extra/control-devel/inst/options.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/options.m 2011-11-19 18:01:27 UTC (rev 9139) +++ trunk/octave-forge/extra/control-devel/inst/options.m 2011-11-19 20:44:42 UTC (rev 9140) @@ -1,3 +1,60 @@ +## 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{opt} =} options (@var{"key1"}, @var{value1}, @var{"key2"}, @var{value2}, @dots{}) +## Create options struct @var{opt} from a number of property and value pairs. +## For use with order reduction commands. +## +## @strong{Inputs} +## @table @var +## @item key, property +## The name of the property. +## @item value +## The value of the property. +## @end table +## +## @strong{Outputs} +## @table @var +## @item opt +## Struct with fields for each key. +## @end table +## +## @strong{Example} +## @example +## @group +## octave:1> opt = options ("method", "spa", "tol", 1e-6) +## opt = +## +## scalar structure containing the fields: +## +## method = spa +## tol = 1.0000e-06 +## +## octave:2> +## @end group +## @end example +## +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: November 2011 +## Version: 0.1 + function opt = options (varargin) if (nargin == 0) @@ -11,6 +68,6 @@ key = reshape (varargin(1:2:end-1), [], 1); val = reshape (varargin(2:2:end), [], 1); - opt = cell2struct (val, key, 1) + opt = cell2struct (val, key, 1); endfunction \ No newline at end of file Modified: trunk/octave-forge/extra/control-devel/inst/spamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-11-19 18:01:27 UTC (rev 9139) +++ trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-11-19 20:44:42 UTC (rev 9140) @@ -16,7 +16,9 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{sysr}, @var{nr}] =} spamodred (@var{sys}, @dots{}) +## @deftypefn{Function File} {[@var{sysr}, @var{nr}] =} spamodred (@var{sys}) +## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} spamodred (@var{sys}, @dots{}) +## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} spamodred (@var{sys}, @var{opt}) ## Model order reduction by frequency weighted optimal Hankel-norm approximation method. ## ## @strong{Inputs} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-11-24 19:56:17
|
Revision: 9176 http://octave.svn.sourceforge.net/octave/?rev=9176&view=rev Author: paramaniac Date: 2011-11-24 19:56:11 +0000 (Thu, 24 Nov 2011) Log Message: ----------- control-devel: quicksave work on bstmodred Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/bstmodred.m Added Paths: ----------- trunk/octave-forge/extra/control-devel/inst/__modred_check_equil__.m Added: trunk/octave-forge/extra/control-devel/inst/__modred_check_equil__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_equil__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_equil__.m 2011-11-24 19:56:11 UTC (rev 9176) @@ -0,0 +1,33 @@ +## 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_order__ (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 Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-24 18:25:12 UTC (rev 9175) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-24 19:56:11 UTC (rev 9176) @@ -66,12 +66,40 @@ ## 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 "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}. +## @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 "approx", "approach" +## The order of the obtained system @var{Gr}. ## @item nr ## The order of the obtained system @var{Gr}. ## @item nr ## The order of the obtained system @var{Gr}. ## @item nr ## The order of the obtained system @var{Gr}. +## @item nr +## The order of the obtained system @var{Gr}. +## @item nr +## The order of the obtained system @var{Gr}. ## @end table ## ## @strong{Algorithm}@* @@ -148,6 +176,9 @@ 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", prop); endswitch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-01 18:30:05
|
Revision: 9237 http://octave.svn.sourceforge.net/octave/?rev=9237&view=rev Author: paramaniac Date: 2011-12-01 18:29:55 +0000 (Thu, 01 Dec 2011) Log Message: ----------- control-devel: use argument handling from bstmodred for all *modred commands Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m trunk/octave-forge/extra/control-devel/inst/bstmodred.m trunk/octave-forge/extra/control-devel/inst/btamodred.m trunk/octave-forge/extra/control-devel/inst/hnamodred.m trunk/octave-forge/extra/control-devel/inst/spamodred.m Modified: trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-01 16:55:42 UTC (rev 9236) +++ trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-01 18:29:55 UTC (rev 9237) @@ -42,9 +42,22 @@ error ("%smodred: first argument must be an LTI system", method); endif - if (npv == 1) - varargin = __opt2cell__ (varargin{1}); - elseif (rem (npv, 2)) + 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 + + npv = numel (varargin); # number of properties and values + + if (rem (npv, 2)) error ("%smodred: properties and values must come in pairs", method); endif Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-01 16:55:42 UTC (rev 9236) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-01 18:29:55 UTC (rev 9237) @@ -243,9 +243,9 @@ ## nr > key/value > opt) endif - narg = numel (varargin); + npv = numel (varargin); # number of properties and values - if (rem (narg, 2)) + if (rem (npv, 2)) error ("bstmodred: keys and values must come in pairs"); endif @@ -262,7 +262,7 @@ job = 1; ## handle properties and values - for k = 1 : 2 : narg + for k = 1 : 2 : npv prop = lower (varargin{k}); val = varargin{k+1}; switch (prop) Modified: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-01 16:55:42 UTC (rev 9236) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-01 18:29:55 UTC (rev 9237) @@ -16,9 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{sysr}, @var{nr}] =} btamodred (@var{sys}) -## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} btamodred (@var{sys}, @dots{}) -## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} btamodred (@var{sys}, @var{opt}) +## @deftypefn{Function File} {[@var{Gr}, @var{nr}] =} btamodred (@var{G}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} btamodred (@var{G}, @var{nr}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} btamodred (@var{G}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} btamodred (@var{G}, @var{nr}, @var{opt}, @dots{}) +## ## Model order reduction by frequency weighted optimal Hankel-norm approximation method. ## ## @strong{Inputs} Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-01 16:55:42 UTC (rev 9236) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-01 18:29:55 UTC (rev 9237) @@ -16,9 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{sysr}, @var{info}] =} hnamodred (@var{sys}) -## @deftypefnx{Function File} {[@var{sysr}, @var{info}] =} hnamodred (@var{sys}, @dots{}) -## @deftypefnx{Function File} {[@var{sysr}, @var{info}] =} hnamodred (@var{sys}, @var{opt}) +## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} hnamodred (@var{G}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} hnamodred (@var{G}, @var{nr}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} hnamodred (@var{G}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} hnamodred (@var{G}, @var{nr}, @var{opt}, @dots{}) +## ## Model order reduction by frequency weighted optimal Hankel-norm approximation method. ## ## @strong{Inputs} @@ -57,9 +59,22 @@ error ("hnamodred: first argument must be an LTI system"); endif - if (nargin == 2) - varargin = __opt2cell__ (varargin{1}); - elseif (rem (nargin-1, 2)) + if (nargin > 1) # hnamodred (G, ...) + if (is_real_scalar (varargin{1})) # hnamodred (G, nr) + varargin = horzcat (varargin(2:end), {"order"}, varargin(1)); + endif + if (isstruct (varargin{1})) # hnamodred (G, opt, ...), hnamodred (G, nr, opt, ...) + varargin = horzcat (__opt2cell__ (varargin{1}), varargin(2:end)); + endif + ## order placed at the end such that nr from hnamodred (G, nr, ...) + ## and hnamodred (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 + + npv = numel (varargin); # number of properties and values + + if (rem (npv, 2)) error ("hnamodred: properties and values must come in pairs"); endif @@ -80,7 +95,7 @@ nr = 0; ## handle properties and values - for k = 1 : 2 : (nargin-1) + for k = 1 : 2 : npv prop = lower (varargin{k}); val = varargin{k+1}; switch (prop) Modified: trunk/octave-forge/extra/control-devel/inst/spamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-12-01 16:55:42 UTC (rev 9236) +++ trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-12-01 18:29:55 UTC (rev 9237) @@ -16,9 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{sysr}, @var{nr}] =} spamodred (@var{sys}) -## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} spamodred (@var{sys}, @dots{}) -## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} spamodred (@var{sys}, @var{opt}) +## @deftypefn{Function File} {[@var{Gr}, @var{nr}] =} spamodred (@var{G}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} spamodred (@var{G}, @var{nr}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} spamodred (@var{G}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} spamodred (@var{G}, @var{nr}, @var{opt}, @dots{}) +## ## Model order reduction by frequency weighted optimal Hankel-norm approximation method. ## ## @strong{Inputs} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-01 20:25:24
|
Revision: 9239 http://octave.svn.sourceforge.net/octave/?rev=9239&view=rev Author: paramaniac Date: 2011-12-01 20:25:17 +0000 (Thu, 01 Dec 2011) Log Message: ----------- control-devel: add first controller reduction code, doc fixes Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/btamodred.m trunk/octave-forge/extra/control-devel/inst/spamodred.m Added Paths: ----------- trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m trunk/octave-forge/extra/control-devel/inst/btaconred.m trunk/octave-forge/extra/control-devel/inst/spaconred.m Added: trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2011-12-01 20:25:17 UTC (rev 9239) @@ -0,0 +1,173 @@ +## 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{sysr}, @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 [sysr, 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 + + npv = numel (varargin); # number of properties and values + + if (rem (npv, 2)) + error ("%sconred: properties 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); + + ## 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; + dico = 0; + jobc = jobo = 0; + bf = true; # balancing-free + weight = 1; + equil = 0; + ordsel = 1; + nr = 0; + + ## handle properties and values + for k = 1 : 2 : npv + prop = lower (varargin{k}); + val = varargin{k+1}; + switch (prop) + case {"left", "v"} + [av, bv, cv, dv, jobv] = __modred_check_weight__ (val, dt, p, []); + + case {"right", "w"} + [aw, bw, cw, dw, jobw] = __modred_check_weight__ (val, dt, [], m); + + case {"order", "n", "nr"} + [nr, ordsel] = __modred_check_order__ (val); + + 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 "approach" + switch (tolower (val)) + case "sr" + bf = false; + case "bfsr" + bf = true; + otherwise + error ("modred: ""%s"" is an invalid approach", val); + endswitch + + ## TODO: alphac, alphao, jobc, jobo + + otherwise + warning ("modred: invalid property name ""%s"" ignored", prop); + 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, dico, equil, nr, ordsel, alpha, job, \ + av, bv, cv, dv, \ + aw, bw, cw, dw, \ + weight, jobc, jobo, alphac, alphao, \ + tol1, tol2); + + ## assemble reduced order model + sysr = ss (ar, br, cr, dr, tsam); + + ## assemble info struct + info = struct ("nr", nr, "ns", ns, "hsv", hsv); + +endfunction + + + + Added: trunk/octave-forge/extra/control-devel/inst/btaconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btaconred.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/btaconred.m 2011-12-01 20:25:17 UTC (rev 9239) @@ -0,0 +1,104 @@ +## 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{nr}, @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{nr}, @var{opt}, @dots{}) +## +## Model order reduction by frequency weighted optimal Hankel-norm approximation method. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI model to be reduced. +## @item @dots{} +## Pairs of properties and values. +## TODO: describe options. +## @end table +## +## @strong{Outputs} +## @table @var +## @item sysr +## Reduced order state-space model. +## @item nr +## The order of the obtained system @var{sysr}. +## @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 +%! 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 (AV, BV, CV, DV, "scaled", true); +%! +%! Kr = btaconred (G, K, 2, "weight", "ERROR", "tol1", 0.1, "tol2", 0.0); +%! [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 ]; +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [Ae, Be; Ce, De]; +%! +%!assert (Mo, Me, 1e-4); \ No newline at end of file Modified: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-01 19:56:49 UTC (rev 9238) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-01 20:25:17 UTC (rev 9239) @@ -16,10 +16,10 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{Gr}, @var{nr}] =} btamodred (@var{G}, @dots{}) -## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} btamodred (@var{G}, @var{nr}, @dots{}) -## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} btamodred (@var{G}, @var{opt}, @dots{}) -## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} btamodred (@var{G}, @var{nr}, @var{opt}, @dots{}) +## @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 optimal Hankel-norm approximation method. ## Added: trunk/octave-forge/extra/control-devel/inst/spaconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/spaconred.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/spaconred.m 2011-12-01 20:25:17 UTC (rev 9239) @@ -0,0 +1,58 @@ +## 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}] =} spaconred (@var{G}, @var{K}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} spaconred (@var{G}, @var{K}, @var{nr}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} spaconred (@var{G}, @var{K}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} spaconred (@var{G}, @var{K}, @var{nr}, @var{opt}, @dots{}) +## +## Model order reduction by frequency weighted optimal Hankel-norm approximation method. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI model to be reduced. +## @item @dots{} +## Pairs of properties and values. +## TODO: describe options. +## @end table +## +## @strong{Outputs} +## @table @var +## @item sysr +## Reduced order state-space model. +## @item nr +## The order of the obtained system @var{sysr}. +## @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] = spaconred (varargin) + + [Kr, info] = __conred_sb16ad__ ("spa", varargin{:}); + +endfunction + +## TODO: add a test \ No newline at end of file Modified: trunk/octave-forge/extra/control-devel/inst/spamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-12-01 19:56:49 UTC (rev 9238) +++ trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-12-01 20:25:17 UTC (rev 9239) @@ -16,10 +16,10 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{Gr}, @var{nr}] =} spamodred (@var{G}, @dots{}) -## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} spamodred (@var{G}, @var{nr}, @dots{}) -## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} spamodred (@var{G}, @var{opt}, @dots{}) -## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} spamodred (@var{G}, @var{nr}, @var{opt}, @dots{}) +## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} spamodred (@var{G}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} spamodred (@var{G}, @var{nr}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} spamodred (@var{G}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} spamodred (@var{G}, @var{nr}, @var{opt}, @dots{}) ## ## Model order reduction by frequency weighted optimal Hankel-norm approximation method. ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-05 14:10:11
|
Revision: 9273 http://octave.svn.sourceforge.net/octave/?rev=9273&view=rev Author: paramaniac Date: 2011-12-05 14:10:00 +0000 (Mon, 05 Dec 2011) Log Message: ----------- control-devel: get btaconred & spaconred working, touch up code Modified Paths: -------------- 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/bstmodred.m trunk/octave-forge/extra/control-devel/inst/btaconred.m trunk/octave-forge/extra/control-devel/inst/hnamodred.m trunk/octave-forge/extra/control-devel/inst/test_devel.m Modified: trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2011-12-05 04:42:34 UTC (rev 9272) +++ trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2011-12-05 14:10:00 UTC (rev 9273) @@ -59,10 +59,10 @@ ## nr > key/value > opt) endif - npv = numel (varargin); # number of properties and values + nkv = numel (varargin); # number of keys and values - if (rem (npv, 2)) - error ("%sconred: properties and values must come in pairs", method); + if (rem (nkv, 2)) + error ("%sconred: keys and values must come in pairs", method); endif [a, b, c, d, tsam, scaled] = ssdata (G); @@ -79,35 +79,38 @@ ## 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; - dico = 0; + dico = 0; %%%%%%%%%% jobc = jobo = 0; bf = true; # balancing-free - weight = 1; + weight = 0; equil = 0; ordsel = 1; - nr = 0; + ncr = 0; - ## handle properties and values - for k = 1 : 2 : npv - prop = lower (varargin{k}); + ## handle keys and values + for k = 1 : 2 : nkv + key = lower (varargin{k}); val = varargin{k+1}; - switch (prop) - case {"left", "v"} - [av, bv, cv, dv, jobv] = __modred_check_weight__ (val, dt, p, []); + 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 {"right", "w"} - [aw, bw, cw, dw, jobw] = __modred_check_weight__ (val, dt, [], m); + case {"order", "ncr", "nr"} + [ncr, ordsel] = __modred_check_order__ (val); - case {"order", "n", "nr"} - [nr, ordsel] = __modred_check_order__ (val); - case "tol1" tol1 = __modred_check_tol__ (val, "tol1"); @@ -127,35 +130,25 @@ error ("modred: ""%s"" is an invalid approach", val); endswitch - ## TODO: alphac, alphao, jobc, jobo + ## TODO: jobc, jobo otherwise warning ("modred: invalid property name ""%s"" ignored", prop); 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; + jobmr = 0; elseif (method == "bta" && bf) # 'F': use the balancing-free square-root Balance & Truncate method - job = 1; + jobmr = 1; elseif (method == "spa" && ! bf) # 'S': use the square-root Singular Perturbation Approximation method - job = 2; + jobmr = 2; elseif (method == "spa" && bf) # 'P': use the balancing-free square-root Singular Perturbation Approximation method - job = 3; + jobmr = 3; else - error ("modred: invalid job option"); # this should never happen + error ("modred: invalid jobmr option"); # this should never happen endif Modified: trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-05 04:42:34 UTC (rev 9272) +++ trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-05 14:10:00 UTC (rev 9273) @@ -54,10 +54,10 @@ ## nr > key/value > opt) endif - npv = numel (varargin); # number of properties and values + nkv = numel (varargin); # number of keys and values - if (rem (npv, 2)) - error ("%smodred: properties and values must come in pairs", method); + if (rem (nkv, 2)) + error ("%smodred: keys and values must come in pairs", method); endif [a, b, c, d, tsam, scaled] = ssdata (sys); @@ -73,7 +73,6 @@ alphac = alphao = 0.0; tol1 = 0.0; tol2 = 0.0; - dico = 0; jobc = jobo = 0; bf = true; # balancing-free weight = 1; @@ -81,11 +80,11 @@ ordsel = 1; nr = 0; - ## handle properties and values - for k = 1 : 2 : npv - prop = lower (varargin{k}); + ## handle keys and values + for k = 1 : 2 : nkv + key = lower (varargin{k}); val = varargin{k+1}; - switch (prop) + switch (key) case {"left", "v"} [av, bv, cv, dv, jobv] = __modred_check_weight__ (val, dt, p, []); @@ -147,7 +146,7 @@ ## perform model order reduction - [ar, br, cr, dr, nr, hsv, ns] = slab09id (a, b, c, d, dico, equil, nr, ordsel, alpha, job, \ + [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, \ Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-05 04:42:34 UTC (rev 9272) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-05 14:10:00 UTC (rev 9273) @@ -243,9 +243,9 @@ ## nr > key/value > opt) endif - npv = numel (varargin); # number of properties and values + nkv = numel (varargin); # number of keys and values - if (rem (npv, 2)) + if (rem (nkv, 2)) error ("bstmodred: keys and values must come in pairs"); endif @@ -261,11 +261,11 @@ nr = 0; job = 1; - ## handle properties and values - for k = 1 : 2 : npv - prop = lower (varargin{k}); + ## handle keys and values + for k = 1 : 2 : nkv + key = lower (varargin{k}); val = varargin{k+1}; - switch (prop) + switch (key) case {"order", "nr"} [nr, ordsel] = __modred_check_order__ (val); Modified: trunk/octave-forge/extra/control-devel/inst/btaconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btaconred.m 2011-12-05 04:42:34 UTC (rev 9272) +++ trunk/octave-forge/extra/control-devel/inst/btaconred.m 2011-12-05 14:10:00 UTC (rev 9273) @@ -85,7 +85,7 @@ %! %! K = ss (AC, BC, CC, DC, "scaled", true); %! -%! Kr = btaconred (G, K, 2, "weight", "ERROR", "tol1", 0.1, "tol2", 0.0); +%! Kr = btaconred (G, K, 2, "weight", "input", "tol1", 0.1, "tol2", 0.0); %! [Ao, Bo, Co, Do] = ssdata (Kr); %! %! Ae = [ 9.1900 0.0000 Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-05 04:42:34 UTC (rev 9272) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-05 14:10:00 UTC (rev 9273) @@ -72,10 +72,10 @@ ## nr > key/value > opt) endif - npv = numel (varargin); # number of properties and values + nkv = numel (varargin); # number of keys and values - if (rem (npv, 2)) - error ("hnamodred: properties and values must come in pairs"); + if (rem (nkv, 2)) + error ("hnamodred: keys and values must come in pairs"); endif [a, b, c, d, tsam, scaled] = ssdata (sys); @@ -94,11 +94,11 @@ ordsel = 1; nr = 0; - ## handle properties and values - for k = 1 : 2 : npv - prop = lower (varargin{k}); + ## handle keys and values + for k = 1 : 2 : nkv + key = lower (varargin{k}); val = varargin{k+1}; - switch (prop) + switch (key) case {"left", "v"} [av, bv, cv, dv, jobv] = __modred_check_weight__ (val, dt, p, p); ## TODO: correct error messages for non-square weights Modified: trunk/octave-forge/extra/control-devel/inst/test_devel.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/test_devel.m 2011-12-05 04:42:34 UTC (rev 9272) +++ trunk/octave-forge/extra/control-devel/inst/test_devel.m 2011-12-05 14:10:00 UTC (rev 9273) @@ -1,7 +1,10 @@ -# identification +## identification test fitfrd -# model order reduction +## model order reduction test bstmodred test btamodred test hnamodred + +## controller order reduction +test btaconred This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-05 14:18:53
|
Revision: 9274 http://octave.svn.sourceforge.net/octave/?rev=9274&view=rev Author: paramaniac Date: 2011-12-05 14:18:46 +0000 (Mon, 05 Dec 2011) Log Message: ----------- control-devel: touch up draft code Modified Paths: -------------- 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/hnamodred.m Modified: trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2011-12-05 14:10:00 UTC (rev 9273) +++ trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2011-12-05 14:18:46 UTC (rev 9274) @@ -81,14 +81,14 @@ alpha = __modred_default_alpha__ (dt); tol1 = 0.0; tol2 = 0.0; - dico = 0; %%%%%%%%%% jobc = jobo = 0; bf = true; # balancing-free weight = 0; - equil = 0; + equil = scaled && scaledc; ordsel = 1; ncr = 0; + ## handle keys and values for k = 1 : 2 : nkv key = lower (varargin{k}); @@ -131,6 +131,9 @@ endswitch ## TODO: jobc, jobo + + case {"equil", "equilibrate", "equilibration", "scale", "scaling"} + scaled = __modred_check_equil__ (val); otherwise warning ("modred: invalid property name ""%s"" ignored", prop); @@ -153,7 +156,7 @@ ## perform model order reduction - [acr, bcr, ccr, dcr, ncr, hsvc, ncs] = slsb16ad (a, b, c, d, dico, equil, ncr, ordsel, alpha, jobmr, \ + [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); Modified: trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-05 14:10:00 UTC (rev 9273) +++ trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-05 14:18:46 UTC (rev 9274) @@ -115,6 +115,9 @@ ## TODO: alphac, alphao, jobc, jobo + case {"equil", "equilibrate", "equilibration", "scale", "scaling"} + scaled = __modred_check_equil__ (val); + otherwise warning ("modred: invalid property name ""%s"" ignored", prop); endswitch Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-05 14:10:00 UTC (rev 9273) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-05 14:18:46 UTC (rev 9274) @@ -154,6 +154,9 @@ error ("hnamodred: invalid computational approach"); endswitch + case {"equil", "equilibrate", "equilibration", "scale", "scaling"} + scaled = __modred_check_equil__ (val); + otherwise warning ("hnamodred: invalid property name ""%s"" ignored", prop); endswitch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-05 21:04:34
|
Revision: 9276 http://octave.svn.sourceforge.net/octave/?rev=9276&view=rev Author: paramaniac Date: 2011-12-05 21:04:27 +0000 (Mon, 05 Dec 2011) Log Message: ----------- control-devel: work on tests Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/btamodred.m trunk/octave-forge/extra/control-devel/inst/cfconred.m Modified: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-05 16:07:29 UTC (rev 9275) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-05 21:04:27 UTC (rev 9276) @@ -91,7 +91,7 @@ %! %! sysv = ss (AV, BV, CV, DV); %! -%! sysr = btamodred (sys, "nr", 2, "left", sysv, "tol1", 0.1, "tol2", 0.0); +%! sysr = btamodred (sys, 2, "left", sysv, "tol1", 0.1, "tol2", 0.0); %! [Ao, Bo, Co, Do] = ssdata (sysr); %! %! Ae = [ 9.1900 0.0000 @@ -107,4 +107,4 @@ %! Mo = [Ao, Bo; Co, Do]; %! Me = [Ae, Be; Ce, De]; %! -%!assert (Mo, Me, 1e-4); \ No newline at end of file +%!assert (Mo, Me, 1e-4); Modified: trunk/octave-forge/extra/control-devel/inst/cfconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/cfconred.m 2011-12-05 16:07:29 UTC (rev 9275) +++ trunk/octave-forge/extra/control-devel/inst/cfconred.m 2011-12-05 21:04:27 UTC (rev 9276) @@ -210,5 +210,60 @@ endfunction - - +%!shared Mo, Me +%! A = [ 0 1.0000 0 0 0 0 0 0 +%! 0 0 0 0 0 0 0 0 +%! 0 0 -0.0150 0.7650 0 0 0 0 +%! 0 0 -0.7650 -0.0150 0 0 0 0 +%! 0 0 0 0 -0.0280 1.4100 0 0 +%! 0 0 0 0 -1.4100 -0.0280 0 0 +%! 0 0 0 0 0 0 -0.0400 1.850 +%! 0 0 0 0 0 0 -1.8500 -0.040 ]; +%! +%! B = [ 0.0260 +%! -0.2510 +%! 0.0330 +%! -0.8860 +%! -4.0170 +%! 0.1450 +%! 3.6040 +%! 0.2800 ]; +%! +%! C = [ -.996 -.105 0.261 .009 -.001 -.043 0.002 -0.026 ]; +%! +%! D = [ 0.0 ]; +%! +%! Go = ss (A, B, C, D); % "scaled", false +%! +%! F = [ 4.4721e-002 6.6105e-001 4.6986e-003 3.6014e-001 1.0325e-001 -3.7541e-002 -4.2685e-002 3.2873e-002 ]; +%! +%! G = [ 4.1089e-001 +%! 8.6846e-002 +%! 3.8523e-004 +%! -3.6194e-003 +%! -8.8037e-003 +%! 8.4205e-003 +%! 1.2349e-003 +%! 4.2632e-003 ]; +%! +%! Kr = cfconred (Go, F, G, 4, "ERROR", "left", "tol1", 0.1, "tol2", 0.0); +%! [Ao, Bo, Co, Do] = ssdata (Kr); +%! +%! Ae = [ 0.5946 -0.7336 0.1914 -0.3368 +%! 0.5960 -0.0184 -0.1088 0.0207 +%! 1.2253 0.2043 0.1009 -1.4948 +%! -0.0330 -0.0243 1.3440 0.0035 ]; +%! +%! Be = [ 0.0015 +%! -0.0202 +%! 0.0159 +%! -0.0544 ]; +%! +%! Ce = [ 0.3534 0.0274 0.0337 -0.0320 ]; +%! +%! De = [ 0.0000 ]; +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [Ae, Be; Ce, De]; +%! +%!assert (Mo, Me, 1e-4); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-05 21:07:36
|
Revision: 9277 http://octave.svn.sourceforge.net/octave/?rev=9277&view=rev Author: paramaniac Date: 2011-12-05 21:07:30 +0000 (Mon, 05 Dec 2011) Log Message: ----------- control-devel: fix variable name Modified Paths: -------------- 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/bstmodred.m trunk/octave-forge/extra/control-devel/inst/cfconred.m trunk/octave-forge/extra/control-devel/inst/hnamodred.m Modified: trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2011-12-05 21:04:27 UTC (rev 9276) +++ trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2011-12-05 21:07:30 UTC (rev 9277) @@ -136,7 +136,7 @@ scaled = __modred_check_equil__ (val); otherwise - warning ("modred: invalid property name ""%s"" ignored", prop); + warning ("modred: invalid property name ""%s"" ignored", key); endswitch endfor Modified: trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-05 21:04:27 UTC (rev 9276) +++ trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-05 21:07:30 UTC (rev 9277) @@ -119,7 +119,7 @@ scaled = __modred_check_equil__ (val); otherwise - warning ("modred: invalid property name ""%s"" ignored", prop); + warning ("modred: invalid property name ""%s"" ignored", key); endswitch endfor Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-05 21:04:27 UTC (rev 9276) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-05 21:07:30 UTC (rev 9277) @@ -302,7 +302,7 @@ scaled = __modred_check_equil__ (val); otherwise - warning ("bstmodred: invalid property name ""%s"" ignored", prop); + warning ("bstmodred: invalid property name ""%s"" ignored", key); endswitch endfor Modified: trunk/octave-forge/extra/control-devel/inst/cfconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/cfconred.m 2011-12-05 21:04:27 UTC (rev 9276) +++ trunk/octave-forge/extra/control-devel/inst/cfconred.m 2011-12-05 21:07:30 UTC (rev 9277) @@ -177,7 +177,7 @@ scaled = __modred_check_equil__ (val); otherwise - warning ("modred: invalid property name ""%s"" ignored", prop); + warning ("modred: invalid property name ""%s"" ignored", key); endswitch endfor Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-05 21:04:27 UTC (rev 9276) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-05 21:07:30 UTC (rev 9277) @@ -158,7 +158,7 @@ scaled = __modred_check_equil__ (val); otherwise - warning ("hnamodred: invalid property name ""%s"" ignored", prop); + warning ("hnamodred: invalid property name ""%s"" ignored", key); endswitch endfor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-05 21:39:51
|
Revision: 9279 http://octave.svn.sourceforge.net/octave/?rev=9279&view=rev Author: paramaniac Date: 2011-12-05 21:39:45 +0000 (Mon, 05 Dec 2011) Log Message: ----------- control-devel: minor changes Modified Paths: -------------- 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/cfconred.m Modified: trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2011-12-05 21:38:15 UTC (rev 9278) +++ trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2011-12-05 21:39:45 UTC (rev 9279) @@ -136,7 +136,7 @@ scaled = __modred_check_equil__ (val); otherwise - warning ("modred: invalid property name ""%s"" ignored", key); + warning ("%sconred: invalid property name ""%s"" ignored", method, key); endswitch endfor @@ -151,7 +151,7 @@ elseif (method == "spa" && bf) # 'P': use the balancing-free square-root Singular Perturbation Approximation method jobmr = 3; else - error ("modred: invalid jobmr option"); # this should never happen + error ("%smodred: invalid jobmr option"); # this should never happen endif Modified: trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-05 21:38:15 UTC (rev 9278) +++ trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-05 21:39:45 UTC (rev 9279) @@ -119,7 +119,7 @@ scaled = __modred_check_equil__ (val); otherwise - warning ("modred: invalid property name ""%s"" ignored", key); + warning ("%smodred: invalid property name ""%s"" ignored", method, key); endswitch endfor Modified: trunk/octave-forge/extra/control-devel/inst/cfconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/cfconred.m 2011-12-05 21:38:15 UTC (rev 9278) +++ trunk/octave-forge/extra/control-devel/inst/cfconred.m 2011-12-05 21:39:45 UTC (rev 9279) @@ -98,7 +98,7 @@ nkv = numel (varargin); # number of keys and values if (rem (nkv, 2)) - error ("%sconred: keys and values must come in pairs", method); + error ("cfconred: keys and values must come in pairs"); endif [a, b, c, d, tsam, scaled] = ssdata (Go); @@ -146,7 +146,7 @@ case {"b", "p"} # both, performance weight = 3; otherwise - error ("%sconred: ""%s"" is an invalid value for key weight", method, val); + error ("cfconred: ""%s"" is an invalid value for key weight", val); endswitch case {"order", "ncr", "nr"} @@ -177,7 +177,7 @@ scaled = __modred_check_equil__ (val); otherwise - warning ("modred: invalid property name ""%s"" ignored", key); + warning ("cfconred: invalid property name ""%s"" ignored", key); endswitch endfor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-06 20:36:57
|
Revision: 9292 http://octave.svn.sourceforge.net/octave/?rev=9292&view=rev Author: paramaniac Date: 2011-12-06 20:36:51 +0000 (Tue, 06 Dec 2011) Log Message: ----------- control-devel: replace "" by ' Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m trunk/octave-forge/extra/control-devel/inst/__iddata_dim__.m trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m trunk/octave-forge/extra/control-devel/inst/__modred_check_equil__.m trunk/octave-forge/extra/control-devel/inst/bstmodred.m trunk/octave-forge/extra/control-devel/inst/cfconred.m trunk/octave-forge/extra/control-devel/inst/hnamodred.m Modified: trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2011-12-06 20:36:04 UTC (rev 9291) +++ trunk/octave-forge/extra/control-devel/inst/__conred_sb16ad__.m 2011-12-06 20:36:51 UTC (rev 9292) @@ -105,7 +105,7 @@ case {"b", "p"} # both, performance weight = 3; otherwise - error ("%sconred: ""%s"" is an invalid value for key weight", method, val); + error ("%sconred: '%s' is an invalid value for key weight", method, val); endswitch case {"order", "ncr", "nr"} @@ -127,7 +127,7 @@ case "bfsr" bf = true; otherwise - error ("modred: ""%s"" is an invalid approach", val); + error ("modred: '%s' is an invalid approach", val); endswitch ## TODO: jobc, jobo @@ -136,7 +136,7 @@ scaled = __modred_check_equil__ (val); otherwise - warning ("%sconred: invalid property name ""%s"" ignored", method, key); + warning ("%sconred: invalid property name '%s' ignored", method, key); endswitch endfor Modified: trunk/octave-forge/extra/control-devel/inst/__iddata_dim__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__iddata_dim__.m 2011-12-06 20:36:04 UTC (rev 9291) +++ trunk/octave-forge/extra/control-devel/inst/__iddata_dim__.m 2011-12-06 20:36:51 UTC (rev 9292) @@ -12,15 +12,15 @@ [lu, m] = size (u); if (ly != lu) - error ("iddata: matrices ""y"" and ""u"" must have the same number of samples (rows)"); + error ("iddata: matrices 'y' and 'u' must have the same number of samples (rows)"); endif if (ly < p) - warning ("iddata: more outputs than samples - matrice ""y"" should probably be transposed"); + warning ("iddata: more outputs than samples - matrice 'y' should probably be transposed"); endif if (lu < m) - warning ("iddata: more inputs than samples - matrice ""u"" should probably be transposed"); + warning ("iddata: more inputs than samples - matrice 'u' should probably be transposed"); endif endfunction \ No newline at end of file Modified: trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-06 20:36:04 UTC (rev 9291) +++ trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-06 20:36:51 UTC (rev 9292) @@ -110,7 +110,7 @@ case "bfsr" bf = true; otherwise - error ("modred: ""%s"" is an invalid approach", val); + error ("modred: '%s' is an invalid approach", val); endswitch ## TODO: alphac, alphao, jobc, jobo @@ -119,7 +119,7 @@ scaled = __modred_check_equil__ (val); otherwise - warning ("%smodred: invalid property name ""%s"" ignored", method, key); + warning ("%smodred: invalid property name '%s' ignored", method, key); endswitch endfor Modified: trunk/octave-forge/extra/control-devel/inst/__modred_check_equil__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_check_equil__.m 2011-12-06 20:36:04 UTC (rev 9291) +++ trunk/octave-forge/extra/control-devel/inst/__modred_check_equil__.m 2011-12-06 20:36:51 UTC (rev 9292) @@ -27,7 +27,7 @@ if (isscalar (equil)) scaled = ! logical (equil); else - error ("modred: property ""equil"" must be a logical value"); + error ("modred: property 'equil' must be a logical value"); endif endfunction \ No newline at end of file Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-06 20:36:04 UTC (rev 9291) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-06 20:36:51 UTC (rev 9292) @@ -295,14 +295,14 @@ 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); + 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); + warning ("bstmodred: invalid property name '%s' ignored", key); endswitch endfor Modified: trunk/octave-forge/extra/control-devel/inst/cfconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/cfconred.m 2011-12-06 20:36:04 UTC (rev 9291) +++ trunk/octave-forge/extra/control-devel/inst/cfconred.m 2011-12-06 20:36:51 UTC (rev 9292) @@ -146,7 +146,7 @@ case {"b", "p"} # both, performance weight = 3; otherwise - error ("cfconred: ""%s"" is an invalid value for key weight", val); + error ("cfconred: '%s' is an invalid value for key weight", val); endswitch case {"order", "ncr", "nr"} @@ -168,7 +168,7 @@ case "bfsr" bf = true; otherwise - error ("modred: ""%s"" is an invalid approach", val); + error ("modred: '%s' is an invalid approach", val); endswitch ## TODO: jobc, jobo @@ -177,7 +177,7 @@ scaled = __modred_check_equil__ (val); otherwise - warning ("cfconred: invalid property name ""%s"" ignored", key); + warning ("cfconred: invalid property name '%s' ignored", key); endswitch endfor Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-06 20:36:04 UTC (rev 9291) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-06 20:36:51 UTC (rev 9292) @@ -158,7 +158,7 @@ scaled = __modred_check_equil__ (val); otherwise - warning ("hnamodred: invalid property name ""%s"" ignored", key); + warning ("hnamodred: invalid property name '%s' ignored", key); endswitch endfor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-07 13:20:59
|
Revision: 9297 http://octave.svn.sourceforge.net/octave/?rev=9297&view=rev Author: paramaniac Date: 2011-12-07 13:20:49 +0000 (Wed, 07 Dec 2011) Log Message: ----------- control-devel: remove tol1 and tol2 for tests where order is fixed Modified Paths: -------------- 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 Added Paths: ----------- trunk/octave-forge/extra/control-devel/inst/fwcfconred.m Modified: trunk/octave-forge/extra/control-devel/inst/btaconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btaconred.m 2011-12-07 13:03:06 UTC (rev 9296) +++ trunk/octave-forge/extra/control-devel/inst/btaconred.m 2011-12-07 13:20:49 UTC (rev 9297) @@ -85,7 +85,7 @@ %! %! K = ss (AC, BC, CC, DC, "scaled", true); %! -%! Kr = btaconred (G, K, 2, "weight", "input", "tol1", 0.1, "tol2", 0.0); +%! Kr = btaconred (G, K, 2, "weight", "input"); %! [Ao, Bo, Co, Do] = ssdata (Kr); %! %! Ae = [ 9.1900 0.0000 Modified: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-07 13:03:06 UTC (rev 9296) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-07 13:20:49 UTC (rev 9297) @@ -91,7 +91,7 @@ %! %! sysv = ss (AV, BV, CV, DV); %! -%! sysr = btamodred (sys, 2, "left", sysv, "tol1", 0.1, "tol2", 0.0); +%! sysr = btamodred (sys, 2, "left", sysv); %! [Ao, Bo, Co, Do] = ssdata (sysr); %! %! Ae = [ 9.1900 0.0000 Modified: trunk/octave-forge/extra/control-devel/inst/cfconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/cfconred.m 2011-12-07 13:03:06 UTC (rev 9296) +++ trunk/octave-forge/extra/control-devel/inst/cfconred.m 2011-12-07 13:20:49 UTC (rev 9297) @@ -57,7 +57,6 @@ ## @strong{Algorithm}@* ## Uses SLICOT SB16BD by courtesy of ## @uref{http://www.slicot.org, NICONET e.V.} - ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> @@ -225,7 +224,7 @@ %! 1.2349e-003 %! 4.2632e-003 ]; %! -%! [Kr, Info] = cfconred (Go, F, G, 4, "method", "bfsr-bta", "cf", "left", "tol1", 0.1, "tol2", 0.0); +%! [Kr, Info] = cfconred (Go, F, G, 4, "method", "bfsr-bta", "cf", "left"); %! [Ao, Bo, Co, Do] = ssdata (Kr); %! %! Ae = [ 0.5946 -0.7336 0.1914 -0.3368 Added: trunk/octave-forge/extra/control-devel/inst/fwcfconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/fwcfconred.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/fwcfconred.m 2011-12-07 13:20:49 UTC (rev 9297) @@ -0,0 +1,240 @@ +## 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 (@var{Go}, @var{F}, @var{G}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} conred (@var{Go}, @var{F}, @var{G}, @var{nr}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} conred (@var{Go}, @var{F}, @var{G}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} conred (@var{Go}, @var{F}, @var{G}, @var{nr}, @var{opt}, @dots{}) +## +## Coprime factor reduction for state-feedback-observer based controllers. +## +## @strong{Inputs} +## @table @var +## @item Go +## LTI model of the open-loop plant (A,B,C,D). +## It has m inputs, p outputs and n states. +## @item F +## Stabilizing state feedback matrix (m-by-n). +## @item G +## Stabilizing observer gain matrix (n-by-p). +## @item @dots{} +## Optional pairs of keys and values. +## @item opt +## Optional struct with keys as field names. +## @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.hsv +## The Hankel singular values of the extended system?!?. +## The @var{n} Hankel singular values are ordered decreasingly. +## @item info.ncr +## The order of the obtained reduced order controller @var{Kr}. +## @end table +## @end table +## +## +## @strong{Algorithm}@* +## Uses SLICOT SB16CD 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] = fwcfconred (Go, F, G, varargin) + + if (nargin < 3) + print_usage (); + endif + + if (! isa (Go, "lti")) + error ("cfconred: first argument must be an LTI system"); + endif + + if (! is_real_matrix (F)) + error ("cfconred: second argument must be a real matrix"); + endif + + if (! is_real_matrix (G)) + error ("cfconred: third argument must be a real matrix"); + endif + + if (nargin > 3) # fwcfconred (Go, F, G, ...) + if (is_real_scalar (varargin{1})) # fwcfconred (Go, F, G, nr) + varargin = horzcat (varargin(2:end), {"order"}, varargin(1)); + endif + if (isstruct (varargin{1})) # fwcfconred (Go, F, G, opt, ...), fwcfconred (Go, F, G, nr, opt, ...) + varargin = horzcat (__opt2cell__ (varargin{1}), varargin(2:end)); + endif + ## order placed at the end such that nr from fwcfconred (Go, F, G, nr, ...) + ## and fwcfconred (Go, F, 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 ("cfconred: keys and values must come in pairs"); + endif + + [a, b, c, d, tsam, scaled] = ssdata (Go); + [p, m] = size (Go); + n = rows (a); + [mf, nf] = size (F); + [ng, pg] = size (G); + dt = isdt (Go); + jobd = any (d(:)); + + if (mf != m || nf != n) + error ("cfconred: dimensions of state-feedback matrix (%dx%d) and plant (%dx%d, %d states) don't match", \ + mf, nf, p, m, n); + endif + + if (ng != n || pg != p) + error ("cfconred: dimensions of observer matrix (%dx%d) and plant (%dx%d, %d states) don't match", \ + ng, pg, p, m, n); + endif + + ## default arguments + tol1 = 0.0; + tol2 = 0.0; + jobcf = 0; + jobmr = 2; # balancing-free BTA + equil = scaled && scaledc; + ordsel = 1; + ncr = 0; + + + ## handle keys and values + for k = 1 : 2 : nkv + key = lower (varargin{k}); + val = varargin{k+1}; + switch (key) + case {"order", "ncr", "nr"} + [ncr, ordsel] = __modred_check_order__ (val); + + case {"tol1", "tol"} + tol1 = __modred_check_tol__ (val, "tol1"); + + case "cf" + switch (lower (val(1))) + case "l" + jobcf = 0; + case "r" + jobcf = 1; + otherwise + error ("cfconred: '%s' is an invalid coprime factorization", val); + endswitch + + case {"method", "approach", "approx"} # approximation method + switch (tolower (val)) + case {"sr-bta", "b", "sr"} # 'B': use the square-root Balance & Truncate method + jobmr = 0; + case {"bfsr-bta", "f", "bfsr"} # 'F': use the balancing-free square-root Balance & Truncate method + jobmr = 1; + otherwise + error ("cfconred: '%s' is an invalid approach", val); + endswitch + + otherwise + warning ("cfconred: invalid property name '%s' ignored", key); + endswitch + endfor + + + ## perform model order reduction + [acr, bcr, ccr, ncr, hsv] = slsb16bd (a, b, c, d, dt, ncr, ordsel, jobd, jobmr, \ + F, G, jobcf, tol1); + + ## assemble reduced order controller + Kr = ss (acr, bcr, ccr, [], tsam); + + ## assemble info struct + info = struct ("ncr", ncr, "hsv", hsv); + +endfunction + + +%!shared Mo, Me, Info, HSVe +%! A = [ 0 1.0000 0 0 0 0 0 0 +%! 0 0 0 0 0 0 0 0 +%! 0 0 -0.0150 0.7650 0 0 0 0 +%! 0 0 -0.7650 -0.0150 0 0 0 0 +%! 0 0 0 0 -0.0280 1.4100 0 0 +%! 0 0 0 0 -1.4100 -0.0280 0 0 +%! 0 0 0 0 0 0 -0.0400 1.850 +%! 0 0 0 0 0 0 -1.8500 -0.040 ]; +%! +%! B = [ 0.0260 +%! -0.2510 +%! 0.0330 +%! -0.8860 +%! -4.0170 +%! 0.1450 +%! 3.6040 +%! 0.2800 ]; +%! +%! C = [ -.996 -.105 0.261 .009 -.001 -.043 0.002 -0.026 ]; +%! +%! D = [ 0.0 ]; +%! +%! Go = ss (A, B, C, D); % "scaled", false +%! +%! F = [ 4.4721e-002 6.6105e-001 4.6986e-003 3.6014e-001 1.0325e-001 -3.7541e-002 -4.2685e-002 3.2873e-002 ]; +%! +%! G = [ 4.1089e-001 +%! 8.6846e-002 +%! 3.8523e-004 +%! -3.6194e-003 +%! -8.8037e-003 +%! 8.4205e-003 +%! 1.2349e-003 +%! 4.2632e-003 ]; +%! +%! [Kr, Info] = fwcfconred (Go, F, G, 2, "method", "bfsr", "cf", "right"); +%! [Ao, Bo, Co, Do] = ssdata (Kr); +%! +%! Ae = [ 0.5946 -0.7336 0.1914 -0.3368 +%! 0.5960 -0.0184 -0.1088 0.0207 +%! 1.2253 0.2043 0.1009 -1.4948 +%! -0.0330 -0.0243 1.3440 0.0035 ]; +%! +%! Be = [ 0.0015 +%! -0.0202 +%! 0.0159 +%! -0.0544 ]; +%! +%! Ce = [ 0.3534 0.0274 0.0337 -0.0320 ]; +%! +%! De = [ 0.0000 ]; +%! +%! HSVe = [ 4.9078 4.8745 3.8455 3.7811 1.2289 1.1785 0.5176 0.1148 ].'; +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [Ae, Be; Ce, De]; +%! +%!assert (Mo, Me, 1e-4); +%!assert (Info.hsv, HSVe, 1e-4); \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-08 21:08:38
|
Revision: 9311 http://octave.svn.sourceforge.net/octave/?rev=9311&view=rev Author: paramaniac Date: 2011-12-08 21:08:31 +0000 (Thu, 08 Dec 2011) Log Message: ----------- control-devel: work on doc Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/bstmodred.m trunk/octave-forge/extra/control-devel/inst/hnamodred.m Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-08 10:02:29 UTC (rev 9310) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-08 21:08:31 UTC (rev 9311) @@ -154,7 +154,7 @@ ## @var{nr} can be further reduced to ensure that ## @code{HSV(NR-NU) > HSV(NR+1-NU)}. ## -## @item "approx", "approach" +## @item "method", "approx", "approach" ## Approximation method for the H-infinity norm. ## Valid values corresponding to this key are: ## @table @var @@ -291,7 +291,7 @@ endif beta = val; - case {"approx", "approach"} # approximation method + case {"method", "approx", "approach"} # approximation method switch (tolower (val)) case {"sr-bta", "b"} # 'B': use the square-root Balance & Truncate method job = 0; Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-08 10:02:29 UTC (rev 9310) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-08 21:08:31 UTC (rev 9311) @@ -21,12 +21,16 @@ ## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} hnamodred (@var{G}, @var{opt}, @dots{}) ## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} hnamodred (@var{G}, @var{nr}, @var{opt}, @dots{}) ## -## Model order reduction by frequency weighted optimal Hankel-norm approximation method. +## Model order reduction by frequency weighted optimal Hankel-norm (HNA) 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}. ## +## HNA is an absolute error method which tries to minimize ## @iftex ## @tex ## $$ || G - G_r ||_H = min $$ -## $$ || W_o (G - G_r) W_i ||_H = min $$ +## $$ || W_o \\ (G - G_r) \\ W_i ||_H = min $$ ## @end tex ## @end iftex ## @ifnottex @@ -38,7 +42,12 @@ ## H ## @end example ## @end ifnottex +## where @var{Wo} and @var{Wi} denote output and input weightings. ## +## UNSTABLE (from bstmodred) +## +## MIMO (from bstmodred) +## ## Approximation Properties: ## @itemize @bullet ## @item @@ -46,35 +55,94 @@ ## @item ## Lower guaranteed error bound ## @item -## Reduction of unstable systems in combination with modal -## or coprime factorization techniques. -## @item ## Guaranteed a priori error bound ## @iftex ## @tex -## $$ || (G-G_r) ||_{\\infty} \\leq 2 \\sum_{j=r+1}^{n} \\sigma_j $$ +## $$ \\sigma_{r+1} \\leq || (G-G_r) ||_{\\infty} \\leq 2 \\sum_{j=r+1}^{n} \\sigma_j $$ ## @end tex ## @end iftex ## @end itemize - ## +## ## @strong{Inputs} ## @table @var -## @item sys +## @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{} -## Pairs of properties and values. -## TODO: describe options. +## 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 sysr +## @item Gr ## Reduced order state-space model. -## @item nr -## The order of the obtained system @var{sysr}. +## @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*HNORM(As,Bs,Cs))}; +## +## @item "method", "approach" +## Specifies the computational approach to be used. +## Valid values corresponding to this key are: +## @table @var +## @item "descriptor" +## Use the inverse free descriptor system approach. +## @item "standard" +## Use the inversion based standard approach. +## @item "auto" +## Switch automatically to the inverse free +## descriptor approach in case of badly conditioned +## feedthrough matrices in V or W. Default 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 "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 +## ## @strong{Algorithm}@* ## Uses SLICOT AB09JD by courtesy of ## @uref{http://www.slicot.org, NICONET e.V.} @@ -134,11 +202,11 @@ key = lower (varargin{k}); val = varargin{k+1}; switch (key) - case {"left", "v"} + case {"left", "v", "wo"} [av, bv, cv, dv, jobv] = __modred_check_weight__ (val, dt, p, p); ## TODO: correct error messages for non-square weights - case {"right", "w"} + case {"right", "w", "wi"} [aw, bw, cw, dw, jobw] = __modred_check_weight__ (val, dt, m, m); case {"left-inv", "inv-v"} @@ -165,7 +233,7 @@ [aw, bw, cw, dw] = __modred_check_weight__ (val, dt, m, m); jobv = 4 - case {"order", "n", "nr"} + case {"order", "nr"} [nr, ordsel] = __modred_check_order__ (val); case "tol1" @@ -177,7 +245,7 @@ case "alpha" alpha = __modred_check_alpha__ (val, dt); - case {"approach", "jobinv"} + case {"method", "approach", "jobinv"} switch (tolower (val(1))) case {"d", "n"} # "descriptor" jobinv = 0; @@ -208,12 +276,14 @@ sysr = ss (ar, br, cr, dr, tsam); ## assemble info struct - info = struct ("nr", nr, "ns", ns, "hsv", hsv); + n = rows (a); + nu = n - ns; + info = struct ("n", n, "ns", ns, "hsv", hsv, "nu", nu, "nr", nr); endfunction -%!shared Mo, Me +%!shared Mo, Me, Info, HSVe %! A = [ -3.8637 -7.4641 -9.1416 -7.4641 -3.8637 -1.0000 %! 1.0000, 0 0 0 0 0 %! 0 1.0000 0 0 0 0 @@ -232,7 +302,7 @@ %! %! D = [ 0 ]; %! -%! sys = ss (A, B, C, D); # "scaled", false +%! G = ss (A, B, C, D); # "scaled", false %! %! AV = [ 0.2000 -1.0000 %! 1.0000 0 ]; @@ -244,10 +314,10 @@ %! %! DV = [ 1 ]; %! -%! sysv = ss (AV, BV, CV, DV); +%! V = ss (AV, BV, CV, DV); %! -%! sysr = hnamodred (sys, "left", sysv, "tol1", 1e-1, "tol2", 1e-14); -%! [Ao, Bo, Co, Do] = ssdata (sysr); +%! [Gr, Info] = hnamodred (G, "left", V, "tol1", 1e-1, "tol2", 1e-14); +%! [Ao, Bo, Co, Do] = ssdata (Gr); %! %! Ae = [ -0.2391 0.3072 1.1630 1.1967 %! -2.9709 -0.2391 2.6270 3.1027 @@ -263,8 +333,10 @@ %! %! De = [ 0.0219 ]; %! +%! HSVe = [ 2.6790 2.1589 0.8424 0.1929 0.0219 0.0011 ].'; +%! %! Mo = [Ao, Bo; Co, Do]; %! Me = [Ae, Be; Ce, De]; %! %!assert (Mo, Me, 1e-4); - +%!assert (Info.hsv, HSVe, 1e-4); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-08 22:40:33
|
Revision: 9314 http://octave.svn.sourceforge.net/octave/?rev=9314&view=rev Author: paramaniac Date: 2011-12-08 22:40:26 +0000 (Thu, 08 Dec 2011) Log Message: ----------- control-devel: test hankel singular values Modified Paths: -------------- 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 Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-08 22:30:43 UTC (rev 9313) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-08 22:40:26 UTC (rev 9314) @@ -328,7 +328,7 @@ endfunction -%!shared Mo, Me +%!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 @@ -353,10 +353,10 @@ %! 0.0000 0.0000 %! 0.0000 0.0000 ]; %! -%! sys = ss (A, B, C, D, "scaled", true); +%! G = ss (A, B, C, D, "scaled", true); %! -%! sysr = bstmodred (sys, "beta", 1.0, "tol1", 0.1, "tol2", 0.0); -%! [Ao, Bo, Co, Do] = ssdata (sysr); +%! [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 @@ -378,7 +378,10 @@ %! 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); Modified: trunk/octave-forge/extra/control-devel/inst/btaconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btaconred.m 2011-12-08 22:30:43 UTC (rev 9313) +++ trunk/octave-forge/extra/control-devel/inst/btaconred.m 2011-12-08 22:40:26 UTC (rev 9314) @@ -56,7 +56,7 @@ endfunction -%!shared Mo, Me +%!shared Mo, Me, Info, HSVCe %! A = [ -1. 0. 4. %! 0. 2. 0. %! 0. 0. -3. ]; @@ -85,7 +85,7 @@ %! %! K = ss (AC, BC, CC, DC, "scaled", true); %! -%! Kr = btaconred (G, K, 2, "weight", "input"); +%! [Kr, Info] = btaconred (G, K, 2, "weight", "input"); %! [Ao, Bo, Co, Do] = ssdata (Kr); %! %! Ae = [ 9.1900 0.0000 @@ -98,7 +98,10 @@ %! %! De = [ 0.0000 ]; %! +%! HSVCe = [ 3.8253 0.2005 ].'; +%! %! Mo = [Ao, Bo; Co, Do]; %! Me = [Ae, Be; Ce, De]; %! -%!assert (Mo, Me, 1e-4); \ No newline at end of file +%!assert (Mo, Me, 1e-4); +%!assert (Info.hsvc, HSVCe, 1e-4); Modified: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-08 22:30:43 UTC (rev 9313) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-08 22:40:26 UTC (rev 9314) @@ -96,7 +96,7 @@ endfunction -%!shared Mo, Me +%!shared Mo, Me, Info, HSVe %! A = [ -26.4000, 6.4023, 4.3868; %! 32.0000, 0, 0; %! 0, 8.0000, 0 ]; @@ -109,7 +109,7 @@ %! %! D = [ 0 ]; %! -%! sys = ss (A, B, C, D); % "scaled", false +%! G = ss (A, B, C, D); % "scaled", false %! %! AV = [ -1.0000, 0, 4.0000, -9.2994, -1.1624, -0.1090; %! 0, 2.0000, 0, -9.2994, -1.1624, -0.1090; @@ -129,10 +129,10 @@ %! %! DV = [ 0 ]; %! -%! sysv = ss (AV, BV, CV, DV); +%! V = ss (AV, BV, CV, DV); %! -%! sysr = btamodred (sys, 2, "left", sysv); -%! [Ao, Bo, Co, Do] = ssdata (sysr); +%! [Gr, Info] = btamodred (G, 2, "left", V); +%! [Ao, Bo, Co, Do] = ssdata (Gr); %! %! Ae = [ 9.1900 0.0000 %! 0.0000 -34.5297 ]; @@ -144,7 +144,10 @@ %! %! De = [ 0.0000 ]; %! +%! HSVe = [ 3.8253 0.2005 ].'; +%! %! Mo = [Ao, Bo; Co, Do]; %! Me = [Ae, Be; Ce, De]; %! %!assert (Mo, Me, 1e-4); +%!assert (Info.hsv, HSVe, 1e-4); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-10 19:36:04
|
Revision: 9351 http://octave.svn.sourceforge.net/octave/?rev=9351&view=rev Author: paramaniac Date: 2011-12-10 19:35:57 +0000 (Sat, 10 Dec 2011) Log Message: ----------- control-devel: doc update Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/cfconred.m trunk/octave-forge/extra/control-devel/inst/fwcfconred.m Modified: trunk/octave-forge/extra/control-devel/inst/cfconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/cfconred.m 2011-12-09 21:49:15 UTC (rev 9350) +++ trunk/octave-forge/extra/control-devel/inst/cfconred.m 2011-12-10 19:35:57 UTC (rev 9351) @@ -17,11 +17,11 @@ ## -*- texinfo -*- ## @deftypefn{Function File} {[@var{Kr}, @var{info}] =} cfconred (@var{Go}, @var{F}, @var{G}, @dots{}) -## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} cfconred (@var{Go}, @var{F}, @var{G}, @var{nr}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} cfconred (@var{Go}, @var{F}, @var{G}, @var{ncr}, @dots{}) ## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} cfconred (@var{Go}, @var{F}, @var{G}, @var{opt}, @dots{}) -## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} cfconred (@var{Go}, @var{F}, @var{G}, @var{nr}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} cfconred (@var{Go}, @var{F}, @var{G}, @var{ncr}, @var{opt}, @dots{}) ## -## Coprime factor reduction for state-feedback-observer based controllers. +## Reduction of state-feedback-observer based controller by coprime factorization (CF). ## ## @strong{Inputs} ## @table @var @@ -32,10 +32,16 @@ ## Stabilizing state feedback matrix (m-by-n). ## @item G ## Stabilizing observer gain matrix (n-by-p). +## @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. +## 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} Modified: trunk/octave-forge/extra/control-devel/inst/fwcfconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/fwcfconred.m 2011-12-09 21:49:15 UTC (rev 9350) +++ trunk/octave-forge/extra/control-devel/inst/fwcfconred.m 2011-12-10 19:35:57 UTC (rev 9351) @@ -17,11 +17,11 @@ ## -*- texinfo -*- ## @deftypefn{Function File} {[@var{Kr}, @var{info}] =} fwcfconred (@var{Go}, @var{F}, @var{G}, @dots{}) -## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} fwcfconred (@var{Go}, @var{F}, @var{G}, @var{nr}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} fwcfconred (@var{Go}, @var{F}, @var{G}, @var{ncr}, @dots{}) ## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} fwcfconred (@var{Go}, @var{F}, @var{G}, @var{opt}, @dots{}) -## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} fwcfconred (@var{Go}, @var{F}, @var{G}, @var{nr}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} fwcfconred (@var{Go}, @var{F}, @var{G}, @var{ncr}, @var{opt}, @dots{}) ## -## Coprime factor reduction for state-feedback-observer based controllers. +## Reduction of state-feedback-observer based controller by frequency-weighted coprime factorization (FW CF). ## ## @strong{Inputs} ## @table @var @@ -32,10 +32,16 @@ ## Stabilizing state feedback matrix (m-by-n). ## @item G ## Stabilizing observer gain matrix (n-by-p). +## @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. +## 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} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-10 20:16:44
|
Revision: 9357 http://octave.svn.sourceforge.net/octave/?rev=9357&view=rev Author: paramaniac Date: 2011-12-10 20:16:37 +0000 (Sat, 10 Dec 2011) Log Message: ----------- control-devel: doc update (2) Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/btaconred.m trunk/octave-forge/extra/control-devel/inst/spaconred.m Modified: trunk/octave-forge/extra/control-devel/inst/btaconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btaconred.m 2011-12-10 20:09:53 UTC (rev 9356) +++ trunk/octave-forge/extra/control-devel/inst/btaconred.m 2011-12-10 20:16:37 UTC (rev 9357) @@ -17,28 +17,48 @@ ## -*- 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{nr}, @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{nr}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} btaconred (@var{G}, @var{K}, @var{ncr}, @var{opt}, @dots{}) ## -## Model order reduction by frequency weighted optimal Hankel-norm approximation method. +## Controller reduction by frequency-weighted Balanced Truncation Approximation (BTA). ## ## @strong{Inputs} ## @table @var -## @item sys -## LTI model to be reduced. +## @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{} -## Pairs of properties and values. -## TODO: describe options. +## 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 sysr -## Reduced order state-space model. -## @item nr -## The order of the obtained system @var{sysr}. +## @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{Algorithm}@* ## Uses SLICOT SB16AD by courtesy of Modified: trunk/octave-forge/extra/control-devel/inst/spaconred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/spaconred.m 2011-12-10 20:09:53 UTC (rev 9356) +++ trunk/octave-forge/extra/control-devel/inst/spaconred.m 2011-12-10 20:16:37 UTC (rev 9357) @@ -17,28 +17,48 @@ ## -*- texinfo -*- ## @deftypefn{Function File} {[@var{Kr}, @var{info}] =} spaconred (@var{G}, @var{K}, @dots{}) -## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} spaconred (@var{G}, @var{K}, @var{nr}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} spaconred (@var{G}, @var{K}, @var{ncr}, @dots{}) ## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} spaconred (@var{G}, @var{K}, @var{opt}, @dots{}) -## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} spaconred (@var{G}, @var{K}, @var{nr}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Kr}, @var{info}] =} spaconred (@var{G}, @var{K}, @var{ncr}, @var{opt}, @dots{}) ## -## Model order reduction by frequency weighted optimal Hankel-norm approximation method. +## Controller reduction by frequency-weighted Singular Perturbation Approximation (SPA). ## ## @strong{Inputs} ## @table @var -## @item sys -## LTI model to be reduced. +## @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{} -## Pairs of properties and values. -## TODO: describe options. +## 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 sysr -## Reduced order state-space model. -## @item nr -## The order of the obtained system @var{sysr}. +## @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{Algorithm}@* ## Uses SLICOT SB16AD by courtesy of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-10 20:33:22
|
Revision: 9358 http://octave.svn.sourceforge.net/octave/?rev=9358&view=rev Author: paramaniac Date: 2011-12-10 20:33:15 +0000 (Sat, 10 Dec 2011) Log Message: ----------- control-devel: doc update (3) Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m trunk/octave-forge/extra/control-devel/inst/btamodred.m trunk/octave-forge/extra/control-devel/inst/spamodred.m Modified: trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-10 20:16:37 UTC (rev 9357) +++ trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-10 20:33:15 UTC (rev 9358) @@ -16,7 +16,7 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{sysr}, @var{info}] =} __modred_ab09id__ (@var{method}, @dots{}) +## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} __modred_ab09id__ (@var{method}, @dots{}) ## Backend for btamodred and spamodred. ## @end deftypefn @@ -24,7 +24,7 @@ ## Created: November 2011 ## Version: 0.1 -function [sysr, info] = __modred_ab09id__ (method, varargin) +function [Gr, info] = __modred_ab09id__ (method, varargin) if (nargin < 2) print_usage (); @@ -34,10 +34,10 @@ error ("modred: invalid method"); endif - sys = varargin{1}; + G = varargin{1}; varargin = varargin(2:end); - if (! isa (sys, "lti")) + if (! isa (G, "lti")) error ("%smodred: first argument must be an LTI system", method); endif @@ -60,9 +60,9 @@ error ("%smodred: keys and values must come in pairs", method); endif - [a, b, c, d, tsam, scaled] = ssdata (sys); - [p, m] = size (sys); - dt = isdt (sys); + [a, b, c, d, tsam, scaled] = ssdata (G); + [p, m] = size (G); + dt = isdt (G); ## default arguments alpha = __modred_default_alpha__ (dt); @@ -156,7 +156,7 @@ tol1, tol2); ## assemble reduced order model - sysr = ss (ar, br, cr, dr, tsam); + Gr = ss (ar, br, cr, dr, tsam); ## assemble info struct info = struct ("nr", nr, "ns", ns, "hsv", hsv); Modified: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-10 20:16:37 UTC (rev 9357) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-10 20:33:15 UTC (rev 9358) @@ -65,20 +65,41 @@ ## ## @strong{Inputs} ## @table @var -## @item sys +## @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{} -## Pairs of properties and values. -## TODO: describe options. +## 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 sysr +## @item Gr ## Reduced order state-space model. -## @item nr -## The order of the obtained system @var{sysr}. +## @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{Algorithm}@* ## Uses SLICOT AB09ID by courtesy of @@ -89,9 +110,9 @@ ## Created: November 2011 ## Version: 0.1 -function [sysr, info] = btamodred (varargin) +function [Gr, info] = btamodred (varargin) - [sysr, info] = __modred_ab09id__ ("bta", varargin{:}); + [Gr, info] = __modred_ab09id__ ("bta", varargin{:}); endfunction Modified: trunk/octave-forge/extra/control-devel/inst/spamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-12-10 20:16:37 UTC (rev 9357) +++ trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-12-10 20:33:15 UTC (rev 9358) @@ -21,24 +21,45 @@ ## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} spamodred (@var{G}, @var{opt}, @dots{}) ## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} spamodred (@var{G}, @var{nr}, @var{opt}, @dots{}) ## -## Model order reduction by frequency weighted optimal Hankel-norm approximation method. +## Model order reduction by frequency weighted Singular Perturbation Approximation (SPA). ## ## @strong{Inputs} ## @table @var -## @item sys +## @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{} -## Pairs of properties and values. -## TODO: describe options. +## 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 sysr +## @item Gr ## Reduced order state-space model. -## @item nr -## The order of the obtained system @var{sysr}. +## @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{Algorithm}@* ## Uses SLICOT AB09ID by courtesy of @@ -49,9 +70,9 @@ ## Created: November 2011 ## Version: 0.1 -function [sysr, info] = spamodred (varargin) +function [Gr, info] = spamodred (varargin) - [sysr, info] = __modred_ab09id__ ("spa", varargin{:}); + [Gr, info] = __modred_ab09id__ ("spa", varargin{:}); endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |