Home > matlab > integrator > ACADOintegratorsSettings.m

ACADOintegratorsSettings

PURPOSE ^

ACADOintegrators is a collection of different integrators for solving ODE and

SYNOPSIS ^

function [ settings ] = ACADOintegratorsSettings( model,integrator )

DESCRIPTION ^

ACADOintegrators is a collection of different integrators for solving ODE and 
DAE systems including efficient sensitivity generation.
ACADOintegratorsSettings returns a settings struct for calling ACADOintegrators.

Call

    settings = ACADOintegratorsSettings;

for obtaining a settings struct comprising the following items:

    Model               --  a) File name (without .cpp) containing the C++  
                               implementation of the ODE/DAE,
                               e.g. 'gettting_started' for getting_started.cpp
                            b) a cell array of size one containing a Matlab  
                               function handle to an ODE specified in an m-script,
                               e.g. '{ @glycemia_matlab }' for an ODE given as: 
                               dx = glycemia_matlab( t,x,u,p,w ) 
                            c) a cell array of size one containing a Matlab  
                               function handle to a DAE specified in an m-script,
                               e.g. '{ @simple_dae_matlab }' for an DAE given as: 
                               f = glycemia_matlab( t,x,xa,u,p,w ) 

    Integrator          --  Name of one of the following integrators:
                            a) 'RK12' for an error-controlled Runge-Kunga12
                            b) 'RK23' for an error-controlled Runge-Kunga23
                            c) 'RK45' for an error-controlled Runge-Kunga45
                            d) 'RK78' for an error-controlled Runge-Kunga78
                            e) 'BDF'  for an error-controlled, implicit integrator
                                      based on the backward differentiation formula
 
    Tolerance           --  Integration tolerance 
    AbsoluteTolerance   --  Integration absolute tolerance
    MaxNumberOfSteps    --  Maximum number of integrator steps
    MinimumStepSize     --  Minimum integrator step size
    MaximumStepSize     --  Maximum integrator step size
    InitialStepSize     --  Initial step size integrator
    CorrectorTolerance  --  Corrector Tollerance
    StepSizeTuning      --  Step size tuning parameter
    LinearAlgebraSolver --  Specifies how the linear systems are solved:
                            a) 'dense' for a dense solver
                            b) 'sparse' for a sparse solver

    u                   --  Constant value of controls affecting the ODE/DAE
    p                   --  Constant value of parameters affecting the ODE/DAE
    w                   --  Constant value of disturbances affecting the ODE/DAE
    dxInit              --  Initial value for differential states derivatives
                            (only for DAEs)

    SensitivityMode     --  String specifying one of the following modes for 
                            efficient sensitivity generation:
                            a) '' (empty) for no sensitivity generation
                            b) 'AD_FORWARD'  for 1st order forward sensitivities
                            c) 'AD_BACKWARD' for 1st order backward sensitivities
                            d) 'AD_FORWARD2' for 2nd order forward sensitivities
                            e) 'AD_FORWARD_BACKWARD' for 2st order sensitivities,
                               first forward then backward

    mu                  --  Backward seed
    lambdaX             --  Forward seed w.r.t. differential states x
    lambdaU             --  Forward seed w.r.t. controls u
    lambdaP             --  Forward seed w.r.t. parameters p
    lambdaW             --  Forward seed w.r.t. disturbances w
    mu2                 --  Backward seed (2nd order)
    lambdaX2            --  Forward seed w.r.t. differential states x (2nd order)
    lambdaU2            --  Forward seed w.r.t. controls u (2nd order)
    lambdaP2            --  Forward seed w.r.t. parameters p (2nd order)
    lambdaW2            --  Forward seed w.r.t. disturbances w (2nd order)

    PrintLevel          --  Flag indicating if integrator shall print messages to
                            Matlab command window: 0 for no, 1 for yes
    PlotXTrajectory     --  Array containg a list of all indices of differential
                            states that shall be printed, e.g. [] for none
    PlotXaTrajectory    --  Array containg a list of all indices of algebraic 
                            states that shall be plotted, e.g. [] for none
    UseSubplots         --  Flag indicating if plot routine shall use subplots in 
                            order to use fewer figures: 0 for no, 1 for yes
    StorageResolution   --  Defines the number of time points at which the trajectory
                            is stored and optionally plotted. By default these time
                            points are equidistant and 101 in total.

Except for Model and Integrator, all components are optional and default
values might be used by the respective integrator. In particular, if 
SensitivityMode is empty, no sensitivities are calculated and no seeds need 
to be given (otherwise, at least on non-empty seed is expected).

As a short-cut, you can also call

    settings = ACADOintegratorsSettings( 'modelname','integratorname' );

for obtaining a settings struct with Model set to 'modelname' and Integrator
set to 'integratorname' and all other components empty. This might be directly 
used (inlined) within a call to ACADOintegrators.


See also ACADOINTEGRATORS, ACADOINTEGRATORSOUTPUTS


