Changeset 3894 for trunk/test_more


Ignore:
Timestamp:
Mar 4, 2017 9:56:53 PM (3 years ago)
Author:
bradbell
Message:

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: 9d1ea999dbd90dec52823dffd5fa895e1c9310f5
end hash code: 3b109e81aefcb411666ec6e837a7f4f446f9e5ee

commit 3b109e81aefcb411666ec6e837a7f4f446f9e5ee
Author: Brad Bell <bradbell@…>
Date: Sat Mar 4 14:38:17 2017 -0700

Test for and fix bug in optimization of conditional expressions.

commit 14db8c17e53c9b6b3e77f75e0b657b4f28b32ad0
Author: Brad Bell <bradbell@…>
Date: Sat Mar 4 12:12:37 2017 -0700

Change cskip_info -> cexp_info.

commit 6f992748e730afac24d234c637443f7e0d9ee629
Author: Brad Bell <bradbell@…>
Date: Sat Mar 4 10:38:32 2017 -0700

Advance to cppad-20170304.
cskip_op.hpp: add assert that occurs in cppad_mixed.

commit b117c84074fed0dda343a0acfe4f55345b88d9ed
Author: Brad Bell <bradbell@…>
Date: Sat Mar 4 06:59:20 2017 -0700

efficient.sh: complete binary search.

commit 18f33e4944a48380f62aca7cfa693575dd6303af
Author: Brad Bell <bradbell@…>
Date: Sat Mar 4 06:47:13 2017 -0700

efficient.sh: more entries in binary search.

commit 65af44ff04f26c8cab2dd0e77ed624d5ce1ea425
Author: Brad Bell <bradbell@…>
Date: Sat Mar 4 06:28:29 2017 -0700

efficient.sh: fix trailing white space in date, more entries in binary search.

commit 48762517923a145caad43c53cec3f8d1adc45e0e
Author: Brad Bell <bradbell@…>
Date: Sat Mar 4 06:16:41 2017 -0700

efficient.sh: set up for doing binary search one entry at a time.

commit 4c6239a403eacac861600ca5f835cfb8cda58d3b
Author: Brad Bell <bradbell@…>
Date: Sat Mar 4 05:42:37 2017 -0700

efficient.sh: shorten date display

commit 23ff81053ec230784fb17b29930405825f6d82fa
Author: Brad Bell <bradbell@…>
Date: Sat Mar 4 05:39:51 2017 -0700

efficient.sh: switch to hash codes, print date, detect cppad_path.

commit 51491eed7fe36fdb70f64bb499000e3dc5bbb5ed
Author: Brad Bell <bradbell@…>
Date: Fri Mar 3 10:26:30 2017 -0700

efficient.sh: Test that shows change in sparsity efficiency.

commit 01bc1fd364462f2bcd62d4da8c3159aee1d07429
Author: Brad Bell <bradbell@…>
Date: Mon Feb 27 09:14:28 2017 -0700

Advance to cppad-20170227.
CMakeLists.txt: fix supression of cmake WIN32 warning.

commit 8c8a107cda142a48d92e00d8249b8ced812ea772
Author: Brad Bell <bradbell@…>
Date: Sun Feb 26 07:40:21 2017 -0700

Add atomic element-wise vector operations to wish list.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test_more/optimize.cpp

    r3871 r3894  
    18751875                ok &= NearEqual(y[1], x[0] - x[1], eps10, eps10);
    18761876                ok &= NearEqual(y[2], exp(x[0]), eps10, eps10);
     1877
     1878                return ok;
     1879        }
     1880
     1881        // Test case where a variable is removed during optimization
     1882        // (bug fixed 2017-03-04)
     1883        bool cond_exp_skip_remove_var(void)
     1884        {       bool ok = true;
     1885                using CppAD::vector;
     1886                using CppAD::AD;
     1887                using CppAD::NearEqual;
     1888                double eps10 = 10.0 * std::numeric_limits<double>::epsilon();
     1889
     1890                vector< AD<double> > ax(2), ay(2);
     1891                ax[0] = 1.0;
     1892                ax[1] = 2.0;
     1893                Independent(ax);
     1894                //
     1895                AD<double> var_1   = ax[0] + ax[1];
     1896                AD<double> var_2   = ax[0] + ax[1]; // gets removed during optimization
     1897                AD<double> var_3   = ax[0] - ax[1];
     1898                AD<double> par_1   = 1.0;
     1899                //
     1900                // first conditional expression depends on var_1
     1901                // 6 * x_0 if x_0 + x_1 >= 1.0,  7 * x_1 otherwise
     1902                ay[0] = CppAD::CondExpGe(var_1, par_1, 6.0 * ax[0], 7.0 * ax[1]);
     1903                //
     1904                // second conditional expression depends on var_3
     1905                // 8 * x_0 if x_0 - x_1 >= x_0 + x_1, 9 * x_1 otherwise
     1906                ay[1] = CppAD::CondExpGe(var_3, par_1, 8.0 * ax[0], 9.0 * ax[1]);
     1907                CppAD::ADFun<double> f(ax, ay);
     1908                //
     1909                if( conditional_skip_ )
     1910                        f.optimize();
     1911                else
     1912                        f.optimize("no_conditional_skip");
     1913
     1914                // check case where x[0] = 2, x[1] = 4
     1915                vector<double> x(2), y(2);
     1916                x[0] = 2.0;
     1917                x[1] = 4.0;
     1918                y    = f.Forward(0, x);
     1919                ok &= NearEqual(y[0], 6.0 * x[0], eps10, eps10);
     1920                ok &= NearEqual(y[1], 9.0 * x[1], eps10, eps10);
    18771921
    18781922                return ok;
     
    19501994                ok     &= cond_exp_reverse();
    19511995                // check case where an expresion needed by both true and false case
    1952                 ok     &=  cond_exp_both_true_and_false();
    1953         }
     1996                ok     &= cond_exp_both_true_and_false();
     1997                // check case were a variable in left or right expressions
     1998                // is removed during the optimization
     1999                ok     &= cond_exp_skip_remove_var();
     2000        }
     2001                ok     &= cond_exp_skip_remove_var();
    19542002        //
    19552003        CppAD::user_atomic<double>::clear();
Note: See TracChangeset for help on using the changeset viewer.