source: trunk/example/ipopt_solve/solve.cpp @ 3746

Last change on this file since 3746 was 3746, checked in by bradbell, 4 years ago

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: 57d3215cae5e9da7b4c92e89f038d70870ef7327
end hash code: 9aebc1ca2c0949dec7c2d156517db26e60f28159

commit 9aebc1ca2c0949dec7c2d156517db26e60f28159
Author: Brad Bell <bradbell@…>
Date: Sun Nov 8 20:15:38 2015 -0800

Remove invisible white space.

commit a92ac50e9f4c8d0007ea5a245b3e23145dfcebfe
Author: Brad Bell <bradbell@…>
Date: Sun Nov 8 20:15:31 2015 -0800

Use vectorBool with partial sparsity patterns per pass to reduce memory requirements.


solve_callback.hpp: remove invisible white space.
rev_sparse_jac.hpp: fix bug (argument transposed).
bool_sparsity.cpp: remove invisible white space.

commit c09744b13ba2c70d6ffa857206d45560154d800a
Author: Brad Bell <bradbell@…>
Date: Sun Nov 8 03:22:57 2015 -0800

check_for_nan.hpp: fix minor type in documentation.

  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1/* $Id: solve.cpp 3746 2015-11-09 04:50:27Z bradbell $ */
2/* --------------------------------------------------------------------------
3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
4
5CppAD is distributed under multiple licenses. This distribution is under
6the terms of the
7                    Eclipse Public License Version 1.0.
8
9A copy of this license is included in the COPYING file of this distribution.
10Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
11-------------------------------------------------------------------------- */
12
13// system include files used for I/O
14# include <iostream>
15
16// C style asserts
17# include <cassert>
18
19// ipopt solve include file
20# include <cppad/ipopt/solve.hpp>
21
22// external complied tests
23extern bool get_started(void);
24extern bool ode_inverse(void);
25extern bool retape(void);
26
27namespace {
28        // function that runs one test
29        static size_t Run_ok_count    = 0;
30        static size_t Run_error_count = 0;
31        bool Run(bool TestOk(void), const char *name)
32        {       bool ok = true;
33                double s0 = CppAD::elapsed_seconds();
34                ok &= TestOk();
35                double s1 = CppAD::elapsed_seconds();
36                double sec = std::floor(100*(s1 - s0) + 0.5) / 100.;
37                if( ok )
38                {       std::cout << "OK:    " << "ipopt_solve: " << name;
39                        std::cout << ", seconds = " << sec  << std::endl;
40                        Run_ok_count++;
41                }
42                else
43                {       std::cout << "Error: " << "ipopt_solve: " << name << std::endl;
44                        Run_error_count++;
45                }
46                return ok;
47        }
48}
49
50// main program that runs all the tests
51int main(void)
52{       bool ok = true;
53
54        // This line is used by test_one.sh
55
56        // external compiled tests
57        ok &= Run( get_started,         "get_started"  );
58        ok &= Run( ode_inverse,         "ode_inverse"  );
59        ok &= Run( retape,              "retape"       );
60
61        // check for errors
62        using std::cout;
63        using std::endl;
64        assert( ok || (Run_error_count > 0) );
65        if( CppAD::thread_alloc::free_all() )
66        {       Run_ok_count++;
67                cout << "OK:    " << "No memory leak detected" << endl;
68        }
69        else
70        {       ok = false;
71                Run_error_count++;
72                cout << "Error: " << "memory leak detected" << endl;
73        }
74        // convert int(size_t) to avoid warning on _MSC_VER systems
75        if( ok )
76                cout << "All " << int(Run_ok_count) << " tests passed." << endl;
77        else    cout << int(Run_error_count) << " tests failed." << endl;
78
79        return static_cast<int>( ! ok );
80}
Note: See TracBrowser for help on using the repository browser.