MOOCHO (Single Doxygen Collection) Version of the Day
IterationPack_AlgorithmStepTesting.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 <iomanip>
00030 
00031 #include "IterationPack_AlgorithmStepTesting.hpp"
00032 #include "IterationPack_Algorithm.hpp"
00033 #include "IterationPack_print_algorithm_step.hpp"
00034 
00035 namespace {
00036 char step_type_name[3][15] = { "DO_MAIN_STEP", "DO_PRE_STEP" , "DO_POST_STEP" };
00037 } // namespace
00038 
00039 namespace IterationPack {
00040 
00041 bool AlgorithmStepTesting::do_step(Algorithm& algo, poss_type step_poss, EDoStepType type
00042     , poss_type assoc_step_poss)
00043 {
00044   print_algorithm_step( algo, step_poss, type, assoc_step_poss
00045     , algo.track().journal_out() );
00046   return true;
00047 }
00048 
00049 void AlgorithmStepTesting::initialize_step(
00050   Algorithm& algo, poss_type step_poss, EDoStepType type
00051   ,poss_type assoc_step_poss
00052   )
00053 {
00054   print_step_poss( algo, step_poss, type, assoc_step_poss );
00055   algo.track().journal_out() << "\" : initialize_step(...) called\n";
00056 }
00057 
00058 void AlgorithmStepTesting::inform_updated(
00059   Algorithm& algo, poss_type step_poss, EDoStepType type
00060   ,poss_type assoc_step_poss
00061   )
00062 {
00063   print_step_poss( algo, step_poss, type, assoc_step_poss );
00064   algo.track().journal_out() << "\" : inform_step(...) called\n";
00065 }
00066 
00067 void AlgorithmStepTesting::finalize_step(
00068   Algorithm& algo, poss_type step_poss, EDoStepType type
00069   ,poss_type assoc_step_poss
00070   )
00071 {
00072   print_step_poss( algo, step_poss, type, assoc_step_poss );
00073   algo.track().journal_out() << "\" : finalize_step(...) called\n";
00074 }
00075 
00076 void AlgorithmStepTesting::print_step( const Algorithm& algo, poss_type step_poss, EDoStepType type
00077   , poss_type assoc_step_poss ,std::ostream& out, const std::string& leading_str ) const
00078 {
00079   algo.track().journal_out()
00080     << std::endl << leading_str << step_poss << ", " << step_type_name[type];
00081   if(type == DO_MAIN_STEP) {
00082     algo.track().journal_out()
00083       << ", \"" << algo.get_step_name(step_poss) << "\"";
00084   }
00085   else {
00086     EAssocStepType _type = (type == DO_PRE_STEP ? PRE_STEP : POST_STEP );
00087     algo.track().journal_out()
00088       << ", " << assoc_step_poss
00089       << ", \"" << algo.get_assoc_step_name(step_poss,_type,assoc_step_poss) << "\"";
00090   }
00091   algo.track().journal_out()
00092     << "\" : print_step(algo,step_poss,type,assoc_step_poss,out) called\n";
00093 }
00094 
00095 // private
00096 
00097 void AlgorithmStepTesting::print_step_poss(
00098   const Algorithm& algo, poss_type step_poss, EDoStepType type
00099   ,poss_type assoc_step_poss
00100   ) const
00101 {
00102   algo.track().journal_out()
00103     << std::endl << step_poss << ", " << step_type_name[type];
00104   if(type == DO_MAIN_STEP) {
00105     algo.track().journal_out()
00106       << ", \"" << algo.get_step_name(step_poss) << "\"";
00107   }
00108   else {
00109     EAssocStepType _type = (type == DO_PRE_STEP ? PRE_STEP : POST_STEP );
00110     algo.track().journal_out()
00111       << ", " << assoc_step_poss
00112       << ", \"" << algo.get_assoc_step_name(step_poss,_type,assoc_step_poss) << "\"";
00113   }
00114 }
00115 
00116 } // end namespace IterationPack 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines