# TaoSetFromOptions
Sets various Tao parameters from user options. 
## Synopsis
```
#include "petsctao.h" 
PetscErrorCode TaoSetFromOptions(Tao tao)
```
Collective on tao


## Input Parameter

- ***tao -*** the Tao solver context



## options Database Keys

- ***-tao_type <type> -*** The algorithm that Tao uses (lmvm, nls, etc.)
- ***-tao_gatol <gatol> -*** absolute error tolerance for ||gradient||
- ***-tao_grtol <grtol> -*** relative error tolerance for ||gradient||
- ***-tao_gttol <gttol> -*** reduction of ||gradient|| relative to initial gradient
- ***-tao_max_it <max> -*** sets maximum number of iterations
- ***-tao_max_funcs <max> -*** sets maximum number of function evaluations
- ***-tao_fmin <fmin> -*** stop if function value reaches fmin
- ***-tao_steptol <tol> -*** stop if trust region radius less than <tol>
- ***-tao_trust0 <t> -*** initial trust region radius
- ***-tao_monitor -*** prints function value and residual at each iteration
- ***-tao_smonitor -*** same as tao_monitor, but truncates very small values
- ***-tao_cmonitor -*** prints function value, residual, and constraint norm at each iteration
- ***-tao_view_solution -*** prints solution vector at each iteration
- ***-tao_view_ls_residual -*** prints least-squares residual vector at each iteration
- ***-tao_view_stepdirection -*** prints step direction vector at each iteration
- ***-tao_view_gradient -*** prints gradient vector at each iteration
- ***-tao_draw_solution -*** graphically view solution vector at each iteration
- ***-tao_draw_step -*** graphically view step vector at each iteration
- ***-tao_draw_gradient -*** graphically view gradient at each iteration
- ***-tao_fd_gradient -*** use gradient computed with finite differences
- ***-tao_fd_hessian -*** use hessian computed with finite differences
- ***-tao_mf_hessian -*** use matrix-free hessian computed with finite differences
- ***-tao_cancelmonitors -*** cancels all monitors (except those set with command line)
- ***-tao_view -*** prints information about the Tao after solving
- ***-tao_converged_reason -*** prints the reason Tao stopped iterating



## Notes
To see all options, run your program with the -help option or consult the
user's manual. Should be called after `TaoCreate()` but before `TaoSolve()`




