returnValue CondensingExport::setStateBounds( const VariablesGrid& _xBounds ) { BooleanType isFinite = BT_FALSE; Vector lbTmp = _xBounds.getLowerBounds(0); Vector ubTmp = _xBounds.getUpperBounds(0); if ( xBoundsIdx != 0 ) delete[] xBoundsIdx; xBoundsIdx = new int[_xBounds.getDim()+1]; for( uint j=0; j<lbTmp.getDim(); ++j ) { if ( acadoIsGreater( ubTmp(j),lbTmp(j) ) == BT_FALSE ) return ACADOERROR( RET_INVALID_ARGUMENTS ); if ( ( acadoIsFinite( ubTmp(j) ) == BT_TRUE ) || ( acadoIsFinite( lbTmp(j) ) == BT_TRUE ) ) isFinite = BT_TRUE; } for( uint i=1; i<_xBounds.getNumPoints(); ++i ) { lbTmp = _xBounds.getLowerBounds(i); ubTmp = _xBounds.getUpperBounds(i); for( uint j=0; j<lbTmp.getDim(); ++j ) { if ( acadoIsGreater( ubTmp(j),lbTmp(j) ) == BT_FALSE ) return ACADOERROR( RET_INVALID_ARGUMENTS ); if ( ( acadoIsFinite( ubTmp(j) ) == BT_TRUE ) || ( acadoIsFinite( lbTmp(j) ) == BT_TRUE ) ) { xBoundsIdx[nxBounds] = i*lbTmp.getDim()+j; ++nxBounds; isFinite = BT_TRUE; } } } xBoundsIdx[nxBounds] = -1; if ( isFinite == BT_TRUE ) xBounds = _xBounds; else xBounds.init(); return SUCCESSFUL_RETURN; }
BooleanType Curve::isInTimeDomain( double t ) const { if( isEmpty( ) == BT_TRUE ) return BT_FALSE; if ( ( acadoIsGreater( t,grid->getFirstTime() ) == BT_TRUE ) && ( acadoIsSmaller( t,grid->getLastTime() ) == BT_TRUE ) ) return BT_TRUE; else return BT_FALSE; }
Vector DenseCP::getMergedDualSolution( ) const { Vector dualSolution( getNV()+getNC() ); uint i; for( i=0; i<getNV(); ++i ) { if ( acadoIsGreater( fabs( (*ylb)(i) ),1e-10 ) == BT_TRUE ) dualSolution(i) = (*ylb)(i); else dualSolution(i) = (*yub)(i); } for( i=0; i<getNC(); ++i ) { if ( acadoIsGreater( fabs( (*ylbA)(i) ),1e-10 ) == BT_TRUE ) dualSolution( getNV()+i ) = (*ylbA)(i); else dualSolution( getNV()+i ) = (*yubA)(i); } return dualSolution; }
returnValue PlotWindow::getAutoScaleYLimits( const VariablesGrid& dataGridY, PlotFormat plotFormat, double& lowerLimit, double& upperLimit ) const { double maxValue = dataGridY.getMax( ); double minValue = dataGridY.getMin( ); double meanValue = dataGridY.getMean( ); if ( ( acadoIsZero( maxValue ) == BT_TRUE ) && ( acadoIsZero( minValue ) == BT_TRUE ) ) meanValue = 0.1 / 0.025; lowerLimit = minValue - 0.1*( maxValue-minValue ) - 0.025*meanValue - 1.0e-8; upperLimit = maxValue + 0.1*( maxValue-minValue ) + 0.025*meanValue + 1.0e-8; if ( ( plotFormat == PF_LOG ) || ( plotFormat == PF_LOG_LOG ) ) { if ( ( acadoIsStrictlyGreater( minValue,0.0, ZERO ) == BT_TRUE ) && ( acadoIsGreater( lowerLimit,0.0, ZERO ) == BT_FALSE ) ) { lowerLimit = ( minValue + acadoMin( minValue,EPS ) ) / sqrt(10.0); upperLimit = upperLimit * sqrt(10.0); } } else { if ( ( acadoIsStrictlyGreater( minValue,0.0, ZERO ) == BT_TRUE ) && ( acadoIsGreater( lowerLimit,0.0, ZERO ) == BT_FALSE ) ) lowerLimit = 0.0; if ( ( acadoIsStrictlySmaller( maxValue,0.0 ) == BT_TRUE ) && ( acadoIsSmaller( upperLimit,0.0 ) == BT_FALSE ) ) upperLimit = 0.0; } return SUCCESSFUL_RETURN; }
returnValue VariablesGrid::appendTimes( const VariablesGrid& arg, MergeMethod _mergeMethod ) { // nothing to do for empty grids if ( arg.getNumPoints( ) == 0 ) return SUCCESSFUL_RETURN; if ( getNumPoints( ) == 0 ) { *this = arg; return SUCCESSFUL_RETURN; } // consistency check if ( acadoIsGreater( arg.getFirstTime( ),getLastTime( ) ) == BT_FALSE ) return ACADOERROR( RET_INVALID_ARGUMENTS ); if ( acadoIsEqual( getLastTime( ),arg.getFirstTime( ) ) == BT_FALSE ) { // simply append for( uint i=0; i<arg.getNumPoints( ); ++i ) addMatrix( *(arg.values[i]),arg.getTime( i ) ); } else { // if last and first time point coincide, merge as specified switch ( _mergeMethod ) { case MM_KEEP: break; case MM_REPLACE: setVector( getLastIndex(),arg.getFirstVector( ) ); break; case MM_DUPLICATE: addMatrix( *(arg.values[0]),arg.getTime( 0 ) ); break; } // simply append all remaining points for( uint i=1; i<arg.getNumPoints( ); ++i ) addMatrix( *(arg.values[i]),arg.getTime( i ) ); } return SUCCESSFUL_RETURN; }