Lines Matching refs:tao

41 static PetscErrorCode TaoSetUp_ASILS(Tao tao)  in TaoSetUp_ASILS()  argument
43 TAO_SSLS *asls = (TAO_SSLS *)tao->data; in TaoSetUp_ASILS()
46 PetscCall(VecDuplicate(tao->solution, &tao->gradient)); in TaoSetUp_ASILS()
47 PetscCall(VecDuplicate(tao->solution, &tao->stepdirection)); in TaoSetUp_ASILS()
48 PetscCall(VecDuplicate(tao->solution, &asls->ff)); in TaoSetUp_ASILS()
49 PetscCall(VecDuplicate(tao->solution, &asls->dpsi)); in TaoSetUp_ASILS()
50 PetscCall(VecDuplicate(tao->solution, &asls->da)); in TaoSetUp_ASILS()
51 PetscCall(VecDuplicate(tao->solution, &asls->db)); in TaoSetUp_ASILS()
52 PetscCall(VecDuplicate(tao->solution, &asls->t1)); in TaoSetUp_ASILS()
53 PetscCall(VecDuplicate(tao->solution, &asls->t2)); in TaoSetUp_ASILS()
68 Tao tao = (Tao)ptr; in Tao_ASLS_FunctionGradient() local
69 TAO_SSLS *asls = (TAO_SSLS *)tao->data; in Tao_ASLS_FunctionGradient()
72 PetscCall(TaoComputeConstraints(tao, X, tao->constraints)); in Tao_ASLS_FunctionGradient()
73 PetscCall(VecFischer(X, tao->constraints, tao->XL, tao->XU, asls->ff)); in Tao_ASLS_FunctionGradient()
77 PetscCall(TaoComputeJacobian(tao, tao->solution, tao->jacobian, tao->jacobian_pre)); in Tao_ASLS_FunctionGradient()
78 …PetscCall(MatDFischer(tao->jacobian, tao->solution, tao->constraints, tao->XL, tao->XU, asls->t1, … in Tao_ASLS_FunctionGradient()
80 PetscCall(MatMultTranspose(tao->jacobian, asls->t1, G)); in Tao_ASLS_FunctionGradient()
86 static PetscErrorCode TaoDestroy_ASILS(Tao tao) in TaoDestroy_ASILS() argument
88 TAO_SSLS *ssls = (TAO_SSLS *)tao->data; in TaoDestroy_ASILS()
106 PetscCall(KSPDestroy(&tao->ksp)); in TaoDestroy_ASILS()
107 PetscCall(PetscFree(tao->data)); in TaoDestroy_ASILS()
111 static PetscErrorCode TaoSolve_ASILS(Tao tao) in TaoSolve_ASILS() argument
113 TAO_SSLS *asls = (TAO_SSLS *)tao->data; in TaoSolve_ASILS()
122 PetscCall(TaoComputeVariableBounds(tao)); in TaoSolve_ASILS()
123 …etscCall(TaoLineSearchSetObjectiveAndGradientRoutine(tao->linesearch, Tao_ASLS_FunctionGradient, t… in TaoSolve_ASILS()
124 PetscCall(TaoLineSearchSetObjectiveRoutine(tao->linesearch, Tao_SSLS_Function, tao)); in TaoSolve_ASILS()
128 …PetscCall(TaoLineSearchComputeObjectiveAndGradient(tao->linesearch, tao->solution, &psi, asls->dps… in TaoSolve_ASILS()
131 tao->reason = TAO_CONTINUE_ITERATING; in TaoSolve_ASILS()
134 …PetscCall(PetscInfo(tao, "iter %" PetscInt_FMT ", merit: %g, ||dpsi||: %g\n", tao->niter, (double)… in TaoSolve_ASILS()
135 PetscCall(TaoLogConvergenceHistory(tao, asls->merit, ndpsi, 0.0, tao->ksp_its)); in TaoSolve_ASILS()
136 PetscCall(TaoMonitor(tao, tao->niter, asls->merit, ndpsi, 0.0, t)); in TaoSolve_ASILS()
137 PetscUseTypeMethod(tao, convergencetest, tao->cnvP); in TaoSolve_ASILS()
138 if (TAO_CONTINUE_ITERATING != tao->reason) break; in TaoSolve_ASILS()
141 PetscTryTypeMethod(tao, update, tao->niter, tao->user_update); in TaoSolve_ASILS()
142 tao->niter++; in TaoSolve_ASILS()
166 PetscCall(MatNorm(tao->jacobian, NORM_1, &asls->identifier)); in TaoSolve_ASILS()
178 PetscCall(PetscInfo(tao, "Number of fixed variables: %" PetscInt_FMT "\n", nf)); in TaoSolve_ASILS()
182 PetscCall(TaoVecGetSubVec(asls->ff, asls->fixed, tao->subset_type, 0.0, &asls->r1)); in TaoSolve_ASILS()
183 PetscCall(TaoVecGetSubVec(asls->da, asls->fixed, tao->subset_type, 1.0, &asls->r2)); in TaoSolve_ASILS()
185 PetscCall(VecSet(tao->stepdirection, 0.0)); in TaoSolve_ASILS()
186 PetscCall(VecISAXPY(tao->stepdirection, asls->fixed, 1.0, asls->r1)); in TaoSolve_ASILS()
193 PetscCall(TaoVecGetSubVec(asls->da, asls->free, tao->subset_type, 0.0, &asls->r1)); in TaoSolve_ASILS()
194 PetscCall(TaoVecGetSubVec(asls->ff, asls->free, tao->subset_type, 0.0, &asls->r2)); in TaoSolve_ASILS()
195 PetscCall(TaoVecGetSubVec(asls->db, asls->free, tao->subset_type, 1.0, &asls->r3)); in TaoSolve_ASILS()
207 PetscCall(MatMult(tao->jacobian, tao->stepdirection, asls->t1)); in TaoSolve_ASILS()
208 PetscCall(TaoVecGetSubVec(asls->t1, asls->free, tao->subset_type, 0.0, &asls->r3)); in TaoSolve_ASILS()
212 …if (!asls->w && (tao->subset_type == TAO_SUBSET_MASK || tao->subset_type == TAO_SUBSET_MATRIXFREE)… in TaoSolve_ASILS()
213 PetscCall(TaoMatGetSubMat(tao->jacobian, asls->free, asls->w, tao->subset_type, &asls->J_sub)); in TaoSolve_ASILS()
214 if (tao->jacobian != tao->jacobian_pre) { in TaoSolve_ASILS()
215 …PetscCall(TaoMatGetSubMat(tao->jacobian_pre, asls->free, asls->w, tao->subset_type, &asls->Jpre_su… in TaoSolve_ASILS()
222 … PetscCall(TaoVecGetSubVec(tao->stepdirection, asls->free, tao->subset_type, 0.0, &asls->dxfree)); in TaoSolve_ASILS()
227 PetscCall(KSPReset(tao->ksp)); in TaoSolve_ASILS()
228 PetscCall(KSPSetOperators(tao->ksp, asls->J_sub, asls->Jpre_sub)); in TaoSolve_ASILS()
229 PetscCall(KSPSolve(tao->ksp, asls->r2, asls->dxfree)); in TaoSolve_ASILS()
230 PetscCall(KSPGetIterationNumber(tao->ksp, &tao->ksp_its)); in TaoSolve_ASILS()
231 tao->ksp_tot_its += tao->ksp_its; in TaoSolve_ASILS()
234 PetscCall(VecISAXPY(tao->stepdirection, asls->free, 1.0, asls->dxfree)); in TaoSolve_ASILS()
238 PetscCall(VecNorm(tao->stepdirection, NORM_2, &normd)); in TaoSolve_ASILS()
239 PetscCall(VecDot(tao->stepdirection, asls->dpsi, &innerd)); in TaoSolve_ASILS()
242 PetscCall(PetscInfo(tao, "Gradient direction: %5.4e.\n", (double)innerd)); in TaoSolve_ASILS()
243 …PetscCall(PetscInfo(tao, "Iteration %" PetscInt_FMT ": newton direction not descent\n", tao->niter… in TaoSolve_ASILS()
244 PetscCall(VecCopy(asls->dpsi, tao->stepdirection)); in TaoSolve_ASILS()
245 PetscCall(VecDot(asls->dpsi, tao->stepdirection, &innerd)); in TaoSolve_ASILS()
248 PetscCall(VecScale(tao->stepdirection, -1.0)); in TaoSolve_ASILS()
253 PetscCall(TaoLineSearchSetInitialStepLength(tao->linesearch, 1.0)); in TaoSolve_ASILS()
254 …PetscCall(TaoLineSearchApply(tao->linesearch, tao->solution, &psi, asls->dpsi, tao->stepdirection,… in TaoSolve_ASILS()
275 PETSC_EXTERN PetscErrorCode TaoCreate_ASILS(Tao tao) in TaoCreate_ASILS() argument
282 tao->data = (void *)asls; in TaoCreate_ASILS()
283 tao->ops->solve = TaoSolve_ASILS; in TaoCreate_ASILS()
284 tao->ops->setup = TaoSetUp_ASILS; in TaoCreate_ASILS()
285 tao->ops->view = TaoView_SSLS; in TaoCreate_ASILS()
286 tao->ops->setfromoptions = TaoSetFromOptions_SSLS; in TaoCreate_ASILS()
287 tao->ops->destroy = TaoDestroy_ASILS; in TaoCreate_ASILS()
288 tao->subset_type = TAO_SUBSET_SUBVEC; in TaoCreate_ASILS()
305 PetscCall(TaoParametersInitialize(tao)); in TaoCreate_ASILS()
307 PetscCall(TaoLineSearchCreate(((PetscObject)tao)->comm, &tao->linesearch)); in TaoCreate_ASILS()
308 PetscCall(PetscObjectIncrementTabLevel((PetscObject)tao->linesearch, (PetscObject)tao, 1)); in TaoCreate_ASILS()
309 PetscCall(TaoLineSearchSetType(tao->linesearch, armijo_type)); in TaoCreate_ASILS()
310 PetscCall(TaoLineSearchSetOptionsPrefix(tao->linesearch, tao->hdr.prefix)); in TaoCreate_ASILS()
311 PetscCall(TaoLineSearchSetFromOptions(tao->linesearch)); in TaoCreate_ASILS()
313 PetscCall(KSPCreate(((PetscObject)tao)->comm, &tao->ksp)); in TaoCreate_ASILS()
314 PetscCall(PetscObjectIncrementTabLevel((PetscObject)tao->ksp, (PetscObject)tao, 1)); in TaoCreate_ASILS()
315 PetscCall(KSPSetOptionsPrefix(tao->ksp, tao->hdr.prefix)); in TaoCreate_ASILS()
316 PetscCall(KSPSetFromOptions(tao->ksp)); in TaoCreate_ASILS()
319 PetscObjectParameterSetDefault(tao, max_it, 2000); in TaoCreate_ASILS()
320 PetscObjectParameterSetDefault(tao, max_funcs, 4000); in TaoCreate_ASILS()
321 PetscObjectParameterSetDefault(tao, gttol, 0); in TaoCreate_ASILS()
322 PetscObjectParameterSetDefault(tao, grtol, 0); in TaoCreate_ASILS()
323 PetscObjectParameterSetDefault(tao, gatol, PetscDefined(USE_REAL_SINGLE) ? 1.0e-6 : 1.0e-16); in TaoCreate_ASILS()
324 PetscObjectParameterSetDefault(tao, fmin, PetscDefined(USE_REAL_SINGLE) ? 1.0e-4 : 1.0e-8); in TaoCreate_ASILS()