Initialization of the disturbances. Initialize disturbances on different time points. The matrix M can contain multiple rows for different initializations of the disturbances. Note that these are only initializations, the optimization routine is not forced to use these values exactly. If values should be fixed, use "ocp.subjectTo". Usage: >> algo.initializeDisturbances(M) Parameters: M m x (n_z + 1) Matrix with initial values where m = number of different initializations on different times n_z = number of disturbances the first column represents the time points the second column represents the first disturbance the thirth column represents the second disturbance ... A warning will be shown when the number of columns is not equal to the number of disturbances + 1 (the time); Example: Example 1: Initialize initial (on t=0) values of 2 disturbances. Initial values are: w1(0) = 5 and w2(0) = 2.5. In this case the matrix M will have one row, the first element is '0' (the time), the second and thirth element are 5 and 2.5 (note that the sequence should be the same as how the disturbances are defined) >> Disturbance w1 w2; >> M = [0 5 2.5]; >> algo.initializeDisturbances(M); Example 2: Initialize on t=0 and t=1 (for example we know what these values will be due to other calculations). Initial values are: w1(0) = 5, w2(0) = 2.5 and w1(1) = 5.5, w2(1) = -1 >> Disturbance w1 w2; >> M = [0 5 2.5 1 5.5 -1]; >> algo.initializeDisturbances(M); Example 3: Although we have two disturbances, we only want to initialize the first: w1(0) = 5. In this case the matrix should only contain one extra column next to the time reference. Note that a warning will be displayed to indicate a possible problem. Ignore this warning. >> Disturbance w1 w2; >> M = [0 5]; >> algo.initializeDisturbances(M); Example 4: We only want to initialize the second disturbance: w2(0) = 2.5. In this case you should reverse the order how the disturbances are defined! >> Disturbance w2 w1; >> M = [0 2.5]; >> algo.initializeDisturbances(M); Licence: This file is part of ACADO Toolkit - (http://www.acadotoolkit.org/) ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization. Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven. Developed within the Optimization in Engineering Center (OPTEC) under supervision of Moritz Diehl. All rights reserved. ACADO Toolkit is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. ACADO Toolkit 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with ACADO Toolkit; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Author: David Ariens Date: 2010
0001 function initializeDisturbances(obj, varargin) 0002 %Initialization of the disturbances. Initialize disturbances on different time points. 0003 % The matrix M can contain multiple rows for different initializations of 0004 % the disturbances. Note that these are only initializations, the optimization 0005 % routine is not forced to use these values exactly. 0006 % If values should be fixed, use "ocp.subjectTo". 0007 % 0008 % Usage: 0009 % >> algo.initializeDisturbances(M) 0010 % 0011 % Parameters: 0012 % M m x (n_z + 1) Matrix with initial values 0013 % where m = number of different initializations on different times 0014 % n_z = number of disturbances 0015 % the first column represents the time points 0016 % the second column represents the first disturbance 0017 % the thirth column represents the second disturbance 0018 % ... 0019 % 0020 % A warning will be shown when the number of columns is not equal to the 0021 % number of disturbances + 1 (the time); 0022 % 0023 % Example: 0024 % Example 1: Initialize initial (on t=0) values of 2 disturbances. 0025 % Initial values are: w1(0) = 5 and w2(0) = 2.5. In this case the matrix 0026 % M will have one row, the first element is '0' (the time), the second 0027 % and thirth element are 5 and 2.5 (note that the sequence should be the 0028 % same as how the disturbances are defined) 0029 % >> Disturbance w1 w2; 0030 % >> M = [0 5 2.5]; 0031 % >> algo.initializeDisturbances(M); 0032 % 0033 % Example 2: Initialize on t=0 and t=1 (for example we know what these 0034 % values will be due to other calculations). Initial values are: 0035 % w1(0) = 5, w2(0) = 2.5 and w1(1) = 5.5, w2(1) = -1 0036 % >> Disturbance w1 w2; 0037 % >> M = [0 5 2.5 0038 % 1 5.5 -1]; 0039 % >> algo.initializeDisturbances(M); 0040 % 0041 % Example 3: Although we have two disturbances, we only want to 0042 % initialize the first: w1(0) = 5. In this case the matrix should only 0043 % contain one extra column next to the time reference. Note that a 0044 % warning will be displayed to indicate a possible problem. Ignore this 0045 % warning. 0046 % >> Disturbance w1 w2; 0047 % >> M = [0 5]; 0048 % >> algo.initializeDisturbances(M); 0049 % 0050 % Example 4: We only want to initialize the second disturbance: w2(0) = 2.5. 0051 % In this case you should reverse the order how the disturbances are defined! 0052 % >> Disturbance w2 w1; 0053 % >> M = [0 2.5]; 0054 % >> algo.initializeDisturbances(M); 0055 % 0056 % 0057 % Licence: 0058 % This file is part of ACADO Toolkit - (http://www.acadotoolkit.org/) 0059 % 0060 % ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization. 0061 % Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven. 0062 % Developed within the Optimization in Engineering Center (OPTEC) under 0063 % supervision of Moritz Diehl. All rights reserved. 0064 % 0065 % ACADO Toolkit is free software; you can redistribute it and/or 0066 % modify it under the terms of the GNU Lesser General Public 0067 % License as published by the Free Software Foundation; either 0068 % version 3 of the License, or (at your option) any later version. 0069 % 0070 % ACADO Toolkit is distributed in the hope that it will be useful, 0071 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0072 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0073 % Lesser General Public License for more details. 0074 % 0075 % You should have received a copy of the GNU Lesser General Public 0076 % License along with ACADO Toolkit; if not, write to the Free Software 0077 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0078 % 0079 % Author: David Ariens 0080 % Date: 2010 0081 % 0082 0083 global ACADO_; 0084 0085 if (length(varargin) == 1) 0086 0087 [m n] = size(varargin{1}); 0088 if (length(ACADO_.helper.w) == n) 0089 warning('ACADO:initialize', 'Possible problem in initializeDisturbances. You have %d disturbances and the number of columns in the initialisation matrix is also %d. This is probably not correct since the first column should contain a time reference. This matrix should thus have %d columns. See also <a href="matlab: help acado.OptimizationAlgorithm.initializeDisturbances">help acado.OptimizationAlgorithm.initializeDisturbances</a>', length(ACADO_.helper.w), n, length(ACADO_.helper.w)+1); 0090 elseif (length(ACADO_.helper.w) ~= (n-1)) 0091 warning('ACADO:initialize', 'Possible problem in initializeDisturbances. You have %d disturbances and the number of columns in the initialisation matrix is %d. First column should be a time reference, the next columns should be initialisations for all disturbances. This matrix should thus have %d columns. See also <a href="matlab: help acado.OptimizationAlgorithm.initializeDisturbances">help acado.OptimizationAlgorithm.initializeDisturbances</a>', length(ACADO_.helper.w), n, length(ACADO_.helper.w)+1); 0092 end 0093 0094 obj.initdisturbances = acado.Matrix(varargin{1}); 0095 0096 else %error 0097 0098 error('ERROR: Invalid initializeDisturbances call. <a href="matlab: help acado.OptimizationAlgorithm.initializeDisturbances">help acado.OptimizationAlgorithm.initializeDisturbances</a>'); 0099 0100 end 0101 0102 0103 end