MOOCHO (Single Doxygen Collection) Version of the Day
NLPWBCounterExampleMain.cpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00005 //                  Copyright (2003) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #include <iostream>
00030 
00031 #include "NLPInterfacePack_NLPWBCounterExample.hpp"
00032 #include "MoochoPack_MoochoSolver.hpp"
00033 #include "Teuchos_GlobalMPISession.hpp"
00034 #include "Teuchos_CommandLineProcessor.hpp"
00035 #include "Teuchos_StandardCatchMacros.hpp"
00036 
00037 int main( int argc, char* argv[] )
00038 {
00039   using MoochoPack::MoochoSolver;
00040   using NLPInterfacePack::NLPWBCounterExample;
00041   using Teuchos::CommandLineProcessor;
00042   bool success = true;
00043 
00044   Teuchos::GlobalMPISession mpiSession(&argc, &argv);
00045 
00046   try {
00047 
00048     MoochoSolver  solver;
00049   
00050     //
00051     // Get options from the command line
00052     //
00053     
00054     double   xinit[3]          = { 0.0, 0.0, 0.0 };
00055     double   a                 = 0.0;
00056     double   b                 = 1.0;
00057     bool     nlp_selects_basis = true;
00058     bool     linear_obj        = true;
00059 
00060     CommandLineProcessor  clp(false); // don't throw exceptions
00061     solver.setup_commandline_processor(&clp);
00062     clp.setOption( "x1-init",  &xinit[0], "Initail guess for x(1)" );
00063     clp.setOption( "x2-init",  &xinit[1], "Initail guess for x(2)" );
00064     clp.setOption( "x3-init",  &xinit[2], "Initail guess for x(3)" );
00065     clp.setOption( "a",  &a, "Constant for c(1)" );
00066     clp.setOption( "b",  &b, "Constant for c(2)" );
00067     clp.setOption(
00068       "nlp-selects-basis", "no-nlp-selects-basis", &nlp_selects_basis
00069       ,"Determine if NLP will select basis" );
00070     clp.setOption(
00071       "linear-obj", "nonlinear-obj", &linear_obj
00072       ,"Determine if objective is linear" );
00073     CommandLineProcessor::EParseCommandLineReturn
00074       parse_return = clp.parse(argc,argv,&std::cerr);
00075     if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
00076       return parse_return;
00077     
00078     //
00079     // Create the NLP and solve it
00080     //
00081 
00082     // Create the NLP
00083     NLPWBCounterExample
00084       nlp(xinit,a,b,nlp_selects_basis,linear_obj);
00085     // Set the NLP
00086     solver.set_nlp( Teuchos::rcp(&nlp,false) );
00087     // Solve the NLP
00088     const MoochoSolver::ESolutionStatus
00089       solution_status = solver.solve_nlp();
00090     
00091     //
00092     // Return the solution status (0 if sucessfull)
00093     //
00094 
00095     return solution_status;
00096 
00097   }
00098   TEUCHOS_STANDARD_CATCH_STATEMENTS(true,std::cout,success)
00099 
00100   return MoochoSolver::SOLVE_RETURN_EXCEPTION;
00101 
00102 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines