exact_hessian.cpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  */
00025 
00026 
00034 #include <acado/nlp_derivative_approximation/exact_hessian.hpp>
00035 
00036 
00037 
00038 BEGIN_NAMESPACE_ACADO
00039 
00040 
00041 //
00042 // PUBLIC MEMBER FUNCTIONS:
00043 //
00044 
00045 ExactHessian::ExactHessian( ) : NLPderivativeApproximation( )
00046 {
00047 }
00048 
00049 
00050 ExactHessian::ExactHessian( UserInteraction* _userInteraction ) : NLPderivativeApproximation( _userInteraction )
00051 {
00052 }
00053 
00054 
00055 ExactHessian::ExactHessian( const ExactHessian& rhs ) : NLPderivativeApproximation( rhs )
00056 {
00057 }
00058 
00059 
00060 ExactHessian::~ExactHessian( )
00061 {
00062 }
00063 
00064 
00065 ExactHessian& ExactHessian::operator=( const ExactHessian& rhs )
00066 {
00067         if ( this != &rhs )
00068         {
00069                 NLPderivativeApproximation::operator=( rhs );
00070         }
00071 
00072         return *this;
00073 }
00074 
00075 
00076 NLPderivativeApproximation* ExactHessian::clone( ) const
00077 {
00078         return new ExactHessian( *this );
00079 }
00080 
00081 
00082 returnValue ExactHessian::initHessian(  BlockMatrix& B,
00083                                                                                 uint N,
00084                                                                                 const OCPiterate& iter
00085                                                                                 )
00086 {
00087         if( N > 1 )
00088         {
00089                 for( uint run1=0; run1<N; ++run1 )
00090                 {
00091                         if ( iter.getNX() != 0 )
00092                                 B.setIdentity( run1,run1, iter.getNX() );
00093 
00094                         if ( iter.getNXA() != 0 )
00095                                 B.setIdentity( N+run1,N+run1, iter.getNXA() );
00096 
00097                         if ( ( iter.getNP() != 0 ) && ( run1 != N-1 ) )
00098                                 B.setIdentity( 2*N+run1,2*N+run1, iter.getNP() );
00099 
00100                         if ( ( iter.getNU() != 0 ) && ( run1 != N-1 ) )
00101                                 B.setIdentity( 3*N+run1,3*N+run1, iter.getNU() );
00102 
00103                         if ( ( iter.getNW() != 0 ) && ( run1 != N-1 ) )
00104                                 B.setIdentity( 4*N+run1,4*N+run1, iter.getNW() );
00105                 }
00106         }
00107         else
00108         {
00109                 if ( iter.getNP() != 0 )
00110                         B.setIdentity( 2,2, iter.getNP() );
00111 
00112                 if ( iter.getNU() != 0 )
00113                         B.setIdentity( 3,3, iter.getNU() );
00114 
00115                 if ( iter.getNW() != 0 )
00116                         B.setIdentity( 4,4, iter.getNW() );
00117         }
00118 
00119         return SUCCESSFUL_RETURN;
00120 }
00121 
00122 
00123 returnValue ExactHessian::initScaling(  BlockMatrix& B,
00124                                                                                 const BlockMatrix& x,
00125                                                                                 const BlockMatrix& y
00126                                                                                 )
00127 {
00128     DMatrix scale1, scale2;
00129 
00130     (x^x).getSubBlock(0,0,scale1,1,1);
00131     (y^y).getSubBlock(0,0,scale2,1,1);
00132 
00133     if ( ( scale1(0,0) <= 1000.0*EPS ) || ( scale2(0,0) <= 1000.0*EPS ) )
00134         {
00135                 hessianScaling = 1.0;
00136         }
00137         else
00138         {
00139                 hessianScaling = sqrt( scale2(0,0)/scale1(0,0) );
00140         }
00141 
00142     return SUCCESSFUL_RETURN;
00143 }
00144 
00145 
00146 returnValue ExactHessian::apply(        BlockMatrix &B,
00147                                                                         const BlockMatrix &x,
00148                                                                         const BlockMatrix &y
00149                                                                         )
00150 {
00151         return SUCCESSFUL_RETURN;
00152 }
00153 
00154 
00155 
00156 //
00157 // PROTECTED MEMBER FUNCTIONS:
00158 //
00159 
00160 
00161 
00162 
00163 
00164 CLOSE_NAMESPACE_ACADO
00165 
00166 // end of file.


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:58:09