multi_objective_functionality.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 
00033 #include <acado/ocp/multi_objective_functionality.hpp>
00034 #include <acado/matrix_vector/matrix_vector.hpp>
00035 #include <acado/symbolic_expression/symbolic_expression.hpp>
00036 
00037 
00038 BEGIN_NAMESPACE_ACADO
00039 
00040 
00041 
00042 //
00043 // PUBLIC MEMBER FUNCTIONS:
00044 //
00045 
00046 
00047 MultiObjectiveFunctionality::MultiObjectiveFunctionality( ){
00048 
00049     nMayer     = 0;
00050     mayerTerms = 0;
00051 }
00052 
00053 
00054 MultiObjectiveFunctionality::MultiObjectiveFunctionality( const MultiObjectiveFunctionality& rhs ){
00055 
00056     int run1;
00057     nMayer = rhs.nMayer;
00058 
00059     if( nMayer > 0 ){
00060         mayerTerms = (Expression**)calloc(nMayer,sizeof(Expression*));
00061         for( run1 = 0; run1 < nMayer; run1++ ){
00062             mayerTerms[run1] = new Expression(*rhs.mayerTerms[run1]);
00063         }
00064     }
00065     else{
00066         mayerTerms = 0;
00067     }
00068 }
00069 
00070 
00071 MultiObjectiveFunctionality::~MultiObjectiveFunctionality( ){
00072 
00073     int run1;
00074     for( run1 = 0; run1 < nMayer; run1++ )
00075         if( mayerTerms[run1] != 0 ) delete mayerTerms[run1];
00076 
00077     if( mayerTerms != 0 )
00078         free(mayerTerms);
00079 }
00080 
00081 
00082 MultiObjectiveFunctionality& MultiObjectiveFunctionality::operator=( const MultiObjectiveFunctionality& rhs ){
00083 
00084     int run1;
00085 
00086     if ( this != &rhs ){
00087 
00088         for( run1 = 0; run1 < nMayer; run1++ )
00089             if( mayerTerms[run1] != 0 ) delete mayerTerms[run1];
00090 
00091         if( mayerTerms != 0 )
00092             free(mayerTerms);
00093 
00094         nMayer = rhs.nMayer;
00095 
00096         if( nMayer > 0 ){
00097             mayerTerms = (Expression**)calloc(nMayer,sizeof(Expression*));
00098             for( run1 = 0; run1 < nMayer; run1++ ){
00099                 mayerTerms[run1] = new Expression( *rhs.mayerTerms[run1] );
00100             }
00101         }
00102         else{
00103             mayerTerms = 0;
00104         }
00105     }
00106     return *this;
00107 }
00108 
00109 
00110 
00111 returnValue MultiObjectiveFunctionality::minimizeMayerTerm( const int &multiObjectiveIdx,
00112                                                             const Expression& arg ){
00113 
00114     ASSERT( multiObjectiveIdx >= 0 );
00115 
00116     if( multiObjectiveIdx >= nMayer ){
00117         ASSERT( multiObjectiveIdx == nMayer );
00118         nMayer = multiObjectiveIdx+1;
00119         mayerTerms = (Expression**)realloc(mayerTerms,nMayer*sizeof(Expression*));
00120         mayerTerms[multiObjectiveIdx] = new Expression(arg);
00121         return SUCCESSFUL_RETURN;
00122     }
00123     mayerTerms[multiObjectiveIdx] = new Expression( *mayerTerms[multiObjectiveIdx] + arg );
00124     return SUCCESSFUL_RETURN;
00125 }
00126 
00127 int MultiObjectiveFunctionality::getNumberOfMayerTerms() const{
00128 
00129     return nMayer;
00130 }
00131 
00132 returnValue MultiObjectiveFunctionality::getObjective( const int &multiObjectiveIdx, Expression **arg ) const{
00133 
00134     ASSERT( arg != 0 );
00135     ASSERT( multiObjectiveIdx < nMayer);
00136     *arg = new Expression(*mayerTerms[multiObjectiveIdx]);
00137 
00138     return SUCCESSFUL_RETURN;
00139 }
00140 
00141 
00142 CLOSE_NAMESPACE_ACADO
00143 
00144 // end of file.


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