Ejemplo n.º 1
0
void throwSequenceSizeError( const size_t aSize, const size_t aMin )
{
    THROW_EXCEPTION( RangeError,
                     "size of the sequence must be at least " 
                     + stringCast( aMin ) + 
                     + " ( " + stringCast( aSize ) + " given)" );
}
Ejemplo n.º 2
0
void throwSequenceSizeError( const size_t aSize, 
                             const size_t aMin, const size_t aMax )
{
    THROW_EXCEPTION( RangeError,
                     "size of the sequence must be within [ " 
                     + stringCast( aMin ) + ", " + stringCast( aMax )
                     + " ] ( " + stringCast( aSize ) + " given)" );
}
Ejemplo n.º 3
0
bool Process::removeVariableReference( Integer anID, bool raiseException )
{
    VariableReferenceVector::iterator i( findVariableReference( anID ) );
    if ( i == theVariableReferenceVector.end() )
    {
        if ( !raiseException )
        {
            return false;
        }
        THROW_EXCEPTION_INSIDE( NotFound,
                                asString() + ": VariableReference #"
                                + stringCast( anID )
                                + " not found in this Process" );
    }
    theVariableReferenceVector.erase( i );
    return true;
}
Ejemplo n.º 4
0
VariableReference const&
Process::getVariableReference( Integer anID ) const
{
    VariableReferenceVector::const_iterator anIterator(
            findVariableReference( anID ) );

    if( anIterator != theVariableReferenceVector.end() )
    {
        return *anIterator;
    }
    else
    {
        THROW_EXCEPTION_INSIDE( NotFound,
                                asString() + ": VariableReference #"
                                + stringCast( anID )
                                + " not found in this Process" );
    }
}
Ejemplo n.º 5
0
void AdaptiveDifferentialStepper::updateInternalState( Real aStepInterval )
{
    theStateFlag = false;

    clearVariables();

    Integer theRejectedStepCounter( 0 );

    while ( !calculate( aStepInterval ) )
    {
        if ( ++theRejectedStepCounter >= theTolerableRejectedStepCount )
        {
            THROW_EXCEPTION_INSIDE( SimulationError,
                String( "The times of rejections of step calculation "
                    "exceeded a maximum tolerable count (" )
                + stringCast( theTolerableRejectedStepCount ) + ")." );
        }
 
        // shrink it if the error exceeds 110%
        aStepInterval = aStepInterval * safety * std::pow( getMaxErrorRatio(),
                                                  -1.0 / getOrder() );
    }

    const Real maxError( getMaxErrorRatio() );

    // an extra calculation for resetting the activities of processes
    fireProcesses();

    setTolerableStepInterval( aStepInterval );

    theStateFlag = true;

    // grow it if error is 50% less than desired
    Real aNewStepInterval( aStepInterval );
    if ( maxError < 0.5 )
    {
        aNewStepInterval = aNewStepInterval * safety * std::pow( maxError,
                                            -1.0 / ( getOrder() + 1 ) );
    }

    setNextStepInterval( aNewStepInterval );

    DifferentialStepper::updateInternalState( aStepInterval );
}
Ejemplo n.º 6
0
std::string stringCast(PixelFormat format)
{
  return std::string(stringCast(format.semantic())) + stringCast(format.type());
}