Lines Matching refs:ls

63 PetscErrorCode TaoLineSearchView(TaoLineSearch ls, PetscViewer viewer)  in TaoLineSearchView()  argument
69 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchView()
70 if (!viewer) PetscCall(PetscViewerASCIIGetStdout(((PetscObject)ls)->comm, &viewer)); in TaoLineSearchView()
72 PetscCheckSameComm(ls, 1, viewer, 2); in TaoLineSearchView()
77 PetscCall(PetscObjectPrintClassNamePrefixType((PetscObject)ls, viewer)); in TaoLineSearchView()
79 PetscTryTypeMethod(ls, view, viewer); in TaoLineSearchView()
82 …PetscCall(PetscViewerASCIIPrintf(viewer, "maximum function evaluations=%" PetscInt_FMT "\n", ls->m… in TaoLineSearchView()
83 …ewer, "tolerances: ftol=%g, rtol=%g, gtol=%g\n", (double)ls->ftol, (double)ls->rtol, (double)ls->g… in TaoLineSearchView()
84 …ViewerASCIIPrintf(viewer, "total number of function evaluations=%" PetscInt_FMT "\n", ls->nfeval)); in TaoLineSearchView()
85 …ViewerASCIIPrintf(viewer, "total number of gradient evaluations=%" PetscInt_FMT "\n", ls->ngeval)); in TaoLineSearchView()
86 …IPrintf(viewer, "total number of function/gradient evaluations=%" PetscInt_FMT "\n", ls->nfgeval)); in TaoLineSearchView()
88 if (ls->bounded) PetscCall(PetscViewerASCIIPrintf(viewer, "using variable bounds\n")); in TaoLineSearchView()
89 …cViewerASCIIPrintf(viewer, "Termination reason: %s\n", TaoLineSearchConvergedReasons[ls->reason])); in TaoLineSearchView()
92 PetscCall(TaoLineSearchGetType(ls, &type)); in TaoLineSearchView()
119 TaoLineSearch ls; in TaoLineSearchCreate() local
125 …PetscCall(PetscHeaderCreate(ls, TAOLINESEARCH_CLASSID, "TaoLineSearch", "Linesearch", "Tao", comm,… in TaoLineSearchCreate()
126 ls->max_funcs = 30; in TaoLineSearchCreate()
127 ls->ftol = 0.0001; in TaoLineSearchCreate()
128 ls->gtol = 0.9; in TaoLineSearchCreate()
130 ls->rtol = 1.0e-5; in TaoLineSearchCreate()
132 ls->rtol = 1.0e-10; in TaoLineSearchCreate()
134 ls->stepmin = 1.0e-20; in TaoLineSearchCreate()
135 ls->stepmax = 1.0e+20; in TaoLineSearchCreate()
136 ls->step = 1.0; in TaoLineSearchCreate()
137 ls->initstep = 1.0; in TaoLineSearchCreate()
138 *newls = ls; in TaoLineSearchCreate()
161 PetscErrorCode TaoLineSearchSetUp(TaoLineSearch ls) in TaoLineSearchSetUp() argument
167 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchSetUp()
168 if (ls->setupcalled) PetscFunctionReturn(PETSC_SUCCESS); in TaoLineSearchSetUp()
169 if (!((PetscObject)ls)->type_name) PetscCall(TaoLineSearchSetType(ls, default_type)); in TaoLineSearchSetUp()
170 PetscTryTypeMethod(ls, setup); in TaoLineSearchSetUp()
171 if (ls->usetaoroutines) { in TaoLineSearchSetUp()
172 PetscCall(TaoIsObjectiveDefined(ls->tao, &flg)); in TaoLineSearchSetUp()
173 ls->hasobjective = flg; in TaoLineSearchSetUp()
174 PetscCall(TaoIsGradientDefined(ls->tao, &flg)); in TaoLineSearchSetUp()
175 ls->hasgradient = flg; in TaoLineSearchSetUp()
176 PetscCall(TaoIsObjectiveAndGradientDefined(ls->tao, &flg)); in TaoLineSearchSetUp()
177 ls->hasobjectiveandgradient = flg; in TaoLineSearchSetUp()
179 if (ls->ops->computeobjective) { in TaoLineSearchSetUp()
180 ls->hasobjective = PETSC_TRUE; in TaoLineSearchSetUp()
182 ls->hasobjective = PETSC_FALSE; in TaoLineSearchSetUp()
184 if (ls->ops->computegradient) { in TaoLineSearchSetUp()
185 ls->hasgradient = PETSC_TRUE; in TaoLineSearchSetUp()
187 ls->hasgradient = PETSC_FALSE; in TaoLineSearchSetUp()
189 if (ls->ops->computeobjectiveandgradient) { in TaoLineSearchSetUp()
190 ls->hasobjectiveandgradient = PETSC_TRUE; in TaoLineSearchSetUp()
192 ls->hasobjectiveandgradient = PETSC_FALSE; in TaoLineSearchSetUp()
195 ls->setupcalled = PETSC_TRUE; in TaoLineSearchSetUp()
213 PetscErrorCode TaoLineSearchReset(TaoLineSearch ls) in TaoLineSearchReset() argument
216 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchReset()
217 PetscTryTypeMethod(ls, reset); in TaoLineSearchReset()
234 PetscErrorCode TaoLineSearchDestroy(TaoLineSearch *ls) in TaoLineSearchDestroy() argument
237 if (!*ls) PetscFunctionReturn(PETSC_SUCCESS); in TaoLineSearchDestroy()
238 PetscValidHeaderSpecific(*ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchDestroy()
239 if (--((PetscObject)*ls)->refct > 0) { in TaoLineSearchDestroy()
240 *ls = NULL; in TaoLineSearchDestroy()
243 PetscCall(VecDestroy(&(*ls)->stepdirection)); in TaoLineSearchDestroy()
244 PetscCall(VecDestroy(&(*ls)->start_x)); in TaoLineSearchDestroy()
245 PetscCall(VecDestroy(&(*ls)->upper)); in TaoLineSearchDestroy()
246 PetscCall(VecDestroy(&(*ls)->lower)); in TaoLineSearchDestroy()
247 PetscTryTypeMethod(*ls, destroy); in TaoLineSearchDestroy()
248 if ((*ls)->usemonitor) PetscCall(PetscViewerDestroy(&(*ls)->viewer)); in TaoLineSearchDestroy()
249 PetscCall(PetscHeaderDestroy(ls)); in TaoLineSearchDestroy()
285 PetscErrorCode TaoLineSearchApply(TaoLineSearch ls, Vec x, PetscReal *f, Vec g, Vec s, PetscReal *s… in TaoLineSearchApply() argument
290 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchApply()
296 PetscCheckSameComm(ls, 1, x, 2); in TaoLineSearchApply()
306 PetscCall(VecDestroy(&ls->stepdirection)); in TaoLineSearchApply()
307 ls->stepdirection = s; in TaoLineSearchApply()
309 PetscCall(TaoLineSearchSetUp(ls)); in TaoLineSearchApply()
310 ls->nfeval = 0; in TaoLineSearchApply()
311 ls->ngeval = 0; in TaoLineSearchApply()
312 ls->nfgeval = 0; in TaoLineSearchApply()
314 if (ls->ftol < 0.0) { in TaoLineSearchApply()
315 PetscCall(PetscInfo(ls, "Bad Line Search Parameter: ftol (%g) < 0\n", (double)ls->ftol)); in TaoLineSearchApply()
318 if (ls->rtol < 0.0) { in TaoLineSearchApply()
319 PetscCall(PetscInfo(ls, "Bad Line Search Parameter: rtol (%g) < 0\n", (double)ls->rtol)); in TaoLineSearchApply()
322 if (ls->gtol < 0.0) { in TaoLineSearchApply()
323 PetscCall(PetscInfo(ls, "Bad Line Search Parameter: gtol (%g) < 0\n", (double)ls->gtol)); in TaoLineSearchApply()
326 if (ls->stepmin < 0.0) { in TaoLineSearchApply()
327 PetscCall(PetscInfo(ls, "Bad Line Search Parameter: stepmin (%g) < 0\n", (double)ls->stepmin)); in TaoLineSearchApply()
330 if (ls->stepmax < ls->stepmin) { in TaoLineSearchApply()
331 …PetscCall(PetscInfo(ls, "Bad Line Search Parameter: stepmin (%g) > stepmax (%g)\n", (double)ls->st… in TaoLineSearchApply()
334 if (ls->max_funcs < 0) { in TaoLineSearchApply()
335 …PetscCall(PetscInfo(ls, "Bad Line Search Parameter: max_funcs (%" PetscInt_FMT ") < 0\n", ls->max_… in TaoLineSearchApply()
339 …PetscCall(PetscInfo(ls, "Initial Line Search Function Value is infinity or NaN (%g)\n", (double)*f… in TaoLineSearchApply()
344 PetscCall(VecDestroy(&ls->start_x)); in TaoLineSearchApply()
345 ls->start_x = x; in TaoLineSearchApply()
347 PetscCall(PetscLogEventBegin(TAOLINESEARCH_Apply, ls, 0, 0, 0)); in TaoLineSearchApply()
348 PetscUseTypeMethod(ls, apply, x, f, g, s); in TaoLineSearchApply()
349 PetscCall(PetscLogEventEnd(TAOLINESEARCH_Apply, ls, 0, 0, 0)); in TaoLineSearchApply()
350 *reason = ls->reason; in TaoLineSearchApply()
351 ls->new_f = *f; in TaoLineSearchApply()
353 if (steplength) *steplength = ls->step; in TaoLineSearchApply()
355 PetscCall(TaoLineSearchViewFromOptions(ls, NULL, "-tao_ls_view")); in TaoLineSearchApply()
376 PetscErrorCode TaoLineSearchSetType(TaoLineSearch ls, TaoLineSearchType type) in TaoLineSearchSetType() argument
382 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchSetType()
384 PetscCall(PetscObjectTypeCompare((PetscObject)ls, type, &flg)); in TaoLineSearchSetType()
388 …PetscCheck(r, PetscObjectComm((PetscObject)ls), PETSC_ERR_ARG_UNKNOWN_TYPE, "Unable to find reques… in TaoLineSearchSetType()
389 PetscTryTypeMethod(ls, destroy); in TaoLineSearchSetType()
390 ls->max_funcs = 30; in TaoLineSearchSetType()
391 ls->ftol = 0.0001; in TaoLineSearchSetType()
392 ls->gtol = 0.9; in TaoLineSearchSetType()
394 ls->rtol = 1.0e-5; in TaoLineSearchSetType()
396 ls->rtol = 1.0e-10; in TaoLineSearchSetType()
398 ls->stepmin = 1.0e-20; in TaoLineSearchSetType()
399 ls->stepmax = 1.0e+20; in TaoLineSearchSetType()
401 ls->nfeval = 0; in TaoLineSearchSetType()
402 ls->ngeval = 0; in TaoLineSearchSetType()
403 ls->nfgeval = 0; in TaoLineSearchSetType()
404 ls->ops->setup = NULL; in TaoLineSearchSetType()
405 ls->ops->apply = NULL; in TaoLineSearchSetType()
406 ls->ops->view = NULL; in TaoLineSearchSetType()
407 ls->ops->setfromoptions = NULL; in TaoLineSearchSetType()
408 ls->ops->destroy = NULL; in TaoLineSearchSetType()
409 ls->setupcalled = PETSC_FALSE; in TaoLineSearchSetType()
410 PetscCall((*r)(ls)); in TaoLineSearchSetType()
411 PetscCall(PetscObjectChangeTypeName((PetscObject)ls, type)); in TaoLineSearchSetType()
433 PetscErrorCode TaoLineSearchMonitor(TaoLineSearch ls, PetscInt its, PetscReal f, PetscReal step) in TaoLineSearchMonitor() argument
438 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchMonitor()
439 if (ls->usemonitor) { in TaoLineSearchMonitor()
440 PetscCall(PetscViewerASCIIGetTab(ls->viewer, &tabs)); in TaoLineSearchMonitor()
441 PetscCall(PetscViewerASCIISetTab(ls->viewer, ((PetscObject)ls)->tablevel)); in TaoLineSearchMonitor()
442 PetscCall(PetscViewerASCIIPrintf(ls->viewer, "%3" PetscInt_FMT " LS", its)); in TaoLineSearchMonitor()
443 PetscCall(PetscViewerASCIIPrintf(ls->viewer, " Function value: %g,", (double)f)); in TaoLineSearchMonitor()
444 PetscCall(PetscViewerASCIIPrintf(ls->viewer, " Step length: %g\n", (double)step)); in TaoLineSearchMonitor()
445 if (ls->ops->monitor && its > 0) { in TaoLineSearchMonitor()
446 PetscCall(PetscViewerASCIISetTab(ls->viewer, ((PetscObject)ls)->tablevel + 3)); in TaoLineSearchMonitor()
447 PetscUseTypeMethod(ls, monitor); in TaoLineSearchMonitor()
449 PetscCall(PetscViewerASCIISetTab(ls->viewer, tabs)); in TaoLineSearchMonitor()
478 PetscErrorCode TaoLineSearchSetFromOptions(TaoLineSearch ls) in TaoLineSearchSetFromOptions() argument
486 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchSetFromOptions()
487 PetscObjectOptionsBegin((PetscObject)ls); in TaoLineSearchSetFromOptions()
488 if (((PetscObject)ls)->type_name) default_type = ((PetscObject)ls)->type_name; in TaoLineSearchSetFromOptions()
492 PetscCall(TaoLineSearchSetType(ls, type)); in TaoLineSearchSetFromOptions()
493 } else if (!((PetscObject)ls)->type_name) { in TaoLineSearchSetFromOptions()
494 PetscCall(TaoLineSearchSetType(ls, default_type)); in TaoLineSearchSetFromOptions()
497 …sInt("-tao_ls_max_funcs", "max function evals in line search", "", ls->max_funcs, &ls->max_funcs, … in TaoLineSearchSetFromOptions()
498 …PetscCall(PetscOptionsReal("-tao_ls_ftol", "tol for sufficient decrease", "", ls->ftol, &ls->ftol,… in TaoLineSearchSetFromOptions()
499 …PetscCall(PetscOptionsReal("-tao_ls_gtol", "tol for curvature condition", "", ls->gtol, &ls->gtol,… in TaoLineSearchSetFromOptions()
500 …PetscCall(PetscOptionsReal("-tao_ls_rtol", "relative tol for acceptable step", "", ls->rtol, &ls->… in TaoLineSearchSetFromOptions()
501 …PetscCall(PetscOptionsReal("-tao_ls_stepmin", "lower bound for step", "", ls->stepmin, &ls->stepmi… in TaoLineSearchSetFromOptions()
502 …PetscCall(PetscOptionsReal("-tao_ls_stepmax", "upper bound for step", "", ls->stepmax, &ls->stepma… in TaoLineSearchSetFromOptions()
503 …PetscCall(PetscOptionsReal("-tao_ls_stepinit", "initial step", "", ls->initstep, &ls->initstep, NU… in TaoLineSearchSetFromOptions()
506 PetscCall(PetscViewerASCIIOpen(PetscObjectComm((PetscObject)ls), monfilename, &monviewer)); in TaoLineSearchSetFromOptions()
507 ls->viewer = monviewer; in TaoLineSearchSetFromOptions()
508 ls->usemonitor = PETSC_TRUE; in TaoLineSearchSetFromOptions()
510 PetscTryTypeMethod(ls, setfromoptions, PetscOptionsObject); in TaoLineSearchSetFromOptions()
530 PetscErrorCode TaoLineSearchGetType(TaoLineSearch ls, TaoLineSearchType *type) in TaoLineSearchGetType() argument
533 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchGetType()
535 *type = ((PetscObject)ls)->type_name; in TaoLineSearchGetType()
562 PetscErrorCode TaoLineSearchGetNumberFunctionEvaluations(TaoLineSearch ls, PetscInt *nfeval, PetscI… in TaoLineSearchGetNumberFunctionEvaluations() argument
565 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchGetNumberFunctionEvaluations()
566 *nfeval = ls->nfeval; in TaoLineSearchGetNumberFunctionEvaluations()
567 *ngeval = ls->ngeval; in TaoLineSearchGetNumberFunctionEvaluations()
568 *nfgeval = ls->nfgeval; in TaoLineSearchGetNumberFunctionEvaluations()
589 PetscErrorCode TaoLineSearchIsUsingTaoRoutines(TaoLineSearch ls, PetscBool *flg) in TaoLineSearchIsUsingTaoRoutines() argument
592 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchIsUsingTaoRoutines()
593 *flg = ls->usetaoroutines; in TaoLineSearchIsUsingTaoRoutines()
627 …rorCode TaoLineSearchSetObjectiveRoutine(TaoLineSearch ls, PetscErrorCode (*func)(TaoLineSearch ls in TaoLineSearchSetObjectiveRoutine() argument
630 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchSetObjectiveRoutine()
632 ls->ops->computeobjective = func; in TaoLineSearchSetObjectiveRoutine()
633 if (ctx) ls->userctx_func = ctx; in TaoLineSearchSetObjectiveRoutine()
634 ls->usetaoroutines = PETSC_FALSE; in TaoLineSearchSetObjectiveRoutine()
668 …rrorCode TaoLineSearchSetGradientRoutine(TaoLineSearch ls, PetscErrorCode (*func)(TaoLineSearch ls in TaoLineSearchSetGradientRoutine() argument
671 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchSetGradientRoutine()
672 ls->ops->computegradient = func; in TaoLineSearchSetGradientRoutine()
673 if (ctx) ls->userctx_grad = ctx; in TaoLineSearchSetGradientRoutine()
674 ls->usetaoroutines = PETSC_FALSE; in TaoLineSearchSetGradientRoutine()
708 …LineSearchSetObjectiveAndGradientRoutine(TaoLineSearch ls, PetscErrorCode (*func)(TaoLineSearch ls in TaoLineSearchSetObjectiveAndGradientRoutine() argument
711 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchSetObjectiveAndGradientRoutine()
712 ls->ops->computeobjectiveandgradient = func; in TaoLineSearchSetObjectiveAndGradientRoutine()
713 if (ctx) ls->userctx_funcgrad = ctx; in TaoLineSearchSetObjectiveAndGradientRoutine()
714 ls->usetaoroutines = PETSC_FALSE; in TaoLineSearchSetObjectiveAndGradientRoutine()
758 …e TaoLineSearchSetObjectiveAndGTSRoutine(TaoLineSearch ls, PetscErrorCode (*func)(TaoLineSearch ls in TaoLineSearchSetObjectiveAndGTSRoutine() argument
761 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchSetObjectiveAndGTSRoutine()
762 ls->ops->computeobjectiveandgts = func; in TaoLineSearchSetObjectiveAndGTSRoutine()
763 if (ctx) ls->userctx_funcgts = ctx; in TaoLineSearchSetObjectiveAndGTSRoutine()
764 ls->usegts = PETSC_TRUE; in TaoLineSearchSetObjectiveAndGTSRoutine()
765 ls->usetaoroutines = PETSC_FALSE; in TaoLineSearchSetObjectiveAndGTSRoutine()
783 PetscErrorCode TaoLineSearchUseTaoRoutines(TaoLineSearch ls, Tao ts) in TaoLineSearchUseTaoRoutines() argument
786 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchUseTaoRoutines()
788 ls->tao = ts; in TaoLineSearchUseTaoRoutines()
789 ls->usetaoroutines = PETSC_TRUE; in TaoLineSearchUseTaoRoutines()
813 PetscErrorCode TaoLineSearchComputeObjective(TaoLineSearch ls, Vec x, PetscReal *f) in TaoLineSearchComputeObjective() argument
819 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchComputeObjective()
822 PetscCheckSameComm(ls, 1, x, 2); in TaoLineSearchComputeObjective()
823 if (ls->usetaoroutines) { in TaoLineSearchComputeObjective()
824 PetscCall(TaoComputeObjective(ls->tao, x, f)); in TaoLineSearchComputeObjective()
826 …etscCheck(ls->ops->computeobjective || ls->ops->computeobjectiveandgradient || ls->ops->computeobj… in TaoLineSearchComputeObjective()
827 PetscCall(PetscLogEventBegin(TAOLINESEARCH_Eval, ls, 0, 0, 0)); in TaoLineSearchComputeObjective()
828 …if (ls->ops->computeobjective) PetscCallBack("TaoLineSearch callback objective", (*ls->ops->comput… in TaoLineSearchComputeObjective()
829 else if (ls->ops->computeobjectiveandgradient) { in TaoLineSearchComputeObjective()
831 …CallBack("TaoLineSearch callback objective", (*ls->ops->computeobjectiveandgradient)(ls, x, f, gdu… in TaoLineSearchComputeObjective()
833 …ck("TaoLineSearch callback objective", (*ls->ops->computeobjectiveandgts)(ls, x, ls->stepdirection… in TaoLineSearchComputeObjective()
834 PetscCall(PetscLogEventEnd(TAOLINESEARCH_Eval, ls, 0, 0, 0)); in TaoLineSearchComputeObjective()
836 ls->nfeval++; in TaoLineSearchComputeObjective()
861 PetscErrorCode TaoLineSearchComputeObjectiveAndGradient(TaoLineSearch ls, Vec x, PetscReal *f, Vec … in TaoLineSearchComputeObjectiveAndGradient() argument
864 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchComputeObjectiveAndGradient()
868 PetscCheckSameComm(ls, 1, x, 2); in TaoLineSearchComputeObjectiveAndGradient()
869 PetscCheckSameComm(ls, 1, g, 4); in TaoLineSearchComputeObjectiveAndGradient()
870 if (ls->usetaoroutines) { in TaoLineSearchComputeObjectiveAndGradient()
871 PetscCall(TaoComputeObjectiveAndGradient(ls->tao, x, f, g)); in TaoLineSearchComputeObjectiveAndGradient()
873 PetscCall(PetscLogEventBegin(TAOLINESEARCH_Eval, ls, 0, 0, 0)); in TaoLineSearchComputeObjectiveAndGradient()
874ls->ops->computeobjectiveandgradient) PetscCallBack("TaoLineSearch callback objective/gradient", (… in TaoLineSearchComputeObjectiveAndGradient()
876 …PetscCallBack("TaoLineSearch callback objective", (*ls->ops->computeobjective)(ls, x, f, ls->userc… in TaoLineSearchComputeObjectiveAndGradient()
877 …PetscCallBack("TaoLineSearch callback gradient", (*ls->ops->computegradient)(ls, x, g, ls->userctx… in TaoLineSearchComputeObjectiveAndGradient()
879 PetscCall(PetscLogEventEnd(TAOLINESEARCH_Eval, ls, 0, 0, 0)); in TaoLineSearchComputeObjectiveAndGradient()
880 PetscCall(PetscInfo(ls, "TaoLineSearch Function evaluation: %14.12e\n", (double)(*f))); in TaoLineSearchComputeObjectiveAndGradient()
882 ls->nfgeval++; in TaoLineSearchComputeObjectiveAndGradient()
906 PetscErrorCode TaoLineSearchComputeGradient(TaoLineSearch ls, Vec x, Vec g) in TaoLineSearchComputeGradient() argument
911 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchComputeGradient()
914 PetscCheckSameComm(ls, 1, x, 2); in TaoLineSearchComputeGradient()
915 PetscCheckSameComm(ls, 1, g, 3); in TaoLineSearchComputeGradient()
916 if (ls->usetaoroutines) { in TaoLineSearchComputeGradient()
917 PetscCall(TaoComputeGradient(ls->tao, x, g)); in TaoLineSearchComputeGradient()
919 PetscCall(PetscLogEventBegin(TAOLINESEARCH_Eval, ls, 0, 0, 0)); in TaoLineSearchComputeGradient()
920 …if (ls->ops->computegradient) PetscCallBack("TaoLineSearch callback gradient", (*ls->ops->computeg… in TaoLineSearchComputeGradient()
921 …cCallBack("TaoLineSearch callback gradient", (*ls->ops->computeobjectiveandgradient)(ls, x, &fdumm… in TaoLineSearchComputeGradient()
922 PetscCall(PetscLogEventEnd(TAOLINESEARCH_Eval, ls, 0, 0, 0)); in TaoLineSearchComputeGradient()
924 ls->ngeval++; in TaoLineSearchComputeGradient()
950 PetscErrorCode TaoLineSearchComputeObjectiveAndGTS(TaoLineSearch ls, Vec x, PetscReal *f, PetscReal… in TaoLineSearchComputeObjectiveAndGTS() argument
953 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchComputeObjectiveAndGTS()
957 PetscCheckSameComm(ls, 1, x, 2); in TaoLineSearchComputeObjectiveAndGTS()
958 PetscCall(PetscLogEventBegin(TAOLINESEARCH_Eval, ls, 0, 0, 0)); in TaoLineSearchComputeObjectiveAndGTS()
959 …"TaoLineSearch callback objective/gts", (*ls->ops->computeobjectiveandgts)(ls, x, ls->stepdirectio… in TaoLineSearchComputeObjectiveAndGTS()
960 PetscCall(PetscLogEventEnd(TAOLINESEARCH_Eval, ls, 0, 0, 0)); in TaoLineSearchComputeObjectiveAndGTS()
961 PetscCall(PetscInfo(ls, "TaoLineSearch Function evaluation: %14.12e\n", (double)(*f))); in TaoLineSearchComputeObjectiveAndGTS()
962 ls->nfeval++; in TaoLineSearchComputeObjectiveAndGTS()
985 PetscErrorCode TaoLineSearchGetSolution(TaoLineSearch ls, Vec x, PetscReal *f, Vec g, PetscReal *st… in TaoLineSearchGetSolution() argument
988 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchGetSolution()
993 if (ls->new_x) PetscCall(VecCopy(ls->new_x, x)); in TaoLineSearchGetSolution()
994 *f = ls->new_f; in TaoLineSearchGetSolution()
995 if (ls->new_g) PetscCall(VecCopy(ls->new_g, g)); in TaoLineSearchGetSolution()
996 if (steplength) *steplength = ls->step; in TaoLineSearchGetSolution()
997 *reason = ls->reason; in TaoLineSearchGetSolution()
1017 PetscErrorCode TaoLineSearchGetStartingVector(TaoLineSearch ls, Vec *x) in TaoLineSearchGetStartingVector() argument
1020 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchGetStartingVector()
1021 if (x) *x = ls->start_x; in TaoLineSearchGetStartingVector()
1041 PetscErrorCode TaoLineSearchGetStepDirection(TaoLineSearch ls, Vec *s) in TaoLineSearchGetStepDirection() argument
1044 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchGetStepDirection()
1045 if (s) *s = ls->stepdirection; in TaoLineSearchGetStepDirection()
1064 PetscErrorCode TaoLineSearchGetFullStepObjective(TaoLineSearch ls, PetscReal *f_fullstep) in TaoLineSearchGetFullStepObjective() argument
1067 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchGetFullStepObjective()
1068 *f_fullstep = ls->f_fullstep; in TaoLineSearchGetFullStepObjective()
1090 PetscErrorCode TaoLineSearchSetVariableBounds(TaoLineSearch ls, Vec xl, Vec xu) in TaoLineSearchSetVariableBounds() argument
1093 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchSetVariableBounds()
1098 PetscCall(VecDestroy(&ls->lower)); in TaoLineSearchSetVariableBounds()
1099 PetscCall(VecDestroy(&ls->upper)); in TaoLineSearchSetVariableBounds()
1100 ls->lower = xl; in TaoLineSearchSetVariableBounds()
1101 ls->upper = xu; in TaoLineSearchSetVariableBounds()
1102 ls->bounded = (PetscBool)(xl || xu); in TaoLineSearchSetVariableBounds()
1120 PetscErrorCode TaoLineSearchSetInitialStepLength(TaoLineSearch ls, PetscReal s) in TaoLineSearchSetInitialStepLength() argument
1123 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchSetInitialStepLength()
1124 PetscValidLogicalCollectiveReal(ls, s, 2); in TaoLineSearchSetInitialStepLength()
1125 ls->initstep = s; in TaoLineSearchSetInitialStepLength()
1144 PetscErrorCode TaoLineSearchGetStepLength(TaoLineSearch ls, PetscReal *s) in TaoLineSearchGetStepLength() argument
1147 PetscValidHeaderSpecific(ls, TAOLINESEARCH_CLASSID, 1); in TaoLineSearchGetStepLength()
1148 *s = ls->step; in TaoLineSearchGetStepLength()
1210 PetscErrorCode TaoLineSearchAppendOptionsPrefix(TaoLineSearch ls, const char p[]) in TaoLineSearchAppendOptionsPrefix() argument
1212 return PetscObjectAppendOptionsPrefix((PetscObject)ls, p); in TaoLineSearchAppendOptionsPrefix()
1231 PetscErrorCode TaoLineSearchGetOptionsPrefix(TaoLineSearch ls, const char *p[]) in TaoLineSearchGetOptionsPrefix() argument
1233 return PetscObjectGetOptionsPrefix((PetscObject)ls, p); in TaoLineSearchGetOptionsPrefix()
1269 PetscErrorCode TaoLineSearchSetOptionsPrefix(TaoLineSearch ls, const char p[]) in TaoLineSearchSetOptionsPrefix() argument
1271 return PetscObjectSetOptionsPrefix((PetscObject)ls, p); in TaoLineSearchSetOptionsPrefix()