output_fcn.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 
00027 
00036 #include <acado/function/function_.hpp>
00037 #include <acado/function/output_fcn.hpp>
00038 
00039 
00040 
00041 BEGIN_NAMESPACE_ACADO
00042 
00043 
00044 //
00045 // PUBLIC MEMBER FUNCTIONS:
00046 //
00047 
00048 OutputFcn::OutputFcn( ) : Function( )
00049 {
00050 }
00051 
00052 
00053 OutputFcn::OutputFcn( const OutputFcn& rhs ) : Function( rhs )
00054 {
00055 }
00056 
00057 
00058 OutputFcn::~OutputFcn( )
00059 {
00060 }
00061 
00062 
00063 OutputFcn& OutputFcn::operator=( const OutputFcn& rhs )
00064 {
00065     if ( this != &rhs )
00066     {
00067                 Function::operator=( rhs );
00068     }
00069 
00070     return *this;
00071 }
00072 
00073 
00074 Output OutputFcn::operator()(   uint componentIdx
00075                                                                 )
00076 {
00077         Operator* componentOperator = getExpression( componentIdx );
00078 
00079         Expression tmp;
00080         
00081         if ( componentOperator != 0 )
00082         {
00083                 tmp = *componentOperator;
00084                 delete componentOperator;
00085         }
00086 
00087         return Output( tmp,componentIdx );
00088 }
00089 
00090 
00091 returnValue OutputFcn::evaluate( double *x, double *_result ){
00092 
00093     return Function::evaluate( 0, x, _result );
00094 }
00095 
00096 
00097 
00098 returnValue OutputFcn::evaluate( const VariablesGrid *x ,
00099                                  const VariablesGrid *xa,
00100                                  const VariablesGrid *p ,
00101                                  const VariablesGrid *u ,
00102                                  const VariablesGrid *w ,
00103                                  VariablesGrid       *_result ){
00104 
00105     int run1;
00106 
00107     OCPiterate iter( x, xa, p, u, w );
00108     const int N = iter.getNumPoints();
00109     _result->init( getDim(), iter.getGrid() );
00110 
00111     EvaluationPoint z( *this, iter );
00112 
00113     for( run1 = 0; run1 < N; run1++ ){
00114 
00115         z.setZ( run1, iter ); 
00116         _result->setVector( run1, Function::evaluate(z) );
00117     }
00118 
00119     return SUCCESSFUL_RETURN;
00120 }
00121 
00122 
00123 
00124 DVector OutputFcn::evaluate( const EvaluationPoint &x,
00125                             const int              &number ){
00126 
00127     return Function::evaluate( x, number );
00128 }
00129 
00130 
00131 
00132 
00133 //
00134 // PROTECTED MEMBER FUNCTIONS:
00135 //
00136 
00137 
00138 
00139 
00140 
00141 CLOSE_NAMESPACE_ACADO
00142 
00143 // end of file.


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