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_solver/scp_step.hpp> 00035 #include <acado/curve/curve.hpp> 00036 #include <acado/bindings/acado_qpoases/qp_solver_qpoases.hpp> 00037 00038 00039 BEGIN_NAMESPACE_ACADO 00040 00041 00042 // 00043 // PUBLIC MEMBER FUNCTIONS: 00044 // 00045 00046 SCPstep::SCPstep( ) : AlgorithmicBase( ) 00047 { 00048 setupOptions( ); 00049 setupLogging( ); 00050 00051 meritFcn = new SCPmeritFunction; 00052 } 00053 00054 00055 SCPstep::SCPstep( UserInteraction* _userInteraction ) : AlgorithmicBase( _userInteraction ) 00056 { 00057 // setup options and loggings for stand-alone instances 00058 if ( _userInteraction == 0 ) 00059 { 00060 setupOptions( ); 00061 setupLogging( ); 00062 } 00063 00064 meritFcn = new SCPmeritFunction( _userInteraction ); 00065 } 00066 00067 00068 SCPstep::SCPstep( const SCPstep& rhs ) : AlgorithmicBase( rhs ) 00069 { 00070 if( rhs.meritFcn != 0 ) meritFcn = new SCPmeritFunction( *(rhs.meritFcn) ); 00071 else meritFcn = 0; 00072 } 00073 00074 00075 SCPstep::~SCPstep( ) 00076 { 00077 if( meritFcn != 0 ) 00078 delete meritFcn; 00079 } 00080 00081 00082 SCPstep& SCPstep::operator=( const SCPstep& rhs ) 00083 { 00084 if ( this != &rhs ) 00085 { 00086 if( meritFcn != 0 ) 00087 delete meritFcn; 00088 00089 AlgorithmicBase::operator=( rhs ); 00090 00091 if( rhs.meritFcn != 0 ) meritFcn = new SCPmeritFunction( *(rhs.meritFcn) ); 00092 else meritFcn = 0; 00093 } 00094 00095 return *this; 00096 } 00097 00098 00099 00100 // 00101 // PROTECTED MEMBER FUNCTIONS: 00102 // 00103 00104 returnValue SCPstep::setupOptions( ) 00105 { 00106 return SUCCESSFUL_RETURN; 00107 } 00108 00109 00110 returnValue SCPstep::setupLogging( ) 00111 { 00112 return SUCCESSFUL_RETURN; 00113 } 00114 00115 00116 returnValue SCPstep::applyStep( OCPiterate& iter, 00117 BandedCP& cp, 00118 double alpha 00119 ) const 00120 { 00121 return iter.applyStep( cp.deltaX,alpha ); 00122 } 00123 00124 00125 // returnValue SCPstep::getUpdatedFirstControl( const OCPiterate& iter, 00126 // const BandedCP& cp, 00127 // double alpha, 00128 // DVector& _u 00129 // ) const 00130 // { 00131 // DMatrix tmp; 00132 // 00133 // cp.deltaX.getSubBlock( 3*iter.getNumPoints()+0, 0, tmp, _u.getDim(), 1 ); 00134 // 00135 // for( uint run1 = 0; run1 < _u.getDim(); run1++ ) 00136 // _u(run1) += alpha*tmp(run1,0); 00137 // 00138 // return SUCCESSFUL_RETURN; 00139 // } 00140 00141 00142 CLOSE_NAMESPACE_ACADO 00143 00144 // end of file.