## See Also
 `Tao`, `TaoCreate()`, `TaoSolve()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/interface/taosolver.c.html#TaoSetFromOptions">src/tao/interface/taosolver.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex20opt_ic.c.html">src/ts/tutorials/ex20opt_ic.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex20opt_p.c.html">src/ts/tutorials/ex20opt_p.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/burgers_spectral.c.html">src/tao/unconstrained/tutorials/burgers_spectral.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/eptorsion1.c.html">src/tao/unconstrained/tutorials/eptorsion1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/eptorsion2.c.html">src/tao/unconstrained/tutorials/eptorsion2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/eptorsion2f.F90.html">src/tao/unconstrained/tutorials/eptorsion2f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/minsurf1.c.html">src/tao/unconstrained/tutorials/minsurf1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/minsurf2.c.html">src/tao/unconstrained/tutorials/minsurf2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/rosenbrock1.c.html">src/tao/unconstrained/tutorials/rosenbrock1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/rosenbrock1f.F90.html">src/tao/unconstrained/tutorials/rosenbrock1f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/rosenbrock2.c.html">src/tao/unconstrained/tutorials/rosenbrock2.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/bound/impls/blmvm/blmvm.c.html#TaoSetFromOptions_BLMVM">TaoSetFromOptions_BLMVM in src/tao/bound/impls/blmvm/blmvm.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/bound/impls/bncg/bncg.c.html#TaoSetFromOptions_BNCG">TaoSetFromOptions_BNCG in src/tao/bound/impls/bncg/bncg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/bound/impls/bnk/bnk.c.html#TaoSetFromOptions_BNK">TaoSetFromOptions_BNK in src/tao/bound/impls/bnk/bnk.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/bound/impls/bnk/bntl.c.html#TaoSetFromOptions_BNTL">TaoSetFromOptions_BNTL in src/tao/bound/impls/bnk/bntl.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/bound/impls/bnk/bntr.c.html#TaoSetFromOptions_BNTR">TaoSetFromOptions_BNTR in src/tao/bound/impls/bnk/bntr.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/bound/impls/bqnk/bqnk.c.html#TaoSetFromOptions_BQNK">TaoSetFromOptions_BQNK in src/tao/bound/impls/bqnk/bqnk.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/bound/impls/bqnls/bqnls.c.html#TaoSetFromOptions_BQNLS">TaoSetFromOptions_BQNLS in src/tao/bound/impls/bqnls/bqnls.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/bound/impls/tron/tron.c.html#TaoSetFromOptions_TRON">TaoSetFromOptions_TRON in src/tao/bound/impls/tron/tron.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/complementarity/impls/ssls/ssls.c.html#TaoSetFromOptions_SSLS">TaoSetFromOptions_SSLS in src/tao/complementarity/impls/ssls/ssls.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/constrained/impls/admm/admm.c.html#TaoSetFromOptions_ADMM">TaoSetFromOptions_ADMM in src/tao/constrained/impls/admm/admm.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/constrained/impls/almm/almm.c.html#TaoSetFromOptions_ALMM">TaoSetFromOptions_ALMM in src/tao/constrained/impls/almm/almm.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/constrained/impls/ipm/ipm.c.html#TaoSetFromOptions_IPM">TaoSetFromOptions_IPM in src/tao/constrained/impls/ipm/ipm.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/constrained/impls/ipm/pdipm.c.html#TaoSetFromOptions_PDIPM">TaoSetFromOptions_PDIPM in src/tao/constrained/impls/ipm/pdipm.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/leastsquares/impls/brgn/brgn.c.html#TaoSetFromOptions_BRGN">TaoSetFromOptions_BRGN in src/tao/leastsquares/impls/brgn/brgn.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/leastsquares/impls/pounders/pounders.c.html#TaoSetFromOptions_POUNDERS">TaoSetFromOptions_POUNDERS in src/tao/leastsquares/impls/pounders/pounders.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/pde_constrained/impls/lcl/lcl.c.html#TaoSetFromOptions_LCL">TaoSetFromOptions_LCL in src/tao/pde_constrained/impls/lcl/lcl.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/quadratic/impls/bqpip/bqpip.c.html#TaoSetFromOptions_BQPIP">TaoSetFromOptions_BQPIP in src/tao/quadratic/impls/bqpip/bqpip.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/quadratic/impls/gpcg/gpcg.c.html#TaoSetFromOptions_GPCG">TaoSetFromOptions_GPCG in src/tao/quadratic/impls/gpcg/gpcg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/impls/bmrm/bmrm.c.html#TaoSetFromOptions_BMRM">TaoSetFromOptions_BMRM in src/tao/unconstrained/impls/bmrm/bmrm.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/impls/cg/taocg.c.html#TaoSetFromOptions_CG">TaoSetFromOptions_CG in src/tao/unconstrained/impls/cg/taocg.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/impls/lmvm/lmvm.c.html#TaoSetFromOptions_LMVM">TaoSetFromOptions_LMVM in src/tao/unconstrained/impls/lmvm/lmvm.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/impls/neldermead/neldermead.c.html#TaoSetFromOptions_NM">TaoSetFromOptions_NM in src/tao/unconstrained/impls/neldermead/neldermead.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/impls/nls/nls.c.html#TaoSetFromOptions_NLS">TaoSetFromOptions_NLS in src/tao/unconstrained/impls/nls/nls.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/impls/ntl/ntl.c.html#TaoSetFromOptions_NTL">TaoSetFromOptions_NTL in src/tao/unconstrained/impls/ntl/ntl.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/impls/ntr/ntr.c.html#TaoSetFromOptions_NTR">TaoSetFromOptions_NTR in src/tao/unconstrained/impls/ntr/ntr.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/impls/owlqn/owlqn.c.html#TaoSetFromOptions_OWLQN">TaoSetFromOptions_OWLQN in src/tao/unconstrained/impls/owlqn/owlqn.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/tao/interface/taosolver.c)


[Index of all Tao routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
