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_CommandLineProcessor.hpp"
00034 #include "Teuchos_StandardCatchMacros.hpp"
00035 
00036 int main( int argc, char* argv[] )
00037 {
00038   using MoochoPack::MoochoSolver;
00039   using NLPInterfacePack::NLPWBCounterExample;
00040   using Teuchos::CommandLineProcessor;
00041   bool success = true;
00042 
00043   try {
00044 
00045     MoochoSolver  solver;
00046   
00047     //
00048     // Get options from the command line
00049     //
00050     
00051     double   xinit[3]          = { 0.0, 0.0, 0.0 };
00052     double   a                 = 0.0;
00053     double   b                 = 1.0;
00054     bool     nlp_selects_basis = true;
00055     bool     linear_obj        = true;
00056 
00057     CommandLineProcessor  clp(false); // don't throw exceptions
00058     solver.setup_commandline_processor(&clp);
00059     clp.setOption( "x1-init",  &xinit[0], "Initail guess for x(1)" );
00060     clp.setOption( "x2-init",  &xinit[1], "Initail guess for x(2)" );
00061     clp.setOption( "x3-init",  &xinit[2], "Initail guess for x(3)" );
00062     clp.setOption( "a",  &a, "Constant for c(1)" );
00063     clp.setOption( "b",  &b, "Constant for c(2)" );
00064     clp.setOption(
00065       "nlp-selects-basis", "no-nlp-selects-basis", &nlp_selects_basis
00066       ,"Determine if NLP will select basis" );
00067     clp.setOption(
00068       "linear-obj", "nonlinear-obj", &linear_obj
00069       ,"Determine if objective is linear" );
00070     CommandLineProcessor::EParseCommandLineReturn
00071       parse_return = clp.parse(argc,argv,&std::cerr);
00072     if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
00073       return parse_return;
00074     
00075     //
00076     // Create the NLP and solve it
00077     //
00078 
00079     // Create the NLP
00080     NLPWBCounterExample
00081       nlp(xinit,a,b,nlp_selects_basis,linear_obj);
00082     // Set the NLP
00083     solver.set_nlp( Teuchos::rcp(&nlp,false) );
00084     // Solve the NLP
00085     const MoochoSolver::ESolutionStatus
00086       solution_status = solver.solve_nlp();
00087     
00088     //
00089     // Return the solution status (0 if sucessfull)
00090     //
00091 
00092     return solution_status;
00093 
00094   }
00095   TEUCHOS_STANDARD_CATCH_STATEMENTS(true,std::cout,success)
00096 
00097   return MoochoSolver::SOLVE_RETURN_EXCEPTION;
00098 
00099 }

Generated on Thu Sep 18 12:35:19 2008 for MOOCHO (Single Doxygen Collection) by doxygen 1.3.9.1