interval.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/set_arithmetics/interval.hpp>
00035 
00036 
00037 BEGIN_NAMESPACE_ACADO
00038 
00039 
00040 
00041 BooleanType Interval::isCompact() const{
00042  
00043         BooleanType result = BT_TRUE;
00044         
00045         if( acadoIsNaN   ( _l ) == BT_TRUE  ) result = BT_FALSE;
00046         if( acadoIsFinite( _l ) == BT_FALSE ) result = BT_FALSE;
00047         if( acadoIsNaN   ( _u ) == BT_TRUE  ) result = BT_FALSE;
00048         if( acadoIsFinite( _u ) == BT_FALSE ) result = BT_FALSE;
00049         
00050         return result;
00051 }
00052 
00053 
00054 
00055 double Interval::mid( const double convRel, const double concRel, const double valCut, int &indexMid ) const{
00056 
00057   int ICONV = 0;
00058   int ICUT  = 1;
00059   int ICONC = 2;
00060 
00061   if( indexMid < 0 ){
00062     if ( valCut < convRel ){
00063       indexMid = ICONV;
00064       return convRel;
00065     }
00066     else
00067     if ( valCut < concRel ){
00068       indexMid = ICUT;
00069       return valCut;
00070     }
00071     else{
00072       indexMid = ICONC;
00073       return concRel;
00074     }
00075   }
00076 
00077   if ( indexMid == ICONV )
00078     return convRel;
00079 
00080   else
00081   if ( indexMid == ICUT )
00082     return valCut;
00083 
00084   else
00085     return concRel;
00086 }
00087 
00088 
00089 CLOSE_NAMESPACE_ACADO
00090 
00091 
00092 /*
00093  *      end of file
00094  */


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