MoochoPack : Framework for Large-Scale Optimization Algorithms Version of the Day
MoochoPack_CalcD_vStep_Step.cpp
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 <limits>
00030 #include <ostream>
00031 #include <iostream>
00032 
00033 #include "MoochoPack_CalcD_vStep_Step.hpp"
00034 #include "MoochoPack_IpState.hpp"
00035 #include "MoochoPack_moocho_algo_conversion.hpp"
00036 #include "IterationPack_print_algorithm_step.hpp"
00037 //#include "ConstrainedOptPack_print_vector_change_stats.hpp"
00038 #include "AbstractLinAlgPack_MatrixSymDiagStd.hpp"
00039 #include "AbstractLinAlgPack_VectorMutable.hpp"
00040 #include "AbstractLinAlgPack_VectorStdOps.hpp"
00041 #include "AbstractLinAlgPack_VectorAuxiliaryOps.hpp"
00042 #include "AbstractLinAlgPack_VectorOut.hpp"
00043 #include "AbstractLinAlgPack_LinAlgOpPack.hpp"
00044 #include "Teuchos_dyn_cast.hpp"
00045 
00046 
00047 bool MoochoPack::CalcD_vStep_Step::do_step(Algorithm& _algo
00048   , poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
00049   {
00050   using Teuchos::dyn_cast;
00051   using IterationPack::print_algorithm_step;
00052   using AbstractLinAlgPack::ele_wise_prod;
00053   using AbstractLinAlgPack::lowerbound_multipliers_step;
00054   using AbstractLinAlgPack::upperbound_multipliers_step;
00055 
00056   NLPAlgo &algo = rsqp_algo(_algo);
00057   IpState  &s    = dyn_cast<IpState>(_algo.state());
00058   NLP      &nlp  = algo.nlp();
00059 
00060   EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
00061   std::ostream& out = algo.track().journal_out();
00062 
00063   // print step header.
00064   if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) 
00065     {
00066     using IterationPack::print_algorithm_step;
00067     print_algorithm_step( algo, step_poss, type, assoc_step_poss, out );
00068     }
00069 
00070   // Get iteration quantities
00071   const value_type& mu = s.barrier_parameter().get_k(0);
00072   const Vector &d_k = s.d().get_k(0);
00073   const MatrixSymDiagStd& invXl = s.invXl().get_k(0);
00074   const MatrixSymDiagStd& invXu = s.invXu().get_k(0);
00075   const MatrixSymDiagStd& Vl = s.Vl().get_k(0);
00076   const MatrixSymDiagStd& Vu = s.Vu().get_k(0);
00077 
00078   VectorMutable& dvl_k = s.dvl().set_k(0);
00079   VectorMutable& dvu_k = s.dvu().set_k(0);
00080 
00081   lowerbound_multipliers_step(mu, invXl.diag(), Vl.diag(), d_k, &dvl_k);
00082   upperbound_multipliers_step(mu, invXu.diag(), Vu.diag(), d_k, &dvu_k);
00083 
00084   /*
00085   // dvl = mu*invXl*e - vl - invXl*Vl*d_k
00086   dvl_k = 0;
00087   ele_wise_prod(-1.0, invXl.diag(), Vl.diag(), &dvl_k);
00088   ele_wise_prod(1.0, dvl_k, d_k, &dvl_k);
00089 
00090   std::cout << "d_k =\n" << d_k;
00091    std::cout << "-invXl*Vl*d_k = \n" << dvl_k;
00092  
00093   dvl_k.axpy(-1.0, Vl.diag());
00094   
00095    std::cout << "-vl-invXl*Vl*d_k = \n" << dvl_k;
00096 
00097   dvl_k.axpy(mu, invXl.diag());
00098 
00099    std::cout << "dvl_k = \n" << dvl_k;
00100 
00101   // dvu = mu*invXu*e - vu + invXu*Vu*d_k
00102   dvu_k = 0;
00103   ele_wise_prod(1.0, invXu.diag(), Vu.diag(), &dvu_k);
00104   ele_wise_prod(1.0, dvu_k, d_k, &dvu_k);
00105 
00106   dvu_k.axpy(-1.0, Vu.diag());
00107   
00108   dvu_k.axpy(mu, invXu.diag());
00109   */
00110   if( static_cast<int>(olevel) >= static_cast<int>(PRINT_VECTORS) ) 
00111     {
00112     out << "\nx_k = \n" << s.x().get_k(0)
00113       << "\nxl = \n" << nlp.xl()
00114       << "\nxu = \n" << nlp.xu()
00115       << "\ndvl_k = \n" << dvl_k
00116       << "\ndvu_k = \n" << dvu_k;
00117     }
00118 
00119   return true;
00120   }
00121 
00122 void MoochoPack::CalcD_vStep_Step::print_step( const Algorithm& algo
00123   , poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss
00124   , std::ostream& out, const std::string& L ) const
00125 {
00126   out
00127     << L << "*** Calculates the search direction for the dual variables\n"
00128     << L << "dvl_k = mu*invXl_k*e - vl_k - invXl_k*Vl_k*d_k\n"
00129     << L << "dvu_k = mu*invXu_k*e - vu_k + invXu_k*Vu_k*d_k\n";
00130 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends