Skip to content

Commit f0de791

Browse files
committed
adding weights through the code (linear system and resids)
1 parent 5887c75 commit f0de791

File tree

4 files changed

+46
-13
lines changed

4 files changed

+46
-13
lines changed

src/Optimization/KktLinSysLowRank.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +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());
103104
nlp_->log->write("Dx in KKT", *Dx_, hovMatrices);
104105

105106
hess_low_rank->update_logbar_diag(*Dx_);
@@ -218,7 +219,7 @@ bool KktLinSysLowRank::solveCompressed(hiopVector& rx,
218219
// some outputing
219220
nlp_->log->write("KKT Low rank: solve compressed SOL", hovIteration);
220221
nlp_->log->write(" dx: ", dx, hovIteration);
221-
nlp_->log->write(" dyc: ", dyc, hovIteration);
222+
nlp_->log->write(" dyc: ", dyc, hovWarning);
222223
nlp_->log->write(" dyd: ", dyd, hovIteration);
223224
delete r;
224225
#endif

src/Optimization/hiopIterate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,8 @@ void hiopIterate::addLinearDampingTermToGrad_x(const double& mu,
621621
assert(x->get_local_size() == grad_x.get_local_size());
622622

623623
const double ct = kappa_d * mu * beta;
624-
grad_x.addLinearDampingTerm(nlp->get_ixl(), nlp->get_ixu(), 1.0, ct);
624+
//grad_x.addLinearDampingTerm(nlp->get_ixl(), nlp->get_ixu(), 1.0, ct);
625+
nlp->inner_prod()->add_linear_damping_term(nlp->get_ixl(), nlp->get_ixu(), ct, grad_x);
625626
}
626627

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

src/Optimization/hiopKKTLinSys.cpp

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ bool hiopKKTLinSysCompressedXYcYd::update(const hiopIterate* iter,
568568
Dx_->axdzpy_w_pattern(1.0, *iter_->zl, *iter_->sxl, nlp_->get_ixl());
569569
Dx_->axdzpy_w_pattern(1.0, *iter_->zu, *iter_->sxu, nlp_->get_ixu());
570570
nlp_->log->write("Dx in KKT", *Dx_, hovMatrices);
571-
571+
assert(false);
572572
// Dd=(Sdl)^{-1}Vu + (Sdu)^{-1}Vu
573573
Dd_->setToZero();
574574
Dd_->axdzpy_w_pattern(1.0, *iter_->vl, *iter_->sdl, nlp_->get_idl());
@@ -595,31 +595,58 @@ bool hiopKKTLinSysCompressedXYcYd::computeDirections(const hiopResidual* resid,
595595

596596
/***********************************************************************
597597
* perform the reduction to the compressed linear system
598-
* rx_tilde = rx+Sxl^{-1}*[rszl-Zl*rxl] - Sxu^{-1}*(rszu-Zu*rxu)
598+
* rx_tilde = rx+ M_lumped* Sxl^{-1}*[rszl-Zl*rxl] - M_lumped* Sxu^{-1}*(rszu-Zu*rxu)
599599
* ryd_tilde = ryd + [(Sdl^{-1}Vl+Sdu^{-1}Vu)]^{-1}*
600600
* [rd + Sdl^{-1}*(rsvl-Vl*rdl)-Sdu^{-1}(rsvu-Vu*rdu)]
601601
* rd_tilde = rd + Sdl^{-1}*(rsvl-Vl*rdl)-Sdu^{-1}(rsvu-Vu*rdu)
602602
* Dd_inv = [(Sdl^{-1}Vl+Sdu^{-1}Vu)]^{-1}
603603
* yd_tilde = ryd + Dd_inv*rd_tilde
604604
*/
605605
rx_tilde_->copyFrom(*r.rx);
606+
607+
// if(nlp_->n_low_local() > 0) {
608+
// // rl:=rszl-Zl*rxl (using dir->x as working buffer)
609+
// hiopVector& rl = *(dir->x); // temporary working buffer
610+
// rl.copyFrom(*r.rszl);
611+
// rl.axzpy(-1.0, *iter_->zl, *r.rxl);
612+
// // rx_tilde = rx+Sxl^{-1}*rl
613+
// rx_tilde_->axdzpy_w_pattern(1.0, rl, *iter_->sxl, nlp_->get_ixl());
614+
// }
615+
// if(nlp_->n_upp_local() > 0) {
616+
// // ru:=rszu-Zu*rxu (using dir->x as working buffer)
617+
// hiopVector& ru = *(dir->x); // temporary working buffer
618+
// ru.copyFrom(*r.rszu);
619+
// ru.axzpy(-1.0, *iter_->zu, *r.rxu);
620+
// // rx_tilde = rx_tilde - Sxu^{-1}*ru
621+
// rx_tilde_->axdzpy_w_pattern(-1.0, ru, *iter_->sxu, nlp_->get_ixu());
622+
// }
623+
624+
hiopVector& rx2 = *(dir->sxl); // temporary working buffer
625+
rx2.setToZero();
606626
if(nlp_->n_low_local() > 0) {
607-
// rl:=rszl-Zl*rxl (using dir->x as working buffer)
608627
hiopVector& rl = *(dir->x); // temporary working buffer
609628
rl.copyFrom(*r.rszl);
610629
rl.axzpy(-1.0, *iter_->zl, *r.rxl);
611-
// rx_tilde = rx+Sxl^{-1}*rl
612-
rx_tilde_->axdzpy_w_pattern(1.0, rl, *iter_->sxl, nlp_->get_ixl());
630+
//// rx_tilde = rx+Sxl^{-1}*rl
631+
//rx_tilde_->axdzpy_w_pattern(1.0, rl, *iter_->sxl, nlp_->get_ixl());
632+
rx2.axdzpy_w_pattern(1.0, rl, *iter_->sxl, nlp_->get_ixl());
613633
}
634+
614635
if(nlp_->n_upp_local() > 0) {
615-
// ru:=rszu-Zu*rxu (using dir->x as working buffer)
616-
hiopVector& ru = *(dir->x); // temporary working buffer
636+
// ru:=rszu-Zu*rxu
637+
hiopVector& ru = *(dir->x);
617638
ru.copyFrom(*r.rszu);
618639
ru.axzpy(-1.0, *iter_->zu, *r.rxu);
619-
// rx_tilde = rx_tilde - Sxu^{-1}*ru
620-
rx_tilde_->axdzpy_w_pattern(-1.0, ru, *iter_->sxu, nlp_->get_ixu());
640+
//// rx_tilde = rx_tilde - Sxu^{-1}*ru
641+
////rx_tilde_->axdzpy_w_pattern(-1.0, ru, *iter_->sxu, nlp_->get_ixu());
642+
rx2.axdzpy_w_pattern(-1.0, ru, *iter_->sxu, nlp_->get_ixu());
643+
}
644+
if(nlp_->n_low_local() > 0 || nlp_->n_upp_local() > 0) {
645+
rx2.componentMult(*nlp_->inner_prod()->M_lumped());
646+
rx_tilde_->axpy(1.0, rx2);
621647
}
622648

649+
623650
// for ryd_tilde:
624651
ryd_tilde_->copyFrom(*r.ryd);
625652
// 1. the diag (Sdl^{-1}Vl+Sdu^{-1}Vu)^{-1} has already computed in Dd_inv in 'update'

src/Optimization/hiopResidual.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ double hiopResidual::compute_nlp_infeasib_onenorm(const hiopIterate& it, const h
146146
rdu->axpy(-1.0, *it.d);
147147
rdu->selectPattern(nlp->get_idu());
148148
}
149-
149+
//! the ifs above seem to do nothing for the return value
150150
nlp->runStats.tmSolverInternal.stop();
151151
return nrmOne_infeasib;
152152
}
@@ -192,6 +192,8 @@ int hiopResidual::update(const hiopIterate& it,
192192
jac_d.transTimesVec(1.0, *rx, 1.0, *it.yd);
193193
rx->axpy(1.0, grad);
194194

195+
//nlp->log->write("rx w/o log terms:", *rx, hovWarning);
196+
195197
//buf = rx->infnorm_local();
196198
buf = nlp->inner_prod()->norm_stationarity(*rx);
197199
nrmInf_nlp_optim = fmax(nrmInf_nlp_optim, buf);
@@ -205,6 +207,8 @@ int hiopResidual::update(const hiopIterate& it,
205207
nrmInf_bar_optim = fmax(nrmInf_bar_optim, nlp->inner_prod()->norm_stationarity(*rx));
206208
nrmOne_bar_optim += nlp->inner_prod()->norm_M_one(*rx);
207209

210+
//nlp->log->write("rx with log terms:", *rx, hovWarning);
211+
208212
//~ done with rx
209213
// rd
210214
rd->copyFrom(*it.yd);
@@ -470,7 +474,7 @@ void hiopResidual::update_soc(const hiopIterate& it,
470474
nrmInf_bar_optim = nrmInf_bar_feasib = nrmInf_bar_complem = 0;
471475
nrmOne_nlp_feasib = nrmOne_bar_feasib = 0.;
472476
nrmOne_nlp_optim = nrmOne_bar_optim = 0.;
473-
477+
assert(false);
474478
size_type nx_loc = rx->get_local_size();
475479
const double& mu = logprob.mu;
476480
double buf;

0 commit comments

Comments
 (0)