For additional information see the ACADOintegrators Tutorial and User's Manual
or visit http://www.acadotoolkit.org.

Please send remarks and questions to support@acadotoolkit.org!

  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: Niels Haverbeke, Boris Houska, Hans Joachim Ferreau, David Ariens
    Date: 2008-2010

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %ACADOintegrators is a collection of different integrators for solving ODE and
0002 %DAE systems including efficient sensitivity generation.
0003 %ACADOintegratorsSettings returns a settings struct for calling ACADOintegrators.
0004 %
0005 %Call
0006 %
0007 %    settings = ACADOintegratorsSettings;
0008 %
0009 %for obtaining a settings struct comprising the following items:
0010 %
0011 %    Model               --  a) File name (without .cpp) containing the C++
0012 %                               implementation of the ODE/DAE,
0013 %                               e.g. 'gettting_started' for getting_started.cpp
0014 %                            b) a cell array of size one containing a Matlab
0015 %                               function handle to an ODE specified in an m-script,
0016 %                               e.g. '{ @glycemia_matlab }' for an ODE given as:
0017 %                               dx = glycemia_matlab( t,x,u,p,w )
0018 %                            c) a cell array of size one containing a Matlab
0019 %                               function handle to a DAE specified in an m-script,
0020 %                               e.g. '{ @simple_dae_matlab }' for an DAE given as:
0021 %                               f = glycemia_matlab( t,x,xa,u,p,w )
0022 %
0023 %    Integrator          --  Name of one of the following integrators:
0024 %                            a) 'RK12' for an error-controlled Runge-Kunga12
0025 %                            b) 'RK23' for an error-controlled Runge-Kunga23
0026 %                            c) 'RK45' for an error-controlled Runge-Kunga45
0027 %                            d) 'RK78' for an error-controlled Runge-Kunga78
0028 %                            e) 'BDF'  for an error-controlled, implicit integrator
0029 %                                      based on the backward differentiation formula
0030 %
0031 %    Tolerance           --  Integration tolerance
0032 %    AbsoluteTolerance   --  Integration absolute tolerance
0033 %    MaxNumberOfSteps    --  Maximum number of integrator steps
0034 %    MinimumStepSize     --  Minimum integrator step size
0035 %    MaximumStepSize     --  Maximum integrator step size
0036 %    InitialStepSize     --  Initial step size integrator
0037 %    CorrectorTolerance  --  Corrector Tollerance
0038 %    StepSizeTuning      --  Step size tuning parameter
0039 %    LinearAlgebraSolver --  Specifies how the linear systems are solved:
0040 %                            a) 'dense' for a dense solver
0041 %                            b) 'sparse' for a sparse solver
0042 %
0043 %    u                   --  Constant value of controls affecting the ODE/DAE
0044 %    p                   --  Constant value of parameters affecting the ODE/DAE
0045 %    w                   --  Constant value of disturbances affecting the ODE/DAE
0046 %    dxInit              --  Initial value for differential states derivatives
0047 %                            (only for DAEs)
0048 %
0049 %    SensitivityMode     --  String specifying one of the following modes for
0050 %                            efficient sensitivity generation:
0051 %                            a) '' (empty) for no sensitivity generation
0052 %                            b) 'AD_FORWARD'  for 1st order forward sensitivities
0053 %                            c) 'AD_BACKWARD' for 1st order backward sensitivities
0054 %                            d) 'AD_FORWARD2' for 2nd order forward sensitivities
0055 %                            e) 'AD_FORWARD_BACKWARD' for 2st order sensitivities,
0056 %                               first forward then backward
0057 %
0058 %    mu                  --  Backward seed
0059 %    lambdaX             --  Forward seed w.r.t. differential states x
0060 %    lambdaU             --  Forward seed w.r.t. controls u
0061 %    lambdaP             --  Forward seed w.r.t. parameters p
0062 %    lambdaW             --  Forward seed w.r.t. disturbances w
0063 %    mu2                 --  Backward seed (2nd order)
0064 %    lambdaX2            --  Forward seed w.r.t. differential states x (2nd order)
0065 %    lambdaU2            --  Forward seed w.r.t. controls u (2nd order)
0066 %    lambdaP2            --  Forward seed w.r.t. parameters p (2nd order)
0067 %    lambdaW2            --  Forward seed w.r.t. disturbances w (2nd order)
0068 %
0069 %    PrintLevel          --  Flag indicating if integrator shall print messages to
0070 %                            Matlab command window: 0 for no, 1 for yes
0071 %    PlotXTrajectory     --  Array containg a list of all indices of differential
0072 %                            states that shall be printed, e.g. [] for none
0073 %    PlotXaTrajectory    --  Array containg a list of all indices of algebraic
0074 %                            states that shall be plotted, e.g. [] for none
0075 %    UseSubplots         --  Flag indicating if plot routine shall use subplots in
0076 %                            order to use fewer figures: 0 for no, 1 for yes
0077 %    StorageResolution   --  Defines the number of time points at which the trajectory
0078 %                            is stored and optionally plotted. By default these time
0079 %                            points are equidistant and 101 in total.
0080 %
0081 %Except for Model and Integrator, all components are optional and default
0082 %values might be used by the respective integrator. In particular, if
0083 %SensitivityMode is empty, no sensitivities are calculated and no seeds need
0084 %to be given (otherwise, at least on non-empty seed is expected).
0085 %
0086 %As a short-cut, you can also call
0087 %
0088 %    settings = ACADOintegratorsSettings( 'modelname','integratorname' );
0089 %
0090 %for obtaining a settings struct with Model set to 'modelname' and Integrator
0091 %set to 'integratorname' and all other components empty. This might be directly
0092 %used (inlined) within a call to ACADOintegrators.
0093 %
0094 %
0095 %See also ACADOINTEGRATORS, ACADOINTEGRATORSOUTPUTS
0096 %
0097 %
0098 %For additional information see the ACADOintegrators Tutorial and User's Manual
0099 %or visit http://www.acadotoolkit.org.
0100 %
0101 %Please send remarks and questions to support@acadotoolkit.org!
0102 %
0103 %  Licence:
0104 %    This file is part of ACADO Toolkit  - (http://www.acadotoolkit.org/)
0105 %
0106 %    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
0107 %    Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven.
0108 %    Developed within the Optimization in Engineering Center (OPTEC) under
0109 %    supervision of Moritz Diehl. All rights reserved.
0110 %
0111 %    ACADO Toolkit is free software; you can redistribute it and/or
0112 %    modify it under the terms of the GNU Lesser General Public
0113 %    License as published by the Free Software Foundation; either
0114 %    version 3 of the License, or (at your option) any later version.
0115 %
0116 %    ACADO Toolkit is distributed in the hope that it will be useful,
0117 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
0118 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0119 %    Lesser General Public License for more details.
0120 %
0121 %    You should have received a copy of the GNU Lesser General Public
0122 %    License along with ACADO Toolkit; if not, write to the Free Software
0123 %    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0124 %
0125 %    Author: Niels Haverbeke, Boris Houska, Hans Joachim Ferreau, David Ariens
0126 %    Date: 2008-2010
0127 
0128 function [ settings ] = ACADOintegratorsSettings( model,integrator )
0129 
0130     settings = struct(    'Model',[],...
0131                         'Integrator',[],...
0132                         'Tolerance',[],...
0133                         'AbsoluteTolerance',1e-6,...
0134                         'MaxNumberOfSteps',1000,...
0135                         'MinimumStepSize',1e-6,...
0136                         'MaximumStepSize',1e8,...
0137                         'InitialStepSize',1e-3,...
0138                         'CorrectorTolerance', 1e-14,...
0139                         'StepSizeTuning',0.5,...
0140                         'LinearAlgebraSolver','dense',...
0141                         'u',[],...
0142                         'p',[],...
0143                         'w',[],...
0144                         'dxInit',[],...
0145                         'SensitivityMode',[],...
0146                         'mu',[],...
0147                         'lambdaX',[],...
0148                         'lambdaU',[],...
0149                         'lambdaP',[],...
0150                         'lambdaW',[],...
0151                         'mu2',[],...
0152                         'lambda2X',[],...
0153                         'lambda2U',[],...
0154                         'lambda2P',[],...
0155                         'lambda2W',[],...
0156                         'PrintLevel',1,...
0157                         'PlotXTrajectory',[],...
0158                         'PlotXaTrajectory',[],...
0159                         'UseSubplots',0, ...
0160                         'StorageResolution',101, ...
0161                         'Jacobian', []);
0162 
0163     switch ( nargin )
0164         case 0
0165             return;
0166 
0167         case 1
0168             settings.Model = model;
0169             return;
0170 
0171         case 2
0172             settings.Model = model;
0173             settings.Integrator = integrator;
0174             settings.Tolerance = determineDefaultTolerance( integrator );
0175             return;
0176 
0177         otherwise
0178             disp('ERROR (integratorSettings): At most two input arguments allowed!');
0179             return;
0180     end
0181 
0182 end
0183 
0184 
0185 function [ tolerance ] = determineDefaultTolerance( integrator )
0186 
0187     switch ( integrator )
0188         case 'BDF'
0189             tolerance = 1e-6;
0190             return;
0191 
0192         case 'RK12'
0193             tolerance = 1e-1;
0194             return;
0195 
0196         case 'RK23'
0197             tolerance = 1e-2;
0198             return;
0199 
0200         case 'RK45'
0201             tolerance = 1e-6;
0202             return;
0203 
0204         case 'RK78'
0205             tolerance = 1e-6;
0206             return;
0207 
0208         otherwise
0209             tolerance = [];
0210             return;
0211     end
0212 
0213 end

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