Lines Matching refs:tao

5 static PetscErrorCode TaoSolve_BLMVM(Tao tao)  in TaoSolve_BLMVM()  argument
7 TAO_BLMVM *blmP = (TAO_BLMVM *)tao->data; in TaoSolve_BLMVM()
14 PetscCall(TaoComputeVariableBounds(tao)); in TaoSolve_BLMVM()
15 PetscCall(VecMedian(tao->XL, tao->solution, tao->XU, tao->solution)); in TaoSolve_BLMVM()
16 PetscCall(TaoLineSearchSetVariableBounds(tao->linesearch, tao->XL, tao->XU)); in TaoSolve_BLMVM()
19 PetscCall(TaoComputeObjectiveAndGradient(tao, tao->solution, &f, blmP->unprojected_gradient)); in TaoSolve_BLMVM()
20 …ll(VecBoundGradientProjection(blmP->unprojected_gradient, tao->solution, tao->XL, tao->XU, tao->gr… in TaoSolve_BLMVM()
22 PetscCall(TaoGradientNorm(tao, tao->gradient, NORM_2, &gnorm)); in TaoSolve_BLMVM()
23 …fOrNanReal(f) && !PetscIsInfOrNanReal(gnorm), PetscObjectComm((PetscObject)tao), PETSC_ERR_USER, "… in TaoSolve_BLMVM()
25 tao->reason = TAO_CONTINUE_ITERATING; in TaoSolve_BLMVM()
26 PetscCall(TaoLogConvergenceHistory(tao, f, gnorm, 0.0, tao->ksp_its)); in TaoSolve_BLMVM()
27 PetscCall(TaoMonitor(tao, tao->niter, f, gnorm, 0.0, stepsize)); in TaoSolve_BLMVM()
28 PetscUseTypeMethod(tao, convergencetest, tao->cnvP); in TaoSolve_BLMVM()
29 if (tao->reason != TAO_CONTINUE_ITERATING) PetscFunctionReturn(PETSC_SUCCESS); in TaoSolve_BLMVM()
39 while (tao->reason == TAO_CONTINUE_ITERATING) { in TaoSolve_BLMVM()
41 if (tao->ops->update) { in TaoSolve_BLMVM()
42 PetscUseTypeMethod(tao, update, tao->niter, tao->user_update); in TaoSolve_BLMVM()
43 PetscCall(TaoComputeObjective(tao, tao->solution, &f)); in TaoSolve_BLMVM()
54 PetscCall(MatLMVMUpdate(blmP->M, tao->solution, tao->gradient)); in TaoSolve_BLMVM()
55 PetscCall(MatSolve(blmP->M, blmP->unprojected_gradient, tao->stepdirection)); in TaoSolve_BLMVM()
56 …PetscCall(VecBoundGradientProjection(tao->stepdirection, tao->solution, tao->XL, tao->XU, tao->gra… in TaoSolve_BLMVM()
59 PetscCall(VecDot(blmP->unprojected_gradient, tao->gradient, &gdx)); in TaoSolve_BLMVM()
66 PetscCall(MatLMVMUpdate(blmP->M, tao->solution, blmP->unprojected_gradient)); in TaoSolve_BLMVM()
67 PetscCall(MatSolve(blmP->M, blmP->unprojected_gradient, tao->stepdirection)); in TaoSolve_BLMVM()
69 PetscCall(VecScale(tao->stepdirection, -1.0)); in TaoSolve_BLMVM()
73 PetscCall(VecCopy(tao->solution, blmP->Xold)); in TaoSolve_BLMVM()
75 PetscCall(TaoLineSearchSetInitialStepLength(tao->linesearch, 1.0)); in TaoSolve_BLMVM()
76 …PetscCall(TaoLineSearchApply(tao->linesearch, tao->solution, &f, blmP->unprojected_gradient, tao->… in TaoSolve_BLMVM()
77 PetscCall(TaoAddLineSearchCounts(tao)); in TaoSolve_BLMVM()
85 PetscCall(VecCopy(blmP->Xold, tao->solution)); in TaoSolve_BLMVM()
89 PetscCall(MatLMVMUpdate(blmP->M, tao->solution, blmP->unprojected_gradient)); in TaoSolve_BLMVM()
90 PetscCall(MatSolve(blmP->M, blmP->unprojected_gradient, tao->stepdirection)); in TaoSolve_BLMVM()
91 PetscCall(VecScale(tao->stepdirection, -1.0)); in TaoSolve_BLMVM()
95 PetscCall(TaoLineSearchSetInitialStepLength(tao->linesearch, 1.0)); in TaoSolve_BLMVM()
96 …PetscCall(TaoLineSearchApply(tao->linesearch, tao->solution, &f, blmP->unprojected_gradient, tao->… in TaoSolve_BLMVM()
97 PetscCall(TaoAddLineSearchCounts(tao)); in TaoSolve_BLMVM()
100 tao->reason = TAO_DIVERGED_LS_FAILURE; in TaoSolve_BLMVM()
106 …ll(VecBoundGradientProjection(blmP->unprojected_gradient, tao->solution, tao->XL, tao->XU, tao->gr… in TaoSolve_BLMVM()
107 PetscCall(TaoGradientNorm(tao, tao->gradient, NORM_2, &gnorm)); in TaoSolve_BLMVM()
108 …fOrNanReal(f) && !PetscIsInfOrNanReal(gnorm), PetscObjectComm((PetscObject)tao), PETSC_ERR_USER, "… in TaoSolve_BLMVM()
109 tao->niter++; in TaoSolve_BLMVM()
110 PetscCall(TaoLogConvergenceHistory(tao, f, gnorm, 0.0, tao->ksp_its)); in TaoSolve_BLMVM()
111 PetscCall(TaoMonitor(tao, tao->niter, f, gnorm, 0.0, stepsize)); in TaoSolve_BLMVM()
112 PetscUseTypeMethod(tao, convergencetest, tao->cnvP); in TaoSolve_BLMVM()
117 static PetscErrorCode TaoSetup_BLMVM(Tao tao) in TaoSetup_BLMVM() argument
119 TAO_BLMVM *blmP = (TAO_BLMVM *)tao->data; in TaoSetup_BLMVM()
123 PetscCall(VecDuplicate(tao->solution, &blmP->Xold)); in TaoSetup_BLMVM()
124 PetscCall(VecDuplicate(tao->solution, &blmP->Gold)); in TaoSetup_BLMVM()
125 PetscCall(VecDuplicate(tao->solution, &blmP->unprojected_gradient)); in TaoSetup_BLMVM()
126 if (!tao->stepdirection) PetscCall(VecDuplicate(tao->solution, &tao->stepdirection)); in TaoSetup_BLMVM()
127 if (!tao->gradient) PetscCall(VecDuplicate(tao->solution, &tao->gradient)); in TaoSetup_BLMVM()
129 PetscCall(MatLMVMAllocate(blmP->M, tao->solution, blmP->unprojected_gradient)); in TaoSetup_BLMVM()
136 static PetscErrorCode TaoDestroy_BLMVM(Tao tao) in TaoDestroy_BLMVM() argument
138 TAO_BLMVM *blmP = (TAO_BLMVM *)tao->data; in TaoDestroy_BLMVM()
141 if (tao->setupcalled) { in TaoDestroy_BLMVM()
148 PetscCall(PetscFree(tao->data)); in TaoDestroy_BLMVM()
152 static PetscErrorCode TaoSetFromOptions_BLMVM(Tao tao, PetscOptionItems PetscOptionsObject) in TaoSetFromOptions_BLMVM() argument
154 TAO_BLMVM *blmP = (TAO_BLMVM *)tao->data; in TaoSetFromOptions_BLMVM()
161 PetscCall(MatSetOptionsPrefix(blmP->M, ((PetscObject)tao)->prefix)); in TaoSetFromOptions_BLMVM()
165 …PetscCheck(is_set && is_spd, PetscObjectComm((PetscObject)tao), PETSC_ERR_ARG_INCOMP, "LMVM matrix… in TaoSetFromOptions_BLMVM()
169 static PetscErrorCode TaoView_BLMVM(Tao tao, PetscViewer viewer) in TaoView_BLMVM() argument
171 TAO_BLMVM *lmP = (TAO_BLMVM *)tao->data; in TaoView_BLMVM()
185 static PetscErrorCode TaoComputeDual_BLMVM(Tao tao, Vec DXL, Vec DXU) in TaoComputeDual_BLMVM() argument
187 TAO_BLMVM *blm = (TAO_BLMVM *)tao->data; in TaoComputeDual_BLMVM()
190 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoComputeDual_BLMVM()
193 …PetscCheck(tao->gradient && blm->unprojected_gradient, PETSC_COMM_SELF, PETSC_ERR_ORDER, "Dual var… in TaoComputeDual_BLMVM()
195 PetscCall(VecCopy(tao->gradient, DXL)); in TaoComputeDual_BLMVM()
201 PetscCall(VecAXPY(DXU, -1.0, tao->gradient)); in TaoComputeDual_BLMVM()
218 PETSC_EXTERN PetscErrorCode TaoCreate_BLMVM(Tao tao) in TaoCreate_BLMVM() argument
224 tao->ops->setup = TaoSetup_BLMVM; in TaoCreate_BLMVM()
225 tao->ops->solve = TaoSolve_BLMVM; in TaoCreate_BLMVM()
226 tao->ops->view = TaoView_BLMVM; in TaoCreate_BLMVM()
227 tao->ops->setfromoptions = TaoSetFromOptions_BLMVM; in TaoCreate_BLMVM()
228 tao->ops->destroy = TaoDestroy_BLMVM; in TaoCreate_BLMVM()
229 tao->ops->computedual = TaoComputeDual_BLMVM; in TaoCreate_BLMVM()
234 tao->data = (void *)blmP; in TaoCreate_BLMVM()
237 PetscCall(TaoParametersInitialize(tao)); in TaoCreate_BLMVM()
238 PetscObjectParameterSetDefault(tao, max_it, 2000); in TaoCreate_BLMVM()
239 PetscObjectParameterSetDefault(tao, max_funcs, 4000); in TaoCreate_BLMVM()
241 PetscCall(TaoLineSearchCreate(((PetscObject)tao)->comm, &tao->linesearch)); in TaoCreate_BLMVM()
242 PetscCall(PetscObjectIncrementTabLevel((PetscObject)tao->linesearch, (PetscObject)tao, 1)); in TaoCreate_BLMVM()
243 PetscCall(TaoLineSearchSetType(tao->linesearch, morethuente_type)); in TaoCreate_BLMVM()
244 PetscCall(TaoLineSearchUseTaoRoutines(tao->linesearch, tao)); in TaoCreate_BLMVM()
247 PetscCall(MatCreate(((PetscObject)tao)->comm, &blmP->M)); in TaoCreate_BLMVM()
249 PetscCall(PetscObjectIncrementTabLevel((PetscObject)blmP->M, (PetscObject)tao, 1)); in TaoCreate_BLMVM()
264 PetscErrorCode TaoLMVMRecycle(Tao tao, PetscBool flg) in TaoLMVMRecycle() argument
271 PetscCall(PetscObjectTypeCompare((PetscObject)tao, TAOLMVM, &is_lmvm)); in TaoLMVMRecycle()
272 PetscCall(PetscObjectTypeCompare((PetscObject)tao, TAOBLMVM, &is_blmvm)); in TaoLMVMRecycle()
274 lmP = (TAO_LMVM *)tao->data; in TaoLMVMRecycle()
277 blmP = (TAO_BLMVM *)tao->data; in TaoLMVMRecycle()
294 PetscErrorCode TaoLMVMSetH0(Tao tao, Mat H0) in TaoLMVMSetH0() argument
301 PetscCall(PetscObjectTypeCompare((PetscObject)tao, TAOLMVM, &is_lmvm)); in TaoLMVMSetH0()
302 PetscCall(PetscObjectTypeCompare((PetscObject)tao, TAOBLMVM, &is_blmvm)); in TaoLMVMSetH0()
304 lmP = (TAO_LMVM *)tao->data; in TaoLMVMSetH0()
308 blmP = (TAO_BLMVM *)tao->data; in TaoLMVMSetH0()
328 PetscErrorCode TaoLMVMGetH0(Tao tao, Mat *H0) in TaoLMVMGetH0() argument
336 PetscCall(PetscObjectTypeCompare((PetscObject)tao, TAOLMVM, &is_lmvm)); in TaoLMVMGetH0()
337 PetscCall(PetscObjectTypeCompare((PetscObject)tao, TAOBLMVM, &is_blmvm)); in TaoLMVMGetH0()
339 lmP = (TAO_LMVM *)tao->data; in TaoLMVMGetH0()
342 blmP = (TAO_BLMVM *)tao->data; in TaoLMVMGetH0()
344 …} else SETERRQ(PetscObjectComm((PetscObject)tao), PETSC_ERR_ARG_WRONG, "This routine applies to TA… in TaoLMVMGetH0()
362 PetscErrorCode TaoLMVMGetH0KSP(Tao tao, KSP *ksp) in TaoLMVMGetH0KSP() argument
370 PetscCall(PetscObjectTypeCompare((PetscObject)tao, TAOLMVM, &is_lmvm)); in TaoLMVMGetH0KSP()
371 PetscCall(PetscObjectTypeCompare((PetscObject)tao, TAOBLMVM, &is_blmvm)); in TaoLMVMGetH0KSP()
373 lmP = (TAO_LMVM *)tao->data; in TaoLMVMGetH0KSP()
376 blmP = (TAO_BLMVM *)tao->data; in TaoLMVMGetH0KSP()
378 …} else SETERRQ(PetscObjectComm((PetscObject)tao), PETSC_ERR_ARG_WRONG, "This routine applies to TA… in TaoLMVMGetH0KSP()