Home > matlab > acado > packages > +acado > @OptimizationAlgorithmBase > initializeControls.m

initializeControls

PURPOSE ^

Initialization of the Controls. Initialize Controls on different time points.

SYNOPSIS ^

function initializeControls(obj, varargin)

DESCRIPTION ^

Initialization of the Controls. Initialize Controls on different time points. 
 The matrix M can contain multiple rows for different initializations of 
 the Controls. 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.initializeControls(M)

  Controls:
    M       m x (n_z + 1) Matrix with initial values
         where m   = number of different initializations on different times
               n_z = number of Controls
         the first column represents the time points
         the second column represents the first Control
         the thirth column represents the second Control
         ...

    A warning will be shown when the number of columns is not equal to the
    number of Controls + 1 (the time);

  Example:
    Example 1: Initialize initial (on t=0) values of 2 Controls.
    Initial values are: u1(0) = 5 and u2(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 Controls are defined)
     >> Control u1 u2;
     >> M = [0  5  2.5];
     >> algo.initializeControls(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: 
    u1(0) = 5, u2(0) = 2.5 and u1(1) = 5.5, u2(1) = -1
     >> Control u1 u2;
     >> M = [0  5    2.5
             1  5.5  -1];
     >> algo.initializeControls(M);

    Example 3: Although we have two Controls, we only want to 
    initialize the first: u1(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.
     >> Control u1 u2;
     >> M = [0  5];
     >> algo.initializeControls(M);

    Example 4: We only want to initialize the second Control: u2(0) = 2.5. 
    In this case you should reverse the order how the Controls are defined!
     >> Control u2 u1;
     >> M = [0  2.5];
     >> algo.initializeControls(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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function initializeControls(obj, varargin)
0002 %Initialization of the Controls. Initialize Controls on different time points.
0003 % The matrix M can contain multiple rows for different initializations of
0004 % the Controls. 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.initializeControls(M)
0010 %
0011 %  Controls:
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 Controls
0015 %         the first column represents the time points
0016 %         the second column represents the first Control
0017 %         the thirth column represents the second Control
0018 %         ...
0019 %
0020 %    A warning will be shown when the number of columns is not equal to the
0021 %    number of Controls + 1 (the time);
0022 %
0023 %  Example:
0024 %    Example 1: Initialize initial (on t=0) values of 2 Controls.
0025 %    Initial values are: u1(0) = 5 and u2(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 Controls are defined)
0029 %     >> Control u1 u2;
0030 %     >> M = [0  5  2.5];
0031 %     >> algo.initializeControls(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 %    u1(0) = 5, u2(0) = 2.5 and u1(1) = 5.5, u2(1) = -1
0036 %     >> Control u1 u2;
0037 %     >> M = [0  5    2.5
0038 %             1  5.5  -1];
0039 %     >> algo.initializeControls(M);
0040 %
0041 %    Example 3: Although we have two Controls, we only want to
0042 %    initialize the first: u1(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 %     >> Control u1 u2;
0047 %     >> M = [0  5];
0048 %     >> algo.initializeControls(M);
0049 %
0050 %    Example 4: We only want to initialize the second Control: u2(0) = 2.5.
0051 %    In this case you should reverse the order how the Controls are defined!
0052 %     >> Control u2 u1;
0053 %     >> M = [0  2.5];
0054 %     >> algo.initializeControls(M);
0055 %
0056 %
0057 %
0058 %  Licence:
0059 %    This file is part of ACADO Toolkit  - (http://www.acadotoolkit.org/)
0060 %
0061 %    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
0062 %    Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven.
0063 %    Developed within the Optimization in Engineering Center (OPTEC) under
0064 %    supervision of Moritz Diehl. All rights reserved.
0065 %
0066 %    ACADO Toolkit is free software; you can redistribute it and/or
0067 %    modify it under the terms of the GNU Lesser General Public
0068 %    License as published by the Free Software Foundation; either
0069 %    version 3 of the License, or (at your option) any later version.
0070 %
0071 %    ACADO Toolkit is distributed in the hope that it will be useful,
0072 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
0073 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0074 %    Lesser General Public License for more details.
0075 %
0076 %    You should have received a copy of the GNU Lesser General Public
0077 %    License along with ACADO Toolkit; if not, write to the Free Software
0078 %    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0079 %
0080 %    Author: David Ariens
0081 %    Date: 2010
0082 %
0083 
0084 
0085 global ACADO_;
0086 
0087 if (length(varargin) == 1) 
0088     
0089     [m n] = size(varargin{1});
0090     if (length(ACADO_.helper.u) == n)
0091         warning('ACADO:initialize', 'Possible problem in initializeControls. You have %d controls 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.initializeControls">help acado.OptimizationAlgorithm.initializeControls</a>', length(ACADO_.helper.u), n, length(ACADO_.helper.u)+1);
0092     elseif (length(ACADO_.helper.u) ~= (n-1))
0093         warning('ACADO:initialize', 'Possible problem in initializeControls. You have %d controls 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 controls. This matrix should thus have %d columns. See also <a href="matlab: help acado.OptimizationAlgorithm.initializeControls">help acado.OptimizationAlgorithm.initializeControls</a>', length(ACADO_.helper.u), n, length(ACADO_.helper.u)+1);
0094     end
0095     
0096     obj.initcontrols = acado.Matrix(varargin{1});
0097     
0098 else %error
0099     
0100    error('ERROR: Invalid initializeControls call. <a href="matlab: help acado.OptimizationAlgorithm.initializeControls">help acado.OptimizationAlgorithm.initializeControls</a>'); 
0101 
0102 end
0103 
0104 
0105 end

www.acadotoolkit.org/matlab
Generated on Tue 01-Jun-2010 20:14:12 by m2html © 2005