Home > matlab > acado > packages > +acado > @OCP > minimizeLSQEndTerm.m

minimizeLSQEndTerm

PURPOSE ^

Adds an Least Square term that is only evaluated at the end:

SYNOPSIS ^

function minimizeLSQEndTerm(obj, varargin)

DESCRIPTION ^

Adds an Least Square term that is only evaluated at the end:
 0.5* || ( m(T,x(T),u(T),p(T),...) - r ) ||^2_S
 where S is a weighting matrix, r a reference vector and T the time
 at the last objective grid point. 

  Usage:
    >> ocp.minimizeLSQEndTerm(m, r)
    >> ocp.minimizeLSQEndTerm(S, m, r)

  Parameters:
    m       the LSQ-Function    (1 x n  FUNCTION)
    S       a weighting matrix  (n x n  MATRIX)
    r       the reference       (1 x n  VECTOR)

  Example:
    >> S = [10 0; 0 1];
    >> m = {x1, x2};
    >> r = [0, 0];
    >> ocp.minimizeLSQEndTerm(S, m, r);

  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 minimizeLSQEndTerm(obj, varargin)
0002 %Adds an Least Square term that is only evaluated at the end:
0003 % 0.5* || ( m(T,x(T),u(T),p(T),...) - r ) ||^2_S
0004 % where S is a weighting matrix, r a reference vector and T the time
0005 % at the last objective grid point.
0006 %
0007 %  Usage:
0008 %    >> ocp.minimizeLSQEndTerm(m, r)
0009 %    >> ocp.minimizeLSQEndTerm(S, m, r)
0010 %
0011 %  Parameters:
0012 %    m       the LSQ-Function    (1 x n  FUNCTION)
0013 %    S       a weighting matrix  (n x n  MATRIX)
0014 %    r       the reference       (1 x n  VECTOR)
0015 %
0016 %  Example:
0017 %    >> S = [10 0; 0 1];
0018 %    >> m = {x1, x2};
0019 %    >> r = [0, 0];
0020 %    >> ocp.minimizeLSQEndTerm(S, m, r);
0021 %
0022 %  Licence:
0023 %    This file is part of ACADO Toolkit  - (http://www.acadotoolkit.org/)
0024 %
0025 %    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
0026 %    Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven.
0027 %    Developed within the Optimization in Engineering Center (OPTEC) under
0028 %    supervision of Moritz Diehl. All rights reserved.
0029 %
0030 %    ACADO Toolkit is free software; you can redistribute it and/or
0031 %    modify it under the terms of the GNU Lesser General Public
0032 %    License as published by the Free Software Foundation; either
0033 %    version 3 of the License, or (at your option) any later version.
0034 %
0035 %    ACADO Toolkit is distributed in the hope that it will be useful,
0036 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
0037 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0038 %    Lesser General Public License for more details.
0039 %
0040 %    You should have received a copy of the GNU Lesser General Public
0041 %    License along with ACADO Toolkit; if not, write to the Free Software
0042 %    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0043 %
0044 %    Author: David Ariens
0045 %    Date: 2010
0046 %
0047 
0048 index = length(obj.minLSQEndTermh);
0049 
0050 if (length(varargin) == 2)  %ocp.minimizeLSQEndTerm(h, r)
0051     h = varargin{1};
0052     r = varargin{2};
0053     
0054     obj.minLSQEndTermh{index+1} = acado.Function(h);
0055     obj.minLSQEndTermr{index+1} = obj.checkVectorMatrix(r);
0056     obj.minLSQEndTermr{index+1} = {};
0057     
0058 elseif (length(varargin) == 3)  %ocp.minimizeLSQEndTerm(S, h, r)
0059     h = varargin{2};
0060     r = varargin{3};
0061     S = varargin{1};
0062 
0063     obj.minLSQEndTermh{index+1} = acado.Function(h);
0064     obj.minLSQEndTermr{index+1} = obj.checkVectorMatrix(r);
0065     obj.minLSQEndTermS{index+1} = acado.Matrix(S);
0066 
0067     
0068 else %error
0069    error('ERROR: Invalid minimizeLSQEndTerm call. <a href="matlab: help acado.OCP.minimizeLSQEndTerm">help acado.OCP.minimizeLSQEndTerm</a>'); 
0070 end
0071 
0072 
0073 end

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