[Boost-bugs] [Boost C++ Libraries] #11535: standard integrate_times function causes tiny time steps

Subject: [Boost-bugs] [Boost C++ Libraries] #11535: standard integrate_times function causes tiny time steps
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-08-12 02:50:48


#11535: standard integrate_times function causes tiny time steps
------------------------------+--------------------------
 Reporter: gaiwa84@… | Owner: karsten
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: odeint
  Version: Boost 1.58.0 | Severity: Optimization
 Keywords: |
------------------------------+--------------------------
 Hello!

 While implementing a new algorithm, I discovered that the function
 boost::numeric::odeint::detail::integrate_times(...) produces tiny time
 steps due to numerical accuracy issues (the relative error dt/t < 1e-18
 for type long double with 18 significant digits). After changing the
 function as below, the runge_kutta4 algorithm became about 15% faster for
 my problem at the same accuracy. But maybe I am missing the reason for the
 old implementation?

 Here is the new code with the old stuff commented out:


 {{{
 /*
  * integrate_times for simple stepper
  */
 template< class Stepper , class System , class State , class TimeIterator
 , class Time , class Observer >
 size_t integrate_times(
         Stepper stepper , System system , State &start_state ,
         TimeIterator start_time , TimeIterator end_time , Time dt ,
         Observer observer , stepper_tag
 )
 {
     BOOST_USING_STD_MIN();

     typename odeint::unwrap_reference< Observer >::type &obs = observer;

     size_t steps = 0;
     Time current_dt = dt;
     while( true )
     {
         Time current_time = *start_time++;
         obs( start_state , current_time );
         if( start_time == end_time )
             break;
 // while( less_with_sign( current_time , *start_time , current_dt
 ) )
 // {
             current_dt = min BOOST_PREVENT_MACRO_SUBSTITUTION ( dt ,
 *start_time - current_time );
             stepper.do_step( system , start_state , current_time ,
 current_dt );
 // current_time += current_dt;
             current_time = *start_time; //THIS IS NEW!
             steps++;
 // }
     }
     return steps;
 }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11535>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC