00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <iostream>
00030
00031 #include "NLPInterfacePack_ExampleNLPBanded.hpp"
00032 #include "MoochoPack_MoochoSolver.hpp"
00033 #include "Teuchos_CommandLineProcessor.hpp"
00034 #include "Teuchos_StandardCatchMacros.hpp"
00035
00036 int main( int argc, char* argv[] )
00037 {
00038 namespace mp = MoochoPack;
00039 namespace nlpip = NLPInterfacePack;
00040 using mp::MoochoSolver;
00041 using nlpip::NLP;
00042 using nlpip::ExampleNLPBanded;
00043 typedef nlpip::size_type size_type;
00044 typedef nlpip::value_type value_type;
00045 using Teuchos::CommandLineProcessor;
00046 bool success = true;
00047
00048 try {
00049
00050 MoochoSolver solver;
00051
00052
00053
00054
00055
00056 bool show_options = false;
00057 int nD = 1;
00058 int nI = 1;
00059 int bw = 1;
00060 int mI = 0;
00061 double xo = 1;
00062 bool nlp_selects_basis = true;
00063 double xDl = -NLP::infinite_bound();
00064 double xDu = +NLP::infinite_bound();
00065 double xIl = -NLP::infinite_bound();
00066 double xIu = +NLP::infinite_bound();
00067
00068
00069
00070
00071
00072 int mU = 0;
00073 double hl = -NLP::infinite_bound();
00074 double hu = +NLP::infinite_bound();
00075 double diag_scal = 1.0;
00076 double diag_vary = 1.0;
00077 bool sym_basis = false;
00078 double f_offset = 0.0;
00079 double co = 0.0;
00080 bool ignore_constraints = false;
00081
00082 CommandLineProcessor clp(false);
00083
00084 solver.setup_commandline_processor(&clp);
00085
00086 clp.setOption( "show-options", "no-show-options", &show_options, "Show the commandline options or not." );
00087 clp.setOption( "nD", &nD, "Number of dependent variables" );
00088 clp.setOption( "nI", &nI, "Number of independent variables" );
00089 clp.setOption( "bw", &bw, "Band width of the basis matrix" );
00090 clp.setOption( "mI", &mI, "Number of general inequality constriants" );
00091 clp.setOption( "xo", &xo, "Initial guess for x" );
00092 clp.setOption( "xDl", &xDl, "Lower bounds on xD" );
00093 clp.setOption( "xDu", &xDu, "Upper bounds on xD" );
00094 clp.setOption( "xIl", &xIl, "Lower bounds on xI" );
00095 clp.setOption( "xIu", &xIu, "Upper bounds on xI" );
00096
00097 clp.setOption( "hl", &hl, "Lower bounds on general inequalities" );
00098 clp.setOption( "hu", &hu, "Upper bounds on general inequalities" );
00099 clp.setOption( "diag-scal", &diag_scal, "Scaling of the basis diagonal" );
00100 clp.setOption( "diag-vary", &diag_vary, "Variation of the basis diagonal scaling" );
00101 clp.setOption(
00102 "nlp-selects-basis", "no-nlp-selects-basis", &nlp_selects_basis
00103 ,"Determine if the NLP will select basis" );
00104 clp.setOption(
00105 "sym-basis", "unsym-basis", &sym_basis
00106 ,"Determine if the basis is symmetric" );
00107 clp.setOption( "f_offset", &f_offset, "Constant offset for objective function" );
00108 clp.setOption( "co", &co, "Constant term in general equalities" );
00109 clp.setOption(
00110 "ignore-constraints", "no-ignore-constraints", &ignore_constraints
00111 ,"Determine if constraints are ignored or not" );
00112
00113 CommandLineProcessor::EParseCommandLineReturn
00114 parse_return = clp.parse(argc,argv,&std::cerr);
00115
00116 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
00117 return parse_return;
00118
00119 if(show_options) {
00120 std::cout << "\nPrinting commandline options used (options used shown as (default: \?\?\?) ...\n\n";
00121 clp.printHelpMessage(argv[0],std::cout);
00122 }
00123
00124
00125
00126
00127
00128 ExampleNLPBanded
00129 nlp(nD,nI,bw,mU,mI,xo,xDl,xDu,xIl,xIu,hl,hu
00130 ,nlp_selects_basis,diag_scal,diag_vary
00131 ,sym_basis,f_offset,co,ignore_constraints
00132 );
00133
00134 solver.set_nlp( Teuchos::rcp(&nlp,false) );
00135
00136 const MoochoSolver::ESolutionStatus
00137 solution_status = solver.solve_nlp();
00138
00139 return solution_status;
00140
00141 }
00142 TEUCHOS_STANDARD_CATCH_STATEMENTS(true,std::cout,success)
00143
00144 return MoochoSolver::SOLVE_RETURN_EXCEPTION;
00145 }