Lines Matching refs:tao

106 PetscErrorCode TaoSolve_BNTL(Tao tao)  in TaoSolve_BNTL()  argument
108 TAO_BNK *bnk = (TAO_BNK *)tao->data; in TaoSolve_BNTL()
118 tao->reason = TAO_CONTINUE_ITERATING; in TaoSolve_BNTL()
119 PetscCall(TaoBNKInitialize(tao, bnk->init_type, &needH)); in TaoSolve_BNTL()
120 if (tao->reason != TAO_CONTINUE_ITERATING) PetscFunctionReturn(PETSC_SUCCESS); in TaoSolve_BNTL()
123 while (tao->reason == TAO_CONTINUE_ITERATING) { in TaoSolve_BNTL()
125 if (tao->ops->update) { in TaoSolve_BNTL()
126 PetscUseTypeMethod(tao, update, tao->niter, tao->user_update); in TaoSolve_BNTL()
127 PetscCall(TaoComputeObjective(tao, tao->solution, &bnk->f)); in TaoSolve_BNTL()
132 PetscCall(TaoBNKTakeCGSteps(tao, &cgTerminate)); in TaoSolve_BNTL()
134 tao->reason = bnk->bncg->reason; in TaoSolve_BNTL()
138 PetscCall((*bnk->computehessian)(tao)); in TaoSolve_BNTL()
143 PetscCall((*bnk->computestep)(tao, shift, &ksp_reason, &stepType)); in TaoSolve_BNTL()
146 oldTrust = tao->trust; in TaoSolve_BNTL()
148 PetscCall(VecCopy(tao->solution, bnk->Xold)); in TaoSolve_BNTL()
149 PetscCall(VecCopy(tao->gradient, bnk->Gold)); in TaoSolve_BNTL()
153 PetscCall(VecAXPY(tao->solution, 1.0, tao->stepdirection)); in TaoSolve_BNTL()
154 PetscCall(TaoBoundSolution(tao->solution, tao->XL, tao->XU, 0.0, &nDiff, tao->solution)); in TaoSolve_BNTL()
160 PetscCall(VecCopy(tao->solution, tao->stepdirection)); in TaoSolve_BNTL()
161 PetscCall(VecAXPY(tao->stepdirection, -1.0, bnk->Xold)); in TaoSolve_BNTL()
162 PetscCall(TaoBNKRecomputePred(tao, tao->stepdirection, &prered)); in TaoSolve_BNTL()
165 PetscCall(KSPCGGetObjFcn(tao->ksp, &prered)); in TaoSolve_BNTL()
170 PetscCall(TaoComputeObjective(tao, tao->solution, &bnk->f)); in TaoSolve_BNTL()
171 …PetscCheck(!PetscIsInfOrNanReal(bnk->f), PetscObjectComm((PetscObject)tao), PETSC_ERR_USER, "User … in TaoSolve_BNTL()
173 …PetscCall(TaoBNKUpdateTrustRadius(tao, prered, actred, bnk->update_type, stepType, &stepAccepted)); in TaoSolve_BNTL()
180 PetscCall(TaoComputeGradient(tao, tao->solution, bnk->unprojected_gradient)); in TaoSolve_BNTL()
181 PetscCall(TaoBNKEstimateActiveSet(tao, bnk->as_type)); in TaoSolve_BNTL()
182 PetscCall(VecCopy(bnk->unprojected_gradient, tao->gradient)); in TaoSolve_BNTL()
183 if (bnk->active_idx) PetscCall(VecISSet(tao->gradient, bnk->active_idx, 0.0)); in TaoSolve_BNTL()
184 PetscCall(TaoGradientNorm(tao, tao->gradient, NORM_2, &bnk->gnorm)); in TaoSolve_BNTL()
188 PetscCall(VecCopy(bnk->Xold, tao->solution)); in TaoSolve_BNTL()
190 PetscCall(TaoBNKSafeguardStep(tao, ksp_reason, &stepType)); in TaoSolve_BNTL()
191 PetscCall(TaoBNKPerformLineSearch(tao, &stepType, &steplen, &ls_reason)); in TaoSolve_BNTL()
197 PetscCall(VecCopy(bnk->Xold, tao->solution)); in TaoSolve_BNTL()
198 PetscCall(VecCopy(bnk->Gold, tao->gradient)); in TaoSolve_BNTL()
200 tao->trust = 0.0; in TaoSolve_BNTL()
201 tao->reason = TAO_DIVERGED_LS_FAILURE; in TaoSolve_BNTL()
206 PetscCall(TaoBNKEstimateActiveSet(tao, bnk->as_type)); in TaoSolve_BNTL()
207 PetscCall(VecCopy(bnk->unprojected_gradient, tao->gradient)); in TaoSolve_BNTL()
208 if (bnk->active_idx) PetscCall(VecISSet(tao->gradient, bnk->active_idx, 0.0)); in TaoSolve_BNTL()
209 PetscCall(TaoGradientNorm(tao, tao->gradient, NORM_2, &bnk->gnorm)); in TaoSolve_BNTL()
211 tao->trust = oldTrust; in TaoSolve_BNTL()
212 … PetscCall(TaoBNKUpdateTrustRadius(tao, prered, actred, BNK_UPDATE_STEP, stepType, &stepAccepted)); in TaoSolve_BNTL()
214 PetscCall(TaoBNKAddStepCounts(tao, stepType)); in TaoSolve_BNTL()
219 PetscCall(VecFischer(tao->solution, bnk->unprojected_gradient, tao->XL, tao->XU, bnk->W)); in TaoSolve_BNTL()
221 …PetscCheck(!PetscIsInfOrNanReal(resnorm), PetscObjectComm((PetscObject)tao), PETSC_ERR_USER, "User… in TaoSolve_BNTL()
222 ++tao->niter; in TaoSolve_BNTL()
223 PetscCall(TaoLogConvergenceHistory(tao, bnk->f, resnorm, 0.0, tao->ksp_its)); in TaoSolve_BNTL()
224 PetscCall(TaoMonitor(tao, tao->niter, bnk->f, resnorm, 0.0, steplen)); in TaoSolve_BNTL()
225 PetscUseTypeMethod(tao, convergencetest, tao->cnvP); in TaoSolve_BNTL()
230 static PetscErrorCode TaoSetUp_BNTL(Tao tao) in TaoSetUp_BNTL() argument
236 PetscCall(TaoSetUp_BNK(tao)); in TaoSetUp_BNTL()
237 PetscCall(TaoGetKSP(tao, &ksp)); in TaoSetUp_BNTL()
239 …PetscCheck(valid, PetscObjectComm((PetscObject)tao), PETSC_ERR_SUP, "Not for KSP type %s. Must use… in TaoSetUp_BNTL()
243 static PetscErrorCode TaoSetFromOptions_BNTL(Tao tao, PetscOptionItems PetscOptionsObject) in TaoSetFromOptions_BNTL() argument
245 TAO_BNK *bnk = (TAO_BNK *)tao->data; in TaoSetFromOptions_BNTL()
248 PetscCall(TaoSetFromOptions_BNK(tao, PetscOptionsObject)); in TaoSetFromOptions_BNTL()
270 PETSC_EXTERN PetscErrorCode TaoCreate_BNTL(Tao tao) in TaoCreate_BNTL() argument
275 PetscCall(TaoCreate_BNK(tao)); in TaoCreate_BNTL()
276 tao->ops->solve = TaoSolve_BNTL; in TaoCreate_BNTL()
277 tao->ops->setup = TaoSetUp_BNTL; in TaoCreate_BNTL()
278 tao->ops->setfromoptions = TaoSetFromOptions_BNTL; in TaoCreate_BNTL()
280 bnk = (TAO_BNK *)tao->data; in TaoCreate_BNTL()