Skip to content

Commit 018e956

Browse files
committed
finished renaming to VectorSpace
1 parent 9663829 commit 018e956

13 files changed

+55
-137
lines changed

src/Drivers/Dense/NlpDenseConsEx1.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ class DenseConsEx1 : public hiop::hiopInterfaceDenseConstraints
292292
/**
293293
* Enables the use of weighted inner products via @applyM, @applyH, and @applyHinv
294294
*/
295-
virtual bool useWeightedInnerProducts()
295+
virtual bool useWeightedVectorSpace()
296296
{
297297
return use_weighted_space_;
298298
}

src/Optimization/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set(hiopOptimization_SRC
99
KktLinSysLowRank.cpp
1010
hiopKKTLinSysMDS.cpp
1111
HessianDiagPlusRowRank.cpp
12-
InnerProduct.cpp
12+
VectorSpace.cpp
1313
hiopDualsUpdater.cpp
1414
hiopNlpTransforms.cpp
1515
hiopPDPerturbation.cpp
@@ -30,7 +30,7 @@ set(hiopOptimization_INTERFACE_HEADERS
3030
hiopFactAcceptor.hpp
3131
hiopFilter.hpp
3232
HessianDiagPlusRowRank.hpp
33-
InnerProduct.hpp
33+
VectorSpace.hpp
3434
hiopIterate.hpp
3535
hiopKKTLinSys.hpp
3636
hiopKKTLinSysDense.hpp

src/Optimization/HessianDiagPlusRowRank.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ bool HessianDiagPlusRowRank::update_logbar_diag(const hiopVector& Dx)
241241
{
242242
// DhInv = (B0+Dx)^{-1}
243243
//DhInv_->setToConstant(sigma_);
244-
const hiopVector& B0 = *nlp_->inner_prod()->M_lumped();
244+
const hiopVector& B0 = *nlp_->vec_space()->M_lumped();
245245
DhInv_->copyFrom(B0);
246246
DhInv_->scale(sigma_);
247247
DhInv_->axpy(1.0, Dx);
@@ -322,8 +322,8 @@ bool HessianDiagPlusRowRank::update(const hiopIterate& it_curr,
322322
Jac_d_prev_->transTimesVec(1.0, y_new, -1.0, *it_curr.yd);
323323

324324
const double sTy = s_new.dotProductWith(y_new);
325-
const double s_nrm2 = nlp_->inner_prod()->norm_M(s_new);//s_new.twonorm();
326-
const double y_nrm2 = nlp_->inner_prod()->norm_H_dual(y_new);//y_new.twonorm();
325+
const double s_nrm2 = nlp_->vec_space()->norm_H_primal(s_new);//s_new.twonorm();
326+
const double y_nrm2 = nlp_->vec_space()->norm_H_dual(y_new);//y_new.twonorm();
327327

328328
nlp_->log->printf(hovWarning, //hovLinAlgScalarsVerb,
329329
"sigma HessianDiagPlusRowRank: s^T*y=%20.14e ||s||=%20.14e ||y||=%20.14e ||s||_inf=%20.14e\n",
@@ -463,7 +463,7 @@ void HessianDiagPlusRowRank::updateInternalBFGSRepresentation()
463463

464464
//-- block (1,2)
465465
hiopMatrixDense& StB0DhInvYmL = DpYtDhInvY; // just a rename
466-
const hiopVector& B0 = *nlp_->inner_prod()->M_lumped();
466+
const hiopVector& B0 = *nlp_->vec_space()->M_lumped();
467467
hiopVector& B0DhInv = new_n_vec1(n);
468468
B0DhInv.copyFrom(*DhInv_);
469469
B0DhInv.scale(sigma_);
@@ -562,7 +562,7 @@ void HessianDiagPlusRowRank::solve(const hiopVector& rhsx, hiopVector& x)
562562
hiopVector& B0DhInvx = new_n_vec1(n);
563563
B0DhInvx.copyFrom(x); // it contains DhInv*res
564564
B0DhInvx.scale(sigma_); // B0*(DhInv*res)
565-
const hiopVector& B0 = *nlp_->inner_prod()->M_lumped();
565+
const hiopVector& B0 = *nlp_->vec_space()->M_lumped();
566566
B0DhInvx.componentMult(B0);
567567

568568
St_->timesVec(0.0, stx, 1.0, B0DhInvx);
@@ -629,7 +629,7 @@ void HessianDiagPlusRowRank::sym_mat_times_inverse_times_mattrans(double beta,
629629
auto& Y1 = new_Y1(X, *Yt_); // both are kxl
630630
hiopVector& B0DhInv = new_n_vec1(n);
631631
B0DhInv.copyFrom(*DhInv_);
632-
const hiopVector& B0 = *nlp_->inner_prod()->M_lumped();
632+
const hiopVector& B0 = *nlp_->vec_space()->M_lumped();
633633
B0DhInv.scale(sigma_);
634634
B0DhInv.componentMult(B0);
635635
mat_times_diag_times_mattrans_local(S1, X, B0DhInv, *St_);
@@ -1078,7 +1078,7 @@ void HessianDiagPlusRowRank::times_vec_common(double beta,
10781078

10791079
// we have B+=B-B*s*B*s'/(s'*B*s)+yy'/(y'*s)
10801080
// B0 is sigma*I. There is an additional diagonal log-barrier term Dx_
1081-
const hiopVector& B0 = *nlp_->inner_prod()->M_lumped();
1081+
const hiopVector& B0 = *nlp_->vec_space()->M_lumped();
10821082

10831083
bool print = false;
10841084
if(print) {

src/Optimization/KktLinSysLowRank.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ bool KktLinSysLowRank::update(const hiopIterate* iter,
100100
Dx_->setToZero();
101101
Dx_->axdzpy_w_pattern(1.0, *iter_->zl, *iter_->sxl, nlp_->get_ixl());
102102
Dx_->axdzpy_w_pattern(1.0, *iter_->zu, *iter_->sxu, nlp_->get_ixu());
103-
Dx_->componentMult(*nlp_->inner_prod()->M_lumped());
103+
Dx_->componentMult(*nlp_->vec_space()->M_lumped());
104104
nlp_->log->write("Dx in KKT", *Dx_, hovMatrices);
105105

106106
hess_low_rank->update_logbar_diag(*Dx_);
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
*
5353
*/
5454

55-
56-
#include "InnerProduct.hpp"
55+
#include "VectorSpace.hpp"
5756
#include "hiopNlpFormulation.hpp"
5857

5958
namespace hiop
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@
4646
// product endorsement purposes.
4747

4848
/**
49-
* @file InnerProduct.hpp
49+
* @file VectorSpace.hpp
5050
*
5151
* @author Cosmin G. Petra <petra1@llnl.gov>, LLNL
5252
*
5353
*/
5454

55-
#ifndef HIOP_NLP_INNERPROD
56-
#define HIOP_NLP_INNERPROD
55+
#ifndef HIOP_NLP_VECSPACE
56+
#define HIOP_NLP_VECSPACE
5757

5858
#include "hiopVector.hpp"
5959

src/Optimization/hiopDualsUpdater.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ bool hiopDualsLsqUpdateLinsysRedDense::do_lsq_update(hiopIterate& iter,
280280
//vecx.axpy(1.0, *iter.get_zu());
281281
vecx.copyFrom(*iter.get_zu());
282282
vecx.axpy(-1.0, *iter.get_zl());
283-
vecx.componentMult(*nlp_->inner_prod()->M_lumped());
283+
vecx.componentMult(*nlp_->vec_space()->M_lumped());
284284
vecx.axpy(1.0, grad_f);
285285
hiopVector& vecd = *vec_mi_;
286286
vecd.copyFrom(*iter.get_vl());

src/Optimization/hiopIterate.cpp

Lines changed: 11 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -196,77 +196,12 @@ void hiopIterate::setEqualityDualsToConstant(const double& v)
196196
yd->setToConstant(v);
197197
}
198198

199-
// double hiopIterate::normOneOfBoundDuals() const
200-
// {
201-
// #ifdef HIOP_DEEPCHECKS
202-
// assert(zl->matchesPattern(nlp->get_ixl()));
203-
// assert(zu->matchesPattern(nlp->get_ixu()));
204-
// assert(vl->matchesPattern(nlp->get_idl()));
205-
// assert(vu->matchesPattern(nlp->get_idu()));
206-
// #endif
207-
// // work locally with all the vectors. This will result in only one MPI_Allreduce call instead of two.
208-
// double nrm1 = zl->onenorm_local() + zu->onenorm_local();
209-
// #ifdef HIOP_USE_MPI
210-
// double nrm1_global;
211-
// int ierr = MPI_Allreduce(&nrm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm());
212-
// assert(MPI_SUCCESS == ierr);
213-
// nrm1 = nrm1_global;
214-
// #endif
215-
// nrm1 += vl->onenorm_local() + vu->onenorm_local();
216-
// return nrm1;
217-
// }
218-
219-
// double hiopIterate::normOneOfEqualityDuals() const
220-
// {
221-
// #ifdef HIOP_DEEPCHECKS
222-
// assert(zl->matchesPattern(nlp->get_ixl()));
223-
// assert(zu->matchesPattern(nlp->get_ixu()));
224-
// assert(vl->matchesPattern(nlp->get_idl()));
225-
// assert(vu->matchesPattern(nlp->get_idu()));
226-
// #endif
227-
// // work locally with all the vectors. This will result in only one MPI_Allreduce call instead of two.
228-
// double nrm1 = zl->onenorm_local() + zu->onenorm_local();
229-
// #ifdef HIOP_USE_MPI
230-
// double nrm1_global;
231-
// int ierr = MPI_Allreduce(&nrm1, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm());
232-
// assert(MPI_SUCCESS == ierr);
233-
// nrm1 = nrm1_global;
234-
// #endif
235-
// nrm1 += vl->onenorm_local() + vu->onenorm_local() + yc->onenorm_local() + yd->onenorm_local();
236-
// return nrm1;
237-
// }
238-
239-
// void hiopIterate::normOneOfDuals(double& nrm1Eq, double& nrm1Bnd) const
240-
// {
241-
// #ifdef HIOP_DEEPCHECKS
242-
// assert(zl->matchesPattern(nlp->get_ixl()));
243-
// assert(zu->matchesPattern(nlp->get_ixu()));
244-
// assert(vl->matchesPattern(nlp->get_idl()));
245-
// assert(vu->matchesPattern(nlp->get_idu()));
246-
// #endif
247-
// // work locally with all the vectors. This will result in only one MPI_Allreduce call
248-
// nrm1Bnd = zl->onenorm_local() + zu->onenorm_local();
249-
// #ifdef HIOP_USE_MPI
250-
// double nrm1_global;
251-
// int ierr = MPI_Allreduce(&nrm1Bnd, &nrm1_global, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm());
252-
// assert(MPI_SUCCESS == ierr);
253-
// nrm1Bnd = nrm1_global;
254-
// #endif
255-
// nrm1Bnd += vl->onenorm_local() + vu->onenorm_local();
256-
// nrm1Eq = yc->onenorm_local() + yd->onenorm_local();
257-
258-
// nlp->log->printf(hovWarning,
259-
// "sc=--- sd=--- volume_n=--- nrm zl=%12.5e zu=%12.5e vl=%12.5e vu=%12.5e yc=%12.5e yd=%12.5e\n",
260-
// zl->onenorm(), zu->onenorm(), vl->onenorm(), vu->onenorm(), yc->onenorm(), yd->onenorm());
261-
262-
// }
263-
264199
/// @brief Computes scaling factors sc and sd; also returns the "norms" of duals
265200
bool hiopIterate::compute_sc_sd(double& sc, double& sd, double& nrmDualsEq, double& nrmDualsBou) const
266201
{
267-
const auto nrmzl = nlp->inner_prod()->norm_M_one(*zl);
268-
const auto nrmzu = nlp->inner_prod()->norm_M_one(*zu);
269-
const auto volume_n = nlp->inner_prod()->volume();
202+
const auto nrmzl = nlp->vec_space()->norm_M_one(*zl);
203+
const auto nrmzu = nlp->vec_space()->norm_M_one(*zu);
204+
const auto volume_n = nlp->vec_space()->volume();
270205
const auto nrmvl = vl->onenorm_local();
271206
const auto nrmvu = vu->onenorm_local();
272207
nrmDualsBou = nrmzl + nrmzu + nrmvl + nrmvu;
@@ -278,7 +213,7 @@ bool hiopIterate::compute_sc_sd(double& sc, double& sd, double& nrmDualsEq, doub
278213
nrmDualsEq = nrmyc+nrmyd;
279214
sd = (nrmDualsBou+nrmDualsEq)/(volume_n+volume_m);
280215

281-
nlp->log->printf(hovWarning,
216+
nlp->log->printf(hovScalars,
282217
"sc=%g sd=%g volume_n=%12.5e norms zl=%12.5e zu=%12.5e vl=%12.5e vu=%12.5e yc=%12.5e yd=%12.5e\n",
283218
sc, sd, volume_n, nrmzl, nrmzu, nrmvl, nrmvu, nrmyc, nrmyd);
284219
return true;
@@ -568,11 +503,8 @@ bool hiopIterate::adjustDuals_primalLogHessian(const double& mu, const double& k
568503

569504
double hiopIterate::evalLogBarrier() const
570505
{
571-
double barrier;
572-
//barrier = sxl->logBarrier_local(nlp->get_ixl());
573-
//barrier += sxu->logBarrier_local(nlp->get_ixu());
574-
barrier = nlp->inner_prod()->log_barrier_eval_local(*sxl, nlp->get_ixl());
575-
barrier += nlp->inner_prod()->log_barrier_eval_local(*sxu, nlp->get_ixu());
506+
auto barrier = nlp->vec_space()->log_barrier_eval_local(*sxl, nlp->get_ixl());
507+
barrier += nlp->vec_space()->log_barrier_eval_local(*sxu, nlp->get_ixu());
576508
#ifdef HIOP_USE_MPI
577509
double res;
578510
int ierr = MPI_Allreduce(&barrier, &res, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm());
@@ -590,8 +522,8 @@ void hiopIterate::addLogBarGrad_x(const double& mu, hiopVector& gradx) const
590522
// gradx = grad - mu / sxl = grad - mu * select/sxl
591523
//gradx.addLogBarrierGrad(-mu, *sxl, nlp->get_ixl());
592524
//gradx.addLogBarrierGrad(mu, *sxu, nlp->get_ixu());
593-
nlp->inner_prod()->log_barrier_grad_add(-mu, *sxl, nlp->get_ixl(), gradx);
594-
nlp->inner_prod()->log_barrier_grad_add( mu, *sxu, nlp->get_ixu(), gradx);
525+
nlp->vec_space()->log_barrier_grad_add(-mu, *sxl, nlp->get_ixl(), gradx);
526+
nlp->vec_space()->log_barrier_grad_add( mu, *sxu, nlp->get_ixu(), gradx);
595527
}
596528

597529
void hiopIterate::addLogBarGrad_d(const double& mu, hiopVector& gradd) const
@@ -602,11 +534,10 @@ void hiopIterate::addLogBarGrad_d(const double& mu, hiopVector& gradd) const
602534

603535
double hiopIterate::linearDampingTerm(const double& mu, const double& kappa_d) const
604536
{
605-
//double term;
606537
//term = sxl->linearDampingTerm_local(nlp->get_ixl(), nlp->get_ixu(), mu, kappa_d);
607538
//term += sxu->linearDampingTerm_local(nlp->get_ixu(), nlp->get_ixl(), mu, kappa_d);
608-
double term = nlp->inner_prod()->linear_damping_term_local(*sxl, nlp->get_ixl(), nlp->get_ixu(), mu, kappa_d);
609-
term += nlp->inner_prod()->linear_damping_term_local(*sxu, nlp->get_ixu(), nlp->get_ixl(), mu, kappa_d);
539+
double term = nlp->vec_space()->linear_damping_term_local(*sxl, nlp->get_ixl(), nlp->get_ixu(), mu, kappa_d);
540+
term += nlp->vec_space()->linear_damping_term_local(*sxu, nlp->get_ixu(), nlp->get_ixl(), mu, kappa_d);
610541
#ifdef HIOP_USE_MPI
611542
double res;
612543
int ierr = MPI_Allreduce(&term, &res, 1, MPI_DOUBLE, MPI_SUM, nlp->get_comm());
@@ -628,7 +559,7 @@ void hiopIterate::addLinearDampingTermToGrad_x(const double& mu,
628559

629560
const double ct = kappa_d * mu * beta;
630561
//grad_x.addLinearDampingTerm(nlp->get_ixl(), nlp->get_ixu(), 1.0, ct);
631-
nlp->inner_prod()->add_linear_damping_term(nlp->get_ixl(), nlp->get_ixu(), ct, grad_x);
562+
nlp->vec_space()->add_linear_damping_term(nlp->get_ixl(), nlp->get_ixu(), ct, grad_x);
632563
}
633564

634565
void hiopIterate::addLinearDampingTermToGrad_d(const double& mu,

src/Optimization/hiopIterate.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,6 @@ class hiopIterate
138138
const double& beta,
139139
hiopVector& grad_d) const;
140140

141-
/** norms for individual parts of the iterate (on demand computation) */
142-
//virtual double normOneOfBoundDuals() const;
143-
//virtual double normOneOfEqualityDuals() const;
144-
/* same as above but computed in one shot to save on communication and computation */
145-
//virtual void normOneOfDuals(double& nrm1Eq, double& nrm1Bnd) const;
146-
147141
/// @brief Computes scaling factors sc and sd; also returns the "norms" of duals
148142
bool compute_sc_sd(double& sc, double& sd, double& nrmDualsEq, double& nrmDualsBou) const;
149143

src/Optimization/hiopKKTLinSys.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ double hiopKKTLinSys::errorKKT(const hiopResidual* resid, const hiopIterate* sol
104104
//hiopVector* RX = resid->rx->new_copy();
105105
hiopVector* RX = sol->zl->new_copy();
106106
RX->axpy(-1.0, *sol->zu);
107-
RX->componentMult(*nlp_->inner_prod()->M_lumped());
107+
RX->componentMult(*nlp_->vec_space()->M_lumped());
108108
RX->axpy(1.0, *resid->rx);
109109

110110
HessianTimesVec_noLogBarrierTerm(1.0, *RX, -1.0, *sol->x);
@@ -646,7 +646,7 @@ bool hiopKKTLinSysCompressedXYcYd::computeDirections(const hiopResidual* resid,
646646
rx2.axdzpy_w_pattern(-1.0, ru, *iter_->sxu, nlp_->get_ixu());
647647
}
648648
if(nlp_->n_low_local() > 0 || nlp_->n_upp_local() > 0) {
649-
rx2.componentMult(*nlp_->inner_prod()->M_lumped());
649+
rx2.componentMult(*nlp_->vec_space()->M_lumped());
650650
rx_tilde_->axpy(1.0, rx2);
651651
}
652652

@@ -1223,7 +1223,7 @@ bool hiopMatVecKKTFullOpr::times_vec(hiopVector& yvec, const hiopVector& xvec)
12231223
// rx = H*dx + delta_wx*I*dx + Jc'*dyc + Jd'*dyd - dzl + dzu
12241224
yrx_->copyFrom(*dzu_);
12251225
yrx_->axpy(-1.0, *dzl_);
1226-
yrx_->componentMult(*kkt_->nlp_->inner_prod()->M_lumped());
1226+
yrx_->componentMult(*kkt_->nlp_->vec_space()->M_lumped());
12271227
Hess->timesVec(1.0, *yrx_, +1.0, *dx_);
12281228
yrx_->axzpy(1., *delta_wx, *dx_);
12291229
Jac_c->transTimesVec(1.0, *yrx_, 1.0, *dyc_);
@@ -1386,13 +1386,13 @@ bool hiopMatVecKKTFullOpr::trans_times_vec(hiopVector& yvec, const hiopVector& x
13861386
// RXL = -dx + Sxl*dsxl
13871387
yrsxl_->setToZero();
13881388
//yrsxl_->axpy(-1.0, *dx_);
1389-
yrsxl_->axzpy(-1.0, *dx_, *kkt_->nlp_->inner_prod()->M_lumped());
1389+
yrsxl_->axzpy(-1.0, *dx_, *kkt_->nlp_->vec_space()->M_lumped());
13901390
yrsxl_->axzpy(1.0, *iter_->get_sxl(), *dsxl_);
13911391
yrsxl_->selectPattern(kkt_->nlp_->get_ixl());
13921392

13931393
// RXU = dx + Sxu*dsxu
13941394
yrsxu_->copyFrom(*dx_);
1395-
yrsxu_->componentMult(*kkt_->nlp_->inner_prod()->M_lumped());
1395+
yrsxu_->componentMult(*kkt_->nlp_->vec_space()->M_lumped());
13961396
yrsxu_->axzpy(1.0, *iter_->get_sxu(), *dsxu_);
13971397
yrsxu_->selectPattern(kkt_->nlp_->get_ixu());
13981398

0 commit comments

Comments
 (0)