MoochoPack_ActSetStats_AddedStep.cpp

00001 #if 0
00002 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00007 //                  Copyright (2003) Sandia Corporation
00008 // 
00009 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00010 // license for use of this work by or on behalf of the U.S. Government.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00027 // 
00028 // ***********************************************************************
00029 // @HEADER
00030 
00031 #include <ostream>
00032 
00033 #include "MoochoPack_ActSetStats_AddedStep.hpp"
00034 #include "MoochoPack_active_set_change.hpp"
00035 #include "MoochoPack_moocho_algo_conversion.hpp"
00036 #include "IterationPack_print_algorithm_step.hpp"
00037 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_SpVectorClass.hpp"
00038 
00039 bool MoochoPack::ActSetStats_AddedStep::do_step(Algorithm& _algo
00040   , poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
00041 {
00042   NLPAlgo &algo = rsqp_algo(_algo);
00043   NLPAlgoState  &s    = algo.rsqp_state();
00044 
00045   EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
00046   EJournalOutputLevel ns_olevel = algo.algo_cntr().null_space_journal_output_level();
00047   std::ostream& out = algo.track().journal_out();
00048 
00049   // print step header.
00050   if( static_cast<int>(ns_olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
00051     using IterationPack::print_algorithm_step;
00052     print_algorithm_step( algo, step_poss, type, assoc_step_poss, out );
00053   }
00054 
00055   if( s.nu().updated_k(0) ) {
00056     size_type
00057       num_active = 0, num_adds = 0, num_drops = 0,
00058       num_active_indep = 0, num_adds_indep = 0, num_drops_indep = 0;
00059     const SpVector &nu_k = s.nu().get_k(0);
00060     num_active = nu_k.nz();
00061     if( s.nu().updated_k(-1) ) {
00062       const SpVector &nu_km1  = s.nu().get_k(-1);
00063       active_set_change(
00064         nu_k(), nu_km1(), s.var_indep(), olevel, &out
00065         ,&num_adds, &num_drops, &num_active_indep, &num_adds_indep, &num_drops_indep );
00066       act_set_stats_(s).set_k(0).set_stats(num_active,num_adds,num_drops
00067                          ,num_active_indep,num_adds_indep,num_drops_indep);
00068     }
00069     else {
00070       act_set_stats_(s).set_k(0).set_stats(
00071         num_active, ActSetStats::NOT_KNOWN, ActSetStats::NOT_KNOWN
00072         , nu_k(s.var_indep()).nz(), ActSetStats::NOT_KNOWN, ActSetStats::NOT_KNOWN );
00073     }
00074   }
00075   else {
00076     if( static_cast<int>(ns_olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
00077       out << "\nnu not calculated for the kth iteration\n";
00078     }
00079   }
00080 
00081   return true;
00082 }
00083 
00084 void MoochoPack::ActSetStats_AddedStep::print_step( const Algorithm& algo
00085   , poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss
00086   , std::ostream& out, const std::string& L ) const
00087 {
00088   out
00089     << L << "*** Updates active set statistics for changes from the last iteration\n"
00090     << L << "Given nu_km1 and nu_k update:\n"
00091     << L << "    act_set_stats_k(num_active,num_adds,num_drops,num_active_indep,num_adds_indep,num_drops_indep)\n";
00092 }
00093 
00094 #endif // 0

Generated on Wed May 12 21:32:12 2010 for MoochoPack : Framework for Large-Scale Optimization Algorithms by  doxygen 1.4.7