Skip to content

Commit

Permalink
renamed HessianLowRank class and files
Browse files Browse the repository at this point in the history
  • Loading branch information
cnpetra committed Oct 9, 2024
1 parent e281882 commit 2325d0d
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 101 deletions.
4 changes: 2 additions & 2 deletions src/Optimization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(hiopOptimization_SRC
hiopKKTLinSys.cpp
KktLinSysLowRank.cpp
hiopKKTLinSysMDS.cpp
hiopHessianLowRank.cpp
HessianDiagPlusRowRank.cpp
hiopDualsUpdater.cpp
hiopNlpTransforms.cpp
hiopPDPerturbation.cpp
Expand All @@ -28,7 +28,7 @@ set(hiopOptimization_INTERFACE_HEADERS
hiopDualsUpdater.hpp
hiopFactAcceptor.hpp
hiopFilter.hpp
hiopHessianLowRank.hpp
HessianDiagPlusRowRank.hpp
hiopIterate.hpp
hiopKKTLinSys.hpp
hiopKKTLinSysDense.hpp
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ namespace hiop
* Parallel computations: Dk, B0 are distributed vectors, M is distributed
* column-wise, and N is local (stored on all processors).
*/
class hiopHessianLowRank : public hiopMatrix
class HessianDiagPlusRowRank : public hiopMatrix
{
public:
hiopHessianLowRank(hiopNlpDenseConstraints* nlp_in, int max_memory_length);
virtual ~hiopHessianLowRank();
HessianDiagPlusRowRank(hiopNlpDenseConstraints* nlp_in, int max_memory_length);
virtual ~HessianDiagPlusRowRank();

/// Updates Hessian if hereditary positive definitness is maintained and returns true, otherwise false.
virtual bool update(const hiopIterate& x_curr,
Expand Down Expand Up @@ -282,9 +282,9 @@ class hiopHessianLowRank : public hiopMatrix
void solveWithV(hiopVector& rhs_s, hiopVector& rhs_y);
void solveWithV(hiopMatrixDense& rhs);
private:
hiopHessianLowRank() {};
hiopHessianLowRank(const hiopHessianLowRank&) {};
hiopHessianLowRank& operator=(const hiopHessianLowRank&) {return *this;};
HessianDiagPlusRowRank() {};
HessianDiagPlusRowRank(const HessianDiagPlusRowRank&) {};
HessianDiagPlusRowRank& operator=(const HessianDiagPlusRowRank&) {return *this;};

/* methods that need to be implemented as the class inherits from hiopMatrix*/
public:
Expand Down
8 changes: 4 additions & 4 deletions src/Optimization/KktLinSysLowRank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bool KktLinSysLowRank::update(const hiopIterate* iter,
const hiopVector* grad_f,
const hiopMatrixDense* Jac_c,
const hiopMatrixDense* Jac_d,
hiopHessianLowRank* hess_low_rank)
HessianDiagPlusRowRank* hess_low_rank)
{
nlp_->runStats.tmSolverInternal.start();

Expand Down Expand Up @@ -133,7 +133,7 @@ bool KktLinSysLowRank::update(const hiopIterate* iter,
* and then solving for dx from
* dx = - (H+Dx)^{-1}*(Jc^T*dyc+Jd^T*dyd - rx)
*
* Note that ops H+Dx are provided by hiopHessianLowRank
* Note that ops H+Dx are provided by HessianDiagPlusRowRank
*/
bool KktLinSysLowRank::solveCompressed(hiopVector& rx,
hiopVector& ryc,
Expand All @@ -160,7 +160,7 @@ bool KktLinSysLowRank::solveCompressed(hiopVector& rx,
J.copyRowsFrom(*Jac_c_de, nlp_->m_eq(), 0); //!opt
J.copyRowsFrom(*Jac_d_de, nlp_->m_ineq(), nlp_->m_eq());//!opt

auto* hess_low_rank = dynamic_cast<hiopHessianLowRank*>(Hess_);
auto* hess_low_rank = dynamic_cast<HessianDiagPlusRowRank*>(Hess_);

//N = J*(Hess\J')
//Hess->symmetricTimesMat(0.0, *N, 1.0, J);
Expand Down Expand Up @@ -460,7 +460,7 @@ double KktLinSysLowRank::errorCompressedLinsys(const hiopVector& rx,
const hiopVector& dyd)
{
nlp_->log->printf(hovLinAlgScalars, "KktLinSysLowRank::errorCompressedLinsys residuals norm:\n");
auto* hess_low_rank = dynamic_cast<hiopHessianLowRank*>(Hess_);
auto* hess_low_rank = dynamic_cast<HessianDiagPlusRowRank*>(Hess_);

double derr = -1.;
double aux;
Expand Down
10 changes: 5 additions & 5 deletions src/Optimization/KktLinSysLowRank.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ namespace hiop
* by low-rank matrix plus a multiple of identity and the number of the constraints is not
* too large.
*
* It works with Hessian being a HessianLowRank class and the constraints Jacobian being
* hiopMatrixDense.
* It works with Hessian being a HessianDiagPlusLowRank class and the constraints Jacobian
* being hiopMatrixDense.
*
* This class solves the XYcYd compression of the full KKT. See solveCompressed method
* for details on the approach used to solve the linear system.
Expand All @@ -90,7 +90,7 @@ class KktLinSysLowRank : public hiopKKTLinSysCompressedXYcYd
{
const hiopMatrixDense* Jac_c_ = dynamic_cast<const hiopMatrixDense*>(Jac_c);
const hiopMatrixDense* Jac_d_ = dynamic_cast<const hiopMatrixDense*>(Jac_d);
hiopHessianLowRank* Hess_ = dynamic_cast<hiopHessianLowRank*>(Hess);
HessianDiagPlusRowRank* Hess_ = dynamic_cast<HessianDiagPlusRowRank*>(Hess);
if(Jac_c_==nullptr || Jac_d_==nullptr || Hess_==nullptr) {
assert(false);
return false;
Expand All @@ -103,7 +103,7 @@ class KktLinSysLowRank : public hiopKKTLinSysCompressedXYcYd
const hiopVector* grad_f,
const hiopMatrixDense* Jac_c,
const hiopMatrixDense* Jac_d,
hiopHessianLowRank* Hess);
HessianDiagPlusRowRank* Hess);

virtual bool build_kkt_matrix(const hiopPDPerturbation& pdreg)
{
Expand Down Expand Up @@ -148,7 +148,7 @@ class KktLinSysLowRank : public hiopKKTLinSysCompressedXYcYd
/// @brief perform y=beta*y+alpha*H*x without the log barrier term from H
void HessianTimesVec_noLogBarrierTerm(double beta, hiopVector& y, double alpha, const hiopVector& x)
{
hiopHessianLowRank* hesslowrank = dynamic_cast<hiopHessianLowRank*>(Hess_);
HessianDiagPlusRowRank* hesslowrank = dynamic_cast<HessianDiagPlusRowRank*>(Hess_);
assert(nullptr != hesslowrank);
hesslowrank->times_vec_no_logbar_term(beta, y, alpha, x);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Optimization/hiopAlgFilterIPM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ hiopSolveStatus hiopAlgFilterIPMQuasiNewton::run()
resetSolverStatus();

//types of linear algebra objects are known now
hiopHessianLowRank* Hess = dynamic_cast<hiopHessianLowRank*>(_Hess_Lagr);
auto* Hess = dynamic_cast<HessianDiagPlusRowRank*>(_Hess_Lagr);

nlp->runStats.initialize();
nlp->runStats.kkt.initialize();
Expand Down Expand Up @@ -1599,7 +1599,7 @@ void hiopAlgFilterIPMQuasiNewton::save_state_to_sidre_group(::axom::sidre::Group
SidreHelper::copy_iterate_to_views(group, "alg_iterate_", *it_curr);

//state of quasi-Newton Hessian approximation
hiopHessianLowRank& hqn = dynamic_cast<hiopHessianLowRank&>(*_Hess_Lagr);
HessianDiagPlusRowRank& hqn = dynamic_cast<HessianDiagPlusRowRank&>(*_Hess_Lagr);
const double hqn_params[] = {(double)hqn.l_max_,
(double)hqn.l_curr_,
hqn.sigma_,
Expand Down Expand Up @@ -1712,7 +1712,7 @@ void hiopAlgFilterIPMQuasiNewton::load_state_from_sidre_group(const sidre::Group
//
//state of quasi-Newton Hessian approximation
//
hiopHessianLowRank& hqn = dynamic_cast<hiopHessianLowRank&>(*_Hess_Lagr);
HessianDiagPlusRowRank& hqn = dynamic_cast<HessianDiagPlusRowRank&>(*_Hess_Lagr);
//!!!note: nparams needs to match the # of params from save_state_to_sidre_group
const int nhqn_params = 5;
double hqn_params[nhqn_params];
Expand Down
2 changes: 1 addition & 1 deletion src/Optimization/hiopAlgFilterIPM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#include "hiopIterate.hpp"
#include "hiopResidual.hpp"
#include "hiopFilter.hpp"
#include "hiopHessianLowRank.hpp"
#include "HessianDiagPlusRowRank.hpp"
#include "hiopKKTLinSys.hpp"
#include "hiopLogBarProblem.hpp"
#include "hiopDualsUpdater.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/Optimization/hiopIterate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class hiopIterate
friend class hiopKKTLinSysDenseXYcYd;
friend class hiopKKTLinSysDenseXDYcYd;
friend class KktLinSysLowRank;
friend class hiopHessianLowRank;
friend class HessianDiagPlusRowRank;
friend class hiopKKTLinSysCompressedMDSXYcYd;
friend class hiopHessianInvLowRank_obsolette;
friend class hiopKKTLinSysSparse;
Expand Down
2 changes: 1 addition & 1 deletion src/Optimization/hiopKKTLinSys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

#include "hiopIterate.hpp"
#include "hiopResidual.hpp"
#include "hiopHessianLowRank.hpp"
#include "HessianDiagPlusRowRank.hpp"
#include "hiopPDPerturbation.hpp"
#include "hiopLinSolver.hpp"
#include "hiopFactAcceptor.hpp"
Expand Down
4 changes: 2 additions & 2 deletions src/Optimization/hiopNlpFormulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
*/

#include "hiopNlpFormulation.hpp"
#include "hiopHessianLowRank.hpp"
#include "HessianDiagPlusRowRank.hpp"
#include "hiopVector.hpp"
#include "LinAlgFactory.hpp"
#include "hiopLogger.hpp"
Expand Down Expand Up @@ -1636,7 +1636,7 @@ hiopMatrixDense* hiopNlpDenseConstraints::alloc_Jac_cons()

hiopMatrix* hiopNlpDenseConstraints::alloc_Hess_Lagr()
{
return new hiopHessianLowRank(this, this->options->GetInteger("secant_memory_len"));
return new HessianDiagPlusRowRank(this, this->options->GetInteger("secant_memory_len"));
}

hiopMatrixDense* hiopNlpDenseConstraints::alloc_multivector_primal(int nrows, int maxrows/*=-1*/) const
Expand Down
2 changes: 1 addition & 1 deletion src/Optimization/hiopNlpFormulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ class hiopNlpDenseConstraints : public hiopNlpFormulation
virtual hiopMatrixDense* alloc_Jac_c();
virtual hiopMatrixDense* alloc_Jac_d();
virtual hiopMatrixDense* alloc_Jac_cons();
//returns hiopHessianLowRank which (fakely) inherits from hiopMatrix
//returns HessianDiagPlusRowRank which (fakely) inherits from hiopMatrix
virtual hiopMatrix* alloc_Hess_Lagr();

/* this is in general for a dense matrix with n_vars cols and a small number of
Expand Down
9 changes: 6 additions & 3 deletions src/Utils/hiopLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

#include "hiopVector.hpp"
#include "hiopResidual.hpp"
#include "hiopHessianLowRank.hpp"
#include "HessianDiagPlusRowRank.hpp"
#include "hiopFilter.hpp"
#include "hiopOptions.hpp"

Expand Down Expand Up @@ -97,7 +97,10 @@ void hiopLogger::write(const char* msg, const hiopIterate& it, hiopOutVerbosity
}

#ifdef HIOP_DEEPCHECKS
void hiopLogger::write(const char* msg, const hiopHessianLowRank& Hess, hiopOutVerbosity v, int loggerid/*=0*/)
void hiopLogger::write(const char* msg,
const HessianDiagPlusRowRank& Hess,
hiopOutVerbosity v,
int loggerid/*=0*/)
{
if(master_rank_ != my_rank_) return;
hiopOutVerbosity _verb = (hiopOutVerbosity) options_->GetInteger("verbosity_level");
Expand All @@ -106,7 +109,7 @@ void hiopLogger::write(const char* msg, const hiopHessianLowRank& Hess, hiopOutV
}
#endif

void hiopLogger::write(const char* msg, const hiopOptions& options, hiopOutVerbosity v, int loggerid/*=0*/)
void hiopLogger::write(const char* msg, const hiopOptions& options, hiopOutVerbosity v, int loggerid/*=0*/)
{
if(master_rank_ != my_rank_) return;
hiopOutVerbosity _verb = (hiopOutVerbosity) options_->GetInteger("verbosity_level");
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/hiopLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class hiopVector;
class hiopResidual;
class hiopIterate;
class hiopMatrix;
class hiopHessianLowRank;
class HessianDiagPlusRowRank;
class hiopNlpFormulation;
class hiopOptions;
class hiopFilter;
Expand Down Expand Up @@ -105,7 +105,7 @@ class hiopLogger
void write(const char* msg, const hiopIterate& r, hiopOutVerbosity v, int loggerid=0);
void write(const char* msg, const hiopMatrix& M, hiopOutVerbosity v, int loggerid=0);
#ifdef HIOP_DEEPCHECKS
void write(const char* msg, const hiopHessianLowRank& Hess, hiopOutVerbosity v, int loggerid=0);
void write(const char* msg, const HessianDiagPlusRowRank& Hess, hiopOutVerbosity v, int loggerid=0);
#endif
void write(const char* msg, const hiopNlpFormulation& nlp, hiopOutVerbosity v, int loggerid=0);
void write(const char* msg, const hiopOptions& options, hiopOutVerbosity v, int loggerid=0);
Expand Down

0 comments on commit 2325d0d

Please sign in to comment.