50 #include "NLPInterfacePack_ExampleNLPDirectRun.hpp"
51 #include "AbstractLinAlgPack_exampleNLPDiagSetup.hpp"
52 #include "AbstractLinAlgPack_VectorSpace.hpp"
53 #include "Teuchos_Workspace.hpp"
54 #include "Teuchos_oblackholestream.hpp"
56 int main(
int argc,
char* argv[] ) {
60 namespace mmp = MemMngPack;
63 typedef AbstractLinAlgPack::value_type value_type;
64 namespace NLPIP = NLPInterfacePack;
65 namespace rsqp = MoochoPack;
66 using rsqp::MoochoSolver;
83 MPI_Init(&argc,&argv);
84 int num_proc, proc_rank;
85 MPI_Comm_size( MPI_COMM_WORLD, &num_proc );
86 MPI_Comm_rank( MPI_COMM_WORLD, &proc_rank );
99 PROG_NLP_TEST_ERR = -1,
101 PROG_MAX_ITER_EXEEDED = -3,
102 PROG_MAX_TIME_EXEEDED = -4;
104 int prog_return = PROG_SUCCESS;
107 std::ostream &out = std::cout;
108 std::ostream &eout = std::cerr;
122 VectorSpace::space_ptr_t vec_space;
123 const int err = AbstractLinAlgPack::exampleNLPDiagSetup(argc,argv,MPI_COMM_WORLD,&vec_space,&n,&xo,&has_bounds,&dep_bounded);
127 const MoochoSolver::ESolutionStatus
129 *vec_space, xo, has_bounds, dep_bounded
130 ,proc_rank == 0 ? &out : &blackhole
131 ,proc_rank == 0 ? &eout : &blackhole
132 ,proc_rank == 0 ?
false :
true
133 ,proc_rank == 0 ? NULL : &blackhole
134 ,proc_rank == 0 ? NULL : &blackhole
135 ,proc_rank == 0 ? NULL : &blackhole
138 switch(solve_return) {
139 case MoochoSolver::SOLVE_RETURN_SOLVED:
140 prog_return = PROG_SUCCESS;
142 case MoochoSolver::SOLVE_RETURN_MAX_ITER:
143 prog_return = PROG_MAX_ITER_EXEEDED;
145 case MoochoSolver::SOLVE_RETURN_MAX_RUN_TIME:
146 prog_return = PROG_MAX_TIME_EXEEDED;
148 case MoochoSolver::SOLVE_RETURN_NLP_TEST_FAILED:
149 prog_return = PROG_NLP_TEST_ERR;
151 case MoochoSolver::SOLVE_RETURN_EXCEPTION:
152 prog_return = PROG_EXCEPTION;
159 catch(
const std::exception& excpt) {
160 eout <<
"\nCaught a std::exception on process " << proc_rank<<
": " << excpt.what() << endl;
161 prog_return = PROG_EXCEPTION;
164 eout <<
"\nCaught an unknown exception on process " << proc_rank<<
"\n";
165 prog_return = PROG_EXCEPTION;
MoochoPack::MoochoSolver::ESolutionStatus ExampleNLPDirectRun(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)
TEUCHOSCORE_LIB_DLL_EXPORT Teuchos::RCP< WorkspaceStore > get_default_workspace_store()