49 #include "MoochoPack_active_set_change.hpp"
50 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_SpVectorClass.hpp"
52 void MoochoPack::active_set_change(
53 const SpVectorSlice& nu_k,
const SpVectorSlice& nu_km1, Range1D indep
54 ,EJournalOutputLevel olevel, std::ostream* out
64 *num_adds = *num_drops = *num_adds_indep = *num_drops_indep = 0;
65 *num_active_indep = nu_k(indep).nz();
67 if( !nu_k.nz() && !nu_km1.nz() )
72 bool dump_change = (int)olevel >= (
int)PRINT_ACTIVE_SET;
76 <<
"\n*** Changes in active set\n\n"
79 << setw(w) <<
"dep/indep"
80 << setw(w) <<
"change\n"
81 << setw(w) <<
"----------"
82 << setw(w) <<
"----------"
83 << setw(w) <<
"----------"
84 << setw(w) <<
"----------\n";
87 SpVectorSlice::const_iterator
88 nu_k_itr = nu_k.begin(),
89 nu_k_end = nu_k.end(),
90 nu_km1_itr = nu_km1.begin(),
91 nu_km1_end = nu_km1.end();
93 while( nu_k_itr != nu_k_end || nu_km1_itr != nu_km1_end ) {
94 if( nu_k_itr != nu_k_end && ( nu_km1_itr == nu_km1_end || ( nu_k_itr != nu_k_end
95 && nu_k_itr->indice()+nu_k.offset() < nu_km1_itr->indice()+nu_km1.offset() ) ) )
98 const size_type i = nu_k_itr->indice() + nu_k.offset();
99 const bool is_indep = indep.in_range(i);
106 << setw(w) << ( nu_k_itr->value() >= 0.0 ?
"upper" :
"lower" )
107 << setw(w) << ( is_indep ?
"indep" :
"dep" )
108 << setw(w) <<
"added" << endl;
111 else if( nu_km1_itr != nu_km1_end && ( nu_k_itr == nu_k_end || ( nu_km1_itr != nu_km1_end
112 && nu_k_itr->indice()+nu_k.offset() > nu_km1_itr->indice()+nu_km1.offset() ) ) )
115 const size_type i = nu_km1_itr->indice() + nu_km1.offset();
116 const bool is_indep = indep.in_range(i);
118 (*num_drops_indep)++;
123 << setw(w) << ( nu_km1_itr->value() >= 0.0 ?
"upper" :
"lower" )
124 << setw(w) << ( is_indep ?
"indep" :
"dep" )
125 << setw(w) <<
"dropped" << endl;
130 const size_type i = nu_k_itr->indice() + nu_k.offset();
131 const bool is_indep = indep.in_range(i);
132 if( nu_k_itr->value() * nu_km1_itr->value() < 0.0 ) {
136 (*num_drops_indep)++;
143 << setw(w) << ( nu_k_itr->value() >= 0.0 ?
"upper" :
"lower" )
144 << setw(w) << ( is_indep ?
"indep" :
"dep" )
145 << setw(w) <<
"switch bnd" << endl;
153 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
155 <<
"\n*** Active set change summary\n"
156 <<
"nact_old = " << nu_km1.nz() << endl
157 <<
"nact_new = " << nu_k.nz() << endl
158 <<
"num_adds = " << *num_adds << endl
159 <<
"num_drops = " << *num_drops << endl
160 <<
"nact_indep_old = " << nu_km1(indep).nz() << endl
161 <<
"nact_indep_new = " << *num_active_indep << endl
162 <<
"num_indep_adds = " << *num_adds_indep << endl
163 <<
"num_indep_drops = " << *num_drops_indep << endl;
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)