[CppAD] Bug in optimize()?
Brad Bell
bradbell at seanet.com
Tue Aug 9 13:20:35 EDT 2011
I think that I have fixed the problem. See
https://projects.coin-or.org/CppAD/browser/branches/base_require/cppad/local/optimize.hpp
1722 Base eps = 10. * epsilon<Base>();
1723 for(i = 0; i < m; i++) CPPAD_ASSERT_KNOWN(
1724 abs_geq( eps * max_taylor , check[i] -
y[i] ) ,
1725 "Error during check of f.optimize()."
1726 );
Please try testing this branch
svn checkout
https://projects.coin-or.org/svn/CppAD/branches/base_require base_require
The branch contains a development version which I plan to merge into the
trunk soon.
The branch is called base_require because it includes significant
modifications to documentation and API for how one defines there own
Base type. This was necessary so that CppAD can check for approximately
equal (using abs_geq) instead of exactly equal (to fix the optimize
bug). Unfortunately, the new documentation will not be on the web until
the branch is merged into the trunk, but the corresponding source code is in
base_require/cppad/base_require.hpp
and the files named "base_*" that are referenced by that file; for example
https://projects.coin-or.org/CppAD/browser/branches/base_require/cppad/local/base_double.hpp
shows how CppAD provides the base type requirements for AD<double>.
On 7/25/2011 8:44 AM, Oliver Ruepp wrote:
> 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
>
> _______________________________________________
> CppAD mailing list
> CppAD at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cppad
>
More information about the CppAD
mailing list