MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MoochoPack_ActSetStats_AddedStep.cpp
Go to the documentation of this file.
1 #if 0
2 
3 // @HEADER
4 // ***********************************************************************
5 //
6 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
7 // Copyright (2003) Sandia Corporation
8 //
9 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
10 // license for use of this work by or on behalf of the U.S. Government.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are
14 // met:
15 //
16 // 1. Redistributions of source code must retain the above copyright
17 // notice, this list of conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution.
22 //
23 // 3. Neither the name of the Corporation nor the names of the
24 // contributors may be used to endorse or promote products derived from
25 // this software without specific prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 //
39 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
40 //
41 // ***********************************************************************
42 // @HEADER
43 
44 #include <ostream>
45 
50 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_SpVectorClass.hpp"
51 
53  , poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
54 {
55  NLPAlgo &algo = rsqp_algo(_algo);
56  NLPAlgoState &s = algo.rsqp_state();
57 
58  EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
59  EJournalOutputLevel ns_olevel = algo.algo_cntr().null_space_journal_output_level();
60  std::ostream& out = algo.track().journal_out();
61 
62  // print step header.
63  if( static_cast<int>(ns_olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
65  print_algorithm_step( algo, step_poss, type, assoc_step_poss, out );
66  }
67 
68  if( s.nu().updated_k(0) ) {
69  size_type
70  num_active = 0, num_adds = 0, num_drops = 0,
71  num_active_indep = 0, num_adds_indep = 0, num_drops_indep = 0;
72  const SpVector &nu_k = s.nu().get_k(0);
73  num_active = nu_k.nz();
74  if( s.nu().updated_k(-1) ) {
75  const SpVector &nu_km1 = s.nu().get_k(-1);
77  nu_k(), nu_km1(), s.var_indep(), olevel, &out
78  ,&num_adds, &num_drops, &num_active_indep, &num_adds_indep, &num_drops_indep );
79  act_set_stats_(s).set_k(0).set_stats(num_active,num_adds,num_drops
80  ,num_active_indep,num_adds_indep,num_drops_indep);
81  }
82  else {
83  act_set_stats_(s).set_k(0).set_stats(
85  , nu_k(s.var_indep()).nz(), ActSetStats::NOT_KNOWN, ActSetStats::NOT_KNOWN );
86  }
87  }
88  else {
89  if( static_cast<int>(ns_olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
90  out << "\nnu not calculated for the kth iteration\n";
91  }
92  }
93 
94  return true;
95 }
96 
97 void MoochoPack::ActSetStats_AddedStep::print_step( const Algorithm& algo
98  , poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss
99  , std::ostream& out, const std::string& L ) const
100 {
101  out
102  << L << "*** Updates active set statistics for changes from the last iteration\n"
103  << L << "Given nu_km1 and nu_k update:\n"
104  << L << " act_set_stats_k(num_active,num_adds,num_drops,num_active_indep,num_adds_indep,num_drops_indep)\n";
105 }
106 
107 #endif // 0
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
AbstractLinAlgPack::size_type size_type
SparseVector< SparseElement< index_type, value_type >, std::allocator< SparseElement< index_type, value_type > > > SpVector
void print_step(const Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss, std::ostream &out, const std::string &leading_str) const
EJournalOutputLevel
enum for journal output.
size_type nz() const
Return the number of non-zero elements.
std::ostream * out
void print_algorithm_step(const Algorithm &algo, Algorithm::poss_type step_poss, EDoStepType type, Algorithm::poss_type assoc_step_poss, std::ostream &out)
Prints to 'out' the algorithm step.
void active_set_change(const SpVectorSlice &nu_k, const SpVectorSlice &nu_km1, Range1D indep, EJournalOutputLevel olevel, std::ostream *out, size_type *num_adds, size_type *num_drops, size_type *num_active_indep, size_type *num_adds_indep, size_type *num_drops_indep)
Calculate the change in the active set and output change if asked to.
NLPAlgo & rsqp_algo(Algorithm &algo)
Convert from a Algorithm to a NLPAlgo.