MoochoPack_ActSetStats_AddedStep.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 <ostream>
00030 
00031 #include "../std/MoochoPack_ActSetStats_AddedStep.hpp"
00032 #include "../std/MoochoPack_active_set_change.hpp"
00033 #include "../MoochoPack_moocho_algo_conversion.hpp"
00034 #include "IterationPack_print_algorithm_step.hpp"
00035 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_SpVectorClass.hpp"
00036 
00037 bool MoochoPack::ActSetStats_AddedStep::do_step(Algorithm& _algo
00038   , poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
00039 {
00040   NLPAlgo &algo = rsqp_algo(_algo);
00041   NLPAlgoState  &s    = algo.rsqp_state();
00042 
00043   EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
00044   EJournalOutputLevel ns_olevel = algo.algo_cntr().null_space_journal_output_level();
00045   std::ostream& out = algo.track().journal_out();
00046 
00047   // print step header.
00048   if( static_cast<int>(ns_olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
00049     using IterationPack::print_algorithm_step;
00050     print_algorithm_step( algo, step_poss, type, assoc_step_poss, out );
00051   }
00052 
00053   if( s.nu().updated_k(0) ) {
00054     size_type
00055       num_active = 0, num_adds = 0, num_drops = 0,
00056       num_active_indep = 0, num_adds_indep = 0, num_drops_indep = 0;
00057     const SpVector &nu_k = s.nu().get_k(0);
00058     num_active = nu_k.nz();
00059     if( s.nu().updated_k(-1) ) {
00060       const SpVector &nu_km1  = s.nu().get_k(-1);
00061       active_set_change(
00062         nu_k(), nu_km1(), s.var_indep(), olevel, &out
00063         ,&num_adds, &num_drops, &num_active_indep, &num_adds_indep, &num_drops_indep );
00064       act_set_stats_(s).set_k(0).set_stats(num_active,num_adds,num_drops
00065                          ,num_active_indep,num_adds_indep,num_drops_indep);
00066     }
00067     else {
00068       act_set_stats_(s).set_k(0).set_stats(
00069         num_active, ActSetStats::NOT_KNOWN, ActSetStats::NOT_KNOWN
00070         , nu_k(s.var_indep()).nz(), ActSetStats::NOT_KNOWN, ActSetStats::NOT_KNOWN );
00071     }
00072   }
00073   else {
00074     if( static_cast<int>(ns_olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
00075       out << "\nnu not calculated for the kth iteration\n";
00076     }
00077   }
00078 
00079   return true;
00080 }
00081 
00082 void MoochoPack::ActSetStats_AddedStep::print_step( const Algorithm& algo
00083   , poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss
00084   , std::ostream& out, const std::string& L ) const
00085 {
00086   out
00087     << L << "*** Updates active set statistics for changes from the last iteration\n"
00088     << L << "Given nu_km1 and nu_k update:\n"
00089     << L << "    act_set_stats_k(num_active,num_adds,num_drops,num_active_indep,num_adds_indep,num_drops_indep)\n";
00090 }

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