[CppAD] Bug in optimize()?

Oliver Ruepp ruepp at in.tum.de
Mon Jul 25 11:44:03 EDT 2011


Hi all,

I recently ran into a problem using the optimize() method of a CppADFun
object. The problem occurs when evaluating a sequence of additions and
subtractions. As soon as the method is called, the program aborts with
the following message:

Error during check of f.optimize().
Error detected by false result for
    check[i] == y[i]
at line 1729 in the file
    /usr/local/include/cppad/local/optimize.hpp
cppad_sum_test: /usr/local/include/cppad/error_handler.hpp:198: static
void CppAD::ErrorHandler::Default(bool, int, const char*, const char*,
const char*): Assertion `false' failed.

This is basically due to CppAD realizing that the optimized computation
does not yield the same result as the original one.
I tried to get to the root of the problem, but couldn't quite figure out
how the 'optimize' method works.
Could it be that it rearranges the sequence of additions/subtractions? I
was thinking that this could be the problem, since floating-point
addition is not always commutative due to rounding.

I was able to reproduce the problem with a very simple example, which is
available here:
<http://www6.in.tum.de/~ruepp/cppad_sum_test.cpp>
I am using cppad-20110701 with g++ 4.5.2 under Linux.


Regards
Oliver Ruepp



More information about the CppAD mailing list