Lines Matching refs:tao

16 PetscErrorCode TaoSetSolution(Tao tao, Vec x0)  in TaoSetSolution()  argument
19 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoSetSolution()
22 PetscCall(VecDestroy(&tao->solution)); in TaoSetSolution()
23 tao->solution = x0; in TaoSetSolution()
27 PetscErrorCode TaoTestGradient(Tao tao, Vec x, Vec g1) in TaoTestGradient() argument
40 PetscObjectOptionsBegin((PetscObject)tao); in TaoTestGradient()
49 PetscCall(PetscObjectGetComm((PetscObject)tao, &comm)); in TaoTestGradient()
52 PetscCall(PetscViewerASCIISetTab(viewer, ((PetscObject)tao)->tablevel)); in TaoTestGradient()
69 PetscCall(TaoDefaultComputeGradient(tao, x, g2, NULL)); in TaoTestGradient()
127 PetscErrorCode TaoComputeGradient(Tao tao, Vec X, Vec G) in TaoComputeGradient() argument
132 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoComputeGradient()
135 PetscCheckSameComm(tao, 1, X, 2); in TaoComputeGradient()
136 PetscCheckSameComm(tao, 1, G, 3); in TaoComputeGradient()
138 if (tao->ops->computegradient) { in TaoComputeGradient()
139 PetscCall(PetscLogEventBegin(TAO_GradientEval, tao, X, G, NULL)); in TaoComputeGradient()
140 … PetscCallBack("Tao callback gradient", (*tao->ops->computegradient)(tao, X, G, tao->user_gradP)); in TaoComputeGradient()
141 PetscCall(PetscLogEventEnd(TAO_GradientEval, tao, X, G, NULL)); in TaoComputeGradient()
142 tao->ngrads++; in TaoComputeGradient()
143 } else if (tao->ops->computeobjectiveandgradient) { in TaoComputeGradient()
144 PetscCall(PetscLogEventBegin(TAO_ObjGradEval, tao, X, G, NULL)); in TaoComputeGradient()
145 …CallBack("Tao callback objective/gradient", (*tao->ops->computeobjectiveandgradient)(tao, X, &dumm… in TaoComputeGradient()
146 PetscCall(PetscLogEventEnd(TAO_ObjGradEval, tao, X, G, NULL)); in TaoComputeGradient()
147 tao->nfuncgrads++; in TaoComputeGradient()
148 …} else SETERRQ(PetscObjectComm((PetscObject)tao), PETSC_ERR_ARG_WRONGSTATE, "TaoSetGradient() has … in TaoComputeGradient()
151 PetscCall(TaoTestGradient(tao, X, G)); in TaoComputeGradient()
175 PetscErrorCode TaoComputeObjective(Tao tao, Vec X, PetscReal *f) in TaoComputeObjective() argument
180 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoComputeObjective()
182 PetscCheckSameComm(tao, 1, X, 2); in TaoComputeObjective()
184 if (tao->ops->computeobjective) { in TaoComputeObjective()
185 PetscCall(PetscLogEventBegin(TAO_ObjectiveEval, tao, X, NULL, NULL)); in TaoComputeObjective()
186 … PetscCallBack("Tao callback objective", (*tao->ops->computeobjective)(tao, X, f, tao->user_objP)); in TaoComputeObjective()
187 PetscCall(PetscLogEventEnd(TAO_ObjectiveEval, tao, X, NULL, NULL)); in TaoComputeObjective()
188 tao->nfuncs++; in TaoComputeObjective()
189 } else if (tao->ops->computeobjectiveandgradient) { in TaoComputeObjective()
190 PetscCall(PetscInfo(tao, "Duplicating variable vector in order to call func/grad routine\n")); in TaoComputeObjective()
192 PetscCall(PetscLogEventBegin(TAO_ObjGradEval, tao, X, NULL, NULL)); in TaoComputeObjective()
193 …cCallBack("Tao callback objective/gradient", (*tao->ops->computeobjectiveandgradient)(tao, X, f, t… in TaoComputeObjective()
194 PetscCall(PetscLogEventEnd(TAO_ObjGradEval, tao, X, NULL, NULL)); in TaoComputeObjective()
196 tao->nfuncgrads++; in TaoComputeObjective()
197 …} else SETERRQ(PetscObjectComm((PetscObject)tao), PETSC_ERR_ARG_WRONGSTATE, "TaoSetObjective() has… in TaoComputeObjective()
198 PetscCall(PetscInfo(tao, "TAO Function evaluation: %20.19e\n", (double)(*f))); in TaoComputeObjective()
224 PetscErrorCode TaoComputeObjectiveAndGradient(Tao tao, Vec X, PetscReal *f, Vec G) in TaoComputeObjectiveAndGradient() argument
227 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoComputeObjectiveAndGradient()
230 PetscCheckSameComm(tao, 1, X, 2); in TaoComputeObjectiveAndGradient()
231 PetscCheckSameComm(tao, 1, G, 4); in TaoComputeObjectiveAndGradient()
233 if (tao->ops->computeobjectiveandgradient) { in TaoComputeObjectiveAndGradient()
234 PetscCall(PetscLogEventBegin(TAO_ObjGradEval, tao, X, G, NULL)); in TaoComputeObjectiveAndGradient()
235 if (tao->ops->computegradient == TaoDefaultComputeGradient) { in TaoComputeObjectiveAndGradient()
236 PetscCall(TaoComputeObjective(tao, X, f)); in TaoComputeObjectiveAndGradient()
237 PetscCall(TaoDefaultComputeGradient(tao, X, G, NULL)); in TaoComputeObjectiveAndGradient()
238 …scCallBack("Tao callback objective/gradient", (*tao->ops->computeobjectiveandgradient)(tao, X, f, … in TaoComputeObjectiveAndGradient()
239 PetscCall(PetscLogEventEnd(TAO_ObjGradEval, tao, X, G, NULL)); in TaoComputeObjectiveAndGradient()
240 tao->nfuncgrads++; in TaoComputeObjectiveAndGradient()
241 } else if (tao->ops->computeobjective && tao->ops->computegradient) { in TaoComputeObjectiveAndGradient()
242 PetscCall(PetscLogEventBegin(TAO_ObjectiveEval, tao, X, NULL, NULL)); in TaoComputeObjectiveAndGradient()
243 … PetscCallBack("Tao callback objective", (*tao->ops->computeobjective)(tao, X, f, tao->user_objP)); in TaoComputeObjectiveAndGradient()
244 PetscCall(PetscLogEventEnd(TAO_ObjectiveEval, tao, X, NULL, NULL)); in TaoComputeObjectiveAndGradient()
245 tao->nfuncs++; in TaoComputeObjectiveAndGradient()
246 PetscCall(PetscLogEventBegin(TAO_GradientEval, tao, X, G, NULL)); in TaoComputeObjectiveAndGradient()
247 … PetscCallBack("Tao callback gradient", (*tao->ops->computegradient)(tao, X, G, tao->user_gradP)); in TaoComputeObjectiveAndGradient()
248 PetscCall(PetscLogEventEnd(TAO_GradientEval, tao, X, G, NULL)); in TaoComputeObjectiveAndGradient()
249 tao->ngrads++; in TaoComputeObjectiveAndGradient()
250 …} else SETERRQ(PetscObjectComm((PetscObject)tao), PETSC_ERR_ARG_WRONGSTATE, "TaoSetObjective() or … in TaoComputeObjectiveAndGradient()
251 PetscCall(PetscInfo(tao, "TAO Function evaluation: %20.19e\n", (double)(*f))); in TaoComputeObjectiveAndGradient()
254 PetscCall(TaoTestGradient(tao, X, G)); in TaoComputeObjectiveAndGradient()
279 PetscErrorCode TaoSetObjective(Tao tao, PetscErrorCode (*func)(Tao tao, Vec x, PetscReal *f, PetscC… in TaoSetObjective() argument
282 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoSetObjective()
283 if (ctx) tao->user_objP = ctx; in TaoSetObjective()
284 if (func) tao->ops->computeobjective = func; in TaoSetObjective()
310 PetscErrorCode TaoGetObjective(Tao tao, PetscErrorCode (**func)(Tao tao, Vec x, PetscReal *f, Petsc… in TaoGetObjective() argument
313 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoGetObjective()
314 if (func) *func = tao->ops->computeobjective; in TaoGetObjective()
315 if (ctx) *(void **)ctx = tao->user_objP; in TaoGetObjective()
341 PetscErrorCode TaoSetResidualRoutine(Tao tao, Vec res, PetscErrorCode (*func)(Tao tao, Vec x, Vec r… in TaoSetResidualRoutine() argument
344 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoSetResidualRoutine()
347 if (tao->ls_res) PetscCall(VecDestroy(&tao->ls_res)); in TaoSetResidualRoutine()
348 tao->ls_res = res; in TaoSetResidualRoutine()
349 tao->user_lsresP = ctx; in TaoSetResidualRoutine()
350 tao->ops->computeresidual = func; in TaoSetResidualRoutine()
377 PetscErrorCode TaoSetResidualWeights(Tao tao, Vec sigma_v, PetscInt n, PetscInt *rows, PetscInt *co… in TaoSetResidualWeights() argument
382 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoSetResidualWeights()
385 PetscCall(VecDestroy(&tao->res_weights_v)); in TaoSetResidualWeights()
386 tao->res_weights_v = sigma_v; in TaoSetResidualWeights()
388 PetscCall(PetscFree(tao->res_weights_rows)); in TaoSetResidualWeights()
389 PetscCall(PetscFree(tao->res_weights_cols)); in TaoSetResidualWeights()
390 PetscCall(PetscFree(tao->res_weights_w)); in TaoSetResidualWeights()
391 PetscCall(PetscMalloc1(n, &tao->res_weights_rows)); in TaoSetResidualWeights()
392 PetscCall(PetscMalloc1(n, &tao->res_weights_cols)); in TaoSetResidualWeights()
393 PetscCall(PetscMalloc1(n, &tao->res_weights_w)); in TaoSetResidualWeights()
394 tao->res_weights_n = n; in TaoSetResidualWeights()
396 tao->res_weights_rows[i] = rows[i]; in TaoSetResidualWeights()
397 tao->res_weights_cols[i] = cols[i]; in TaoSetResidualWeights()
398 tao->res_weights_w[i] = vals[i]; in TaoSetResidualWeights()
401 tao->res_weights_n = 0; in TaoSetResidualWeights()
402 tao->res_weights_rows = NULL; in TaoSetResidualWeights()
403 tao->res_weights_cols = NULL; in TaoSetResidualWeights()
428 PetscErrorCode TaoComputeResidual(Tao tao, Vec X, Vec F) in TaoComputeResidual() argument
431 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoComputeResidual()
434 PetscCheckSameComm(tao, 1, X, 2); in TaoComputeResidual()
435 PetscCheckSameComm(tao, 1, F, 3); in TaoComputeResidual()
436 …PetscCheck(tao->ops->computeresidual, PetscObjectComm((PetscObject)tao), PETSC_ERR_ARG_WRONGSTATE,… in TaoComputeResidual()
437 PetscCall(PetscLogEventBegin(TAO_ObjectiveEval, tao, X, NULL, NULL)); in TaoComputeResidual()
438 …PetscCallBack("Tao callback least-squares residual", (*tao->ops->computeresidual)(tao, X, F, tao->… in TaoComputeResidual()
439 PetscCall(PetscLogEventEnd(TAO_ObjectiveEval, tao, X, NULL, NULL)); in TaoComputeResidual()
440 tao->nfuncs++; in TaoComputeResidual()
441 PetscCall(PetscInfo(tao, "TAO least-squares residual evaluation.\n")); in TaoComputeResidual()
467 PetscErrorCode TaoSetGradient(Tao tao, Vec g, PetscErrorCode (*func)(Tao tao, Vec x, Vec g, PetscCt… in TaoSetGradient() argument
470 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoSetGradient()
473 PetscCheckSameComm(tao, 1, g, 2); in TaoSetGradient()
475 PetscCall(VecDestroy(&tao->gradient)); in TaoSetGradient()
476 tao->gradient = g; in TaoSetGradient()
478 if (func) tao->ops->computegradient = func; in TaoSetGradient()
479 if (ctx) tao->user_gradP = ctx; in TaoSetGradient()
506 PetscErrorCode TaoGetGradient(Tao tao, Vec *g, PetscErrorCode (**func)(Tao tao, Vec x, Vec g, Petsc… in TaoGetGradient() argument
509 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoGetGradient()
510 if (g) *g = tao->gradient; in TaoGetGradient()
511 if (func) *func = tao->ops->computegradient; in TaoGetGradient()
512 if (ctx) *(void **)ctx = tao->user_gradP; in TaoGetGradient()
542 PetscErrorCode TaoSetObjectiveAndGradient(Tao tao, Vec g, PetscErrorCode (*func)(Tao tao, Vec x, Pe… in TaoSetObjectiveAndGradient() argument
545 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoSetObjectiveAndGradient()
548 PetscCheckSameComm(tao, 1, g, 2); in TaoSetObjectiveAndGradient()
550 PetscCall(VecDestroy(&tao->gradient)); in TaoSetObjectiveAndGradient()
551 tao->gradient = g; in TaoSetObjectiveAndGradient()
553 if (ctx) tao->user_objgradP = ctx; in TaoSetObjectiveAndGradient()
554 if (func) tao->ops->computeobjectiveandgradient = func; in TaoSetObjectiveAndGradient()
582 PetscErrorCode TaoGetObjectiveAndGradient(Tao tao, Vec *g, PetscErrorCode (**func)(Tao tao, Vec x, … in TaoGetObjectiveAndGradient() argument
585 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoGetObjectiveAndGradient()
586 if (g) *g = tao->gradient; in TaoGetObjectiveAndGradient()
587 if (func) *func = tao->ops->computeobjectiveandgradient; in TaoGetObjectiveAndGradient()
588 if (ctx) *(void **)ctx = tao->user_objgradP; in TaoGetObjectiveAndGradient()
610 PetscErrorCode TaoIsObjectiveDefined(Tao tao, PetscBool *flg) in TaoIsObjectiveDefined() argument
613 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoIsObjectiveDefined()
614 if (tao->ops->computeobjective == NULL) *flg = PETSC_FALSE; in TaoIsObjectiveDefined()
637 PetscErrorCode TaoIsGradientDefined(Tao tao, PetscBool *flg) in TaoIsGradientDefined() argument
640 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoIsGradientDefined()
641 if (tao->ops->computegradient == NULL) *flg = PETSC_FALSE; in TaoIsGradientDefined()
664 PetscErrorCode TaoIsObjectiveAndGradientDefined(Tao tao, PetscBool *flg) in TaoIsObjectiveAndGradientDefined() argument
667 PetscValidHeaderSpecific(tao, TAO_CLASSID, 1); in TaoIsObjectiveAndGradientDefined()
668 if (tao->ops->computeobjectiveandgradient == NULL) *flg = PETSC_FALSE; in TaoIsObjectiveAndGradientDefined()