44 #include "NLPInterfacePack_NLPFirstOrderThyraModelEvaluator.hpp"
46 #include "MoochoPack_MoochoThyraSolver.hpp"
47 #include "Stratimikos_DefaultLinearSolverBuilder.hpp"
48 #include "Thyra_EpetraModelEvaluator.hpp"
49 #include "Teuchos_GlobalMPISession.hpp"
50 #include "Teuchos_VerboseObject.hpp"
51 #include "Teuchos_CommandLineProcessor.hpp"
52 #include "Teuchos_StandardCatchMacros.hpp"
54 int main(
int argc,
char* argv[] )
57 typedef AbstractLinAlgPack::value_type Scalar;
61 bool dummySuccess =
true;
71 MoochoThyraSolver solver;
96 bool supportDerivs =
true;
98 std::string extraXmlFile =
"";
100 CommandLineProcessor clp(
false);
103 solver.setupCLP(&clp);
105 clp.setOption(
"xt0", &xt0 );
106 clp.setOption(
"xt1", &xt1 );
107 clp.setOption(
"pt0", &pt0 );
108 clp.setOption(
"pt1", &pt1 );
109 clp.setOption(
"d", &d );
110 clp.setOption(
"x00", &x00 );
111 clp.setOption(
"x01", &x01 );
112 clp.setOption(
"p00", &p00 );
113 clp.setOption(
"p01", &p01 );
114 clp.setOption(
"pL0", &pL0 );
115 clp.setOption(
"pL1", &pL1 );
116 clp.setOption(
"pU0", &pU0 );
117 clp.setOption(
"pU1", &pU1 );
118 clp.setOption(
"xL0", &xL0 );
119 clp.setOption(
"xL1", &xL1 );
120 clp.setOption(
"xU0", &xU0 );
121 clp.setOption(
"xU1", &xU1 );
122 clp.setOption(
"support-derivs",
"no-support-derivs", &supportDerivs );
123 clp.setOption(
"extra-xml-file",&extraXmlFile,
"File with extra XML text that will modify the initial XML read in");
125 std::string line(
"");
126 if(extraXmlFile.length()) {
127 std::ifstream myfile(extraXmlFile.c_str());
128 if (myfile.is_open())
130 getline (myfile,line);
131 solver.extraParamsXmlStringOption(line);
132 std::cout << line <<
"\n";
137 CommandLineProcessor::EParseCommandLineReturn
138 parse_return = clp.parse(argc,argv,&std::cerr);
140 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
144 solver.readParameters(out.
get());
166 epetraThyraModel->
initialize(epetraModel,lowsFactory);
173 solver.setModel(epetraThyraModel);
176 solver.readInitialGuess(out.
get());
179 const MoochoSolver::ESolutionStatus solution_status = solver.solve();
182 solver.writeFinalSolution(out.
get());
186 solver.writeParamsFile();
192 return solution_status;
197 return MoochoSolver::SOLVE_RETURN_EXCEPTION;
void set_x_bounds(double xL0, double xL1, double xU0, double xU1)
void setupCLP(Teuchos::CommandLineProcessor *clp)
void set_p_bounds(double pL0, double pL1, double pU0, double pU1)
void readParameters(std::ostream *out)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
RCP< Thyra::LinearOpWithSolveFactoryBase< double > > createLinearSolveStrategy(const std::string &linearSolveStrategyName) const
static RCP< FancyOStream > getDefaultOStream()
void initialize(const RCP< const EpetraExt::ModelEvaluator > &epetraModel, const RCP< LinearOpWithSolveFactoryBase< double > > &W_factory)
void writeParamsFile(const Thyra::LinearOpWithSolveFactoryBase< double > &lowsFactory, const std::string &outputXmlFileName="") const
void setSupportDerivs(bool supportDerivs)
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)