Boost C++ Libraries: Ticket #11535: standard integrate_times function causes tiny time steps https://svn.boost.org/trac10/ticket/11535 <p> Hello! </p> <p> 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 &lt; 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? </p> <p> Here is the new code with the old stuff commented out: </p> <pre class="wiki">/* * integrate_times for simple stepper */ template&lt; class Stepper , class System , class State , class TimeIterator , class Time , class Observer &gt; size_t integrate_times( Stepper stepper , System system , State &amp;start_state , TimeIterator start_time , TimeIterator end_time , Time dt , Observer observer , stepper_tag ) { BOOST_USING_STD_MIN(); typename odeint::unwrap_reference&lt; Observer &gt;::type &amp;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; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11535 Trac 1.4.3 anonymous Wed, 09 Sep 2015 03:28:04 GMT <link>https://svn.boost.org/trac10/ticket/11535#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11535#comment:1</guid> <description> <p> This is the specialization of integrate_times for solvers implementing the <a class="missing wiki">StepperConcept</a>. There is no accuracy for this steppers as step size control is not performed here. The loop (which you commented out) exists to reach the given time points single steps. I don't see how it can work if it is remmoved. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 09 Sep 2015 19:52:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11535#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11535#comment:2</guid> <description> <p> Your new code only works for the case when dt is bigger or equal to the time differences of the given time points. The while loop is exactly there to step through the solution with dt if the time points are further apart. </p> <p> However, I understand your problem and I might have an idea to fix it. Nevertheless, it seems to me that you might want to look into the other integrate functions, like integrate_n_steps. Maybe they are more suitable for your case? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 09 Sep 2015 19:59:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11535#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11535#comment:3</guid> <description> <p> I've filed this on Github as well: <a class="ext-link" href="https://github.com/headmyshoulder/odeint-v2/issues/171"><span class="icon">​</span>https://github.com/headmyshoulder/odeint-v2/issues/171</a> </p> </description> <category>Ticket</category> </item> <item> <author>J.Saffer <j.saffer@…></author> <pubDate>Mon, 16 Apr 2018 15:48:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11535#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11535#comment:4</guid> <description> <p> Are you certain this is really a accuracy error and not related to <a class="new ticket" href="https://svn.boost.org/trac10/ticket/13524" title="#13524: Bugs: Parameter mismatch on make_controlled factory (incorrectly constructed ... (new)">#13524</a> ? You might want to check that out ... </p> </description> <category>Ticket</category> </item> </channel> </rss>