50 #include "NLPInterfacePack_ExampleNLPFirstOrderRun.hpp"
51 #include "AbstractLinAlgPack_exampleNLPDiagSetup.hpp"
52 #include "AbstractLinAlgPack_VectorSpace.hpp"
53 #include "Teuchos_GlobalMPISession.hpp"
54 #include "Teuchos_Workspace.hpp"
55 #include "Teuchos_oblackholestream.hpp"
57 int main(
int argc,
char* argv[]) {
61 namespace mmp = MemMngPack;
64 typedef AbstractLinAlgPack::value_type value_type;
65 namespace NLPIP = NLPInterfacePack;
66 namespace rsqp = MoochoPack;
67 using rsqp::MoochoSolver;
71 GlobalMPISession mpiSession(&argc, &argv);
74 const int proc_rank = GlobalMPISession::getRank();
79 PROG_NLP_TEST_ERR = -1,
81 PROG_MAX_ITER_EXEEDED = -3,
82 PROG_MAX_TIME_EXEEDED = -4;
84 int prog_return = PROG_SUCCESS;
87 std::ostream &out = std::cout;
88 std::ostream &eout = std::cerr;
102 VectorSpace::space_ptr_t vec_space;
103 const int err = AbstractLinAlgPack::exampleNLPDiagSetup(
104 argc, argv, MPI_COMM_WORLD, &vec_space, &n, &xo, &has_bounds, &dep_bounded);
109 const MoochoSolver::ESolutionStatus
111 *vec_space, xo, has_bounds, dep_bounded
112 ,proc_rank == 0 ? &out : &blackhole
113 ,proc_rank == 0 ? &eout : &blackhole
114 ,proc_rank == 0 ?
false :
true
115 ,proc_rank == 0 ? NULL : &blackhole
116 ,proc_rank == 0 ? NULL : &blackhole
117 ,proc_rank == 0 ? NULL : &blackhole
120 switch(solve_return) {
121 case MoochoSolver::SOLVE_RETURN_SOLVED:
122 prog_return = PROG_SUCCESS;
124 case MoochoSolver::SOLVE_RETURN_MAX_ITER:
125 prog_return = PROG_MAX_ITER_EXEEDED;
127 case MoochoSolver::SOLVE_RETURN_MAX_RUN_TIME:
128 prog_return = PROG_MAX_TIME_EXEEDED;
130 case MoochoSolver::SOLVE_RETURN_NLP_TEST_FAILED:
131 prog_return = PROG_NLP_TEST_ERR;
133 case MoochoSolver::SOLVE_RETURN_EXCEPTION:
134 prog_return = PROG_EXCEPTION;
141 catch(
const std::exception& excpt) {
142 eout <<
"\nCaught a std::exception on process " << proc_rank<<
": " << excpt.what() << endl;
143 prog_return = PROG_EXCEPTION;
146 eout <<
"\nCaught an unknown exception on process " << proc_rank<<
"\n";
147 prog_return = PROG_EXCEPTION;
MoochoPack::MoochoSolver::ESolutionStatus ExampleNLPFirstOrderRun(const VectorSpace &vec_space, value_type xo, bool has_bounds, bool dep_bounded, std::ostream *console_out, std::ostream *error_out, bool throw_solve_exception=false, std::ostream *algo_out=NULL, std::ostream *summary_out=NULL, std::ostream *journal_out=NULL)
Function accepts a VectorSpace object and then uses it to define an example NLP and run MoochoPack::M...
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)