|
MoochoPack : Framework for Large-Scale Optimization Algorithms Version of the Day
|
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 // #define RELEASE_TRACE 00030 00031 #include <iostream> // for debugging Release version. 00032 #include <typeinfo> 00033 00034 #include "MoochoPack_NLPAlgo.hpp" 00035 00036 namespace MoochoPack { 00037 00038 NLPAlgo::NLPAlgo() 00039 : algo_cntr_(NULL), nlp_(NULL), first_step_poss_(1) 00040 {} 00041 00042 // Overridden form rSQPAlgoInteface 00043 00044 const NLPAlgoState& NLPAlgo::retrieve_state() const 00045 { 00046 return dynamic_cast<const NLPAlgoState&>(state()); 00047 } 00048 00049 NLPSolverClientInterface::EFindMinReturn 00050 NLPAlgo::dispatch() { 00051 switch( do_algorithm(first_step_poss_) ) { 00052 case IterationPack::TERMINATE_TRUE: 00053 return NLPSolverClientInterface::SOLUTION_FOUND; 00054 case IterationPack::TERMINATE_FALSE: 00055 return NLPSolverClientInterface::ALGORITHMIC_ERROR; 00056 case IterationPack::MAX_ITER_EXCEEDED: 00057 return NLPSolverClientInterface::MAX_ITER_EXCEEDED; 00058 case IterationPack::MAX_RUN_TIME_EXCEEDED: 00059 return NLPSolverClientInterface::MAX_RUN_TIME_EXCEEDED; 00060 case IterationPack::INTERRUPTED_TERMINATE_TRUE: 00061 return NLPSolverClientInterface::SOLUTION_FOUND; 00062 case IterationPack::INTERRUPTED_TERMINATE_FALSE: 00063 return NLPSolverClientInterface::ALGORITHMIC_ERROR; 00064 default: 00065 TEST_FOR_EXCEPT(true); 00066 } 00067 return NLPSolverClientInterface::SOLUTION_FOUND; // will never be called. 00068 } 00069 00070 void NLPAlgo::interface_print_algorithm(std::ostream& out) const { 00071 print_steps(out); 00072 print_algorithm(out); 00073 } 00074 00075 void NLPAlgo::interface_set_algo_timing( bool algo_timing ) { 00076 set_algo_timing(algo_timing); 00077 } 00078 00079 bool NLPAlgo::interface_algo_timing() const { 00080 return algo_timing(); 00081 } 00082 00083 void NLPAlgo::interface_print_algorithm_times( std::ostream& out ) const { 00084 print_algorithm_times(out); 00085 } 00086 00087 // Overridden from Algorithm. 00088 00089 void NLPAlgo::print_algorithm(std::ostream& out) const { 00090 out 00091 << "\n*** NLP ***\n" 00092 << typeName(*get_nlp()) << "\n"; 00093 00094 Algorithm::print_algorithm(out); 00095 } 00096 00097 } // end namespace MoochoPack
1.7.4