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

OCP

PURPOSE ^

The class OCP is a data wrapper for defining optimal control problems.

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

The class OCP is a data wrapper for defining optimal control problems.

  Usage:
    >> OCP();                 Define an OCP without start and end time. Do
                              this only when setting start and end times
                              in the differential equation object.

    >> OCP(timepoints);       Define a grid of timepoints (used in
                              parameter estimation)

    >> OCP(tStart, tEnd);     Normal OCP formulation with start and end time

    >> OCP(tStart, tEnd, N);  Normal OCP formulation with, start and end
                              time + number of intervals

  Parameters:
    tStart     start of the time horizon of the OCP       [NUMERIC]
    tEnd       end of the time horizon of the OCP         [NUMERIC/PARAMETER]
    N          number of discretization intervals         [NUMERIC]
    timepoints vector with timepoints                     [1xn NUMERIC VECTOR]


  Example:
    >> ocp = acado.OCP(0.0, 1.0, 20);
    >> ocp = acado.OCP(0.0, T, 20);
    >> ocp = acado.OCP(0.0, T);
    >> M = [0 1 5 6 7 10];
    >> ocp = acado.OCP(M);


  See also:
    acado.OCP.minimizeLSQ              Least squares term
    acado.OCP.minimizeLSQEndTerm
    acado.OCP.minimizeMayerTerm        Mayer Term
    acado.OCP.maximizeMayerTerm
    acado.OCP.minimizeLagrangeTerm     Lagrange Term
    acado.OCP.maximizeLagrangeTerm
    acado.OCP.subjectTo                Bounds, constraints


  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: 2009-2010

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %The class OCP is a data wrapper for defining optimal control problems.
0002 %
0003 %  Usage:
0004 %    >> OCP();                 Define an OCP without start and end time. Do
0005 %                              this only when setting start and end times
0006 %                              in the differential equation object.
0007 %
0008 %    >> OCP(timepoints);       Define a grid of timepoints (used in
0009 %                              parameter estimation)
0010 %
0011 %    >> OCP(tStart, tEnd);     Normal OCP formulation with start and end time
0012 %
0013 %    >> OCP(tStart, tEnd, N);  Normal OCP formulation with, start and end
0014 %                              time + number of intervals
0015 %
0016 %  Parameters:
0017 %    tStart     start of the time horizon of the OCP       [NUMERIC]
0018 %    tEnd       end of the time horizon of the OCP         [NUMERIC/PARAMETER]
0019 %    N          number of discretization intervals         [NUMERIC]
0020 %    timepoints vector with timepoints                     [1xn NUMERIC VECTOR]
0021 %
0022 %
0023 %  Example:
0024 %    >> ocp = acado.OCP(0.0, 1.0, 20);
0025 %    >> ocp = acado.OCP(0.0, T, 20);
0026 %    >> ocp = acado.OCP(0.0, T);
0027 %    >> M = [0 1 5 6 7 10];
0028 %    >> ocp = acado.OCP(M);
0029 %
0030 %
0031 %  See also:
0032 %    acado.OCP.minimizeLSQ              Least squares term
0033 %    acado.OCP.minimizeLSQEndTerm
0034 %    acado.OCP.minimizeMayerTerm        Mayer Term
0035 %    acado.OCP.maximizeMayerTerm
0036 %    acado.OCP.minimizeLagrangeTerm     Lagrange Term
0037 %    acado.OCP.maximizeLagrangeTerm
0038 %    acado.OCP.subjectTo                Bounds, constraints
0039 %
0040 %
0041 %  Licence:
0042 %    This file is part of ACADO Toolkit  - (http://www.acadotoolkit.org/)
0043 %
0044 %    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
0045 %    Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven.
0046 %    Developed within the Optimization in Engineering Center (OPTEC) under
0047 %    supervision of Moritz Diehl. All rights reserved.
0048 %
0049 %    ACADO Toolkit is free software; you can redistribute it and/or
0050 %    modify it under the terms of the GNU Lesser General Public
0051 %    License as published by the Free Software Foundation; either
0052 %    version 3 of the License, or (at your option) any later version.
0053 %
0054 %    ACADO Toolkit is distributed in the hope that it will be useful,
0055 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
0056 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0057 %    Lesser General Public License for more details.
0058 %
0059 %    You should have received a copy of the GNU Lesser General Public
0060 %    License along with ACADO Toolkit; if not, write to the Free Software
0061 %    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0062 %
0063 %    Author: David Ariens
0064 %    Date: 2009-2010
0065 %
0066 classdef OCP < acado.MultiObjectiveFunctionality    
0067     properties (SetAccess='private')
0068         name = 'ocp';
0069        
0070         % Constructor
0071         tStart;
0072         tEnd;
0073         N;
0074         grid = {};
0075         
0076         % Objective
0077         minMayerTerms = {};
0078         maxMayerTerms = {};
0079         
0080         minLagrangeTerms = {};
0081         maxLagrangeTerms = {};
0082         
0083         minLSQTermS = {};
0084         minLSQTermh = {};
0085         minLSQTermr = {};
0086 
0087         minLSQEndTermS = {};
0088         minLSQEndTermh = {};
0089         minLSQEndTermr = {};
0090 
0091         % Subject to
0092         subjectoItems = {};
0093     end
0094     
0095     methods
0096         function obj = OCP(varargin)
0097             checkActiveModel;
0098             
0099             global ACADO_;
0100             ACADO_.count_ocp = ACADO_.count_ocp+1;
0101             obj.name = strcat(obj.name, num2str(ACADO_.count_ocp));
0102             
0103             if (nargin == 2 )  %OCP(tStart, tEnd)
0104                 obj.tStart = acado.DoubleConstant(varargin{1});   
0105                 
0106                 if (isa(varargin{2}, 'acado.Expression'))
0107                     obj.tEnd = varargin{2};
0108                 else
0109                     obj.tEnd = acado.DoubleConstant(varargin{2});    
0110                 end
0111                 
0112             elseif (nargin == 3)  %OCP(tStart, tEnd, N)
0113                 obj.tStart = acado.DoubleConstant(varargin{1});
0114                 
0115                 if (isa(varargin{2}, 'acado.Expression'))
0116                     obj.tEnd = varargin{2};
0117                 else
0118                     obj.tEnd = acado.DoubleConstant(varargin{2});    
0119                 end
0120                 
0121                 obj.N = acado.DoubleConstant(varargin{3});
0122             
0123             elseif (nargin == 1)  %OCP(timepoints)
0124                 obj.grid = acado.Vector(varargin{1});
0125                 
0126             end
0127             
0128 
0129             ACADO_.helper.addInstruction(obj);
0130             
0131         end
0132         
0133         
0134         function result = checkVectorMatrix(obj, r)
0135             
0136             if (isa(r, 'acado.MexInputVector'))
0137                 result = acado.Vector(r);
0138                 
0139             elseif(isa(r, 'acado.MexInputMatrix'))
0140                 result = acado.Matrix(r);
0141                 
0142             else
0143                 [m n] = size(r);
0144                 
0145                 if( (m == 1 && n >= 1) || (m >= 1 && n == 1) )
0146                     result = acado.Vector(r);
0147                 else
0148                     result = acado.Matrix(r);
0149                 end
0150             end
0151     
0152         end
0153     
0154         
0155         maximizeMayerTerm(obj, varargin)
0156         minimizeMayerTerm(obj, varargin)
0157         
0158         minimizeLagrangeTerm(obj, varargin)
0159         maximizeLagrangeTerm(obj, varargin)
0160         
0161         minimizeLSQ(obj, varargin)
0162         minimizeLSQEndTerm(obj,varargin)
0163         
0164         subjectTo(obj, varargin)
0165         
0166         getInstructions(obj, cppobj, get)
0167 
0168     end
0169     
0170 end
0171

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