NLPInterfacePack_ExampleNLPDirectRun.cpp

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 
00030 #include <assert.h>
00031 
00032 #include <fstream>
00033 #include <fstream>
00034 #include <iostream>
00035 #include <iomanip>
00036 #include <typeinfo>
00037 
00038 #include "NLPInterfacePack_ExampleNLPDirectRun.hpp"
00039 #include "NLPInterfacePack_ExampleNLPDirect.hpp"
00040 #include "MoochoPack_NLPAlgoConfigMamaJama.hpp"
00041 #include "IterationPack_AlgorithmTracker.hpp"
00042 #include "AbstractLinAlgPack_VectorSpace.hpp"
00043 #include "AbstractLinAlgPack_BasisSystem.hpp"
00044 #include "OptionsFromStreamPack_OptionsFromStream.hpp"
00045 
00046 MoochoPack::MoochoSolver::ESolutionStatus
00047 NLPInterfacePack::ExampleNLPDirectRun(
00048   const VectorSpace&   vec_space
00049   ,value_type          xo
00050   ,bool                has_bounds
00051   ,bool                dep_bounded
00052   ,std::ostream*       console_out
00053   ,std::ostream*       error_out
00054   ,bool                throw_solve_exception
00055   ,std::ostream*       algo_out
00056   ,std::ostream*       summary_out
00057   ,std::ostream*       journal_out
00058   )
00059 {
00060   using std::endl;
00061   using std::setw;
00062   namespace rcp = MemMngPack;
00063   using Teuchos::RCP;
00064   namespace ofsp = OptionsFromStreamPack;
00065   using ofsp::OptionsFromStream;
00066   namespace rsqp = MoochoPack;
00067   using rsqp::MoochoSolver;
00068   using rsqp::NLPAlgoConfigMamaJama;
00069 
00070   MoochoSolver::ESolutionStatus
00071     solve_return = MoochoSolver::SOLVE_RETURN_EXCEPTION;
00072 
00073   int err = 0;
00074   
00075   int w = 15;
00076   int prec = 8;
00077 
00078   if(console_out)
00079     *console_out
00080       << std::setprecision(prec)
00081       << std::scientific
00082       << "***************************************************\n"
00083       << "*** Running Tests on ExampleNLPDirect ***\n"
00084       << "***************************************************\n"
00085       << "\nUsing a vector space of type \'" << typeName(vec_space) << "\'"
00086       << "\nwith a dimension of vec_space.dim() = " << vec_space.dim()
00087       << std::endl;
00088 
00089   // Create the nlp
00090   ExampleNLPDirect
00091     nlp(VectorSpace::space_ptr_t(&vec_space,false),xo,has_bounds,dep_bounded);
00092 
00093   // Create the solver object and set it up
00094   MoochoSolver solver;
00095   solver.set_nlp(Teuchos::rcp(&nlp,false));                  // Set the NLP!
00096   solver.set_error_handling(                             // set up outputting
00097     throw_solve_exception
00098     ,Teuchos::rcp(error_out,false)
00099     );
00100   solver.set_console_out(Teuchos::rcp(console_out,false));
00101   solver.set_summary_out(Teuchos::rcp(summary_out,false));
00102   solver.set_journal_out(Teuchos::rcp(journal_out,false));
00103   solver.set_algo_out(   Teuchos::rcp(algo_out,false)   );
00104 
00105   // Run MOOCHO using the MamaJama configuration
00106   solve_return = solver.solve_nlp();
00107 
00108   return solve_return;
00109 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:18:07 2011 for MOOCHO by  doxygen 1.6.3