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