gauss_newton_approximation_bfgs.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/bfgs_update.hpp>
00035 #include <acado/nlp_derivative_approximation/gauss_newton_approximation_bfgs.hpp>
00036 
00037 
00038 BEGIN_NAMESPACE_ACADO
00039 
00040 
00041 //
00042 // PUBLIC MEMBER FUNCTIONS:
00043 //
00044 
00045 GaussNewtonApproximationWithBFGS::GaussNewtonApproximationWithBFGS( ) : GaussNewtonApproximation( )
00046 {
00047         bfgsUpdate = new BFGSupdate;
00048 }
00049 
00050 
00051 GaussNewtonApproximationWithBFGS::GaussNewtonApproximationWithBFGS(     UserInteraction* _userInteraction,
00052                                                                                                                                         uint _nBlocks
00053                                                                                                                                         ) : GaussNewtonApproximation( _userInteraction )
00054 {
00055         bfgsUpdate = new BFGSupdate( _userInteraction,_nBlocks );
00056 }
00057 
00058 
00059 GaussNewtonApproximationWithBFGS::GaussNewtonApproximationWithBFGS( const GaussNewtonApproximationWithBFGS& rhs ) : GaussNewtonApproximation( rhs )
00060 {
00061         if ( rhs.bfgsUpdate != 0 )
00062                 bfgsUpdate = new BFGSupdate( *(rhs.bfgsUpdate) );
00063         else
00064                 bfgsUpdate = 0;
00065 }
00066 
00067 
00068 GaussNewtonApproximationWithBFGS::~GaussNewtonApproximationWithBFGS( )
00069 {
00070         if ( bfgsUpdate != 0 )
00071                 delete bfgsUpdate;
00072 }
00073 
00074 
00075 GaussNewtonApproximationWithBFGS& GaussNewtonApproximationWithBFGS::operator=( const GaussNewtonApproximationWithBFGS& rhs )
00076 {
00077         if ( this != &rhs )
00078         {
00079                 if ( bfgsUpdate != 0 )
00080                         delete bfgsUpdate;
00081 
00082                 GaussNewtonApproximation::operator=( rhs );
00083 
00084                 if ( rhs.bfgsUpdate != 0 )
00085                         bfgsUpdate = new BFGSupdate( *(rhs.bfgsUpdate) );
00086                 else
00087                         bfgsUpdate = 0;
00088         }
00089 
00090         return *this;
00091 }
00092 
00093 
00094 NLPderivativeApproximation* GaussNewtonApproximationWithBFGS::clone( ) const
00095 {
00096         return new GaussNewtonApproximationWithBFGS( *this );
00097 }
00098 
00099 
00100 
00101 returnValue GaussNewtonApproximationWithBFGS::initHessian(      BlockMatrix& B,
00102                                                                                                                         uint N,
00103                                                                                                                         const OCPiterate& iter
00104                                                                                                                         )
00105 {
00106         return GaussNewtonApproximation::initHessian( B,N,iter );
00107 }
00108 
00109 
00110 returnValue GaussNewtonApproximationWithBFGS::initScaling(      BlockMatrix& B,
00111                                                                                                                         const BlockMatrix& x,
00112                                                                                                                         const BlockMatrix& y
00113                                                                                                                         )
00114 {
00115         if ( bfgsUpdate == 0 )
00116                 return ACADOERROR( RET_MEMBER_NOT_INITIALISED );
00117 
00118         bfgsUpdate->initScaling( B,x,y );
00119 
00120         return GaussNewtonApproximation::initScaling( B,x,y );
00121 }
00122 
00123 
00124 
00125 returnValue GaussNewtonApproximationWithBFGS::apply(    BlockMatrix &B,
00126                                                                                                                 const BlockMatrix &x,
00127                                                                                                                 const BlockMatrix &y
00128                                                                                                                 )
00129 {
00130         if ( bfgsUpdate == 0 )
00131                 return ACADOERROR( RET_MEMBER_NOT_INITIALISED );
00132 
00133         bfgsUpdate->apply( B,x,y );
00134 
00135         return GaussNewtonApproximation::apply( B,x,y );
00136 }
00137 
00138 
00139 
00140 //
00141 // PROTECTED MEMBER FUNCTIONS:
00142 //
00143 
00144 
00145 
00146 
00147 
00148 CLOSE_NAMESPACE_ACADO
00149 
00150 // end of file.


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