Tao (Optimization) - Low-level Interface

The Tao (Toolkit for Advanced Optimization) component provides methods for solving optimization problems, including unconstrained minimization, bound-constrained optimization, and constrained optimization.

Overview

Tao supports various optimization algorithms:

  • Unconstrained: Conjugate gradient (CG), limited-memory BFGS (BLMVM), Nelder-Mead
  • Bound-constrained: Bound-constrained BFGS (BNCG, BNLS, BNTL), active-set methods
  • Constrained: Augmented Lagrangian methods (ALMM), interior point methods
  • Least-squares: Gauss-Newton methods, Levenberg-Marquardt
  • Complementarity: Semismooth methods for complementarity problems
  • PDE-constrained: Methods suitable for PDE-constrained optimization

The Tao object manages the optimization process, line searches, convergence monitoring, and provides a unified interface across different optimization algorithms.

Basic Usage

using PETSc, MPI

# Initialize MPI and PETSc
MPI.Init()
petsclib = PETSc.getlib()
PETSc.initialize(petsclib)

# Create a Tao object
tao = LibPETSc.TaoCreate(petsclib, LibPETSc.PETSC_COMM_SELF)

# Set the optimization algorithm (e.g., LMVM, BLMVM, NLS)
LibPETSc.TaoSetType(petsclib, tao, "lmvm")

# Set the objective function and gradient
# LibPETSc.TaoSetObjective(petsclib, tao, objective_function_ptr, C_NULL)
# LibPETSc.TaoSetGradient(petsclib, tao, C_NULL, gradient_function_ptr, C_NULL)

# For bound-constrained problems, set variable bounds
# LibPETSc.TaoSetVariableBounds(petsclib, tao, lower_bound_vec, upper_bound_vec)

# Set convergence tolerances
LibPETSc.TaoSetTolerances(petsclib, tao, 1e-8, 1e-8, 1e-8)

# Set maximum iterations
LibPETSc.TaoSetMaximumIterations(petsclib, tao, 1000)

# Set options from command line/options database
LibPETSc.TaoSetFromOptions(petsclib, tao)

# Set initial guess
# LibPETSc.TaoSetSolution(petsclib, tao, initial_vec)

# Solve the optimization problem
# LibPETSc.TaoSolve(petsclib, tao)

# Get solution information
reason = LibPETSc.TaoGetConvergedReason(petsclib, tao)
iter = LibPETSc.TaoGetIterationNumber(petsclib, tao)

println("Tao reason: $(reason), iterations: $(iter)")

# Cleanup
LibPETSc.TaoDestroy(petsclib, tao)

# Finalize PETSc and MPI
PETSc.finalize(petsclib)
MPI.Finalize()

Common Workflow

  1. Create and configure Tao: Use TaoCreate, TaoSetType
  2. Define objective: TaoSetObjective, TaoSetGradient, optionally TaoSetHessian
  3. Set constraints (if any): TaoSetVariableBounds, TaoSetConstraints
  4. Configure solver: TaoSetTolerances, TaoSetMaximumIterations
  5. Set initial guess: TaoSetSolution
  6. Solve: TaoSolve
  7. Retrieve solution: TaoGetSolution, TaoGetConvergedReason

Optimization Algorithms

Available through TaoSetType:

  • Unconstrained:

    • TAOLMVM: Limited-memory variable metric (quasi-Newton)
    • TAOCG: Conjugate gradient methods
    • TAONM: Nelder-Mead simplex method
    • TAONLS: Newton line search
    • TAONTL: Newton trust-region with line search
  • Bound-constrained:

    • TAOBLMVM: Bound-constrained limited-memory variable metric
    • TAOBNCG: Bound-constrained conjugate gradient
    • TAOBQNLS: Bound-constrained quasi-Newton line search
    • TAOBNTL: Bound-constrained Newton trust-region
    • TAOTRON: Trust-region Newton method

The types built on an LMVM matrix (lmvm, blmvm, bncg, bqnls, bqnkls, bntl and bntr) fail after a PETSc.finalize/PETSc.initialize cycle in which a KSP was created: PETSc 3.25 forgets the LMVM matrix types at PetscFinalize and has no public way to register them again, so TaoSetType throws with "Unknown Mat type given: lmvmbfgs". Initialize once per Julia session, or restart Julia. cg, nm, nls, ntr, ntl and tron are not affected.

  • Constrained:

    • TAOALMM: Augmented Lagrangian multiplier method
    • TAOIPM: Interior point method
    • TAOPDIPM: Primal-dual interior point method
  • Least-squares:

    • TAOPOUNDERS: POUNDERs model-based method
    • TAOBRGN: Bounded regularized Gauss-Newton
  • Complementarity:

    • TAOSSLS: Semismooth least squares
    • TAOASLS: Active-set least squares

Convergence Criteria

Tao monitors several convergence criteria:

  • Gradient tolerance: ||∇f|| < gatol or ||∇f||/||f|| < grtol
  • Function tolerance: |f - f_prev| < fatol or |f - f_prev|/|f| < frtol
  • Step tolerance: ||x - x_prev|| < steptol

Set using TaoSetTolerances(tao, gatol, grtol, gttol).

Hessian Options

For second-order methods:

  • Exact Hessian: Provide via TaoSetHessian
  • Finite-difference approximation: Use matrix-free approach
  • Quasi-Newton approximation: LMVM methods build approximation automatically

Function Reference

PETSc.LibPETSc.TaoADMMGetDualVector — Method
Y::PetscVec = TaoADMMGetDualVector(petsclib::PetscLibType, tao::AbstractTao)

Returns the dual vector associated with the current TAOADMM state

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • Y - the current solution

Level: intermediate

See also: TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMGetMisfitSubsolver — Method
misfit::Tao = TaoADMMGetMisfitSubsolver(petsclib::PetscLibType, tao::AbstractTao)

Get the pointer to the misfit subsolver inside TAOADMM

Collective

Input Parameter:

  • tao - the Tao solver context

Output Parameter:

  • misfit - the Tao subsolver context

Level: advanced

See also: TAOADMM, Tao

External Links

source
PETSc.LibPETSc.TaoADMMGetRegularizerCoefficient — Method
lambda::PetscReal = TaoADMMGetRegularizerCoefficient(petsclib::PetscLibType, tao::AbstractTao)

Get the regularization coefficient lambda for L1 norm regularization case

Collective

Input Parameter:

  • tao - the Tao solver context

Output Parameter:

  • lambda - L1-norm regularizer coefficient

Level: advanced

See also: TaoADMMSetMisfitConstraintJacobian(), TaoADMMSetRegularizerConstraintJacobian(), TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMGetRegularizerType — Method
type::TaoADMMRegularizerType = TaoADMMGetRegularizerType(petsclib::PetscLibType, tao::AbstractTao)

Gets the type of regularizer routine for TAOADMM

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • type - the type of regularizer

Level: intermediate

See also: TaoADMMSetRegularizerType(), TaoADMMRegularizerType, TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMGetSpectralPenalty — Method
mu::PetscReal = TaoADMMGetSpectralPenalty(petsclib::PetscLibType, tao::AbstractTao)

Get the spectral penalty (mu) value

Collective

Input Parameter:

  • tao - the Tao solver context

Output Parameter:

  • mu - spectral penalty

Level: advanced

See also: TaoADMMSetMinimumSpectralPenalty(), TaoADMMSetSpectralPenalty(), TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMGetUpdateType — Method
type::TaoADMMUpdateType = TaoADMMGetUpdateType(petsclib::PetscLibType, tao::AbstractTao)

Gets the type of spectral penalty update routine for TAOADMM

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • type - the type of spectral penalty update routine

Level: intermediate

See also: TaoADMMSetUpdateType(), TaoADMMUpdateType, TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMSetMisfitConstraintJacobian — Method
TaoADMMSetMisfitConstraintJacobian(petsclib::PetscLibType, tao::AbstractTao, J::AbstractPetscMat, Jpre::AbstractPetscMat, func::external, ctx::Ptr{Cvoid})

Set the constraint matrix B for the TAOADMM algorithm. Matrix B constrains the z variable.

Collective

Input Parameters:

  • tao - the Tao solver context
  • J - user-created misfit constraint Jacobian matrix
  • Jpre - user-created misfit Jacobian constraint matrix for constructing the preconditioner, often this is J
  • func - function pointer for the misfit constraint Jacobian update function
  • ctx - application context for the regularizer constraint Jacobian

Calling sequence of func:

  • tao - the Tao context
  • u - in current input solution
  • J - the contribution to the misfit constraint Jacobian
  • Jpre - the contribution to matrix from which to construct a preconditioner for the misfit constraint Jacobian
  • ctx - the optional application context

Level: advanced

See also: TaoADMMSetRegularizerCoefficient(), TaoADMMSetRegularizerConstraintJacobian(), TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMSetMisfitHessianChangeStatus — Method
TaoADMMSetMisfitHessianChangeStatus(petsclib::PetscLibType, tao::AbstractTao, b::PetscBool)

Set boolean that determines whether Hessian matrix of misfit subsolver changes with respect to input vector.

Collective

Input Parameters:

  • tao - the Tao solver context.
  • b - the Hessian matrix change status boolean, PETSC_FALSE when the Hessian matrix does not change, PETSC_TRUE otherwise.

Level: advanced

See also: TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMSetMisfitHessianRoutine — Method
TaoADMMSetMisfitHessianRoutine(petsclib::PetscLibType, tao::AbstractTao, H::AbstractPetscMat, Hpre::AbstractPetscMat, func::external, ctx::Ptr{Cvoid})

Sets the user-defined misfit Hessian call-back function into the algorithm, to be used for subsolverX.

Collective

Input Parameters:

  • tao - the Tao context
  • H - user-created matrix for the Hessian of the misfit term
  • Hpre - user-created matrix for the preconditioner of Hessian of the misfit term
  • func - function pointer for the misfit Hessian evaluation
  • ctx - application context for the misfit Hessian

Calling sequence of func:

  • tao - the Tao context
  • u - in current input solution
  • H - output, the contribution to the Hessian matrix
  • Hpre - an optional contribution to an alternative matrix with which the preconditioner is to be constructed
  • ctx - the optional application context

Level: advanced

See also: TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMSetMisfitObjectiveAndGradientRoutine — Method
TaoADMMSetMisfitObjectiveAndGradientRoutine(petsclib::PetscLibType, tao::AbstractTao, func::external, ctx::Ptr{Cvoid})

Sets the user-defined misfit call-back function

Collective

Input Parameters:

  • tao - the Tao context
  • func - function pointer for the misfit value and gradient evaluation
  • ctx - application context for the misfit

Calling sequence of func:

  • tao - the Tao context
  • u - in current input solution
  • f - the contribution to the objective function
  • g - the contribution to the gradient
  • ctx - the optional application context

Level: advanced

See also: TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMSetRegHessianChangeStatus — Method
TaoADMMSetRegHessianChangeStatus(petsclib::PetscLibType, tao::AbstractTao, b::PetscBool)

Set boolean that determines whether Hessian matrix of regularization subsolver changes with respect to input vector.

Collective

Input Parameters:

  • tao - the Tao solver context
  • b - the Hessian matrix change status boolean, PETSC_FALSE when the Hessian matrix does not change, PETSC_TRUE otherwise.

Level: advanced

See also: TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMSetRegularizerCoefficient — Method
TaoADMMSetRegularizerCoefficient(petsclib::PetscLibType, tao::AbstractTao, lambda::PetscReal)

Set the regularization coefficient lambda for L1 norm regularization case

Collective

Input Parameters:

  • tao - the Tao solver context
  • lambda - L1-norm regularizer coefficient

Level: advanced

See also: TaoADMMSetMisfitConstraintJacobian(), TaoADMMSetRegularizerConstraintJacobian(), TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMSetRegularizerConstraintJacobian — Method
TaoADMMSetRegularizerConstraintJacobian(petsclib::PetscLibType, tao::AbstractTao, J::AbstractPetscMat, Jpre::AbstractPetscMat, func::external, ctx::Ptr{Cvoid})

Set the constraint matrix B for TAOADMM algorithm. Matrix B constraints z variable.

Collective

Input Parameters:

  • tao - the Tao solver context
  • J - user-created regularizer constraint Jacobian matrix
  • Jpre - user-created regularizer Jacobian constraint matrix for constructing the preconditioner, often this is J
  • func - function pointer for the regularizer constraint Jacobian update function
  • ctx - application context for the regularizer constraint Jacobian

Calling sequence of func:

  • tao - the Tao context
  • u - in current input solution
  • J - the contribution to the constraint Jacobian
  • Jpre - the contribution to matrix from which to construct a preconditioner for the constraint Jacobian
  • ctx - the optional application context

Level: advanced

See also: TaoADMMSetRegularizerCoefficient(), TaoADMMSetMisfitConstraintJacobian(), TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMSetRegularizerHessianRoutine — Method
TaoADMMSetRegularizerHessianRoutine(petsclib::PetscLibType, tao::AbstractTao, H::AbstractPetscMat, Hpre::AbstractPetscMat, func::external, ctx::Ptr{Cvoid})

Sets the user-defined regularizer Hessian call-back function, to be used for subsolverZ.

Collective

Input Parameters:

  • tao - the Tao context
  • H - user-created matrix for the Hessian of the regularization term
  • Hpre - user-created matrix for building the preconditioner of the Hessian of the regularization term
  • func - function pointer for the regularizer Hessian evaluation
  • ctx - application context for the regularizer Hessian

Calling sequence of func:

  • tao - the Tao context
  • u - in current input solution
  • H - output, the contribution to the Hessian matrix
  • Hpre - an optional contribution to an alternative matrix with which the preconditioner is to be constructed
  • ctx - the optional application context

Level: advanced

See also: TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMSetRegularizerObjectiveAndGradientRoutine — Method
TaoADMMSetRegularizerObjectiveAndGradientRoutine(petsclib::PetscLibType, tao::AbstractTao, func::external, ctx::Ptr{Cvoid})

Sets the user-defined regularizer call-back function

Collective

Input Parameters:

  • tao - the Tao context
  • func - function pointer for the regularizer value and gradient evaluation
  • ctx - application context for the regularizer

Calling sequence of func:

  • tao - the Tao context
  • u - in current input solution
  • f - the contribution to the objective function
  • g - the contribution to the gradient
  • ctx - the optional application context

Level: advanced

See also: TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMSetRegularizerType — Method
TaoADMMSetRegularizerType(petsclib::PetscLibType, tao::AbstractTao, type::TaoADMMRegularizerType)

Set regularizer type for TAOADMM routine

Not Collective

Input Parameters:

  • tao - the Tao context
  • type - regularizer type

Options Database Key:

  • -tao_admm_regularizer_type (regularizer_user|regularizer_soft_thresh) - select the regularizer

Level: intermediate

See also: TaoADMMGetRegularizerType(), TaoADMMRegularizerType, TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMSetSpectralPenalty — Method
TaoADMMSetSpectralPenalty(petsclib::PetscLibType, tao::AbstractTao, mu::PetscReal)

Set the spectral penalty (mu) value

Collective

Input Parameters:

  • tao - the Tao solver context
  • mu - spectral penalty

Level: advanced

See also: TaoADMMSetMinimumSpectralPenalty(), TAOADMM

External Links

source
PETSc.LibPETSc.TaoADMMSetUpdateType — Method
TaoADMMSetUpdateType(petsclib::PetscLibType, tao::AbstractTao, type::TaoADMMUpdateType)

Set update routine for TAOADMM routine

Not Collective

Input Parameters:

  • tao - the Tao context
  • type - spectral parameter update type

Level: intermediate

See also: TaoADMMGetUpdateType(), TaoADMMUpdateType, TAOADMM

External Links

source
PETSc.LibPETSc.TaoALMMGetDualIS — Method
eq_is::IS,ineq_is::IS = TaoALMMGetDualIS(petsclib::PetscLibType, tao::AbstractTao)

Retrieve the index set that identifies equality and inequality constraint components of the dual vector returned by TaoALMMGetMultipliers().

Input Parameter:

  • tao - the Tao context for the TAOALMM solver

Output Parameters:

  • eq_is - index set associated with the equality constraints (NULL if not needed)
  • ineq_is - index set associated with the inequality constraints (NULL if not needed)

Level: advanced

See also: TAOALMM, Tao, TaoALMMGetMultipliers()

External Links

source
PETSc.LibPETSc.TaoALMMGetMultipliers — Method
Y::PetscVec = TaoALMMGetMultipliers(petsclib::PetscLibType, tao::AbstractTao)

Retrieve a pointer to the Lagrange multipliers.

Input Parameter:

  • tao - the Tao context for the TAOALMM solver

Output Parameter:

  • Y - vector of Lagrange multipliers

Level: advanced

See also: TAOALMM, Tao, TaoALMMSetMultipliers(), TaoALMMGetDualIS()

External Links

source
PETSc.LibPETSc.TaoALMMGetPrimalIS — Method
opt_is::IS,slack_is::IS = TaoALMMGetPrimalIS(petsclib::PetscLibType, tao::AbstractTao)

Retrieve the index set that identifies optimization and slack variable components of the subsolver's solution vector.

Input Parameter:

  • tao - the Tao context for the TAOALMM solver

Output Parameters:

  • opt_is - index set associated with the optimization variables (NULL if not needed)
  • slack_is - index set associated with the slack variables (NULL if not needed)

Level: advanced

See also: TAOALMM, Tao, IS, TaoALMMGetPrimalVector()

External Links

source
PETSc.LibPETSc.TaoALMMGetSubsolver — Method
subsolver::Tao = TaoALMMGetSubsolver(petsclib::PetscLibType, tao::AbstractTao)

Retrieve the subsolver being used by TAOALMM.

Input Parameter:

  • tao - the Tao context for the TAOALMM solver

Output Parameter:

  • subsolver - the Tao context for the subsolver

Level: advanced

See also: Tao, TAOALMM, TaoALMMSetSubsolver()

External Links

source
PETSc.LibPETSc.TaoALMMGetType — Method
type::TaoALMMType = TaoALMMGetType(petsclib::PetscLibType, tao::AbstractTao)

Retrieve the augmented Lagrangian formulation type for the subproblem.

Input Parameter:

  • tao - the Tao context for the TAOALMM solver

Output Parameter:

  • type - augmented Lagragrangian type

Level: advanced

See also: Tao, TAOALMM, TaoALMMSetType(), TaoALMMType

External Links

source
PETSc.LibPETSc.TaoALMMSetMultipliers — Method
TaoALMMSetMultipliers(petsclib::PetscLibType, tao::AbstractTao, Y::AbstractPetscVec)

Set user-defined Lagrange multipliers.

Input Parameters:

  • tao - the Tao context for the TAOALMM solver
  • Y - vector of Lagrange multipliers

Level: advanced

See also: TAOALMM, Tao, TaoALMMGetMultipliers()

External Links

source
PETSc.LibPETSc.TaoALMMSetSubsolver — Method
TaoALMMSetSubsolver(petsclib::PetscLibType, tao::AbstractTao, subsolver::AbstractTao)

Changes the subsolver inside TAOALMM with the user provided one.

Input Parameters:

  • tao - the Tao context for the TAOALMM solver
  • subsolver - the Tao context for the subsolver

Level: advanced

See also: Tao, TAOALMM, TaoALMMGetSubsolver()

External Links

source
PETSc.LibPETSc.TaoALMMSetType — Method
TaoALMMSetType(petsclib::PetscLibType, tao::AbstractTao, type::TaoALMMType)

Determine the augmented Lagrangian formulation type for the subproblem.

Input Parameters:

  • tao - the Tao context for the TAOALMM solver
  • type - augmented Lagragrangian type

Level: advanced

See also: Tao, TAOALMM, TaoALMMGetType(), TaoALMMType

External Links

source
PETSc.LibPETSc.TaoAddLineSearchCounts — Method
TaoAddLineSearchCounts(petsclib::PetscLibType, tao::AbstractTao)

Adds the number of function evaluations spent in the line search to the running total.

Input Parameters:

  • tao - the Tao solver

Level: developer

See also: Tao, TaoGetLineSearch(), TaoLineSearchApply()

External Links

source
PETSc.LibPETSc.TaoAddTerm — Method
TaoAddTerm(petsclib::PetscLibType, tao::AbstractTao, prefix::String, scale::PetscReal, term::TaoTerm, params::AbstractPetscVec, map::AbstractPetscMat)

Add a term to the objective function. If Tao is empty, term will be the objective of Tao.

Collective

Input Parameters:

  • tao - a Tao solver context
  • prefix - the prefix used for configuring the new term (if NULL, the index of the term will be used as a prefix, e.g. "0", "1", etc.)
  • scale - scaling coefficient for the new term
  • term - the real-valued function defining the new term
  • params - (optional) parameters for the new term. It is up to each implementation of TaoTerm to determine how it behaves when parameters are omitted.
  • map - (optional) a map from the tao solution space to the term solution space; if NULL the map is assumed to be the identity

Level: beginner

See also: Tao, TaoTerm, TAOTERMSUM, TaoGetTerm()

External Links

source
PETSc.LibPETSc.TaoAppendOptionsPrefix — Method
TaoAppendOptionsPrefix(petsclib::PetscLibType, tao::AbstractTao, p::String)

Appends to the prefix used for searching for all Tao options in the database.

Logically Collective

Input Parameters:

  • tao - the Tao solver context
  • p - the prefix string to prepend to all Tao option requests

Level: advanced

See also: Tao, TaoSetFromOptions(), TaoSetOptionsPrefix(), TaoGetOptionsPrefix()

External Links

source
PETSc.LibPETSc.TaoBNCGGetType — Method
type::TaoBNCGType = TaoBNCGGetType(petsclib::PetscLibType, tao::AbstractTao)

Return the type for the TAOBNCG solver

Input Parameter:

  • tao - the Tao solver context

Output Parameter:

  • type - TAOBNCG type

Level: advanced

See also: Tao, TAOBNCG, TaoBNCGSetType(), TaoBNCGType

External Links

source
PETSc.LibPETSc.TaoBNCGSetType — Method
TaoBNCGSetType(petsclib::PetscLibType, tao::AbstractTao, type::TaoBNCGType)

Set the type for the TAOBNCG solver

Input Parameters:

  • tao - the Tao solver context
  • type - TAOBNCG type

Level: advanced

See also: Tao, TAOBNCG, TaoBNCGGetType(), TaoBNCGType

External Links

source
PETSc.LibPETSc.TaoBRGNGetDampingVector — Method
d::PetscVec = TaoBRGNGetDampingVector(petsclib::PetscLibType, tao::AbstractTao)

Get the damping vector \mathrm{diag}(J^T J) from a TAOBRGN with TAOBRGN_REGULARIZATION_LM regularization

Collective

Input Parameter:

  • tao - a Tao of type TAOBRGN with TAOBRGN_REGULARIZATION_LM regularization

Output Parameter:

  • d - the damping vector

Level: developer

See also: Tao, TAOBRGN, TaoBRGNRegularzationTypes

External Links

source
PETSc.LibPETSc.TaoBRGNGetRegularizationType — Method
type::TaoBRGNRegularizationType = TaoBRGNGetRegularizationType(petsclib::PetscLibType, tao::AbstractTao)

Get the TaoBRGNRegularizationType of a TAOBRGN

Not collective

Input Parameter:

  • tao - a Tao of type TAOBRGN

Output Parameter:

  • type - the TaoBRGNRegularizationType

Level: advanced

See also: Tao, TAOBRGN, TaoBRGNRegularizationType, TaoBRGNSetRegularizationType()

External Links

source
PETSc.LibPETSc.TaoBRGNGetSubsolver — Method
TaoBRGNGetSubsolver(petsclib::PetscLibType, tao::AbstractTao, subsolver::AbstractTao)

Get the pointer to the subsolver inside a TAOBRGN

Collective

Input Parameters:

  • tao - the Tao solver context
  • subsolver - the Tao sub-solver context

Level: advanced

See also: Tao, Mat, TAOBRGN

External Links

source
PETSc.LibPETSc.TaoBRGNSetDictionaryMatrix — Method
TaoBRGNSetDictionaryMatrix(petsclib::PetscLibType, tao::AbstractTao, dict::AbstractPetscMat)

bind the dictionary matrix from user application context to gn->D, for compressed sensing (with least-squares problem)

Input Parameters:

  • tao - the Tao context
  • dict - the user specified dictionary matrix. We allow to set a NULL dictionary, which means identity matrix by default

Level: advanced

See also: Tao, Mat, TAOBRGN

External Links

source
PETSc.LibPETSc.TaoBRGNSetL1SmoothEpsilon — Method
TaoBRGNSetL1SmoothEpsilon(petsclib::PetscLibType, tao::AbstractTao, epsilon::PetscReal)

Set the L1-norm smooth approximation parameter for L1-regularized least-squares algorithm

Collective

Input Parameters:

  • tao - the Tao solver context
  • epsilon - L1-norm smooth approximation parameter

Level: advanced

See also: Tao, Mat, TAOBRGN

External Links

source
PETSc.LibPETSc.TaoBRGNSetRegularizationType — Method
TaoBRGNSetRegularizationType(petsclib::PetscLibType, tao::AbstractTao, type::TaoBRGNRegularizationType)

Set the TaoBRGNRegularizationType of a TAOBRGN

Logically collective

Input Parameters:

  • tao - a Tao of type TAOBRGN
  • type - the TaoBRGNRegularizationType

Level: advanced

See also: Tao, TAOBRGN, TaoBRGNRegularizationType, TaoBRGNGetRegularizationType

External Links

source
PETSc.LibPETSc.TaoBRGNSetRegularizerHessianRoutine — Method
TaoBRGNSetRegularizerHessianRoutine(petsclib::PetscLibType, tao::AbstractTao, Hreg::AbstractPetscMat, func::external, ctx::Ptr{Cvoid})

Sets the user-defined regularizer call-back function into the algorithm.

Input Parameters:

  • tao - the Tao context
  • Hreg - user-created matrix for the Hessian of the regularization term
  • func - function pointer for the regularizer Hessian evaluation
  • ctx - application context for the regularizer Hessian

Calling sequence:

  • tao - the Tao context
  • u - the location at which to compute the Hessian
  • Hreg - user-created matrix for the Hessian of the regularization term
  • ctx - application context for the regularizer Hessian

Level: advanced

See also: Tao, Mat, TAOBRGN

External Links

source
PETSc.LibPETSc.TaoBRGNSetRegularizerObjectiveAndGradientRoutine — Method
TaoBRGNSetRegularizerObjectiveAndGradientRoutine(petsclib::PetscLibType, tao::AbstractTao, func::external, ctx::Ptr{Cvoid})

Sets the user-defined regularizer call-back function into the algorithm.

Input Parameters:

  • tao - the Tao context
  • func - function pointer for the regularizer value and gradient evaluation
  • ctx - application context for the regularizer

Calling sequence:

  • tao - the Tao context
  • u - the location at which to compute the objective and gradient
  • val - location to store objective function value
  • g - location to store gradient
  • ctx - application context for the regularizer Hessian

Level: advanced

See also: Tao, Mat, TAOBRGN

External Links

source
PETSc.LibPETSc.TaoBRGNSetRegularizerWeight — Method
TaoBRGNSetRegularizerWeight(petsclib::PetscLibType, tao::AbstractTao, lambda::PetscReal)

Set the regularizer weight for the Gauss-Newton least-squares algorithm

Collective

Input Parameters:

  • tao - the Tao solver context
  • lambda - L1-norm regularizer weight

Level: beginner

See also: Tao, Mat, TAOBRGN

External Links

source
PETSc.LibPETSc.TaoBoundSolution — Method
nDiff::PetscInt = TaoBoundSolution(petsclib::PetscLibType, X::AbstractPetscVec, XL::AbstractPetscVec, XU::AbstractPetscVec, bound_tol::PetscReal, Xout::AbstractPetscVec)

Ensures that the solution vector is snapped into the bounds within a given tolerance.

Collective

Input Parameters:

  • X - solution vector
  • XL - lower bound vector
  • XU - upper bound vector
  • bound_tol - absolute tolerance in enforcing the bound

Output Parameters:

  • nDiff - total number of vector entries that have been bounded
  • Xout - modified solution vector satisfying bounds to bound_tol

Level: developer

See also: TAOBNCG, TAOBNTL, TAOBNTR, TaoBoundStep()

External Links

source
PETSc.LibPETSc.TaoBoundStep — Method
TaoBoundStep(petsclib::PetscLibType, X::AbstractPetscVec, XL::AbstractPetscVec, XU::AbstractPetscVec, active_lower::AbstractIS, active_upper::AbstractIS, active_fixed::AbstractIS, scale::PetscReal, S::AbstractPetscVec)

Ensures the correct zero or adjusted step direction values for active variables.

Input Parameters:

  • X - solution vector
  • XL - lower bound vector
  • XU - upper bound vector
  • active_lower - index set for lower bounded active variables
  • active_upper - index set for lower bounded active variables
  • active_fixed - index set for fixed active variables
  • scale - amplification factor for the step that needs to be taken on actively bounded variables

Output Parameter:

  • S - step direction to be modified

Level: developer

See also: TAOBNCG, TAOBNTL, TAOBNTR, TaoBoundSolution()

External Links

source
PETSc.LibPETSc.TaoComputeConstraints — Method
TaoComputeConstraints(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, C::AbstractPetscVec)

Compute the variable bounds using the routine set by TaoSetConstraintsRoutine().

Collective

Input Parameters:

  • tao - the Tao context
  • X - location to evaluate the constraints

Output Parameter:

  • C - the constraints

Level: developer

See also: Tao, TaoSetConstraintsRoutine(), TaoComputeJacobian()

External Links

source
PETSc.LibPETSc.TaoComputeDualVariables — Method
TaoComputeDualVariables(petsclib::PetscLibType, tao::AbstractTao, DL::AbstractPetscVec, DU::AbstractPetscVec)

Computes the dual vectors corresponding to the bounds of the variables

Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • DL - dual variable vector for the lower bounds
  • DU - dual variable vector for the upper bounds

Level: advanced

See also: Tao, TaoComputeObjective(), TaoSetVariableBounds()

External Links

source
PETSc.LibPETSc.TaoComputeEqualityConstraints — Method
TaoComputeEqualityConstraints(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, CE::AbstractPetscVec)

Compute the variable bounds using the routine set by TaoSetEqualityConstraintsRoutine().

Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • X - point the equality constraints were evaluated on
  • CE - vector of equality constraints evaluated at X

Level: developer

See also: Tao, TaoSetEqualityConstraintsRoutine(), TaoComputeJacobianEquality(), TaoComputeInequalityConstraints()

External Links

source
PETSc.LibPETSc.TaoComputeGradient — Method
TaoComputeGradient(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, G::AbstractPetscVec)

Computes the gradient of the objective function

Collective

Input Parameters:

  • tao - the Tao context
  • X - input vector

Output Parameter:

  • G - gradient vector

Options Database Keys:

  • -tao_test_gradient - compare the user provided gradient with one compute via finite differences to check for errors
  • -tao_test_gradient_view - display the user provided gradient, the finite difference gradient and the difference between them to help users detect the location of errors in the user provided gradient

Level: developer

See also: TaoComputeObjective(), TaoComputeObjectiveAndGradient(), TaoSetGradient()

External Links

source
PETSc.LibPETSc.TaoComputeHessian — Method
TaoComputeHessian(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, H::AbstractPetscMat, Hpre::AbstractPetscMat)

Computes the Hessian matrix that has been set with TaoSetHessian().

Collective

Input Parameters:

  • tao - the Tao solver context
  • X - input vector

Output Parameters:

  • H - Hessian matrix
  • Hpre - matrix used to construct the preconditioner, usually the same as H

Options Database Keys:

  • -tao_test_hessian - compare the user provided Hessian with one compute via finite differences to check for errors
  • -tao_test_hessian numerical value - display entries in the difference between the user provided Hessian and finite difference Hessian that are greater than a certain value to help users detect errors
  • -tao_test_hessian_view - display the user provided Hessian, the finite difference Hessian and the difference between them to help users detect the location of errors in the user provided Hessian

Level: developer

See also: Tao, TaoComputeObjective(), TaoComputeObjectiveAndGradient(), TaoSetHessian()

External Links

source
PETSc.LibPETSc.TaoComputeInequalityConstraints — Method
TaoComputeInequalityConstraints(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, CI::AbstractPetscVec)

Compute the variable bounds using the routine set by TaoSetInequalityConstraintsRoutine().

Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • X - point the inequality constraints were evaluated on
  • CI - vector of inequality constraints evaluated at X

Level: developer

See also: Tao, TaoSetInequalityConstraintsRoutine(), TaoComputeJacobianInequality(), TaoComputeEqualityConstraints()

External Links

source
PETSc.LibPETSc.TaoComputeJacobian — Method
TaoComputeJacobian(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, J::AbstractPetscMat, Jpre::AbstractPetscMat)

Computes the Jacobian matrix that has been set with TaoSetJacobianRoutine().

Collective

Input Parameters:

  • tao - the Tao solver context
  • X - input vector

Output Parameters:

  • J - Jacobian matrix
  • Jpre - matrix used to compute the preconditioner, often the same as J

Level: developer

See also: TaoComputeObjective(), TaoComputeObjectiveAndGradient(), TaoSetJacobianRoutine()

External Links

source
PETSc.LibPETSc.TaoComputeJacobianDesign — Method
TaoComputeJacobianDesign(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, J::AbstractPetscMat)

Computes the Jacobian matrix that has been set with TaoSetJacobianDesignRoutine().

Collective

Input Parameters:

  • tao - the Tao solver context
  • X - input vector

Output Parameter:

  • J - Jacobian matrix

Level: developer

See also: Tao, TaoComputeObjective(), TaoComputeObjectiveAndGradient(), TaoSetJacobianDesignRoutine(), TaoSetStateDesignIS()

External Links

source
PETSc.LibPETSc.TaoComputeJacobianEquality — Method
TaoComputeJacobianEquality(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, J::AbstractPetscMat, Jpre::AbstractPetscMat)

Computes the Jacobian matrix that has been set with TaoSetJacobianEqualityRoutine().

Collective

Input Parameters:

  • tao - the Tao solver context
  • X - input vector

Output Parameters:

  • J - Jacobian matrix
  • Jpre - matrix used to construct the preconditioner, often the same as J

Level: developer

See also: TaoComputeObjective(), TaoComputeObjectiveAndGradient(), TaoSetJacobianStateRoutine(), TaoComputeJacobianDesign(), TaoSetStateDesignIS()

External Links

source
PETSc.LibPETSc.TaoComputeJacobianInequality — Method
TaoComputeJacobianInequality(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, J::AbstractPetscMat, Jpre::AbstractPetscMat)

Computes the Jacobian matrix that has been set with TaoSetJacobianInequalityRoutine().

Collective

Input Parameters:

  • tao - the Tao solver context
  • X - input vector

Output Parameters:

  • J - Jacobian matrix
  • Jpre - matrix used to construct the preconditioner

Level: developer

See also: Tao, TaoComputeObjective(), TaoComputeObjectiveAndGradient(), TaoSetJacobianStateRoutine(), TaoComputeJacobianDesign(), TaoSetStateDesignIS()

External Links

source
PETSc.LibPETSc.TaoComputeJacobianState — Method
TaoComputeJacobianState(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, J::AbstractPetscMat, Jpre::AbstractPetscMat, Jinv::AbstractPetscMat)

Computes the Jacobian matrix that has been set with TaoSetJacobianStateRoutine().

Collective

Input Parameters:

  • tao - the Tao solver context
  • X - input vector

Output Parameters:

  • J - Jacobian matrix
  • Jpre - matrix used to construct the preconditioner, often the same as J
  • Jinv - unknown

Level: developer

See also: Tao, TaoComputeObjective(), TaoComputeObjectiveAndGradient(), TaoSetJacobianStateRoutine(), TaoComputeJacobianDesign(), TaoSetStateDesignIS()

External Links

source
PETSc.LibPETSc.TaoComputeObjective — Method
f::PetscReal = TaoComputeObjective(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec)

Computes the objective function value at a given point

Collective

Input Parameters:

  • tao - the Tao context
  • X - input vector

Output Parameter:

  • f - Objective value at X

Level: developer

See also: Tao, TaoComputeGradient(), TaoComputeObjectiveAndGradient(), TaoSetObjective()

External Links

source
PETSc.LibPETSc.TaoComputeObjectiveAndGradient — Method
f::PetscReal = TaoComputeObjectiveAndGradient(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, G::AbstractPetscVec)

Computes the objective function value at a given point

Collective

Input Parameters:

  • tao - the Tao context
  • X - input vector

Output Parameters:

  • f - Objective value at X
  • G - Gradient vector at X

Level: developer

See also: TaoComputeGradient(), TaoSetObjective()

External Links

source
PETSc.LibPETSc.TaoComputeResidual — Method
TaoComputeResidual(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, F::AbstractPetscVec)

Computes a least-squares residual vector at a given point

Collective

Input Parameters:

  • tao - the Tao context
  • X - input vector

Output Parameter:

  • F - Objective vector at X

Level: advanced

See also: Tao, TaoSetResidualRoutine()

External Links

source
PETSc.LibPETSc.TaoComputeResidualJacobian — Method
TaoComputeResidualJacobian(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, J::AbstractPetscMat, Jpre::AbstractPetscMat)

Computes the least-squares residual Jacobian matrix that has been set with TaoSetJacobianResidual().

Collective

Input Parameters:

  • tao - the Tao solver context
  • X - input vector

Output Parameters:

  • J - Jacobian matrix
  • Jpre - matrix used to compute the preconditioner, often the same as J

Level: developer

See also: Tao, TaoComputeResidual(), TaoSetJacobianResidual()

External Links

source
PETSc.LibPETSc.TaoComputeVariableBounds — Method
TaoComputeVariableBounds(petsclib::PetscLibType, tao::AbstractTao)

Compute the variable bounds using the routine set by TaoSetVariableBoundsRoutine().

Collective

Input Parameter:

  • tao - the Tao context

Level: developer

See also: Tao, TaoSetVariableBoundsRoutine(), TaoSetVariableBounds()

External Links

source
PETSc.LibPETSc.TaoCreate — Method
newtao::Tao = TaoCreate(petsclib::PetscLibType, comm::MPI_Comm)

Creates a Tao solver

Collective

Input Parameter:

  • comm - MPI communicator

Output Parameter:

  • newtao - the new Tao context

Options Database Key:

  • -tao_type - select which method Tao should use

Level: beginner

See also: Tao, TaoSolve(), TaoDestroy(), TaoSetFromOptions(), TaoSetType()

External Links

source
PETSc.LibPETSc.TaoDefaultComputeGradient — Method
TaoDefaultComputeGradient(petsclib::PetscLibType, tao::AbstractTao, Xin::AbstractPetscVec, G::AbstractPetscVec, dummy::Ptr{Cvoid})

computes the gradient using finite differences.

Collective

Input Parameters:

  • tao - the Tao context
  • Xin - compute gradient at this point
  • dummy - not used

Output Parameter:

  • G - Gradient Vector

Options Database Key:

  • -tao_fd_gradient - activates TaoDefaultComputeGradient()
  • -tao_fd_delta delta - change in X used to calculate finite differences

Level: advanced

See also: Tao, TaoSetGradient(), TaoTermComputeGradientFD()

External Links

source
PETSc.LibPETSc.TaoDefaultComputeHessian — Method
TaoDefaultComputeHessian(petsclib::PetscLibType, tao::AbstractTao, V::AbstractPetscVec, H::AbstractPetscMat, B::AbstractPetscMat, dummy::Ptr{Cvoid})

Computes the Hessian using finite differences.

Collective

Input Parameters:

  • tao - the Tao context
  • V - compute Hessian at this point
  • dummy - not used

Output Parameters:

  • H - Hessian matrix (not altered in this routine)
  • B - newly computed Hessian matrix to use with preconditioner (generally the same as H)

Options Database Key:

  • -tao_fd_hessian - activates TaoDefaultComputeHessian()

Level: advanced

See also: Tao, TaoSetHessian(), TaoDefaultComputeHessianColor(), SNESComputeJacobianDefault(), TaoSetGradient(), TaoDefaultComputeGradient()

External Links

source
PETSc.LibPETSc.TaoDefaultComputeHessianColor — Method
TaoDefaultComputeHessianColor(petsclib::PetscLibType, tao::AbstractTao, V::AbstractPetscVec, H::AbstractPetscMat, B::AbstractPetscMat, ctx::Ptr{Cvoid})

Computes the Hessian using colored finite differences.

Collective

Input Parameters:

  • tao - the Tao context
  • V - compute Hessian at this point
  • ctx - the color object of type MatFDColoring

Output Parameters:

  • H - Hessian matrix (not altered in this routine)
  • B - newly computed Hessian matrix to use with preconditioner (generally the same as H)

Level: advanced

See also: Tao, MatColoring, TaoSetHessian(), TaoDefaultComputeHessian(), SNESComputeJacobianDefaultColor(), TaoSetGradient()

External Links

source
PETSc.LibPETSc.TaoDefaultComputeHessianMFFD — Method
TaoDefaultComputeHessianMFFD(petsclib::PetscLibType, tao::AbstractTao, X::AbstractPetscVec, H::AbstractPetscMat, B::AbstractPetscMat, ctx::Ptr{Cvoid})

Computes the Hessian using finite differences with MATMFFD.

Collective

Input Parameters:

  • tao - the Tao context
  • X - compute Hessian at this point
  • ctx - ignored

Output Parameters:

  • H - Hessian matrix of type MATMFFD
  • B - should be NULL or equal to H

Level: advanced

See also: Tao, MATMFFD, MatCreateMFFD(), TaoTermCreateHessianMFFD()

External Links

source
PETSc.LibPETSc.TaoDefaultConvergenceTest — Method
TaoDefaultConvergenceTest(petsclib::PetscLibType, tao::AbstractTao, dummy::Ptr{Cvoid})

Determines whether the solver should continue iterating or terminate.

Collective

Input Parameters:

  • tao - the Tao context
  • dummy - unused dummy context

Level: developer

See also: Tao, TaoSetTolerances(), TaoGetConvergedReason(), TaoSetConvergedReason()

External Links

source
PETSc.LibPETSc.TaoDestroy — Method
TaoDestroy(petsclib::PetscLibType, tao::AbstractTao)

Destroys the Tao context that was created with TaoCreate()

Collective

Input Parameter:

  • tao - the Tao context

Level: beginner

See also: Tao, TaoCreate(), TaoSolve()

External Links

source
PETSc.LibPETSc.TaoEstimateActiveBounds — Method
bound_tol::PetscReal,active_lower::IS,active_upper::IS,active_fixed::IS,active::IS,inactive::IS = TaoEstimateActiveBounds(petsclib::PetscLibType, X::AbstractPetscVec, XL::AbstractPetscVec, XU::AbstractPetscVec, G::AbstractPetscVec, S::AbstractPetscVec, W::AbstractPetscVec, steplen::PetscReal)

Generates index sets for variables at the lower and upper bounds, as well as fixed variables where lower and upper bounds equal each other.

Input Parameters:

  • X - solution vector
  • XL - lower bound vector
  • XU - upper bound vector
  • G - unprojected gradient
  • S - step direction with which the active bounds will be estimated
  • W - work vector of type and size of X
  • steplen - the step length at which the active bounds will be estimated (needs to be conservative)

Output Parameters:

  • bound_tol - tolerance for the bound estimation
  • active_lower - index set for active variables at the lower bound
  • active_upper - index set for active variables at the upper bound
  • active_fixed - index set for fixed variables
  • active - index set for all active variables
  • inactive - complementary index set for inactive variables

Level: developer

See also: TAOBNCG, TAOBNTL, TAOBNTR, TaoBoundSolution()

External Links

source
PETSc.LibPETSc.TaoFinalizePackage — Method
TaoFinalizePackage(petsclib::PetscLibType)

This function destroys everything in the PETSc/Tao interface to the Tao package. It is called from PetscFinalize().

Level: developer

See also: TaoInitializePackage(), PetscFinalize(), TaoRegister(), TaoRegisterAll()

External Links

source
PETSc.LibPETSc.TaoGetADMMParentTao — Method
admm_tao::Tao = TaoGetADMMParentTao(petsclib::PetscLibType, tao::AbstractTao)

Gets pointer to parent TAOADMM, used by inner subsolver.

Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • admm_tao - the parent Tao context

Level: advanced

See also: TAOADMM

External Links

source
PETSc.LibPETSc.TaoGetApplicationContext — Method
ctx::Ptr{Cvoid} = TaoGetApplicationContext(petsclib::PetscLibType, tao::AbstractTao)

Gets the user-defined context for a Tao solver provided with TaoSetApplicationContext()

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • ctx - a pointer to the application context

Level: intermediate

See also: Tao, TaoSetApplicationContext()

External Links

source
PETSc.LibPETSc.TaoGetConstraintTolerances — Method
catol::PetscReal,crtol::PetscReal = TaoGetConstraintTolerances(petsclib::PetscLibType, tao::AbstractTao)

Gets constraint tolerance parameters used in TaoSolve() convergence tests

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • catol - absolute constraint tolerance, constraint norm must be less than catol for used for gatol convergence criteria
  • crtol - relative constraint tolerance, constraint norm must be less than crtol for used for gatol, gttol convergence criteria

Level: intermediate

See also: Tao, TaoConvergedReason, TaoGetTolerances(), TaoSetTolerances(), TaoSetConstraintTolerances()

External Links

source
PETSc.LibPETSc.TaoGetConvergedReason — Method
reason::TaoConvergedReason = TaoGetConvergedReason(petsclib::PetscLibType, tao::AbstractTao)

Gets the reason the TaoSolve() was stopped.

Not Collective

Input Parameter:

  • tao - the Tao solver context

Output Parameter:

  • reason - value of TaoConvergedReason

Level: intermediate

See also: Tao, TaoConvergedReason, TaoSetConvergenceTest(), TaoSetTolerances()

External Links

source
PETSc.LibPETSc.TaoGetConvergenceHistory — Method
obj::Ptr{PetscReal},resid::Ptr{PetscReal},cnorm::Ptr{PetscReal},lits::Ptr{PetscInt},nhist::PetscInt = TaoGetConvergenceHistory(petsclib::PetscLibType, tao::AbstractTao)

Gets the arrays used that hold the convergence history.

Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • obj - array used to hold objective value history
  • resid - array used to hold residual history
  • cnorm - array used to hold constraint violation history
  • lits - integer array used to hold linear solver iteration count
  • nhist - size of obj, resid, cnorm, and lits

Level: advanced

See also: Tao, TaoSolve(), TaoSetConvergenceHistory()

External Links

source
PETSc.LibPETSc.TaoGetCurrentFunctionEvaluations — Method
nfuncs::PetscInt = TaoGetCurrentFunctionEvaluations(petsclib::PetscLibType, tao::AbstractTao)

Get current number of function evaluations used by a Tao object

Not Collective

Input Parameter:

  • tao - the Tao solver context

Output Parameter:

  • nfuncs - the current number of function evaluations (maximum between gradient and function evaluations)

Level: intermediate

See also: Tao, TaoSetMaximumFunctionEvaluations(), TaoGetMaximumFunctionEvaluations(), TaoGetMaximumIterations()

External Links

source
PETSc.LibPETSc.TaoGetCurrentTrustRegionRadius — Method
radius::PetscReal = TaoGetCurrentTrustRegionRadius(petsclib::PetscLibType, tao::AbstractTao)

Gets the current trust region radius.

Not Collective

Input Parameter:

  • tao - a Tao optimization solver

Output Parameter:

  • radius - the trust region radius

Level: intermediate

See also: Tao, TaoSetInitialTrustRegionRadius(), TaoGetInitialTrustRegionRadius(), TAONTR

External Links

source
PETSc.LibPETSc.TaoGetDualVariables — Method
DE::PetscVec,DI::PetscVec = TaoGetDualVariables(petsclib::PetscLibType, tao::AbstractTao)

Gets the dual vectors

Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • DE - dual variable vector for the lower bounds
  • DI - dual variable vector for the upper bounds

Level: advanced

See also: Tao, TaoComputeDualVariables()

External Links

source
PETSc.LibPETSc.TaoGetEqualityConstraintsRoutine — Method
ci::PetscVec = TaoGetEqualityConstraintsRoutine(petsclib::PetscLibType, tao::AbstractTao, noname::Ptr{Cvoid})

Gets the function used to compute equality constraints.

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • ci - the vector to internally hold the constraint computation
  • func - the bounds computation routine
  • ctx - the (optional) user-defined context

Calling sequence of func:

  • tao - the Tao solver
  • x - point to evaluate equality constraints
  • ci - vector of equality constraints evaluated at x
  • ctx - the (optional) user-defined function context

Level: intermediate

See also: Tao, TaoSolve(), TaoGetObjective(), TaoGetGradient(), TaoGetHessian(), TaoGetObjectiveAndGradient(), TaoGetInequalityConstraintsRoutine()

External Links

source
PETSc.LibPETSc.TaoGetFunctionLowerBound — Method
fmin::PetscReal = TaoGetFunctionLowerBound(petsclib::PetscLibType, tao::AbstractTao)

Gets the bound on the solution objective value. When an approximate solution with an objective value below this number has been found, the solver will terminate.

Not Collective

Input Parameter:

  • tao - the Tao solver context

Output Parameter:

  • fmin - the minimum function value

Level: intermediate

See also: Tao, TaoConvergedReason, TaoSetFunctionLowerBound()

External Links

source
PETSc.LibPETSc.TaoGetGradient — Method
g::PetscVec = TaoGetGradient(petsclib::PetscLibType, tao::AbstractTao, noname::Ptr{Cvoid})

Gets the gradient evaluation routine for the function being optimized

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • g - the vector to internally hold the gradient computation
  • func - the gradient function
  • ctx - user-defined context for private data for the gradient evaluation routine

Calling sequence of func:

  • tao - the optimizer
  • x - input vector
  • g - gradient value (output)
  • ctx - [optional] user-defined function context

Level: beginner

See also: Tao, TaoSetObjective(), TaoSetHessian(), TaoSetObjectiveAndGradient(), TaoSetGradient()

External Links

source
PETSc.LibPETSc.TaoGetGradientNorm — Method
M::PetscMat = TaoGetGradientNorm(petsclib::PetscLibType, tao::AbstractTao)

Returns the matrix used to define the norm used for measuring the size of the gradient in some of the Tao algorithms

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • M - gradient norm

Level: beginner

See also: Tao, TaoSetGradientNorm(), TaoGradientNorm()

External Links

source
PETSc.LibPETSc.TaoGetHessian — Method
H::PetscMat,Hpre::PetscMat = TaoGetHessian(petsclib::PetscLibType, tao::AbstractTao, noname::Ptr{Cvoid})

Gets the function to compute the Hessian as well as the location to store the matrix.

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • H - Matrix used for the hessian
  • Hpre - Matrix that will be used to construct the preconditioner, can be the same as H
  • func - Hessian evaluation routine
  • ctx - user-defined context for private data for the Hessian evaluation routine

Calling sequence of func:

  • tao - the Tao context
  • x - input vector
  • H - Hessian matrix
  • Hpre - matrix used to construct the preconditioner, usually the same as H
  • ctx - [optional] user-defined Hessian context

Level: beginner

See also: Tao, TaoType, TaoGetObjective(), TaoGetGradient(), TaoGetObjectiveAndGradient(), TaoSetHessian(), TaoGetHessianMatrices()

External Links

source
PETSc.LibPETSc.TaoGetHessianMatrices — Method
H::PetscMat,Hpre::PetscMat = TaoGetHessianMatrices(petsclib::PetscLibType, tao::AbstractTao)

Get the matrices that store the Hessian matrix and its (optional) approximation that is used to construct the preconditioner

Not collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • H - the Hessian matrix
  • Hpre - approximation to the Hessian matrix used to construct the preconditioner (often H)

Level: intermediate

See also: Tao, TaoType, TaoGetObjective(), TaoGetGradient(), TaoGetObjectiveAndGradient(), TaoSetHessian(), TaoGetHessian()

External Links

source
PETSc.LibPETSc.TaoGetInequalityBounds — Method
IL::PetscVec,IU::PetscVec = TaoGetInequalityBounds(petsclib::PetscLibType, tao::AbstractTao)

Gets the upper and lower bounds set via TaoSetInequalityBounds()

Logically Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • IL - vector of lower bounds
  • IU - vector of upper bounds

Level: beginner

See also: TaoSetObjective(), TaoSetHessian(), TaoSetObjectiveAndGradient(), TaoSetInequalityBounds()

External Links

source
PETSc.LibPETSc.TaoGetInequalityConstraintsRoutine — Method
ci::PetscVec = TaoGetInequalityConstraintsRoutine(petsclib::PetscLibType, tao::AbstractTao, noname::Ptr{Cvoid})

Gets the function used to compute inequality constraints.

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • ci - the vector to internally hold the constraint computation
  • func - the bounds computation routine
  • ctx - the (optional) user-defined context

Calling sequence of func:

  • tao - the Tao solver
  • x - point to evaluate inequality constraints
  • ci - vector of inequality constraints evaluated at x
  • ctx - the (optional) user-defined function context

Level: intermediate

See also: Tao, TaoSolve(), TaoGetObjective(), TaoGetGradient(), TaoGetHessian(), TaoGetObjectiveAndGradient(), TaoGetEqualityConstraintsRoutine()

External Links

source
PETSc.LibPETSc.TaoGetInitialTrustRegionRadius — Method
radius::PetscReal = TaoGetInitialTrustRegionRadius(petsclib::PetscLibType, tao::AbstractTao)

Gets the initial trust region radius.

Not Collective

Input Parameter:

  • tao - a Tao optimization solver

Output Parameter:

  • radius - the trust region radius

Level: intermediate

See also: Tao, TaoSetInitialTrustRegionRadius(), TaoGetCurrentTrustRegionRadius(), TAONTR

External Links

source
PETSc.LibPETSc.TaoGetIterationNumber — Method
iter::PetscInt = TaoGetIterationNumber(petsclib::PetscLibType, tao::AbstractTao)

Gets the number of TaoSolve() iterations completed at this time.

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • iter - iteration number

See also: Tao, TaoGetLinearSolveIterations(), TaoGetResidualNorm(), TaoGetObjective()

External Links

source
PETSc.LibPETSc.TaoGetJacobianEqualityRoutine — Method
J::PetscMat,Jpre::PetscMat = TaoGetJacobianEqualityRoutine(petsclib::PetscLibType, tao::AbstractTao, noname::Ptr{Cvoid})

Gets the function used to compute equality constraint Jacobian.

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • J - the matrix to internally hold the constraint computation
  • Jpre - the matrix used to construct the preconditioner
  • func - Jacobian evaluation routine
  • ctx - the (optional) user-defined context

Calling sequence of func:

  • tao - the Tao context
  • x - input vector
  • J - Jacobian matrix
  • Jpre - matrix used to construct the preconditioner, usually the same as J
  • ctx - [optional] user-defined Jacobian context

Level: intermediate

See also: Tao, TaoComputeJacobianEquality(), TaoSetJacobianEqualityRoutine()

External Links

source
PETSc.LibPETSc.TaoGetJacobianInequalityRoutine — Method
J::PetscMat,Jpre::PetscMat = TaoGetJacobianInequalityRoutine(petsclib::PetscLibType, tao::AbstractTao, noname::Ptr{Cvoid})

Gets the function used to compute inequality constraint Jacobian.

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • J - the matrix to internally hold the constraint computation
  • Jpre - the matrix used to construct the preconditioner
  • func - Jacobian evaluation routine
  • ctx - the (optional) user-defined context

Calling sequence of func:

  • tao - the Tao context
  • x - input vector
  • J - Jacobian matrix
  • Jpre - matrix used to construct the preconditioner, usually the same as J
  • ctx - [optional] user-defined Jacobian context

Level: intermediate

See also: Tao, TaoComputeJacobianInequality(), TaoSetJacobianInequalityRoutine()

External Links

source
PETSc.LibPETSc.TaoGetKSP — Method
ksp::KSP = TaoGetKSP(petsclib::PetscLibType, tao::AbstractTao)

Gets the linear solver used by the optimization solver.

Not Collective

Input Parameter:

  • tao - the Tao solver

Output Parameter:

  • ksp - the KSP linear solver used in the optimization solver

Level: intermediate

See also: Tao, KSP

External Links

source
PETSc.LibPETSc.TaoGetLMVMMatrix — Method
B::PetscMat = TaoGetLMVMMatrix(petsclib::PetscLibType, tao::AbstractTao)

Returns a pointer to the internal LMVM matrix. Valid only for quasi-Newton family of methods.

Input Parameter:

  • tao - Tao solver context

Output Parameter:

  • B - LMVM matrix

Level: advanced

See also: TAOBQNLS, TAOBQNKLS, TAOBQNKTL, TAOBQNKTR, MATLMVM, TaoSetLMVMMatrix()

External Links

source
PETSc.LibPETSc.TaoGetLineSearch — Method
ls::TaoLineSearch = TaoGetLineSearch(petsclib::PetscLibType, tao::AbstractTao)

Gets the line search used by the optimization solver.

Not Collective

Input Parameter:

  • tao - the Tao solver

Output Parameter:

  • ls - the line search used in the optimization solver

Level: intermediate

See also: Tao, TaoLineSearch, TaoLineSearchType

External Links

source
PETSc.LibPETSc.TaoGetLinearSolveIterations — Method
lits::PetscInt = TaoGetLinearSolveIterations(petsclib::PetscLibType, tao::AbstractTao)

Gets the total number of linear iterations used by the Tao solver

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • lits - number of linear iterations

Level: intermediate

See also: Tao, TaoGetKSP()

External Links

source
PETSc.LibPETSc.TaoGetMaximumFunctionEvaluations — Method
nfcn::PetscInt = TaoGetMaximumFunctionEvaluations(petsclib::PetscLibType, tao::AbstractTao)

Gets a maximum number of function evaluations allowed for a TaoSolve()

Logically Collective

Input Parameter:

  • tao - the Tao solver context

Output Parameter:

  • nfcn - the maximum number of function evaluations

Level: intermediate

See also: Tao, TaoSetMaximumFunctionEvaluations(), TaoGetMaximumIterations()

External Links

source
PETSc.LibPETSc.TaoGetMaximumIterations — Method
maxits::PetscInt = TaoGetMaximumIterations(petsclib::PetscLibType, tao::AbstractTao)

Gets a maximum number of iterates that will be used

Not Collective

Input Parameter:

  • tao - the Tao solver context

Output Parameter:

  • maxits - the maximum number of iterates

Level: intermediate

See also: Tao, TaoSetMaximumIterations(), TaoGetMaximumFunctionEvaluations()

External Links

source
PETSc.LibPETSc.TaoGetObjective — Method
TaoGetObjective(petsclib::PetscLibType, tao::AbstractTao, noname::Ptr{Cvoid})

Gets the function evaluation routine for the function to be minimized

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • func - the objective function
  • ctx - the user-defined context for private data for the function evaluation

Calling sequence of func:

  • tao - the optimizer
  • x - input vector
  • f - function value
  • ctx - [optional] user-defined function context

Level: beginner

See also: Tao, TaoSetGradient(), TaoSetHessian(), TaoSetObjective()

External Links

source
PETSc.LibPETSc.TaoGetObjectiveAndGradient — Method
g::PetscVec = TaoGetObjectiveAndGradient(petsclib::PetscLibType, tao::AbstractTao, noname::Ptr{Cvoid})

Gets the combined objective function and gradient evaluation routine for the function to be optimized

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • g - the vector to internally hold the gradient computation
  • func - the gradient function
  • ctx - user-defined context for private data for the gradient evaluation routine

Calling sequence of func:

  • tao - the optimizer
  • x - input vector
  • f - objective value (output)
  • g - gradient value (output)
  • ctx - [optional] user-defined function context

Level: beginner

See also: Tao, TaoSolve(), TaoSetObjective(), TaoSetGradient(), TaoSetHessian(), TaoSetObjectiveAndGradient()

External Links

source
PETSc.LibPETSc.TaoGetOptionsPrefix — Method
p::String = TaoGetOptionsPrefix(petsclib::PetscLibType, tao::AbstractTao)

Gets the prefix used for searching for all Tao options in the database

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • p - pointer to the prefix string used is returned

Level: advanced

See also: Tao, TaoSetFromOptions(), TaoSetOptionsPrefix(), TaoAppendOptionsPrefix()

External Links

source
PETSc.LibPETSc.TaoGetRecycleHistory — Method
recycle::PetscBool = TaoGetRecycleHistory(petsclib::PetscLibType, tao::AbstractTao)

Retrieve the boolean flag for re-using iterate information from the previous TaoSolve(). This feature is disabled by default.

Logically Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • recycle - boolean flag

Level: intermediate

See also: Tao, TaoSetRecycleHistory(), TAOBNCG, TAOBQNLS, TAOBQNKLS, TAOBQNKTR, TAOBQNKTL

External Links

source
PETSc.LibPETSc.TaoGetResidualNorm — Method
value::PetscReal = TaoGetResidualNorm(petsclib::PetscLibType, tao::AbstractTao)

Gets the current value of the norm of the residual (gradient) at this time.

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • value - the current value

Level: intermediate

See also: Tao, TaoGetLinearSolveIterations(), TaoGetIterationNumber(), TaoGetObjective()

External Links

source
PETSc.LibPETSc.TaoGetSolution — Method
X::PetscVec = TaoGetSolution(petsclib::PetscLibType, tao::AbstractTao)

Returns the vector with the current solution from the Tao object

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • X - the current solution

Level: intermediate

See also: Tao, TaoSetSolution(), TaoSolve()

External Links

source
PETSc.LibPETSc.TaoGetSolutionStatus — Method
its::PetscInt,f::PetscReal,gnorm::PetscReal,cnorm::PetscReal,xdiff::PetscReal,reason::TaoConvergedReason = TaoGetSolutionStatus(petsclib::PetscLibType, tao::AbstractTao)

Get the current iterate, objective value, residual, infeasibility, and termination from a Tao object

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • its - the current iterate number (>=0)
  • f - the current function value
  • gnorm - the square of the gradient norm, duality gap, or other measure indicating distance from optimality.
  • cnorm - the infeasibility of the current solution with regard to the constraints.
  • xdiff - the step length or trust region radius of the most recent iterate.
  • reason - The termination reason, which can equal TAO_CONTINUE_ITERATING

Level: intermediate

See also: TaoMonitor(), TaoGetConvergedReason()

External Links

source
PETSc.LibPETSc.TaoGetTerm — Method
scale::PetscReal,term::TaoTerm,params::PetscVec,map::PetscMat = TaoGetTerm(petsclib::PetscLibType, tao::AbstractTao)

Get the entire objective function of the Tao as a single TaoTerm in the form \alpha f(Ax; p), where \alpha is a scaling coefficient, f is a TaoTerm, A is an (optional) map and p are the parameters of f.

Not collective

Input Parameter:

  • tao - a Tao context

Output Parameters:

  • scale - the scale of the term
  • term - a TaoTerm for the real-valued function defining the objective
  • params - the vector of parameters for term, or NULL if no parameters were specified for term
  • map - a map from the solution space of tao to the solution space of term, if NULL then the map is the identity

Level: intermediate

See also: Tao, TaoTerm, TAOTERMSUM, TaoAddTerm()

External Links

source
PETSc.LibPETSc.TaoGetTolerances — Method
gatol::PetscReal,grtol::PetscReal,gttol::PetscReal = TaoGetTolerances(petsclib::PetscLibType, tao::AbstractTao)

gets the current values of some tolerances used for the convergence testing of TaoSolve()

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • gatol - stop if norm of gradient is less than this
  • grtol - stop if relative norm of gradient is less than this
  • gttol - stop if norm of gradient is reduced by a this factor

Level: intermediate

See also: Tao, TaoSetTolerances()

External Links

source
PETSc.LibPETSc.TaoGetTotalIterationNumber — Method
iter::PetscInt = TaoGetTotalIterationNumber(petsclib::PetscLibType, tao::AbstractTao)

Gets the total number of TaoSolve() iterations completed. This number keeps accumulating if multiple solves are called with the Tao object.

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • iter - number of iterations

Level: intermediate

See also: Tao, TaoGetLinearSolveIterations()

External Links

source
PETSc.LibPETSc.TaoGetType — Method
type::String = TaoGetType(petsclib::PetscLibType, tao::AbstractTao)

Gets the current TaoType being used in the Tao object

Not Collective

Input Parameter:

  • tao - the Tao solver context

Output Parameter:

  • type - the TaoType

Level: intermediate

See also: Tao, TaoType, TaoSetType(), PetscObjectTypeCompare(), PetscObjectTypeCompareAny()

External Links

source
PETSc.LibPETSc.TaoGetVariableBounds — Method
XL::PetscVec,XU::PetscVec = TaoGetVariableBounds(petsclib::PetscLibType, tao::AbstractTao)

Gets the upper and lower bounds vectors set with TaoSetVariableBounds()

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameters:

  • XL - vector of lower bounds
  • XU - vector of upper bounds

Level: beginner

See also: Tao, TaoSetObjective(), TaoSetHessian(), TaoSetObjectiveAndGradient(), TaoSetVariableBounds()

External Links

source
PETSc.LibPETSc.TaoGradientNorm — Method
gnorm::PetscReal = TaoGradientNorm(petsclib::PetscLibType, tao::AbstractTao, gradient::AbstractPetscVec, type::NormType)

Compute the norm using the NormType, the user has selected

Collective

Input Parameters:

  • tao - the Tao context
  • gradient - the gradient
  • type - the norm type

Output Parameter:

  • gnorm - the gradient norm

Level: advanced

See also: Tao, TaoSetGradientNorm(), TaoGetGradientNorm()

External Links

source
PETSc.LibPETSc.TaoInitializePackage — Method
TaoInitializePackage(petsclib::PetscLibType)

This function sets up PETSc to use the Tao package. When using static or shared libraries, this function is called from the first entry to TaoCreate(); when using shared or static libraries, it is called from PetscDLLibraryRegister_tao()

Level: developer

See also: TaoCreate(), TaoFinalizePackage(), TaoRegister(), TaoRegisterAll()

External Links

source
PETSc.LibPETSc.TaoIsGradientDefined — Method
flg::PetscBool = TaoIsGradientDefined(petsclib::PetscLibType, tao::AbstractTao)

Checks to see if the user has declared a gradient-only routine. Useful for determining when it is appropriate to call TaoComputeGradient() or TaoComputeObjectiveAndGradient()

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • flg - PETSC_TRUE if the objective TaoTerm has this routine, PETSC_FALSE otherwise

Level: developer

See also: TaoSetGradient(), TaoIsObjectiveDefined(), TaoIsObjectiveAndGradientDefined()

External Links

source
PETSc.LibPETSc.TaoIsObjectiveAndGradientDefined — Method
flg::PetscBool = TaoIsObjectiveAndGradientDefined(petsclib::PetscLibType, tao::AbstractTao)

Checks to see if the user has declared a joint objective/gradient routine. Useful for determining when it is appropriate to call TaoComputeObjectiveAndGradient()

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • flg - PETSC_TRUE if the objective TaoTerm has this routine PETSC_FALSE otherwise

Level: developer

See also: TaoSetObjectiveAndGradient(), TaoIsObjectiveDefined(), TaoIsGradientDefined()

External Links

source
PETSc.LibPETSc.TaoIsObjectiveDefined — Method
flg::PetscBool = TaoIsObjectiveDefined(petsclib::PetscLibType, tao::AbstractTao)

Checks to see if the user has declared an objective-only routine. Useful for determining when it is appropriate to call TaoComputeObjective() or TaoComputeObjectiveAndGradient()

Not Collective

Input Parameter:

  • tao - the Tao context

Output Parameter:

  • flg - PETSC_TRUE if the Tao has this routine PETSC_FALSE otherwise

Level: developer

See also: Tao, TaoSetObjective(), TaoIsGradientDefined(), TaoIsObjectiveAndGradientDefined()

External Links

source
PETSc.LibPETSc.TaoKSPSetUseEW — Method
TaoKSPSetUseEW(petsclib::PetscLibType, tao::AbstractTao, flag::PetscBool)

Sets SNES to use Eisenstat-Walker method {cite}ew96 for computing relative tolerance for linear solvers.

Logically Collective

Input Parameters:

  • tao - Tao context
  • flag - PETSC_TRUE or PETSC_FALSE

Level: advanced

See also: Tao, SNESKSPSetUseEW()

External Links

source
PETSc.LibPETSc.TaoLMVMGetH0 — Method
H0::PetscMat = TaoLMVMGetH0(petsclib::PetscLibType, tao::AbstractTao)

Get the matrix object for the QN initial Hessian

Input Parameter:

  • tao - the Tao solver context

Output Parameter:

  • H0 - Mat object for the initial Hessian

Level: advanced

See also: Tao, TAOLMVM, TAOBLMVM, TaoLMVMSetH0(), TaoLMVMGetH0KSP()

External Links

source
PETSc.LibPETSc.TaoLMVMGetH0KSP — Method
ksp::KSP = TaoLMVMGetH0KSP(petsclib::PetscLibType, tao::AbstractTao)

Get the iterative solver for applying the inverse of the QN initial Hessian

Input Parameter:

  • tao - the Tao solver context

Output Parameter:

  • ksp - KSP solver context for the initial Hessian

Level: advanced

See also: Tao, TAOLMVM, TAOBLMVM, TaoLMVMGetH0()

External Links

source
PETSc.LibPETSc.TaoLMVMRecycle — Method
TaoLMVMRecycle(petsclib::PetscLibType, tao::AbstractTao, flg::PetscBool)

Enable/disable recycling of the QN history between subsequent TaoSolve() calls.

Input Parameters:

  • tao - the Tao solver context
  • flg - Boolean flag for recycling (PETSC_TRUE or PETSC_FALSE)

Level: intermediate

See also: Tao, TAOLMVM, TAOBLMVM

External Links

source
PETSc.LibPETSc.TaoLMVMSetH0 — Method
TaoLMVMSetH0(petsclib::PetscLibType, tao::AbstractTao, H0::AbstractPetscMat)

Set the initial Hessian for the QN approximation

Input Parameters:

  • tao - the Tao solver context
  • H0 - Mat object for the initial Hessian

Level: advanced

See also: Tao, TAOLMVM, TAOBLMVM, TaoLMVMGetH0(), TaoLMVMGetH0KSP()

External Links

source
PETSc.LibPETSc.TaoMatGetSubMat — Method
Msub::PetscMat = TaoMatGetSubMat(petsclib::PetscLibType, M::AbstractPetscMat, is::AbstractIS, v1::AbstractPetscVec, subset_type::TaoSubsetType)

Gets a submatrix using the IS

Input Parameters:

  • M - the full matrix (n x n)
  • is - the index set for the submatrix (both row and column index sets need to be the same)
  • v1 - work vector of dimension n, needed for TAO_SUBSET_MASK option
  • subset_type - the method Tao is using for subsetting

Output Parameter:

  • Msub - the submatrix

Level: developer

See also: TaoVecGetSubVec(), TaoSubsetType

External Links

source
PETSc.LibPETSc.TaoMonitor — Method
TaoMonitor(petsclib::PetscLibType, tao::AbstractTao, its::PetscInt, f::PetscReal, res::PetscReal, cnorm::PetscReal, steplength::PetscReal)

Monitor the solver and the current solution. This routine will record the iteration number and residual statistics, and call any monitors specified by the user.

Input Parameters:

  • tao - the Tao context
  • its - the current iterate number (>=0)
  • f - the current objective function value
  • res - the gradient norm, square root of the duality gap, or other measure indicating distance from optimality. This measure will be recorded and

used for some termination tests.

  • cnorm - the infeasibility of the current solution with regard to the constraints.
  • steplength - multiple of the step direction added to the previous iterate.

Options Database Key:

  • -tao_monitor - Use the default monitor, which prints statistics to standard output

Level: developer

See also: Tao, TaoGetConvergedReason(), TaoMonitorDefault(), TaoMonitorSet()

External Links

source
PETSc.LibPETSc.TaoMonitorCancel — Method
TaoMonitorCancel(petsclib::PetscLibType, tao::AbstractTao)

Clears all the monitor functions for a Tao object.

Logically Collective

Input Parameter:

  • tao - the Tao solver context

Options Database Key:

  • -tao_monitor_cancel - cancels all monitors that have been hardwired

into a code by calls to TaoMonitorSet(), but does not cancel those set via the options database

Level: advanced

See also: Tao, TaoMonitorDefault(), TaoMonitorSet()

External Links

source
PETSc.LibPETSc.TaoMonitorConstraintNorm — Method
TaoMonitorConstraintNorm(petsclib::PetscLibType, tao::AbstractTao, vf::Vector{PetscViewerAndFormat})

same as TaoMonitorDefault() except it prints the norm of the constraint function.

Collective

Input Parameters:

  • tao - the Tao context
  • vf - PetscViewerAndFormat context

Options Database Key:

  • -tao_monitor_constraint_norm - monitor the constraints

Level: advanced

See also: Tao, TaoMonitorDefault(), TaoMonitorSet()

External Links

source
PETSc.LibPETSc.TaoMonitorDefault — Method
TaoMonitorDefault(petsclib::PetscLibType, tao::AbstractTao, vf::Vector{PetscViewerAndFormat})

Default routine for monitoring progress of TaoSolve()

Collective

Input Parameters:

  • tao - the Tao context
  • vf - PetscViewerAndFormat context

Options Database Key:

  • -tao_monitor - turn on default monitoring

Level: advanced

See also: Tao, TaoMonitorDefaultShort(), TaoMonitorSet()

External Links

source
PETSc.LibPETSc.TaoMonitorDefaultShort — Method
TaoMonitorDefaultShort(petsclib::PetscLibType, tao::AbstractTao, vf::Vector{PetscViewerAndFormat})

Routine for monitoring progress of TaoSolve() that displays fewer digits than TaoMonitorDefault()

Collective

Input Parameters:

  • tao - the Tao context
  • vf - PetscViewerAndFormat context

Options Database Key:

  • -tao_monitor_short - turn on default short monitoring

Level: advanced

See also: Tao, TaoMonitorDefault(), TaoMonitorSet()

External Links

source
PETSc.LibPETSc.TaoMonitorGlobalization — Method
TaoMonitorGlobalization(petsclib::PetscLibType, tao::AbstractTao, vf::Vector{PetscViewerAndFormat})

Default routine for monitoring progress of TaoSolve() with extra detail on the globalization method.

Collective

Input Parameters:

  • tao - the Tao context
  • vf - PetscViewerAndFormat context

Options Database Key:

  • -tao_monitor_globalization - turn on monitoring with globalization information

Level: advanced

See also: Tao, TaoMonitorDefaultShort(), TaoMonitorSet()

External Links

source
PETSc.LibPETSc.TaoMonitorGradient — Method
TaoMonitorGradient(petsclib::PetscLibType, tao::AbstractTao, vf::Vector{PetscViewerAndFormat})

Views the gradient at each iteration of TaoSolve()

Collective

Input Parameters:

  • tao - the Tao context
  • vf - PetscViewerAndFormat context

Options Database Key:

  • -tao_monitor_gradient - view the gradient at each iteration

Level: advanced

See also: Tao, TaoMonitorDefaultShort(), TaoMonitorSet()

External Links

source
PETSc.LibPETSc.TaoMonitorGradientDraw — Method
TaoMonitorGradientDraw(petsclib::PetscLibType, tao::AbstractTao, ctx::Ptr{Cvoid})

Plots the gradient at each iteration of TaoSolve()

Collective

Input Parameters:

  • tao - the Tao context
  • ctx - PetscViewer context

Options Database Key:

  • -tao_monitor_gradient_draw - draw the gradient at each iteration

Level: advanced

See also: Tao, TaoMonitorGradient(), TaoMonitorSet(), TaoMonitorSolutionDraw()

External Links

source
PETSc.LibPETSc.TaoMonitorResidual — Method
TaoMonitorResidual(petsclib::PetscLibType, tao::AbstractTao, vf::Vector{PetscViewerAndFormat})

Views the least-squares residual at each iteration of TaoSolve()

Collective

Input Parameters:

  • tao - the Tao context
  • vf - PetscViewerAndFormat context

Options Database Key:

  • -tao_monitor_ls_residual - view the residual at each iteration

Level: advanced

See also: Tao, TaoMonitorDefaultShort(), TaoMonitorSet()

External Links

source
PETSc.LibPETSc.TaoMonitorSet — Method
TaoMonitorSet(petsclib::PetscLibType, tao::AbstractTao, func::external, ctx::Ptr{Cvoid}, dest::Ptr{Cvoid})

Sets an additional function that is to be used at every iteration of the solver to display the iteration's progress.

Logically Collective

Input Parameters:

  • tao - the Tao solver context
  • func - monitoring routine
  • ctx - [optional] user-defined context for private data for the monitor routine (may be NULL)
  • dest - [optional] function to destroy the context when the Tao is destroyed, see PetscCtxDestroyFn for the calling sequence

Calling sequence of func:

  • tao - the Tao solver context
  • ctx - [optional] monitoring context

Level: intermediate

See also: Tao, TaoSolve(), TaoMonitorDefault(), TaoMonitorCancel(), TaoView(), PetscCtxDestroyFn

External Links

source
PETSc.LibPETSc.TaoMonitorSetFromOptions — Method
TaoMonitorSetFromOptions(petsclib::PetscLibType, tao::AbstractTao, name::String, help::String, manual::String, monitor::external)

Sets a monitor function and viewer appropriate for the type indicated by the user

Collective

Input Parameters:

  • tao - Tao object you wish to monitor
  • name - the monitor type one is seeking
  • help - message indicating what monitoring is done
  • manual - manual page for the monitor
  • monitor - the monitor function, this must use a PetscViewerFormat as its context

Level: developer

See also: Tao, TaoMonitorSet(), PetscOptionsCreateViewer(), PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHeadBegin(), PetscOptionsStringArray(), PetscOptionsRealArray(), PetscOptionsScalar(), PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), PetscOptionsFList(), PetscOptionsEList()

External Links

source
PETSc.LibPETSc.TaoMonitorSolution — Method
TaoMonitorSolution(petsclib::PetscLibType, tao::AbstractTao, vf::Vector{PetscViewerAndFormat})

Views the solution at each iteration of TaoSolve()

Collective

Input Parameters:

  • tao - the Tao context
  • vf - PetscViewerAndFormat context

Options Database Key:

  • -tao_monitor_solution - view the solution

Level: advanced

See also: Tao, TaoMonitorDefaultShort(), TaoMonitorSet()

External Links

source
PETSc.LibPETSc.TaoMonitorSolutionDraw — Method
TaoMonitorSolutionDraw(petsclib::PetscLibType, tao::AbstractTao, ctx::Ptr{Cvoid})

Plots the solution at each iteration of TaoSolve()

Collective

Input Parameters:

  • tao - the Tao context
  • ctx - TaoMonitorDraw context

Options Database Key:

  • -tao_monitor_solution_draw - draw the solution at each iteration

Level: advanced

See also: Tao, TaoMonitorSolution(), TaoMonitorSet(), TaoMonitorGradientDraw(), TaoMonitorDrawCtxCreate(), TaoMonitorDrawCtxDestroy()

External Links

source
PETSc.LibPETSc.TaoMonitorStep — Method
TaoMonitorStep(petsclib::PetscLibType, tao::AbstractTao, vf::Vector{PetscViewerAndFormat})

Views the step-direction at each iteration of TaoSolve()

Collective

Input Parameters:

  • tao - the Tao context
  • vf - PetscViewerAndFormat context

Options Database Key:

  • -tao_monitor_step - view the step vector at each iteration

Level: advanced

See also: Tao, TaoMonitorDefaultShort(), TaoMonitorSet()

External Links

source
PETSc.LibPETSc.TaoMonitorStepDraw — Method
TaoMonitorStepDraw(petsclib::PetscLibType, tao::AbstractTao, ctx::Ptr{Cvoid})

Plots the step direction at each iteration of TaoSolve()

Collective

Input Parameters:

  • tao - the Tao context
  • ctx - the PetscViewer context

Options Database Key:

  • -tao_monitor_step_draw - draw the step direction at each iteration

Level: advanced

See also: Tao, TaoMonitorSet(), TaoMonitorSolutionDraw

External Links

source
PETSc.LibPETSc.TaoParametersInitialize — Method
TaoParametersInitialize(petsclib::PetscLibType, tao::AbstractTao)

Sets all the parameters in tao to their default value (when TaoCreate() was called) if they currently contain default values. Default values are the parameter values when the object's type is set.

Collective

Input Parameter:

  • tao - the Tao object

Level: developer

See also: Tao, TaoSolve(), TaoDestroy(), PetscObjectParameterSetDefault()

External Links

source
PETSc.LibPETSc.TaoPythonGetType — Method
pyname::String = TaoPythonGetType(petsclib::PetscLibType, tao::AbstractTao)

Get the type of a Tao object implemented in Python.

Not Collective

Input Parameter:

  • tao - the optimization solver (Tao) context.

Output Parameter:

  • pyname - full dotted Python name [package].module[.{class|function}]

Level: intermediate

See also: TaoCreate(), TaoSetType(), TAOPYTHON, PetscPythonInitialize(), TaoPythonSetType()

External Links

source
PETSc.LibPETSc.TaoPythonSetType — Method
TaoPythonSetType(petsclib::PetscLibType, tao::AbstractTao, pyname::String)

Initialize a Tao object implemented in Python.

Collective

Input Parameters:

  • tao - the optimization solver (Tao) context.
  • pyname - full dotted Python name [package].module[.{class|function}]

Options Database Key:

  • -tao_python_type pyname - python class

Level: intermediate

See also: TaoCreate(), TaoSetType(), TAOPYTHON, PetscPythonInitialize()

External Links

source
PETSc.LibPETSc.TaoRegister — Method
TaoRegister(petsclib::PetscLibType, sname::String, func::external)

Adds a method to the Tao package for minimization.

Not Collective, No Fortran Support

Input Parameters:

  • sname - name of a new user-defined solver
  • func - routine to create TaoType specific method context

Calling sequence of func:

  • tao - the Tao object to be created

See also: Tao, TaoSetType(), TaoRegisterAll(), TaoRegisterDestroy()

External Links

source
PETSc.LibPETSc.TaoResetStatistics — Method
TaoResetStatistics(petsclib::PetscLibType, tao::AbstractTao)

Initialize the statistics collected by the Tao object. These statistics include the iteration number, residual norms, and convergence status. This routine gets called before solving each optimization problem.

Collective

Input Parameter:

  • tao - the Tao context

Level: developer

See also: Tao, TaoCreate(), TaoSolve()

External Links

source
PETSc.LibPETSc.TaoSetApplicationContext — Method
TaoSetApplicationContext(petsclib::PetscLibType, tao::AbstractTao, ctx::Ptr{Cvoid})

Sets the optional user-defined context for a Tao solver that can be accessed later, for example in the Tao callback functions with TaoGetApplicationContext()

Logically Collective

Input Parameters:

  • tao - the Tao context
  • ctx - the application context

Level: intermediate

See also: Tao, TaoGetApplicationContext()

External Links

source
PETSc.LibPETSc.TaoSetConstraintTolerances — Method
TaoSetConstraintTolerances(petsclib::PetscLibType, tao::AbstractTao, catol::PetscReal, crtol::PetscReal)

Sets constraint tolerance parameters used in TaoSolve() convergence tests

Logically Collective

Input Parameters:

  • tao - the Tao context
  • catol - absolute constraint tolerance, constraint norm must be less than catol for used for gatol convergence criteria
  • crtol - relative constraint tolerance, constraint norm must be less than crtol for used for gatol, gttol convergence criteria

Options Database Keys:

  • -tao_catol catol - Sets catol
  • -tao_crtol crtol - Sets crtol

Level: intermediate

See also: Tao, TaoConvergedReason, TaoGetTolerances(), TaoGetConstraintTolerances(), TaoSetTolerances()

External Links

source
PETSc.LibPETSc.TaoSetConstraintsRoutine — Method
TaoSetConstraintsRoutine(petsclib::PetscLibType, tao::AbstractTao, c::AbstractPetscVec, func::external, ctx::Ptr{Cvoid})

Sets a function to be used to compute constraints. Tao only handles constraints under certain conditions, see for details

Logically Collective

Input Parameters:

  • tao - the Tao context
  • c - A vector that will be used to store constraint evaluation
  • func - the bounds computation routine
  • ctx - [optional] user-defined context for private data for the constraints computation (may be NULL)

Calling sequence of func:

  • tao - the Tao solver
  • x - point to evaluate constraints
  • c - vector constraints evaluated at x
  • ctx - the (optional) user-defined function context

Level: intermediate

See also: Tao, TaoSetObjective(), TaoSetHessian(), TaoSetObjectiveAndGradient(), TaoSetVariablevBounds()

External Links

source
PETSc.LibPETSc.TaoSetConvergedReason — Method
TaoSetConvergedReason(petsclib::PetscLibType, tao::AbstractTao, reason::TaoConvergedReason)

Sets the termination flag on a Tao object

Logically Collective

Input Parameters:

  • tao - the Tao context
  • reason - the TaoConvergedReason

Level: intermediate

See also: Tao, TaoConvergedReason

External Links

source
PETSc.LibPETSc.TaoSetConvergenceHistory — Method
TaoSetConvergenceHistory(petsclib::PetscLibType, tao::AbstractTao, obj::Vector{PetscReal}, resid::Vector{PetscReal}, cnorm::Vector{PetscReal}, lits::Vector{PetscInt}, na::PetscInt, reset::PetscBool)

Sets the array used to hold the convergence history.

Logically Collective

Input Parameters:

  • tao - the Tao solver context
  • obj - array to hold objective value history
  • resid - array to hold residual history
  • cnorm - array to hold constraint violation history
  • lits - integer array holds the number of linear iterations for each Tao iteration
  • na - size of obj, resid, and cnorm
  • reset - PETSC_TRUE indicates each new minimization resets the history counter to zero,

else it continues storing new values for new minimizations after the old ones

Level: intermediate

See also: TaoGetConvergenceHistory()

External Links

source
PETSc.LibPETSc.TaoSetConvergenceTest — Method
TaoSetConvergenceTest(petsclib::PetscLibType, tao::AbstractTao, conv::external, ctx::Ptr{Cvoid})

Sets the function that is to be used to test for convergence of the iterative minimization solution. The new convergence testing routine will replace Tao's default convergence test.

Logically Collective

Input Parameters:

  • tao - the Tao object
  • conv - the routine to test for convergence
  • ctx - [optional] context for private data for the convergence routine (may be NULL)

Calling sequence of conv:

  • tao - the Tao object
  • ctx - [optional] convergence context

Level: advanced

See also: Tao, TaoSolve(), TaoSetConvergedReason(), TaoGetSolutionStatus(), TaoGetTolerances(), TaoMonitorSet()

External Links

source
PETSc.LibPETSc.TaoSetEqualityConstraintsRoutine — Method
TaoSetEqualityConstraintsRoutine(petsclib::PetscLibType, tao::AbstractTao, ce::AbstractPetscVec, func::external, ctx::Ptr{Cvoid})

Sets a function to be used to compute constraints. Tao only handles constraints under certain conditions, see for details

Logically Collective

Input Parameters:

  • tao - the Tao context
  • ce - A vector that will be used to store equality constraint evaluation
  • func - the bounds computation routine
  • ctx - [optional] user-defined context for private data for the equality constraints computation (may be NULL)

Calling sequence of func:

  • tao - the Tao solver
  • x - point to evaluate equality constraints
  • ce - vector of equality constraints evaluated at x
  • ctx - the (optional) user-defined function context

Level: intermediate

See also: Tao, TaoSetObjective(), TaoSetHessian(), TaoSetObjectiveAndGradient(), TaoSetVariableBounds()

External Links

source
PETSc.LibPETSc.TaoSetFromOptions — Method
TaoSetFromOptions(petsclib::PetscLibType, tao::AbstractTao)

Sets various Tao parameters from the options database

Collective

Input Parameter:

  • tao - the Tao solver context

Options Database Keys:

  • -tao_type type - The algorithm that Tao uses (lmvm, nls, etc.). See TAOType
  • -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 radius - initial trust region radius
  • -tao_view_solution - view the solution at the end of the optimization process
  • -tao_monitor - prints function value and residual norm at each iteration
  • -tao_monitor_short - same as -tao_monitor, but truncates very small values
  • -tao_monitor_constraint_norm - prints objective value, gradient, and constraint norm at each iteration
  • -tao_monitor_globalization - prints information about the globalization at each iteration
  • -tao_monitor_solution - prints solution vector at each iteration
  • -tao_monitor_ls_residual - prints least-squares residual vector at each iteration
  • -tao_monitor_step - prints step vector at each iteration
  • -tao_monitor_gradient - prints gradient vector at each iteration
  • -tao_monitor_solution_draw - graphically view solution vector at each iteration
  • -tao_monitor_step_draw - graphically view step vector at each iteration
  • -tao_monitor_gradient_draw - graphically view gradient at each iteration
  • -tao_monitor_cancel - cancels all monitors (except those set with command line)
  • -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. No TaoTerm support
  • -tao_view - prints information about the Tao after solving
  • -tao_converged_reason - prints the reason Tao stopped iterating
  • -tao_add_terms - takes a comma-separated list of up to 16 options prefixes, a TaoTerm will be created for each and added to the objective function

Level: beginner

See also: Tao, TaoCreate(), TaoSolve()

External Links

source
PETSc.LibPETSc.TaoSetFunctionLowerBound — Method
TaoSetFunctionLowerBound(petsclib::PetscLibType, tao::AbstractTao, fmin::PetscReal)

Sets a bound on the solution objective value. When an approximate solution with an objective value below this number has been found, the solver will terminate.

Logically Collective

Input Parameters:

  • tao - the Tao solver context
  • fmin - the tolerance

Options Database Key:

  • -tao_fmin fmin - sets the minimum function value

Level: intermediate

See also: Tao, TaoConvergedReason, TaoSetTolerances()

External Links

source
PETSc.LibPETSc.TaoSetGradient — Method
TaoSetGradient(petsclib::PetscLibType, tao::AbstractTao, g::AbstractPetscVec, func::external, ctx::Ptr{Cvoid})

Sets the gradient evaluation routine for the function to be optimized

Logically Collective

Input Parameters:

  • tao - the Tao context
  • g - [optional] the vector to internally hold the gradient computation
  • func - the gradient function
  • ctx - [optional] user-defined context for private data for the gradient evaluation

routine (may be NULL)

Calling sequence of func:

  • tao - the optimization solver
  • x - input vector
  • g - gradient value (output)
  • ctx - [optional] user-defined function context

Level: beginner

See also: Tao, TaoSolve(), TaoSetObjective(), TaoSetHessian(), TaoSetObjectiveAndGradient(), TaoGetGradient()

External Links

source
PETSc.LibPETSc.TaoSetGradientNorm — Method
TaoSetGradientNorm(petsclib::PetscLibType, tao::AbstractTao, M::AbstractPetscMat)

Sets the matrix used to define the norm that measures the size of the gradient in some of the Tao algorithms

Collective

Input Parameters:

  • tao - the Tao context
  • M - matrix that defines the norm

Level: beginner

See also: Tao, TaoGetGradientNorm(), TaoGradientNorm()

External Links

source
PETSc.LibPETSc.TaoSetHessian — Method
TaoSetHessian(petsclib::PetscLibType, tao::AbstractTao, H::AbstractPetscMat, Hpre::AbstractPetscMat, func::external, ctx::Ptr{Cvoid})

Sets the function to compute the Hessian as well as the location to store the matrix.

Logically Collective

Input Parameters:

  • tao - the Tao context
  • H - Matrix used for the hessian
  • Hpre - Matrix that will be used to construct the preconditioner, can be same as H
  • func - Hessian evaluation routine
  • ctx - [optional] user-defined context for private data for the

Hessian evaluation routine (may be NULL)

Calling sequence of func:

  • tao - the Tao context
  • x - input vector
  • H - Hessian matrix
  • Hpre - matrix used to construct the preconditioner, usually the same as H
  • ctx - [optional] user-defined Hessian context

Level: beginner

See also: Tao, TaoType, TaoSetObjective(), TaoSetGradient(), TaoSetObjectiveAndGradient(), TaoGetHessian()

External Links

source
PETSc.LibPETSc.TaoSetInequalityBounds — Method
TaoSetInequalityBounds(petsclib::PetscLibType, tao::AbstractTao, IL::AbstractPetscVec, IU::AbstractPetscVec)

Sets the upper and lower bounds

Logically Collective

Input Parameters:

  • tao - the Tao context
  • IL - vector of lower bounds
  • IU - vector of upper bounds

Level: beginner

See also: Tao, TaoSetObjective(), TaoSetHessian(), TaoSetObjectiveAndGradient(), TaoGetInequalityBounds()

External Links

source
PETSc.LibPETSc.TaoSetInequalityConstraintsRoutine — Method
TaoSetInequalityConstraintsRoutine(petsclib::PetscLibType, tao::AbstractTao, ci::AbstractPetscVec, func::external, ctx::Ptr{Cvoid})

Sets a function to be used to compute constraints. Tao only handles constraints under certain conditions, see for details

Logically Collective

Input Parameters:

  • tao - the Tao context
  • ci - A vector that will be used to store inequality constraint evaluation
  • func - the bounds computation routine
  • ctx - [optional] user-defined context for private data for the inequality constraints computation (may be NULL)

Calling sequence of func:

  • tao - the Tao solver
  • x - point to evaluate inequality constraints
  • ci - vector of inequality constraints evaluated at x
  • ctx - the (optional) user-defined function context

Level: intermediate

See also: Tao, TaoSetObjective(), TaoSetHessian(), TaoSetObjectiveAndGradient(), TaoSetVariableBounds()

External Links

source
PETSc.LibPETSc.TaoSetInitialTrustRegionRadius — Method
TaoSetInitialTrustRegionRadius(petsclib::PetscLibType, tao::AbstractTao, radius::PetscReal)

Sets the initial trust region radius.

Logically Collective

Input Parameters:

  • tao - a Tao optimization solver
  • radius - the trust region radius

Options Database Key:

  • -tao_trust0 radius - sets initial trust region radius

Level: intermediate

See also: Tao, TaoGetTrustRegionRadius(), TaoSetTrustRegionTolerance(), TAONTR

External Links

source
PETSc.LibPETSc.TaoSetIterationNumber — Method
TaoSetIterationNumber(petsclib::PetscLibType, tao::AbstractTao, iter::PetscInt)

Sets the current iteration number.

Logically Collective

Input Parameters:

  • tao - the Tao context
  • iter - iteration number

Level: developer

See also: Tao, TaoGetLinearSolveIterations()

External Links

source
PETSc.LibPETSc.TaoSetJacobianDesignRoutine — Method
TaoSetJacobianDesignRoutine(petsclib::PetscLibType, tao::AbstractTao, J::AbstractPetscMat, func::external, ctx::Ptr{Cvoid})

Sets the function to compute the Jacobian of the constraint function with respect to the design variables. Used only for PDE-constrained optimization.

Logically Collective

Input Parameters:

  • tao - the Tao context
  • J - Matrix used for the Jacobian
  • func - Jacobian evaluation routine
  • ctx - [optional] user-defined context for private data for the

Jacobian evaluation routine (may be NULL)

Calling sequence of func:

  • tao - the Tao context
  • x - input vector
  • J - Jacobian matrix
  • ctx - [optional] user-defined Jacobian context

Level: intermediate

See also: Tao, TaoComputeJacobianDesign(), TaoSetJacobianStateRoutine(), TaoSetStateDesignIS()

External Links

source
PETSc.LibPETSc.TaoSetJacobianEqualityRoutine — Method
TaoSetJacobianEqualityRoutine(petsclib::PetscLibType, tao::AbstractTao, J::AbstractPetscMat, Jpre::AbstractPetscMat, func::external, ctx::Ptr{Cvoid})

Sets the function to compute the Jacobian (and its inverse) of the constraint function with respect to the equality variables. Used only for PDE-constrained optimization.

Logically Collective

Input Parameters:

  • tao - the Tao context
  • J - Matrix used for the Jacobian
  • Jpre - Matrix that will be used to construct the preconditioner, can be same as J.
  • func - Jacobian evaluation routine
  • ctx - [optional] user-defined context for private data for the

Jacobian evaluation routine (may be NULL)

Calling sequence of func:

  • tao - the Tao context
  • x - input vector
  • J - Jacobian matrix
  • Jpre - matrix used to construct the preconditioner, usually the same as J
  • ctx - [optional] user-defined Jacobian context

Level: intermediate

See also: Tao, TaoComputeJacobianEquality(), TaoSetJacobianDesignRoutine(), TaoSetEqualityDesignIS()

External Links

source
PETSc.LibPETSc.TaoSetJacobianInequalityRoutine — Method
TaoSetJacobianInequalityRoutine(petsclib::PetscLibType, tao::AbstractTao, J::AbstractPetscMat, Jpre::AbstractPetscMat, func::external, ctx::Ptr{Cvoid})

Sets the function to compute the Jacobian (and its inverse) of the constraint function with respect to the inequality variables. Used only for PDE-constrained optimization.

Logically Collective

Input Parameters:

  • tao - the Tao context
  • J - Matrix used for the Jacobian
  • Jpre - Matrix that will be used to construct the preconditioner, can be same as J.
  • func - Jacobian evaluation routine
  • ctx - [optional] user-defined context for private data for the

Jacobian evaluation routine (may be NULL)

Calling sequence of func:

  • tao - the Tao context
  • x - input vector
  • J - Jacobian matrix
  • Jpre - matrix used to construct the preconditioner, usually the same as J
  • ctx - [optional] user-defined Jacobian context

Level: intermediate

See also: Tao, TaoComputeJacobianInequality(), TaoSetJacobianDesignRoutine(), TaoSetInequalityDesignIS()

External Links

source
PETSc.LibPETSc.TaoSetJacobianResidualRoutine — Method
TaoSetJacobianResidualRoutine(petsclib::PetscLibType, tao::AbstractTao, J::AbstractPetscMat, Jpre::AbstractPetscMat, func::external, ctx::Ptr{Cvoid})

Sets the function to compute the least-squares residual Jacobian as well as the location to store the matrix.

Logically Collective

Input Parameters:

  • tao - the Tao context
  • J - Matrix used for the jacobian
  • Jpre - Matrix that will be used to construct the preconditioner, can be same as J
  • func - Jacobian evaluation routine
  • ctx - [optional] user-defined context for private data for the

Jacobian evaluation routine (may be NULL)

Calling sequence of func:

  • tao - the Tao context
  • x - input vector
  • J - Jacobian matrix
  • Jpre - matrix used to construct the preconditioner, usually the same as J
  • ctx - [optional] user-defined Jacobian context

Level: intermediate

See also: Tao, TaoSetGradient(), TaoSetObjective()

External Links

source
PETSc.LibPETSc.TaoSetJacobianRoutine — Method
TaoSetJacobianRoutine(petsclib::PetscLibType, tao::AbstractTao, J::AbstractPetscMat, Jpre::AbstractPetscMat, func::external, ctx::Ptr{Cvoid})

Sets the function to compute the Jacobian as well as the location to store the matrix.

Logically Collective

Input Parameters:

  • tao - the Tao context
  • J - Matrix used for the Jacobian
  • Jpre - Matrix that will be used to construct the preconditioner, can be same as J
  • func - Jacobian evaluation routine
  • ctx - [optional] user-defined context for private data for the

Jacobian evaluation routine (may be NULL)

Calling sequence of func:

  • tao - the Tao context
  • x - input vector
  • J - Jacobian matrix
  • Jpre - matrix used to construct the preconditioner, usually the same as J
  • ctx - [optional] user-defined Jacobian context

Level: intermediate

See also: Tao, TaoSetGradient(), TaoSetObjective()

External Links

source
PETSc.LibPETSc.TaoSetJacobianStateRoutine — Method
TaoSetJacobianStateRoutine(petsclib::PetscLibType, tao::AbstractTao, J::AbstractPetscMat, Jpre::AbstractPetscMat, Jinv::AbstractPetscMat, func::external, ctx::Ptr{Cvoid})

Sets the function to compute the Jacobian (and its inverse) of the constraint function with respect to the state variables. Used only for PDE-constrained optimization.

Logically Collective

Input Parameters:

  • tao - the Tao context
  • J - Matrix used for the Jacobian
  • Jpre - Matrix that will be used to construct the preconditioner, can be same as J. Only used if Jinv is NULL
  • Jinv - [optional] Matrix used to apply the inverse of the state Jacobian. Use NULL to default to PETSc KSP solvers to apply the inverse.
  • func - Jacobian evaluation routine
  • ctx - [optional] user-defined context for private data for the

Jacobian evaluation routine (may be NULL)

Calling sequence of func:

  • tao - the Tao context
  • x - input vector
  • J - Jacobian matrix
  • Jpre - matrix used to construct the preconditioner, usually the same as J
  • Jinv - inverse of J
  • ctx - [optional] user-defined Jacobian context

Level: intermediate

See also: Tao, TaoComputeJacobianState(), TaoSetJacobianDesignRoutine(), TaoSetStateDesignIS()

External Links

source
PETSc.LibPETSc.TaoSetLMVMMatrix — Method
TaoSetLMVMMatrix(petsclib::PetscLibType, tao::AbstractTao, B::AbstractPetscMat)

Sets an external LMVM matrix into the Tao solver. Valid only for quasi-Newton family of methods.

QN family of methods create their own LMVM matrices and users who wish to manipulate this matrix should use TaoGetLMVMMatrix() instead.

Input Parameters:

  • tao - Tao solver context
  • B - LMVM matrix

Level: advanced

See also: TAOBQNLS, TAOBQNKLS, TAOBQNKTL, TAOBQNKTR, MATLMVM, TaoGetLMVMMatrix()

External Links

source
PETSc.LibPETSc.TaoSetMaximumFunctionEvaluations — Method
TaoSetMaximumFunctionEvaluations(petsclib::PetscLibType, tao::AbstractTao, nfcn::PetscInt)

Sets a maximum number of function evaluations allowed for a TaoSolve().

Logically Collective

Input Parameters:

  • tao - the Tao solver context
  • nfcn - the maximum number of function evaluations (>=0), use PETSC_UNLIMITED to have no bound

Options Database Key:

  • -tao_max_funcs nfcn - sets the maximum number of function evaluations

Level: intermediate

See also: Tao, TaoSetTolerances(), TaoSetMaximumIterations()

External Links

source
PETSc.LibPETSc.TaoSetMaximumIterations — Method
TaoSetMaximumIterations(petsclib::PetscLibType, tao::AbstractTao, maxits::PetscInt)

Sets a maximum number of iterates to be used in TaoSolve()

Logically Collective

Input Parameters:

  • tao - the Tao solver context
  • maxits - the maximum number of iterates (>=0), use PETSC_UNLIMITED to have no bound

Options Database Key:

  • -tao_max_it its - sets the maximum number of iterations

Level: intermediate

See also: Tao, TaoSetTolerances(), TaoSetMaximumFunctionEvaluations()

External Links

source
PETSc.LibPETSc.TaoSetObjective — Method
TaoSetObjective(petsclib::PetscLibType, tao::AbstractTao, func::external, ctx::Ptr{Cvoid})

Sets the function evaluation routine for minimization

Logically Collective

Input Parameters:

  • tao - the Tao context
  • func - the objective function
  • ctx - [optional] user-defined context for private data for the function evaluation

routine (may be NULL)

Calling sequence of func:

  • tao - the optimizer
  • x - input vector
  • f - function value
  • ctx - [optional] user-defined function context

Level: beginner

See also: TaoSetGradient(), TaoSetHessian(), TaoSetObjectiveAndGradient(), TaoGetObjective()

External Links

source
PETSc.LibPETSc.TaoSetObjectiveAndGradient — Method
TaoSetObjectiveAndGradient(petsclib::PetscLibType, tao::AbstractTao, g::AbstractPetscVec, func::external, ctx::Ptr{Cvoid})

Sets a combined objective function and gradient evaluation routine for the function to be optimized

Logically Collective

Input Parameters:

  • tao - the Tao context
  • g - [optional] the vector to internally hold the gradient computation
  • func - the gradient function
  • ctx - [optional] user-defined context for private data for the gradient evaluation

routine (may be NULL)

Calling sequence of func:

  • tao - the optimization object
  • x - input vector
  • f - objective value (output)
  • g - gradient value (output)
  • ctx - [optional] user-defined function context

Level: beginner

See also: Tao, TaoSolve(), TaoSetObjective(), TaoSetHessian(), TaoSetGradient(), TaoGetObjectiveAndGradient()

External Links

source
PETSc.LibPETSc.TaoSetOptionsPrefix — Method
TaoSetOptionsPrefix(petsclib::PetscLibType, tao::AbstractTao, p::String)

Sets the prefix used for searching for all Tao options in the database.

Logically Collective

Input Parameters:

  • tao - the Tao context
  • p - the prefix string to prepend to all Tao option requests

Level: advanced

See also: Tao, TaoSetFromOptions(), TaoAppendOptionsPrefix(), TaoGetOptionsPrefix()

External Links

source
PETSc.LibPETSc.TaoSetRecycleHistory — Method
TaoSetRecycleHistory(petsclib::PetscLibType, tao::AbstractTao, recycle::PetscBool)

Sets the boolean flag to enable/disable re-using iterate information from the previous TaoSolve(). This feature is disabled by default.

Logically Collective

Input Parameters:

  • tao - the Tao context
  • recycle - boolean flag

Options Database Key:

  • -tao_recycle_history (true|false) - reuse the history

Level: intermediate

See also: Tao, TaoGetRecycleHistory(), TAOBNCG, TAOBQNLS, TAOBQNKLS, TAOBQNKTR, TAOBQNKTL

External Links

source
PETSc.LibPETSc.TaoSetResidualRoutine — Method
TaoSetResidualRoutine(petsclib::PetscLibType, tao::AbstractTao, res::AbstractPetscVec, func::external, ctx::Ptr{Cvoid})

Sets the residual evaluation routine for least-square applications

Logically Collective

Input Parameters:

  • tao - the Tao context
  • res - the residual vector
  • func - the residual evaluation routine
  • ctx - [optional] user-defined context for private data for the function evaluation

routine (may be NULL)

Calling sequence of func:

  • tao - the optimizer
  • x - input vector
  • res - function value vector
  • ctx - [optional] user-defined function context

Level: beginner

See also: Tao, TaoSetObjective(), TaoSetJacobianRoutine()

External Links

source
PETSc.LibPETSc.TaoSetResidualWeights — Method
rows::PetscInt,cols::PetscInt,vals::PetscReal = TaoSetResidualWeights(petsclib::PetscLibType, tao::AbstractTao, sigma_v::AbstractPetscVec, n::PetscInt)

Give weights for the residual values. A vector can be used if only diagonal terms are used, otherwise a matrix can be give.

Collective

Input Parameters:

  • tao - the Tao context
  • sigma_v - vector of weights (diagonal terms only)
  • n - the number of weights (if using off-diagonal)
  • rows - index list of rows for sigma_v
  • cols - index list of columns for sigma_v
  • vals - array of weights

Level: intermediate

See also: Tao, TaoSetResidualRoutine()

External Links

source
PETSc.LibPETSc.TaoSetSolution — Method
TaoSetSolution(petsclib::PetscLibType, tao::AbstractTao, x0::AbstractPetscVec)

Sets the vector holding the initial guess for the solve

Logically Collective

Input Parameters:

  • tao - the Tao context
  • x0 - the initial guess

Level: beginner

See also: Tao, TaoCreate(), TaoSolve(), TaoGetSolution()

External Links

source
PETSc.LibPETSc.TaoSetStateDesignIS — Method
TaoSetStateDesignIS(petsclib::PetscLibType, tao::AbstractTao, s_is::AbstractIS, d_is::AbstractIS)

Indicate to the Tao object which variables in the solution vector are state variables and which are design. Only applies to PDE-constrained optimization.

Logically Collective

Input Parameters:

  • tao - The Tao context
  • s_is - the index set corresponding to the state variables
  • d_is - the index set corresponding to the design variables

Level: intermediate

See also: Tao, TaoSetJacobianStateRoutine(), TaoSetJacobianDesignRoutine()

External Links

source
PETSc.LibPETSc.TaoSetTolerances — Method
TaoSetTolerances(petsclib::PetscLibType, tao::AbstractTao, gatol::PetscReal, grtol::PetscReal, gttol::PetscReal)

Sets parameters used in TaoSolve() convergence tests

Logically Collective

Input Parameters:

  • tao - the Tao context
  • gatol - stop if norm of gradient is less than this
  • grtol - stop if relative norm of gradient is less than this
  • gttol - stop if norm of gradient is reduced by this factor

Options Database Keys:

  • -tao_gatol gatol - Sets gatol
  • -tao_grtol grtol - Sets grtol
  • -tao_gttol gttol - Sets gttol

Stopping Criteria: $||g(X)|| <= gatol ||g(X)|| / |f(X)| <= grtol ||g(X)|| / ||g(X0)|| <= gttol$

Level: beginner

See also: Tao, TaoConvergedReason, TaoGetTolerances()

External Links

source
PETSc.LibPETSc.TaoSetTotalIterationNumber — Method
TaoSetTotalIterationNumber(petsclib::PetscLibType, tao::AbstractTao, iter::PetscInt)

Sets the current total iteration number.

Logically Collective

Input Parameters:

  • tao - the Tao context
  • iter - the iteration number

Level: developer

See also: Tao, TaoGetLinearSolveIterations()

External Links

source
PETSc.LibPETSc.TaoSetType — Method
TaoSetType(petsclib::PetscLibType, tao::AbstractTao, type::String)

Sets the TaoType for the minimization solver.

Collective

Input Parameters:

  • tao - the Tao solver context
  • type - a known method

Options Database Key:

  • -tao_type type - Sets the method; see TaoType

Level: intermediate

See also: Tao, TaoCreate(), TaoGetType(), TaoType

External Links

source
PETSc.LibPETSc.TaoSetUp — Method
TaoSetUp(petsclib::PetscLibType, tao::AbstractTao)

Sets up the internal data structures for the later use of a Tao solver

Collective

Input Parameter:

  • tao - the Tao context

Level: advanced

See also: Tao, TaoCreate(), TaoSolve()

External Links

source
PETSc.LibPETSc.TaoSetUpdate — Method
TaoSetUpdate(petsclib::PetscLibType, tao::AbstractTao, func::external, ctx::Ptr{Cvoid})

Sets the general-purpose update function called at the beginning of every iteration of the optimization algorithm. Called after the new solution and the gradient is determined, but before the Hessian is computed (if applicable).

Logically Collective

Input Parameters:

  • tao - The Tao solver
  • func - The function
  • ctx - The update function context

Calling sequence of func:

  • tao - The optimizer context
  • it - The current iteration index
  • ctx - The update context

Level: advanced

See also: Tao, TaoSolve()

External Links

source
PETSc.LibPETSc.TaoSetVariableBounds — Method
TaoSetVariableBounds(petsclib::PetscLibType, tao::AbstractTao, XL::AbstractPetscVec, XU::AbstractPetscVec)

Sets the upper and lower bounds for the optimization problem

Logically Collective

Input Parameters:

  • tao - the Tao context
  • XL - vector of lower bounds
  • XU - vector of upper bounds

Level: beginner

See also: Tao, TaoSetObjective(), TaoSetHessian(), TaoSetObjectiveAndGradient(), TaoGetVariableBounds()

External Links

source
PETSc.LibPETSc.TaoSetVariableBoundsRoutine — Method
TaoSetVariableBoundsRoutine(petsclib::PetscLibType, tao::AbstractTao, func::external, ctx::Ptr{Cvoid})

Sets a function to be used to compute lower and upper variable bounds for the optimization

Logically Collective

Input Parameters:

  • tao - the Tao context
  • func - the bounds computation routine
  • ctx - [optional] user-defined context for private data for the bounds computation (may be NULL)

Calling sequence of func:

  • tao - the Tao solver
  • xl - vector of lower bounds
  • xu - vector of upper bounds
  • ctx - the (optional) user-defined function context

Level: beginner

See also: Tao, TaoSetObjective(), TaoSetHessian(), TaoSetObjectiveAndGradient(), TaoSetVariableBounds()

External Links

source
PETSc.LibPETSc.TaoShellGetContext — Method
ctx::Ptr{Cvoid} = TaoShellGetContext(petsclib::PetscLibType, tao::AbstractTao)

Returns the user-provided context associated with a TAOSHELL

Not Collective

Input Parameter:

  • tao - should have been created with TaoSetType(tao,TAOSHELL);

Output Parameter:

  • ctx - the user provided context

Level: advanced

See also: Tao, TAOSHELL, TaoShellSetContext()

External Links

source
PETSc.LibPETSc.TaoShellSetContext — Method
TaoShellSetContext(petsclib::PetscLibType, tao::AbstractTao, ctx::Ptr{Cvoid})

sets the context for a TAOSHELL

Logically Collective

Input Parameters:

  • tao - the shell Tao
  • ctx - the context

Level: advanced

See also: Tao, TAOSHELL, TaoShellGetContext()

External Links

source
PETSc.LibPETSc.TaoShellSetSolve — Method
TaoShellSetSolve(petsclib::PetscLibType, tao::AbstractTao, solve::external)

Sets routine to apply as solver

Logically Collective

Input Parameters:

  • tao - the nonlinear solver context
  • solve - the application-provided solver routine

Calling sequence of solve:

  • tao - the optimizer, get the application context with TaoShellGetContext()

Level: advanced

See also: Tao, TAOSHELL, TaoShellSetContext(), TaoShellGetContext()

External Links

source
PETSc.LibPETSc.TaoSoftThreshold — Method
TaoSoftThreshold(petsclib::PetscLibType, in::AbstractPetscVec, lb::PetscReal, ub::PetscReal, out::AbstractPetscVec)

Calculates soft thresholding routine with input vector and given lower and upper bound and returns it to output vector.

Collective

Input Parameters:

  • in - input vector to be thresholded
  • lb - lower bound
  • ub - upper bound

Output Parameter:

  • out - Soft thresholded output vector

See also: Tao, Vec

External Links

source
PETSc.LibPETSc.TaoSolve — Method
TaoSolve(petsclib::PetscLibType, tao::AbstractTao)

Solves an optimization problem min F(x) s.t. l <= x <= u

Collective

Input Parameter:

  • tao - the Tao context

Level: beginner

See also: Tao, TaoCreate(), TaoSetObjective(), TaoSetGradient(), TaoSetHessian(), TaoGetConvergedReason(), TaoSetUp()

External Links

source
PETSc.LibPETSc.TaoTestGradient — Method
TaoTestGradient(petsclib::PetscLibType, tao::AbstractTao, x::AbstractPetscVec, g1::AbstractPetscVec)

Compare the user-supplied gradient with a finite-difference approximation, when requested via the options database, and print the difference.

Collective

Input Parameters:

  • tao - the Tao context
  • x - the point at which to evaluate the gradient
  • g1 - the user-supplied gradient at x

Options Database Keys:

  • -tao_test_gradient - enable the comparison
  • -tao_test_gradient_view - display the user-supplied gradient, the finite-difference gradient, and their difference

Level: intermediate

See also: Tao, TaoTestHessian(), TaoComputeGradient()

External Links

source
PETSc.LibPETSc.TaoTestHessian — Method
TaoTestHessian(petsclib::PetscLibType, tao::AbstractTao)

Compare the user-supplied Hessian with a finite-difference approximation, when requested via the options database, and print the difference.

Collective

Input Parameter:

  • tao - the Tao context

Options Database Keys:

  • -tao_test_hessian threshold - enable the comparison, optionally overriding the reporting threshold (default 1e-5)
  • -tao_test_hessian_view - display the user-supplied Hessian, the finite-difference Hessian, and their difference

Level: intermediate

See also: Tao, TaoTestGradient(), TaoComputeHessian()

External Links

source
PETSc.LibPETSc.TaoVecGetSubVec — Method
vreduced::PetscVec = TaoVecGetSubVec(petsclib::PetscLibType, vfull::AbstractPetscVec, is::AbstractIS, reduced_type::TaoSubsetType, maskvalue::PetscReal)

Gets a subvector using the IS

Input Parameters:

  • vfull - the full matrix
  • is - the index set for the subvector
  • reduced_type - the method Tao is using for subsetting
  • maskvalue - the value to set the unused vector elements to (for TAO_SUBSET_MASK or TAO_SUBSET_MATRIXFREE)

Output Parameter:

  • vreduced - the subvector

Level: developer

See also: TaoMatGetSubMat(), TaoSubsetType

External Links

source
PETSc.LibPETSc.TaoView — Method
TaoView(petsclib::PetscLibType, tao::AbstractTao, viewer::PetscViewer)

Prints information about the Tao object

Collective

Input Parameters:

  • tao - the Tao context
  • viewer - visualization context

Options Database Key:

  • -tao_view - Calls TaoView() at the end of TaoSolve()

Level: beginner

See also: Tao, PetscViewerASCIIOpen()

External Links

source
PETSc.LibPETSc.TaoViewFromOptions — Method
TaoViewFromOptions(petsclib::PetscLibType, A::AbstractTao, obj, name::String)

View a Tao object based on values in the options database

Collective

Input Parameters:

  • A - the Tao context
  • obj - Optional object that provides the prefix for the options database
  • name - command line option

Options Database Key:

  • -name [viewertype][:...] - option name and values. See PetscObjectViewFromOptions() for the possible arguments

Level: intermediate

See also: Tao, TaoView, PetscObjectViewFromOptions(), TaoCreate()

External Links

source

Tao Add-ons

Additional Tao utilities and helper functions:

PETSc.LibPETSc.TaoLineSearchAppendOptionsPrefix — Method
TaoLineSearchAppendOptionsPrefix(petsclib::PetscLibType, ls::TaoLineSearch, p::String)

Appends to the prefix used for searching for all TaoLineSearch options in the database.

Collective

Input Parameters:

  • ls - the TaoLineSearch solver context
  • p - the prefix string to prepend to all line search requests

Level: advanced

See also: Tao, TaoLineSearch, TaoLineSearchSetOptionsPrefix(), TaoLineSearchGetOptionsPrefix()

External Links

source
PETSc.LibPETSc.TaoLineSearchApply — Method
f::PetscReal,steplength::PetscReal,reason::TaoLineSearchConvergedReason = TaoLineSearchApply(petsclib::PetscLibType, ls::TaoLineSearch, x::AbstractPetscVec, g::AbstractPetscVec, s::AbstractPetscVec)

Performs a line-search in a given step direction. Criteria for acceptable step length depends on the line-search algorithm chosen

Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • s - search direction

Output Parameters:

  • x - On input the current solution, on output x contains the new solution determined by the line search
  • f - On input the objective function value at current solution, on output contains the objective function value at new solution
  • g - On input the gradient evaluated at x, on output contains the gradient at new solution
  • steplength - scalar multiplier of s used ( x = x_0 + steplength * x)
  • reason - TaoLineSearchConvergedReason reason why the line-search stopped

Level: advanced

See also: Tao, TaoLineSearchConvergedReason, TaoLineSearch, TaoLineSearchCreate(), TaoLineSearchSetType(), TaoLineSearchSetInitialStepLength(), TaoAddLineSearchCounts()

External Links

source
PETSc.LibPETSc.TaoLineSearchComputeGradient — Method
TaoLineSearchComputeGradient(petsclib::PetscLibType, ls::TaoLineSearch, x::AbstractPetscVec, g::AbstractPetscVec)

Computes the gradient of the objective function

Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • x - input vector

Output Parameter:

  • g - gradient vector

Level: developer

See also: Tao, TaoLineSearch, TaoLineSearchComputeObjective(), TaoLineSearchComputeObjectiveAndGradient(), TaoLineSearchSetGradient()

External Links

source
PETSc.LibPETSc.TaoLineSearchComputeObjective — Method
f::PetscReal = TaoLineSearchComputeObjective(petsclib::PetscLibType, ls::TaoLineSearch, x::AbstractPetscVec)

Computes the objective function value at a given point

Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • x - input vector

Output Parameter:

  • f - Objective value at x

Level: developer

See also: Tao, TaoLineSearch, TaoLineSearchComputeGradient(), TaoLineSearchComputeObjectiveAndGradient(), TaoLineSearchSetObjectiveRoutine()

External Links

source
PETSc.LibPETSc.TaoLineSearchComputeObjectiveAndGTS — Method
f::PetscReal,gts::PetscReal = TaoLineSearchComputeObjectiveAndGTS(petsclib::PetscLibType, ls::TaoLineSearch, x::AbstractPetscVec)

Computes the objective function value and inner product of gradient and step direction at a given point

Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • x - input vector

Output Parameters:

  • f - Objective value at x
  • gts - inner product of gradient and step direction at x

Level: developer

See also: Tao, TaoLineSearch, TaoLineSearchComputeGradient(), TaoLineSearchComputeObjectiveAndGradient(), TaoLineSearchSetObjectiveRoutine()

External Links

source
PETSc.LibPETSc.TaoLineSearchComputeObjectiveAndGradient — Method
f::PetscReal = TaoLineSearchComputeObjectiveAndGradient(petsclib::PetscLibType, ls::TaoLineSearch, x::AbstractPetscVec, g::AbstractPetscVec)

Computes the objective function value at a given point

Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • x - input vector

Output Parameters:

  • f - Objective value at x
  • g - Gradient vector at x

Level: developer

See also: Tao, TaoLineSearch, TaoLineSearchComputeGradient(), TaoLineSearchSetObjectiveRoutine()

External Links

source
PETSc.LibPETSc.TaoLineSearchCreate — Method
newls::TaoLineSearch = TaoLineSearchCreate(petsclib::PetscLibType, comm::MPI_Comm)

Creates a TaoLineSearch object. Algorithms in Tao that use line-searches will automatically create one so this all is rarely needed

Collective

Input Parameter:

  • comm - MPI communicator

Output Parameter:

  • newls - the new TaoLineSearch context

Options Database Key:

  • -tao_ls_type (unit|more-thuente|gpcg|armijo|owarmijo|ipm) - select which line search Tao should use

Level: developer

See also: Tao, TaoLineSearch, TaoLineSearchType, TaoLineSearchSetType(), TaoLineSearchApply(), TaoLineSearchDestroy()

External Links

source
PETSc.LibPETSc.TaoLineSearchDestroy — Method
TaoLineSearchDestroy(petsclib::PetscLibType, ls::Union{TaoLineSearch, Ref{TaoLineSearch}})

Destroys the TaoLineSearch context that was created with TaoLineSearchCreate()

Collective

Input Parameter:

  • ls - the TaoLineSearch context

Level: developer

See also: TaoLineSearch, TaoLineSearchCreate(), TaoLineSearchApple()

External Links

source
PETSc.LibPETSc.TaoLineSearchGetFullStepObjective — Method
f_fullstep::PetscReal = TaoLineSearchGetFullStepObjective(petsclib::PetscLibType, ls::TaoLineSearch)

Returns the objective function value at the full step. Useful for some minimization algorithms.

Not Collective

Input Parameter:

  • ls - the TaoLineSearch context

Output Parameter:

  • f_fullstep - the objective value at the full step length

Level: developer

See also: TaoLineSearchGetSolution(), TaoLineSearchGetStartingVector(), TaoLineSearchGetStepDirection()

External Links

source
PETSc.LibPETSc.TaoLineSearchGetNumberFunctionEvaluations — Method
nfeval::PetscInt,ngeval::PetscInt,nfgeval::PetscInt = TaoLineSearchGetNumberFunctionEvaluations(petsclib::PetscLibType, ls::TaoLineSearch)

Gets the number of function and gradient evaluation routines used by the line search in last application (not cumulative).

Not Collective

Input Parameter:

  • ls - the TaoLineSearch context

Output Parameters:

  • nfeval - number of function evaluations
  • ngeval - number of gradient evaluations
  • nfgeval - number of function/gradient evaluations

Level: intermediate

See also: TaoLineSearch

External Links

source
PETSc.LibPETSc.TaoLineSearchGetOptionsPrefix — Method
p::String = TaoLineSearchGetOptionsPrefix(petsclib::PetscLibType, ls::TaoLineSearch)

Gets the prefix used for searching for all TaoLineSearch options in the database

Not Collective

Input Parameter:

  • ls - the TaoLineSearch context

Output Parameter:

  • p - pointer to the prefix string used is returned

Level: advanced

See also: Tao, TaoLineSearch, TaoLineSearchSetOptionsPrefix(), TaoLineSearchAppendOptionsPrefix()

External Links

source
PETSc.LibPETSc.TaoLineSearchGetSolution — Method
f::PetscReal,steplength::PetscReal,reason::TaoLineSearchConvergedReason = TaoLineSearchGetSolution(petsclib::PetscLibType, ls::TaoLineSearch, x::AbstractPetscVec, g::AbstractPetscVec)

Returns the solution to the line search

Collective

Input Parameter:

  • ls - the TaoLineSearch context

Output Parameters:

  • x - the new solution
  • f - the objective function value at x
  • g - the gradient at x
  • steplength - the multiple of the step direction taken by the line search
  • reason - the reason why the line search terminated

Level: developer

See also: TaoLineSearchGetStartingVector(), TaoLineSearchGetStepDirection()

External Links

source
PETSc.LibPETSc.TaoLineSearchGetStepLength — Method
s::PetscReal = TaoLineSearchGetStepLength(petsclib::PetscLibType, ls::TaoLineSearch)

Get the current step length

Not Collective

Input Parameter:

  • ls - the TaoLineSearch context

Output Parameter:

  • s - the current step length

Level: intermediate

See also: Tao, TaoLineSearch, TaoLineSearchSetInitialStepLength(), TaoLineSearchApply()

External Links

source
PETSc.LibPETSc.TaoLineSearchGetType — Method
type::String = TaoLineSearchGetType(petsclib::PetscLibType, ls::TaoLineSearch)

Gets the current line search algorithm

Not Collective

Input Parameter:

  • ls - the TaoLineSearch context

Output Parameter:

  • type - the line search algorithm in effect

Level: developer

See also: TaoLineSearch, TaoLineSearchSetType(), TaoLineSearchType, PetscObjectTypeCompare(), PetscObjectTypeCompareAny()

External Links

source
PETSc.LibPETSc.TaoLineSearchInitializePackage — Method
TaoLineSearchInitializePackage(petsclib::PetscLibType)

This function registers the line-search algorithms in Tao. When using shared or static libraries, this function is called from the first entry to TaoCreate(); when using dynamic, it is called from PetscDLLibraryRegister_tao()

Level: developer

See also: Tao, TaoLineSearch, TaoLineSearchCreate()

External Links

source
PETSc.LibPETSc.TaoLineSearchIsUsingTaoRoutines — Method
flg::PetscBool = TaoLineSearchIsUsingTaoRoutines(petsclib::PetscLibType, ls::TaoLineSearch)

Checks whether the line search is using the standard Tao evaluation routines.

Not Collective

Input Parameter:

  • ls - the TaoLineSearch context

Output Parameter:

  • flg - PETSC_TRUE if the line search is using Tao evaluation routines,

otherwise PETSC_FALSE

Level: developer

See also: TaoLineSearch

External Links

source
PETSc.LibPETSc.TaoLineSearchMonitor — Method
TaoLineSearchMonitor(petsclib::PetscLibType, ls::TaoLineSearch, its::PetscInt, f::PetscReal, step::PetscReal)

Monitor the line search steps. This routine will output the iteration number, step length, and function value before calling the implementation specific monitor.

Input Parameters:

  • ls - the TaoLineSearch context
  • its - the current iterate number (>=0)
  • f - the current objective function value
  • step - the step length

Options Database Key:

  • -tao_ls_monitor - Use the default monitor, which prints statistics to standard output

Level: developer

See also: TaoLineSearch

External Links

source
PETSc.LibPETSc.TaoLineSearchRegister — Method
TaoLineSearchRegister(petsclib::PetscLibType, sname::String, func::external)

Adds a line-search algorithm to the registry

Not Collective, No Fortran Support

Input Parameters:

  • sname - name of a new user-defined solver
  • func - routine to Create method context

Calling sequence of func:

  • ls - the TaoLineSearch object to set with the TaoLineSearchType specific structure

See also: Tao, TaoLineSearch

External Links

source
PETSc.LibPETSc.TaoLineSearchReset — Method
TaoLineSearchReset(petsclib::PetscLibType, ls::TaoLineSearch)

Some line searches may carry state information from one TaoLineSearchApply() to the next. This function resets this state information.

Collective

Input Parameter:

  • ls - the TaoLineSearch context

Level: developer

See also: Tao, TaoLineSearch, TaoLineSearchCreate(), TaoLineSearchApply()

External Links

source
PETSc.LibPETSc.TaoLineSearchSetFromOptions — Method
TaoLineSearchSetFromOptions(petsclib::PetscLibType, ls::TaoLineSearch)

Sets various TaoLineSearch parameters from user options.

Collective

Input Parameter:

  • ls - the TaoLineSearch context

Options Database Keys:

  • -tao_ls_type (unit|more-thuente|gpcg|armijo|owarmijo|ipm) - select which line search Tao should use
  • -tao_ls_ftol tol - tolerance for sufficient decrease
  • -tao_ls_gtol tol - tolerance for curvature condition
  • -tao_ls_rtol tol - relative tolerance for acceptable step
  • -tao_ls_stepinit step - initial steplength allowed
  • -tao_ls_stepmin step - minimum steplength allowed
  • -tao_ls_stepmax step - maximum steplength allowed
  • -tao_ls_max_funcs n - maximum number of function evaluations allowed
  • -tao_ls_view - display line-search results

Level: beginner

See also: Tao, TaoLineSearch, TaoGetLineSearch()

External Links

source
PETSc.LibPETSc.TaoLineSearchSetGradientRoutine — Method
TaoLineSearchSetGradientRoutine(petsclib::PetscLibType, ls::TaoLineSearch, func::external, ctx::Ptr{Cvoid})

Sets the gradient evaluation routine for the line search

Logically Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • func - the gradient evaluation routine
  • ctx - the (optional) user-defined context for private data

Calling sequence of func:

  • ls - the linesearch object
  • x - input vector
  • g - gradient vector
  • ctx - (optional) user-defined context

Level: beginner

See also: Tao, TaoLineSearch, TaoLineSearchCreate(), TaoLineSearchSetObjectiveRoutine(), TaoLineSearchSetObjectiveAndGradientRoutine(), TaoLineSearchUseTaoRoutines()

External Links

source
PETSc.LibPETSc.TaoLineSearchSetInitialStepLength — Method
TaoLineSearchSetInitialStepLength(petsclib::PetscLibType, ls::TaoLineSearch, s::PetscReal)

Sets the initial step length of a line search. If this value is not set then 1.0 is assumed.

Logically Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • s - the initial step size

Level: intermediate

See also: Tao, TaoLineSearch, TaoLineSearchGetStepLength(), TaoLineSearchApply()

External Links

source
PETSc.LibPETSc.TaoLineSearchSetObjectiveAndGTSRoutine — Method
TaoLineSearchSetObjectiveAndGTSRoutine(petsclib::PetscLibType, ls::TaoLineSearch, func::external, ctx::Ptr{Cvoid})

Sets the objective and (gradient'*stepdirection) evaluation routine for the line search.

Logically Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • func - the objective and gradient evaluation routine
  • ctx - the (optional) user-defined context for private data

Calling sequence of func:

  • ls - the linesearch context
  • x - input vector
  • s - step direction
  • f - function value
  • gts - inner product of gradient and step direction vectors
  • ctx - (optional) user-defined context

Level: advanced

See also: Tao, TaoLineSearch, TaoLineSearchCreate(), TaoLineSearchSetObjective(), TaoLineSearchSetGradient(), TaoLineSearchUseTaoRoutines()

External Links

source
PETSc.LibPETSc.TaoLineSearchSetObjectiveAndGradientRoutine — Method
TaoLineSearchSetObjectiveAndGradientRoutine(petsclib::PetscLibType, ls::TaoLineSearch, func::external, ctx::Ptr{Cvoid})

Sets the objective/gradient evaluation routine for the line search

Logically Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • func - the objective and gradient evaluation routine
  • ctx - the (optional) user-defined context for private data

Calling sequence of func:

  • ls - the linesearch object
  • x - input vector
  • f - function value
  • g - gradient vector
  • ctx - (optional) user-defined context

Level: beginner

See also: Tao, TaoLineSearch, TaoLineSearchCreate(), TaoLineSearchSetObjectiveRoutine(), TaoLineSearchSetGradientRoutine(), TaoLineSearchUseTaoRoutines()

External Links

source
PETSc.LibPETSc.TaoLineSearchSetObjectiveRoutine — Method
TaoLineSearchSetObjectiveRoutine(petsclib::PetscLibType, ls::TaoLineSearch, func::external, ctx::Ptr{Cvoid})

Sets the function evaluation routine for the line search

Logically Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • func - the objective function evaluation routine
  • ctx - the (optional) user-defined context for private data

Calling sequence of func:

  • ls - the line search context
  • x - input vector
  • f - function value
  • ctx - (optional) user-defined context

Level: advanced

See also: Tao, TaoLineSearch, TaoLineSearchCreate(), TaoLineSearchSetGradientRoutine(), TaoLineSearchSetObjectiveAndGradientRoutine(), TaoLineSearchUseTaoRoutines()

External Links

source
PETSc.LibPETSc.TaoLineSearchSetOptionsPrefix — Method
TaoLineSearchSetOptionsPrefix(petsclib::PetscLibType, ls::TaoLineSearch, p::String)

Sets the prefix used for searching for all TaoLineSearch options in the database.

Logically Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • p - the prefix string to prepend to all ls option requests

Level: advanced

See also: Tao, TaoLineSearch, TaoLineSearchAppendOptionsPrefix(), TaoLineSearchGetOptionsPrefix()

External Links

source
PETSc.LibPETSc.TaoLineSearchSetType — Method
TaoLineSearchSetType(petsclib::PetscLibType, ls::TaoLineSearch, type::String)

Sets the algorithm used in a line search

Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • type - the TaoLineSearchType selection

Options Database Key:

  • -tao_ls_type (unit|more-thuente|gpcg|armijo|owarmijo|ipm) - select which line search Tao should use

Level: beginner

See also: Tao, TaoLineSearch, TaoLineSearchType, TaoLineSearchCreate(), TaoLineSearchGetType(), TaoLineSearchApply()

External Links

source
PETSc.LibPETSc.TaoLineSearchSetUp — Method
TaoLineSearchSetUp(petsclib::PetscLibType, ls::TaoLineSearch)

Sets up the internal data structures for the later use of a TaoLineSearch

Collective

Input Parameter:

  • ls - the TaoLineSearch context

Level: developer

See also: Tao, TaoLineSearch, TaoLineSearchCreate(), TaoLineSearchApply()

External Links

source
PETSc.LibPETSc.TaoLineSearchSetVariableBounds — Method
TaoLineSearchSetVariableBounds(petsclib::PetscLibType, ls::TaoLineSearch, xl::AbstractPetscVec, xu::AbstractPetscVec)

Sets the upper and lower bounds for a bounded line search

Logically Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • xl - vector of lower bounds
  • xu - vector of upper bounds

Level: beginner

See also: Tao, TaoLineSearch, TaoSetVariableBounds(), TaoLineSearchCreate()

External Links

source
PETSc.LibPETSc.TaoLineSearchUseTaoRoutines — Method
TaoLineSearchUseTaoRoutines(petsclib::PetscLibType, ls::TaoLineSearch, ts::AbstractTao)

Informs the TaoLineSearch to use the objective and gradient evaluation routines from the given Tao object. The default.

Logically Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • ts - the Tao context with defined objective/gradient evaluation routines

Level: developer

See also: Tao, TaoLineSearch, TaoLineSearchCreate()

External Links

source
PETSc.LibPETSc.TaoLineSearchView — Method
TaoLineSearchView(petsclib::PetscLibType, ls::TaoLineSearch, viewer::PetscViewer)

Prints information about the TaoLineSearch

Collective

Input Parameters:

  • ls - the TaoLineSearch context
  • viewer - visualization context

Options Database Key:

  • -tao_ls_view - Calls TaoLineSearchView() at the end of each line search

Level: beginner

See also: Tao, TaoLineSearch, PetscViewerASCIIOpen(), TaoLineSearchViewFromOptions()

External Links

source
PETSc.LibPETSc.TaoLineSearchViewFromOptions — Method
TaoLineSearchViewFromOptions(petsclib::PetscLibType, A::TaoLineSearch, obj, name::String)

View a TaoLineSearch object based on values in the options database

Collective

Input Parameters:

  • A - the Tao context
  • obj - Optional object
  • name - command line option

Options Database Key:

  • -name [viewertype][:...] - option name and values. See PetscObjectViewFromOptions() for the possible arguments

Level: intermediate

See also: Tao, TaoLineSearch, TaoLineSearchView(), PetscObjectViewFromOptions(), TaoLineSearchCreate()

External Links

source
PETSc.LibPETSc.TaoMonitorDrawCtxCreate — Method
ctx::TaoMonitorDrawCtx = TaoMonitorDrawCtxCreate(petsclib::PetscLibType, comm::MPI_Comm, host::String, label::String, x::Cint, y::Cint, m::Cint, n::Cint, howoften::PetscInt)

Creates the monitor context for TaoMonitorSolutionDraw()

Collective

Input Parameters:

  • comm - the communicator to share the context
  • host - the name of the X Windows host that will display the monitor
  • label - the label to put at the top of the display window
  • x - the horizontal coordinate of the lower left corner of the window to open
  • y - the vertical coordinate of the lower left corner of the window to open
  • m - the width of the window
  • n - the height of the window
  • howoften - how many Tao iterations between displaying the monitor information

Output Parameter:

  • ctx - the monitor context

Options Database Keys:

  • -tao_monitor_solution_draw - use TaoMonitorSolutionDraw() to monitor the solution
  • -tao_draw_solution_initial - show initial guess as well as current solution

Level: intermediate

See also: Tao, TaoMonitorSet(), TaoMonitorDefault(), VecView(), TaoMonitorDrawCtx()

External Links

source
PETSc.LibPETSc.TaoMonitorDrawCtxDestroy — Method
TaoMonitorDrawCtxDestroy(petsclib::PetscLibType, ictx::Union{TaoMonitorDrawCtx, Ref{TaoMonitorDrawCtx}})

Destroys the monitor context for TaoMonitorSolutionDraw()

Collective

Input Parameter:

  • ictx - the monitor context

Level: intermediate

See also: Tao, TaoMonitorSet(), TaoMonitorDefault(), VecView(), TaoMonitorSolutionDraw()

External Links

source
PETSc.LibPETSc.TaoTermComputeGradient — Method
TaoTermComputeGradient(petsclib::PetscLibType, term::TaoTerm, x::AbstractPetscVec, params::AbstractPetscVec, g::AbstractPetscVec)

Evaluate the gradient of a TaoTerm for a given solution vector and parameter vector

Collective

Input Parameters:

  • term - a TaoTerm representing a parametric function f(x; p)
  • x - the solution variable x in f(x; p)
  • params - the parameters p in f(x; p) (may be NULL if the term is not parametric)

Output Parameter:

  • g - the value of \nabla_x f(x; p)

Level: developer

TaoTerm, TaoTermComputeObjective(), TaoTermComputeObjectiveAndGradient(), TaoTermComputeHessian(), TaoTermShellSetGradient()

External Links

source
PETSc.LibPETSc.TaoTermComputeGradientFD — Method
TaoTermComputeGradientFD(petsclib::PetscLibType, term::TaoTerm, x::AbstractPetscVec, params::AbstractPetscVec, g::AbstractPetscVec)

Approximate the gradient of a TaoTerm using finite differences

Collective

Input Parameters:

  • term - a TaoTerm
  • x - a solution vector
  • params - parameters vector (may be NULL, see TaoTermParametersMode)

Output Parameter:

  • g - the computed finite difference approximation to the gradient

Options Database Keys:

  • -tao_term_fd_delta <delta> - change in x used to calculate finite differences
  • -tao_term_gradient_use_fd <bool> - Use TaoTermComputeGradientFD() in TaoTermComputeGradient()

Level: advanced

Notes: This routine is slow and expensive, and is not optimized to take advantage of sparsity in the problem. Although not recommended for general use in large-scale applications, it can be useful in checking the correctness of a user-provided gradient. Call TaoTermComputeGradientSetUseFD() to start using this routine in TaoTermComputeGradient().

TaoTerm, TaoTermGetFDDelta(), TaoTermSetFDDelta(), TaoTermComputeGradientSetUseFD(), TaoTermComputeGradientGetUseFD(), TaoTermComputeHessianFD()

External Links

source
PETSc.LibPETSc.TaoTermComputeGradientGetUseFD — Method
use_fd::PetscBool = TaoTermComputeGradientGetUseFD(petsclib::PetscLibType, term::TaoTerm)

Get whether finite differences are used in TaoTermComputeGradient().

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • use_fd - PETSC_TRUE if finite differences are used

Level: advanced

TaoTerm, TaoTermGetFDDelta(), TaoTermSetFDDelta(), TaoTermComputeGradientFD(), TaoTermComputeGradientSetUseFD(), TaoTermComputeHessianFD(), TaoTermComputeHessianSetUseFD(), TaoTermComputeHessianGetUseFD()

External Links

source
PETSc.LibPETSc.TaoTermComputeGradientSetUseFD — Method
TaoTermComputeGradientSetUseFD(petsclib::PetscLibType, term::TaoTerm, use_fd::PetscBool)

Set whether to use finite differences instead of the user-provided or built-in gradient method in TaoTermComputeGradient().

Logically collective

Input Parameters:

  • term - a TaoTerm
  • use_fd - PETSC_TRUE to use finite differences, PETSC_FALSE to use the user-provided or built-in gradient method

Options Database Keys:

  • -tao_term_gradient_use_fd <bool> - use finite differences for gradient computation

Level: advanced

TaoTerm, TaoTermGetFDDelta(), TaoTermSetFDDelta(), TaoTermComputeGradientFD(), TaoTermComputeGradientGetUseFD(), TaoTermComputeHessianFD(), TaoTermComputeHessianSetUseFD(), TaoTermComputeHessianGetUseFD()

External Links

source
PETSc.LibPETSc.TaoTermComputeHessian — Method
TaoTermComputeHessian(petsclib::PetscLibType, term::TaoTerm, x::AbstractPetscVec, params::AbstractPetscVec, H::AbstractPetscMat, Hpre::AbstractPetscMat)

Evaluate the Hessian of a TaoTerm (with respect to the solution variables) for a given solution vector and parameter vector

Collective

Input Parameters:

  • term - a TaoTerm representing a parametric function f(x; p)
  • x - the solution variable x in f(x; p)
  • params - the parameters p in f(x; p) (may be NULL if the term is not parametric)

Output Parameters:

  • H - Hessian matrix \nabla_x^2 f(x;p)
  • Hpre - an (approximate) Hessian from which the preconditioner will be constructed, often the same as H

Level: developer

Note: If there is no separate matrix from which to construct the preconditioner, then TaoTermComputeHessian(term, x, params, H, NULL) and TaoTermComputeHessian(term, x, params, H, H) are equivalent.

TaoTerm, TaoTermComputeObjective(), TaoTermComputeGradient(), TaoTermComputeObjectiveAndGradient(), TaoTermShellSetHessian()

External Links

source
PETSc.LibPETSc.TaoTermComputeHessianFD — Method
TaoTermComputeHessianFD(petsclib::PetscLibType, term::TaoTerm, x::AbstractPetscVec, params::AbstractPetscVec, H::AbstractPetscMat, Hpre::AbstractPetscMat)

Use finite difference to compute Hessian matrix.

Collective

Input Parameters:

  • term - a TaoTerm
  • x - a solution vector
  • params - parameters vector (may be NULL, see TaoTermParametersMode)

Output Parameters:

  • H - (optional) Hessian matrix
  • Hpre - (optional) Hessian preconditioning matrix

Options Database Keys:

  • -tao_term_fd_delta <delta> - change in X used to calculate finite differences
  • -tao_term_hessian_use_fd <bool> - Use TaoTermComputeHessianFD() in TaoTermComputeHessian()

Level: advanced

Notes: This routine is slow and expensive, and is not optimized to take advantage of sparsity in the problem. Although not recommended for general use in large-scale applications, it can be useful in checking the correctness of a user-provided Hessian. Call TaoTermComputeHessianSetUseFD() to start using this routine in TaoTermComputeHessian().

TaoTerm, TaoTermComputeHessian(), TaoTermGetFDDelta(), TaoTermSetFDDelta(), TaoTermComputeHessianSetUseFD(), TaoTermComputeHessianGetUseFD()

External Links

source
PETSc.LibPETSc.TaoTermComputeHessianGetUseFD — Method
use_fd::PetscBool = TaoTermComputeHessianGetUseFD(petsclib::PetscLibType, term::TaoTerm)

Get whether finite differences are used in TaoTermComputeHessian().

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • use_fd - PETSC_TRUE if finite differences are used

Level: advanced

TaoTerm, TaoTermGetFDDelta(), TaoTermSetFDDelta(), TaoTermComputeGradientFD(), TaoTermComputeGradientSetUseFD(), TaoTermComputeGradientGetUseFD(), TaoTermComputeHessianFD(), TaoTermComputeHessianSetUseFD()

External Links

source
PETSc.LibPETSc.TaoTermComputeHessianMFFD — Method
TaoTermComputeHessianMFFD(petsclib::PetscLibType, term::TaoTerm, x::AbstractPetscVec, params::AbstractPetscVec, H::AbstractPetscMat, B::AbstractPetscMat)

Update a matrix-free finite-difference MATMFFD Hessian created by TaoTermCreateHessianMFFD() to represent the Hessian of a TaoTerm at a given point and parameters.

Collective

Input Parameters:

  • term - the TaoTerm
  • x - the point at which the Hessian is to be applied
  • params - the current parameter vector for term, or NULL

Output Parameters:

  • H - the MATMFFD Hessian, reinitialized if needed and updated to base point x
  • B - the preconditioning matrix (unused; retained for API symmetry), or NULL

Level: advanced

See also: TaoTerm, TaoTermCreateHessianMFFD(), TaoTermComputeHessian(), MATMFFD

External Links

source
PETSc.LibPETSc.TaoTermComputeHessianSetUseFD — Method
TaoTermComputeHessianSetUseFD(petsclib::PetscLibType, term::TaoTerm, use_fd::PetscBool)

Set whether to use finite differences instead of the user-provided or built-in methods in TaoTermComputeHessian().

Logically collective

Input Parameters:

  • term - a TaoTerm
  • use_fd - PETSC_TRUE to use finite differences, PETSC_FALSE to use the user-provided or built-in Hessian method

Options Database Keys:

  • -tao_term_hessian_use_fd <bool> - use finite differences for Hessian computation

Level: advanced

TaoTerm, TaoTermGetFDDelta(), TaoTermSetFDDelta(), TaoTermComputeGradientFD(), TaoTermComputeGradientSetUseFD(), TaoTermComputeGradientGetUseFD(), TaoTermComputeHessianFD(), TaoTermComputeHessianGetUseFD()

External Links

source
PETSc.LibPETSc.TaoTermComputeObjective — Method
value::PetscReal = TaoTermComputeObjective(petsclib::PetscLibType, term::TaoTerm, x::AbstractPetscVec, params::AbstractPetscVec)

Evaluate a TaoTerm for a given solution vector and parameter vector

Collective

Input Parameters:

  • term - a TaoTerm representing a parametric function f(x; p)
  • x - the solution variable x in f(x; p)
  • params - the parameters p in f(x; p) (may be NULL if the term is not parametric)

Output Parameter:

  • value - the value of f(x; p)

Level: developer

TaoTerm, TaoTermComputeGradient(), TaoTermComputeObjectiveAndGradient(), TaoTermComputeHessian(), TaoTermShellSetObjective()

External Links

source
PETSc.LibPETSc.TaoTermComputeObjectiveAndGradient — Method
value::PetscReal = TaoTermComputeObjectiveAndGradient(petsclib::PetscLibType, term::TaoTerm, x::AbstractPetscVec, params::AbstractPetscVec, g::AbstractPetscVec)

Evaluate both the value and gradient of a TaoTerm for a given set of solution vector and parameter vector

Collective

Input Parameters:

  • term - a TaoTerm representing a parametric function f(x; p)
  • x - the solution variable x in f(x; p)
  • params - the parameters p in f(x; p) (may be NULL if the term is not parametric)

Output Parameters:

  • value - the value of f(x; p)
  • g - the value of \nabla_x f(x; p)

Level: developer

TaoTerm, TaoTermComputeObjective(), TaoTermComputeGradient(), TaoTermComputeHessian(), TaoTermShellSetObjectiveAndGradient()

External Links

source
PETSc.LibPETSc.TaoTermCreate — Method
term::TaoTerm = TaoTermCreate(petsclib::PetscLibType, comm::MPI_Comm)

Create a TaoTerm to use in defining the function Tao is to optimize

Collective

Input Parameter:

  • comm - communicator for MPI processes that compute the term

Output Parameter:

  • term - a new TaoTerm

Level: beginner

TaoTerm, TaoTermSetType(), TaoAddTerm(), TaoTermSetFromOptions(), TaoTermSetUp(), TaoTermView(), TaoTermDestroy()

External Links

source
PETSc.LibPETSc.TaoTermCreateHalfL2Squared — Method
term::TaoTerm = TaoTermCreateHalfL2Squared(petsclib::PetscLibType, comm::MPI_Comm, n::PetscInt, M_N::PetscInt)

Create a TaoTerm for the objective term \tfrac{1}{2}\|x - p\|_2^2, for solution x and parameters p.

Collective

Input Parameters:

  • comm - the MPI communicator where the TaoTerm will be computed
  • n - the local size of the x and p vectors (or PETSC_DECIDE)
  • N - the global size of the x and p vectors (or PETSC_DECIDE)

Output Parameter:

  • term - the TaoTerm

Level: beginner

Note: If you would like to add a Tikhonov regularization term \alpha \tfrac{1}{2}\|x\|2^2 to the objective function of a Tao, do the following: `` VecGetSizes(x, &n, &N); TaoTermCreateHalfL2Squared(PetscObjectComm((PetscObject)x), n, N, &term); TaoAddTerm(tao, "reg", alpha, term, NULL, NULL); TaoTermDestroy(&term); $If you would like to add a biased regularization term \alpha \tfrac{1}{2}\|x - p \|_2^2, do the same but pass `p` as the parameters of the term:$ TaoAddTerm(tao, "reg_", alpha, term, p, NULL); ``

TaoTerm, TAOTERMHALFL2SQUARED, TaoTermCreateL1(), TaoTermCreateQuadratic()

External Links

source
PETSc.LibPETSc.TaoTermCreateHessianMFFD — Method
mffd::PetscMat = TaoTermCreateHessianMFFD(petsclib::PetscLibType, term::TaoTerm)

Create a MATMFFD for a matrix-free finite-difference approximation of the Hessian of a TaoTerm

Collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • mffd - a Mat of type MATMFFD

Level: advanced

See also: TaoTerm, TaoTermComputeHessianFD()

External Links

source
PETSc.LibPETSc.TaoTermCreateHessianMatrices — Method
H::PetscMat,Hpre::PetscMat = TaoTermCreateHessianMatrices(petsclib::PetscLibType, term::TaoTerm)

Create the matrices that can be inputs to TaoTermComputeHessian()

Collective

Input Parameter:

  • term - a TaoTerm

Output Parameters:

  • H - (optional) a matrix that can store the Hessian computed in TaoTermComputeHessian()
  • Hpre - (optional) a matrix from which a preconditioner can be computed in TaoTermComputeHessian()

Level: advanced

Note: Before Hessian matrices can be created, the size of the solution vector space must be set (see the ways this can be done in TaoTermCreateSolutionVec()). If the term is a TAOTERMSHELL, TaoTermShellSetCreateHessianMatrices() must be called. Most TaoTerms use TaoTermCreateHessianMatricesDefault() to create their Hessian matrices: the behavior of that function can be controlled by TaoTermSetCreateHessianMode().

TaoTerm, TaoTermComputeHessian(), TaoTermShellSetCreateHessianMatrices(), TaoTermCreateSolutionVec(), TaoTermCreateHessianMatricesDefault(), TaoTermGetCreateHessianMode(), TaoTermSetCreateHessianMode(), TaoTermIsCreateHessianMatricesDefined()

External Links

source
PETSc.LibPETSc.TaoTermCreateHessianMatricesDefault — Method
H::PetscMat,Hpre::PetscMat = TaoTermCreateHessianMatricesDefault(petsclib::PetscLibType, term::TaoTerm)

Default routine for creating Hessian matrices that can be used by many TaoTerm implementations

Collective

Input Parameter:

  • term - a TaoTerm

Output Parameters:

  • H - (optional) a matrix that can store the Hessian computed in TaoTermComputeHessian()
  • Hpre - (optional) a matrix from which a preconditioner can be computed in TaoTermComputeHessian()

Level: developer

Developer Note: The behavior of this routine is determined by TaoTermSetCreateHessianMode(). If Hpre_is_H, then the same matrix will be returned for H and Hpre, otherwise they will be separate matrices, with the matrix types H_mattype and Hpre_mattype. If either type is MATMFFD, then it will create a shell matrix with TaoTermCreateHessianMFFD().

TaoTerm, TaoTermComputeHessian(), TaoTermCreateHessianMatrices(), TaoTermGetCreateHessianMode(), TaoTermSetCreateHessianMode()

External Links

source
PETSc.LibPETSc.TaoTermCreateL1 — Method
term::TaoTerm = TaoTermCreateL1(petsclib::PetscLibType, comm::MPI_Comm, n::PetscInt, M_N::PetscInt, epsilon::PetscReal)

Create a TaoTerm for the objective function term \|x - p\|_1.

Collective

Input Parameters:

  • comm - the MPI communicator where the term will be computed
  • n - the local size of the x and p vectors (or PETSC_DECIDE)
  • N - the global size of the x and p vectors (or PETSC_DECIDE)
  • epsilon - a non-negative smoothing parameter (see TaoTermL1SetEpsilon())

Output Parameter:

  • term - the TaoTerm

Level: beginner

Note: If you would like to add an L1 regularization term \alpha \|x\|1 to the objective function of a Tao, do the following: `` VecGetLocalSize(x, &n); VecGetSize(x, &N); TaoTermCreateL1(PetscObjectComm((PetscObject)x), n, N, 0.0, &term); TaoAddTerm(tao, "reg", alpha, term, NULL, NULL); TaoTermDestroy(&term); $If you would like to have a dictionary matrix term \alpha \|D x\|_1, do the same but pass `D` as the map of the term:$ MatGetLocalSize(D, &m, NULL); MatGetSize(D, &M, NULL); TaoTermCreateL1(PetscObjectComm((PetscObject)D), m, M, 0.0, &term); TaoAddTerm(tao, "reg_", alpha, term, NULL, D); TaoTermDestroy(&term); ``

TaoTerm, TAOTERML1, TaoTermL1GetEpsilon(), TaoTermL1SetEpsilon(), TaoTermCreateHalfL2Squared(), TaoTermCreateQuadratic()

External Links

source
PETSc.LibPETSc.TaoTermCreateParametersVec — Method
parameters::PetscVec = TaoTermCreateParametersVec(petsclib::PetscLibType, term::TaoTerm)

Create a parameter vector for a TaoTerm

Collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • parameters - a compatible parameter vector for term

Level: advanced

Notes: Before a TaoTerm can create a parameter vector, you must do one of the following:

  • Call TaoTermSetParametersSizes() to describe the size and parallel layout of a parameters vector.
  • Call TaoTermSetParametersLayout() to directly set PetscLayouts for the parameters vector.
  • Call TaoTermSetParametersTemplate() to set the parameters vector spaces to match existing Vec.
  • If the TaoTerm is a TAOTERMSHELL, you can call TaoTermShellSetCreateParametersVec() to use your

own code for creating vectors.

You can also call TaoTermSetParametersVecType() to set the type of vector created (e.g. VECCUDA).

TaoTerm, TaoTermShellSetCreateParametersVec(), TaoTermGetParametersSizes(), TaoTermSetParametersSizes(), TaoTermSetParametersTemplate(), TaoTermGetParametersVecType(), TaoTermSetParametersVecType(), TaoTermGetParametersLayout(), TaoTermSetParametersLayout(), TaoTermCreateHessianMatrices()

External Links

source
PETSc.LibPETSc.TaoTermCreateQuadratic — Method
term::TaoTerm = TaoTermCreateQuadratic(petsclib::PetscLibType, A::AbstractPetscMat)

Create a TAOTERMQUADRATIC for a given matrix

Collective

Input Parameter:

  • A - a square matrix

Output Parameter:

  • term - a TaoTerm that implements \tfrac{1}{2}(x - p)^T A (x - p)

Level: beginner

TaoTerm, TaoTermCreate(), TAOTERMQUADRATIC, TaoTermCreateHalfL2Squared(), TaoTermCreateL1(), TaoTermQuadraticSetMat()

External Links

source
PETSc.LibPETSc.TaoTermCreateShell — Method
term::TaoTerm = TaoTermCreateShell(petsclib::PetscLibType, comm::MPI_Comm, ctx::Ptr{Cvoid}, destroy::Ptr{Cvoid})

Create a TaoTerm of type TAOTERMSHELL that is ready to accept user-provided callback operations.

Collective

Input Parameters:

  • comm - the MPI communicator for computing the term
  • ctx - (optional) a context to be used by routines
  • destroy - (optional) a routine to destroy the context when term is destroyed

Output Parameter:

  • term - a TaoTerm of type TAOTERMSHELL

Level: intermediate

See also: TaoTerm, TAOTERMSHELL

External Links

source
PETSc.LibPETSc.TaoTermCreateSolutionVec — Method
solution::PetscVec = TaoTermCreateSolutionVec(petsclib::PetscLibType, term::TaoTerm)

Create a solution vector for a TaoTerm

Collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • solution - a compatible solution vector for term

Level: advanced

Note: Before a TaoTerm can create a solution vector, you must do one of the following:

  • Call TaoTermSetSolutionSizes() to describe the size and parallel layout of a solution vector.
  • Call TaoTermSetSolutionLayout() to directly set PetscLayouts for the solution vector.
  • Call TaoTermSetSolutionTemplate() to set the solution vector spaces to match existing Vec.
  • If the TaoTerm is a TAOTERMSHELL, you can call TaoTermShellSetCreateSolutionVec() to use

your own code for creating vectors.

You can also call TaoTermSetSolutionVecType() to set the type of vector created (e.g. VECCUDA).

TaoTerm, TaoTermShellSetCreateSolutionVec(), TaoTermGetSolutionSizes(), TaoTermSetSolutionSizes(), TaoTermSetSolutionTemplate(), TaoTermGetSolutionVecType(), TaoTermSetSolutionVecType(), TaoTermGetSolutionLayout(), TaoTermSetSolutionLayout(), TaoTermCreateHessianMatrices()

External Links

source
PETSc.LibPETSc.TaoTermDestroy — Method
TaoTermDestroy(petsclib::PetscLibType, term::Union{TaoTerm, Ref{TaoTerm}})

Destroy a TaoTerm.

Collective

Input Parameter:

  • term - a TaoTerm

Level: beginner

TaoTerm, TaoTermCreate(), TaoTermSetType(), TaoTermSetFromOptions(), TaoTermSetUp(), TaoTermView()

External Links

source
PETSc.LibPETSc.TaoTermDuplicate — Method
newterm::TaoTerm = TaoTermDuplicate(petsclib::PetscLibType, term::TaoTerm, opt::TaoTermDuplicateOption)

Duplicate a TaoTerm

Collective

Input Parameters:

  • term - a TaoTerm
  • opt - TAOTERM_DUPLICATE_SIZEONLY or TAOTERM_DUPLICATE_TYPE

Output Parameter:

  • newterm - the duplicate TaoTerm

Notes: This function duplicates the solution space layout and vector type, but does not duplicate parameters-related configuration such as the parameters layout, TaoTermParametersMode, Hessian matrix types, or finite-difference settings. These must be set separately on the new TaoTerm if needed.

If TAOTERM_DUPLICATE_SIZEONLY is used, then the duplicated term must have proper TaoTermType set with TaoTermSetType().

Level: intermediate

TaoTerm, TaoTermDuplicateOption

External Links

source
PETSc.LibPETSc.TaoTermGetCreateHessianMode — Method
Hpre_is_H::PetscBool,H_mattype::String,Hpre_mattype::String = TaoTermGetCreateHessianMode(petsclib::PetscLibType, term::TaoTerm)

Get the behavior of TaoTermCreateHessianMatricesDefault().

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameters:

  • Hpre_is_H - (optional) should TaoTermCreateHessianMatricesDefault() make one matrix for H and Hpre?
  • H_mattype - (optional) the MatType to create for H
  • Hpre_mattype - (optional) the MatType to create for Hpre

Level: developer

TaoTerm, TaoTermComputeHessian(), TaoTermCreateHessianMatrices(), TaoTermCreateHessianMatricesDefault(), TaoTermSetCreateHessianMode()

External Links

source
PETSc.LibPETSc.TaoTermGetFDDelta — Method
delta::PetscReal = TaoTermGetFDDelta(petsclib::PetscLibType, term::TaoTerm)

Get the increment used for finite difference derivative approximations in methods like TaoTermComputeGradientFD()

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • delta - the finite difference increment

Options Database Key:

  • -tao_term_fd_delta <delta> - the above increment

Level: advanced

TaoTerm, TaoTermSetFDDelta(), TaoTermComputeGradientFD(), TaoTermComputeGradientSetUseFD(), TaoTermComputeGradientGetUseFD()

External Links

source
PETSc.LibPETSc.TaoTermGetParametersLayout — Method
parameters_layout::PetscLayout = TaoTermGetParametersLayout(petsclib::PetscLibType, term::TaoTerm)

Get the layouts describing the parameter vectors of a TaoTerm.

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • parameters_layout - the PetscLayout for the parameter space

Level: intermediate

TaoTerm, TaoTermGetParametersVecType(), TaoTermSetParametersVecType(), TaoTermSetParametersLayout(), TaoTermSetSolutionTemplate(), TaoTermSetParametersTemplate(), TaoTermCreateParametersVec()

External Links

source
PETSc.LibPETSc.TaoTermGetParametersMode — Method
parameters_mode::TaoTermParametersMode = TaoTermGetParametersMode(petsclib::PetscLibType, term::TaoTerm)

Gets the way a TaoTerm can accept parameters

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • parameters_mode - TAOTERM_PARAMETERS_OPTIONAL, TAOTERM_PARAMETERS_NONE, TAOTERM_PARAMETERS_REQUIRED

Level: intermediate

TaoTerm, TaoTermParametersMode, TaoTermSetParametersMode()

External Links

source
PETSc.LibPETSc.TaoTermGetParametersSizes — Method
k::PetscInt,M_K::PetscInt,bs::PetscInt = TaoTermGetParametersSizes(petsclib::PetscLibType, term::TaoTerm)

Get the sizes describing the layout of the parameter vector space of a TaoTerm.

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameters:

  • k - (optional) the size of a parameter vector on the current MPI process
  • K - (optional) the global size of a parameter vector
  • bs - (optional) the block size of a parameter vector

Level: beginner

TaoTerm, TaoTermSetParametersSizes(), TaoTermSetParametersTemplate(), TaoTermGetParametersVecType(), TaoTermSetParametersVecType(), TaoTermGetParametersLayout(), TaoTermSetParametersLayout(), TaoTermCreateParametersVec()

External Links

source
PETSc.LibPETSc.TaoTermGetParametersVecType — Method
parameters_type::String = TaoTermGetParametersVecType(petsclib::PetscLibType, term::TaoTerm)

Get the vector types of the parameter vector of a TaoTerm

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • parameters_type - the VecType for the parameter space

Level: advanced

TaoTerm, TaoTermSetParametersVecType(), TaoTermGetParametersLayout(), TaoTermSetParametersLayout(), TaoTermSetSolutionTemplate(), TaoTermSetParametersTemplate(), TaoTermCreateParametersVec()

External Links

source
PETSc.LibPETSc.TaoTermGetSolutionLayout — Method
solution_layout::PetscLayout = TaoTermGetSolutionLayout(petsclib::PetscLibType, term::TaoTerm)

Get the layouts describing the solution vectors of a TaoTerm.

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • solution_layout - the PetscLayout for the solution space

Level: intermediate

TaoTerm, TaoTermGetSolutionVecType(), TaoTermSetSolutionVecType(), TaoTermSetSolutionLayout(), TaoTermSetSolutionTemplate(), TaoTermSetParametersTemplate(), TaoTermCreateSolutionVec()

External Links

source
PETSc.LibPETSc.TaoTermGetSolutionSizes — Method
n::PetscInt,M_N::PetscInt,bs::PetscInt = TaoTermGetSolutionSizes(petsclib::PetscLibType, term::TaoTerm)

Get the sizes describing the layout of the solution vector space of a TaoTerm.

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameters:

  • n - (optional) the size of a solution vector on the current MPI process
  • N - (optional) the global size of a solution vector
  • bs - (optional) the block size of a solution vector

Level: beginner

TaoTerm, TaoTermSetSolutionSizes(), TaoTermSetSolutionTemplate(), TaoTermGetSolutionVecType(), TaoTermSetSolutionVecType(), TaoTermGetSolutionLayout(), TaoTermSetSolutionLayout(), TaoTermCreateSolutionVec()

External Links

source
PETSc.LibPETSc.TaoTermGetSolutionVecType — Method
solution_type::String = TaoTermGetSolutionVecType(petsclib::PetscLibType, term::TaoTerm)

Get the vector types of the solution vector of a TaoTerm

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • solution_type - the VecType for the solution space

Level: advanced

TaoTerm, TaoTermSetSolutionVecType(), TaoTermGetSolutionLayout(), TaoTermSetSolutionLayout(), TaoTermSetSolutionTemplate(), TaoTermSetParametersTemplate(), TaoTermCreateSolutionVec()

External Links

source
PETSc.LibPETSc.TaoTermGetType — Method
type::String = TaoTermGetType(petsclib::PetscLibType, term::TaoTerm)

Get the type of a TaoTerm

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • type - the TaoTermType

Level: beginner

TaoTerm, TaoTermType, TaoTermCreate(), TaoTermSetType(), TaoTermSetFromOptions(), TaoTermSetUp(), TaoTermView(), TaoTermDestroy()

External Links

source
PETSc.LibPETSc.TaoTermIsComputeHessianFDPossible — Method
is_fdpossible::PetscBool3 = TaoTermIsComputeHessianFDPossible(petsclib::PetscLibType, term::TaoTerm)

Whether this term can compute Hessian with finite differences with either -tao_term_hessian_use_fd, TaoTermComputeHessianSetUseFD(), or MATMFFD.

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • is_fdpossible - whether Hessian computation with finite differences is possible

Level: developer

TaoTerm, TaoTermComputeObjective(), TaoTermShellSetObjective(), TaoTermIsGradientDefined(), TaoTermIsObjectiveAndGradientDefined(), TaoTermIsHessianDefined()

External Links

source
PETSc.LibPETSc.TaoTermIsCreateHessianMatricesDefined — Method
is_defined::PetscBool = TaoTermIsCreateHessianMatricesDefined(petsclib::PetscLibType, term::TaoTerm)

Whether this term can call TaoTermCreateHessianMatrices().

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • is_defined - whether the term can create new Hessian matrices

Level: developer

TaoTerm, TaoTermCreateHessianMatrices(), TaoTermShellSetCreateHessianMatrices(), TaoTermIsObjectiveDefined(), TaoTermIsGradientDefined(), TaoTermIsObjectiveAndGradientDefined(), TaoTermIsHessianDefined()

External Links

source
PETSc.LibPETSc.TaoTermIsGradientDefined — Method
is_defined::PetscBool = TaoTermIsGradientDefined(petsclib::PetscLibType, term::TaoTerm)

Whether a standalone gradient operation is defined for this TaoTerm

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • is_defined - whether the gradient is defined

Note: This function strictly checks whether a dedicated gradient operation is defined. It does not check whether the gradient could be computed via other operations (e.g., an objective-and-gradient callback or finite differences). TaoTermComputeGradient() may still succeed even if this function returns PETSC_FALSE, by falling back to TaoTermComputeObjectiveAndGradient() or finite-difference approximation.

Level: developer

TaoTerm, TaoTermComputeGradient(), TaoTermShellSetGradient(), TaoTermIsObjectiveDefined(), TaoTermIsObjectiveAndGradientDefined(), TaoTermIsHessianDefined()

External Links

source
PETSc.LibPETSc.TaoTermIsHessianDefined — Method
is_defined::PetscBool = TaoTermIsHessianDefined(petsclib::PetscLibType, term::TaoTerm)

Whether a Hessian operation is defined for this TaoTerm

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • is_defined - whether the Hessian is defined

Note: This function strictly checks whether a dedicated Hessian operation is defined. It does not check whether the Hessian could be computed via finite differences. TaoTermComputeHessian() may still succeed even if this function returns PETSC_FALSE, if finite-difference Hessian computation has been enabled.

Level: developer

TaoTerm, TaoTermComputeHessian(), TaoTermShellSetHessian(), TaoTermIsObjectiveDefined(), TaoTermIsGradientDefined(), TaoTermIsObjectiveAndGradientDefined()

External Links

source
PETSc.LibPETSc.TaoTermIsObjectiveAndGradientDefined — Method
is_defined::PetscBool = TaoTermIsObjectiveAndGradientDefined(petsclib::PetscLibType, term::TaoTerm)

Whether a combined objective-and-gradient operation is defined for this TaoTerm

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • is_defined - whether the objective/gradient is defined

Note: This function strictly checks whether a dedicated combined objective-and-gradient operation is defined. It does not check whether the objective and gradient could be computed via separate objective and gradient operations. TaoTermComputeObjectiveAndGradient() may still succeed even if this function returns PETSC_FALSE, by falling back to separate TaoTermComputeObjective() and TaoTermComputeGradient() calls.

Level: developer

TaoTerm, TaoTermComputeObjectiveAndGradient(), TaoTermShellSetObjectiveAndGradient(), TaoTermIsObjectiveDefined(), TaoTermIsGradientDefined(), TaoTermIsHessianDefined()

External Links

source
PETSc.LibPETSc.TaoTermIsObjectiveDefined — Method
is_defined::PetscBool = TaoTermIsObjectiveDefined(petsclib::PetscLibType, term::TaoTerm)

Whether a standalone objective operation is defined for this TaoTerm

Not collective

Input Parameter:

  • term - a TaoTerm

Output Parameter:

  • is_defined - whether the objective is defined

Note: This function strictly checks whether a dedicated objective operation is defined. It does not check whether the objective could be computed via other operations (e.g., an objective-and-gradient callback). TaoTermComputeObjective() may still succeed even if this function returns PETSC_FALSE, by falling back to TaoTermComputeObjectiveAndGradient().

Level: developer

TaoTerm, TaoTermComputeObjective(), TaoTermShellSetObjective(), TaoTermIsGradientDefined(), TaoTermIsObjectiveAndGradientDefined(), TaoTermIsHessianDefined()

External Links

source
PETSc.LibPETSc.TaoTermL1GetEpsilon — Method
epsilon::PetscReal = TaoTermL1GetEpsilon(petsclib::PetscLibType, term::TaoTerm)

Get the \epsilon smoothing parameter set by TaoTermL1SetEpsilon().

Not collective

Input Parameter:

  • term - a TaoTerm of type TAOTERML1

Output Parameter:

  • epsilon - the smoothing parameter

Level: advanced

TaoTerm, TAOTERML1, TaoTermL1SetEpsilon()

External Links

source
PETSc.LibPETSc.TaoTermL1SetEpsilon — Method
TaoTermL1SetEpsilon(petsclib::PetscLibType, term::TaoTerm, epsilon::PetscReal)

Set an \epsilon smoothing parameter.

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERML1
  • epsilon - a real number \geq 0

Options Database Keys:

  • -tao_term_l1_epsilon <real> - \epsilon

Level: advanced

If \epsilon = 0 (the default), then term computes \|x - p\|1, but if \epsilon > 0, then it computes \sum{i=0}^{n-1} \left(\sqrt{(xi-pi)^2 + \epsilon^2} - \epsilon\right).

TaoTerm, TAOTERML1, TaoTermL1GetEpsilon()

External Links

source
PETSc.LibPETSc.TaoTermQuadraticGetMat — Method
A::PetscMat = TaoTermQuadraticGetMat(petsclib::PetscLibType, term::TaoTerm)

Get the matrix defining a TaoTerm of type TAOTERMQUADRATIC

Not collective

Input Parameter:

  • term - a TaoTerm of type TAOTERMQUADRATIC

Output Parameter:

  • A - the matrix

Level: intermediate

Note: This function will return NULL if the term is not a TAOTERMQUADRATIC.

TaoTerm, TAOTERMQUADRATIC, TaoTermQuadraticSetMat()

External Links

source
PETSc.LibPETSc.TaoTermQuadraticSetMat — Method
TaoTermQuadraticSetMat(petsclib::PetscLibType, term::TaoTerm, A::AbstractPetscMat)

Set the matrix defining a TaoTerm of type TAOTERMQUADRATIC

Collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMQUADRATIC
  • A - the matrix

Level: intermediate

TaoTerm, TAOTERMQUADRATIC, TaoTermQuadraticGetMat()

External Links

source
PETSc.LibPETSc.TaoTermRegister — Method
TaoTermRegister(petsclib::PetscLibType, sname::String, func::external)

Register an implementation of TaoTerm

Not Collective, No Fortran Support

Input Parameters:

  • sname - name of a new user-defined term
  • func - routine to create the context for the TaoTermType

See also: TaoTerm, TaoTermSetType()

External Links

source
PETSc.LibPETSc.TaoTermSetCreateHessianMode — Method
TaoTermSetCreateHessianMode(petsclib::PetscLibType, term::TaoTerm, Hpre_is_H::PetscBool, H_mattype::String, Hpre_mattype::String)

Determine the behavior of TaoTermCreateHessianMatricesDefault().

Logically collective

Input Parameters:

  • term - a TaoTerm
  • Hpre_is_H - should TaoTermCreateHessianMatricesDefault() make one matrix for H and Hpre?
  • H_mattype - the MatType to create for H
  • Hpre_mattype - the MatType to create for Hpre

Options Database Keys:

  • -tao_term_hessian_pre_is_hessian <bool> - Whether TaoTermCreateHessianMatrices() should make a separate matrix for constructing the preconditioner
  • -tao_term_hessian_mat_type <type> - MatType for Hessian matrix created by TaoTermCreateHessianMatrices()
  • -tao_term_hessian_pre_mat_type <type> - MatType for matrix from which a preconditioner can be created by TaoTermCreateHessianMatrices()

Level: developer

TaoTerm, TaoTermComputeHessian(), TaoTermCreateHessianMatrices(), TaoTermCreateHessianMatricesDefault(), TaoTermGetCreateHessianMode()

External Links

source
PETSc.LibPETSc.TaoTermSetFDDelta — Method
TaoTermSetFDDelta(petsclib::PetscLibType, term::TaoTerm, delta::PetscReal)

Set the increment used for finite difference derivative approximations in methods like TaoTermComputeGradientFD()

Logically collective

Input Parameters:

  • term - a TaoTerm
  • delta - the finite difference increment

Options Database Key:

  • -tao_term_fd_delta <delta> - the above increment

Level: advanced

TaoTerm, TaoTermGetFDDelta(), TaoTermComputeGradientFD(), TaoTermComputeGradientSetUseFD(), TaoTermComputeGradientGetUseFD(), TaoTermComputeHessianFD(), TaoTermComputeHessianSetUseFD(), TaoTermComputeHessianGetUseFD()

External Links

source
PETSc.LibPETSc.TaoTermSetFromOptions — Method
TaoTermSetFromOptions(petsclib::PetscLibType, term::TaoTerm)

Configure a TaoTerm from the PETSc options database

Collective

Input Parameter:

  • term - a TaoTerm

Options Database Keys:

  • -tao_term_type <type> - l1, halfl2squared; see TaoTermType for a complete list
  • -tao_term_solution_vec_type <type> - the type of vector to use for the solution, see VecType for a complete list of vector types
  • -tao_term_parameters_vec_type <type> - the type of vector to use for the parameters, see VecType for a complete list of vector types
  • -tao_term_parameters_mode <optional,none,required> - TAOTERM_PARAMETERS_OPTIONAL, TAOTERM_PARAMETERS_NONE, TAOTERM_PARAMETERS_REQUIRED
  • -tao_term_hessian_pre_is_hessian <bool> - Whether TaoTermCreateHessianMatricesDefault() should make a separate preconditioning matrix
  • -tao_term_hessian_mat_type <type> - MatType for Hessian matrix created by TaoTermCreateHessianMatricesDefault()
  • -tao_term_hessian_pre_mat_type <type> - MatType for approximate Hessian matrix used to construct the preconditioner created by TaoTermCreateHessianMatricesDefault()
  • -tao_term_fd_delta <real> - Increment for finite difference derivative approximations in TaoTermComputeGradientFD()
  • -tao_term_gradient_use_fd <bool> - Use finite differences in TaoTermComputeGradient(), overriding other user-provided or built-in routines
  • -tao_term_hessian_use_fd <bool> - Use finite differences in TaoTermComputeHessian(), overriding other user-provided or built-in routines

Level: beginner

TaoTerm, TaoTermCreate(), TaoTermSetType(), TaoTermSetUp(), TaoTermView(), TaoTermDestroy()

External Links

source
PETSc.LibPETSc.TaoTermSetParametersLayout — Method
TaoTermSetParametersLayout(petsclib::PetscLibType, term::TaoTerm, parameters_layout::PetscLayout)

Set the layout describing the parameter vector of TaoTerm.

Collective

Input Parameters:

  • term - a TaoTerm
  • parameters_layout - the PetscLayout for the parameter space

Level: intermediate

Notes: The "parameter space" of a TaoTerm is the vector space of the fixed data p in f(x; p). Parameters are not optimized over. This is distinct from the "solution space" (set with TaoTermSetSolutionSizes()), which is the space of the optimization variable x. Some TaoTermTypes require the solution and parameter spaces to be related (e.g., have the same size); see the documentation for each type.

Alternatively, one may use TaoTermSetParametersSizes() or TaoTermSetParametersTemplate() to define the vector sizes.

TaoTerm, TaoTermGetParametersVecType(), TaoTermSetParametersVecType(), TaoTermGetParametersLayout(), TaoTermSetSolutionTemplate(), TaoTermSetParametersTemplate(), TaoTermCreateParametersVec()

External Links

source
PETSc.LibPETSc.TaoTermSetParametersMode — Method
TaoTermSetParametersMode(petsclib::PetscLibType, term::TaoTerm, parameters_mode::TaoTermParametersMode)

Sets the way a TaoTerm can accept parameters

Logically collective

Input Parameters:

  • term - a TaoTerm
  • parameters_mode - TAOTERM_PARAMETERS_OPTIONAL, TAOTERM_PARAMETERS_NONE, TAOTERM_PARAMETERS_REQUIRED

Options Database Keys:

  • -tao_term_parameters_mode <optional,none,required> - TAOTERM_PARAMETERS_OPTIONAL, TAOTERM_PARAMETERS_NONE, TAOTERM_PARAMETERS_REQUIRED

Level: advanced

TaoTerm, TaoTermParametersMode, TaoTermGetParametersMode()

External Links

source
PETSc.LibPETSc.TaoTermSetParametersSizes — Method
TaoTermSetParametersSizes(petsclib::PetscLibType, term::TaoTerm, k::PetscInt, M_K::PetscInt, bs::PetscInt)

Set the sizes describing the layout of the parameter vector space of a TaoTerm.

Logically collective

Input Parameters:

  • term - a TaoTerm
  • k - the size of a parameter vector on the current MPI process (or PETSC_DECIDE)
  • K - the global size of a parameter vector (or PETSC_DECIDE)
  • bs - the block size of a parameter vector (must be >= 1)

Level: beginner

Notes: The "parameter space" of a TaoTerm is the vector space of the fixed data p in f(x; p). Parameters are not optimized over. This is distinct from the "solution space" (set with TaoTermSetSolutionSizes()), which is the space of the optimization variable x. Some TaoTermTypes require the solution and parameter spaces to be related (e.g., have the same size); see the documentation for each type.

Alternatively, one may use TaoTermSetParametersLayout() or TaoTermSetParametersTemplate() to define the vector sizes.

TaoTerm, TaoTermGetParametersSizes(), TaoTermSetParametersTemplate(), TaoTermGetParametersVecType(), TaoTermSetParametersVecType(), TaoTermGetParametersLayout(), TaoTermSetParametersLayout(), TaoTermCreateParametersVec()

External Links

source
PETSc.LibPETSc.TaoTermSetParametersTemplate — Method
TaoTermSetParametersTemplate(petsclib::PetscLibType, term::TaoTerm, params_template::AbstractPetscVec)

Set the parameter vector space to match a template vector

Collective

Input Parameters:

  • term - a TaoTerm
  • params_template - a vector with the desired size, layout, and VecType of parameter vectors for TaoTerm

Level: intermediate

Notes: The "parameter space" of a TaoTerm is the vector space of the fixed data p in f(x; p). Parameters are not optimized over. This is distinct from the "solution space" (set with TaoTermSetSolutionSizes()), which is the space of the optimization variable x. Some TaoTermTypes require the solution and parameter spaces to be related (e.g., have the same size); see the documentation for each type.

Alternatively, one may use TaoTermSetParametersSizes() or TaoTermSetParametersLayout() to define the vector sizes.

TaoTerm, TaoTermGetParametersVecType(), TaoTermSetParametersVecType(), TaoTermSetSolutionTemplate(), TaoTermGetParametersLayout(), TaoTermSetParametersLayout(), TaoTermCreateSolutionVec()

External Links

source
PETSc.LibPETSc.TaoTermSetParametersVecType — Method
TaoTermSetParametersVecType(petsclib::PetscLibType, term::TaoTerm, parameters_type::String)

Set the vector types of the parameters vector of a TaoTerm

Logically collective

Input Parameters:

  • term - a TaoTerm
  • parameters_type - the VecType for the parameters space

Options Database Keys:

  • -tao_term_parameters_vec_type <type> - VecType for complete list of vector types

Level: advanced

TaoTerm, TaoTermGetParametersVecType(), TaoTermSetParametersLayout(), TaoTermGetParametersLayout(), TaoTermSetParametersTemplate(), TaoTermCreateParametersVec()

External Links

source
PETSc.LibPETSc.TaoTermSetSolutionLayout — Method
TaoTermSetSolutionLayout(petsclib::PetscLibType, term::TaoTerm, solution_layout::PetscLayout)

Set the layout describing the solution vector of TaoTerm.

Collective

Input Parameters:

  • term - a TaoTerm
  • solution_layout - the PetscLayout for the solution space

Level: intermediate

Notes: The "solution space" of a TaoTerm is the vector space of the optimization variable x in f(x; p). This is distinct from the "parameter space" (the space of the fixed data p, set with TaoTermSetParametersSizes()). Some TaoTermTypes require the solution and parameter spaces to be related (e.g., have the same size); see the documentation for each type.

When a mapping matrix A is used to add a term to a Tao via TaoAddTerm(), the mapping transforms the Tao solution vector into this term's solution space. For example, if the Tao solution vector is x \in \mathbb{R}^n and the mapping matrix is A \in \mathbb{R}^{m \times n}, then the term evaluates f(Ax; p) with Ax \in \mathbb{R}^m. The term's solution space is therefore \mathbb{R}^m, and TaoTermView() will report N = m for this term.

Alternatively, one may use TaoTermSetSolutionSizes() or TaoTermSetSolutionTemplate() to define the vector sizes.

TaoTerm, TaoTermGetSolutionVecType(), TaoTermSetSolutionVecType(), TaoTermGetSolutionLayout(), TaoTermSetSolutionTemplate(), TaoTermSetParametersTemplate(), TaoTermCreateSolutionVec()

External Links

source
PETSc.LibPETSc.TaoTermSetSolutionSizes — Method
TaoTermSetSolutionSizes(petsclib::PetscLibType, term::TaoTerm, n::PetscInt, M_N::PetscInt, bs::PetscInt)

Set the sizes describing the layout of the solution vector space of a TaoTerm.

Logically collective

Input Parameters:

  • term - a TaoTerm
  • n - the size of a solution vector on the current MPI process (or PETSC_DECIDE)
  • N - the global size of a solution vector (or PETSC_DECIDE)
  • bs - the block size of a solution vector (must be >= 1)

Level: beginner

Notes: The "solution space" of a TaoTerm is the vector space of the optimization variable x in f(x; p). This is distinct from the "parameter space" (the space of the fixed data p, set with TaoTermSetParametersSizes()). Some TaoTermTypes require the solution and parameter spaces to be related (e.g., have the same size); see the documentation for each type.

When a mapping matrix A is used to add a term to a Tao via TaoAddTerm(), the mapping transforms the Tao solution vector into this term's solution space. For example, if the Tao solution vector is x \in \mathbb{R}^n and the mapping matrix is A \in \mathbb{R}^{m \times n}, then the term evaluates f(Ax; p) with Ax \in \mathbb{R}^m. The term's solution space is therefore \mathbb{R}^m, and TaoTermView() will report N = m for this term.

Alternatively, one may use TaoTermSetSolutionLayout() or TaoTermSetSolutionTemplate() to define the vector sizes.

TaoTerm, TaoTermGetSolutionSizes(), TaoTermSetSolutionTemplate(), TaoTermGetSolutionVecType(), TaoTermSetSolutionVecType(), TaoTermGetSolutionLayout(), TaoTermSetSolutionLayout(), TaoTermCreateSolutionVec()

External Links

source
PETSc.LibPETSc.TaoTermSetSolutionTemplate — Method
TaoTermSetSolutionTemplate(petsclib::PetscLibType, term::TaoTerm, sol_template::AbstractPetscVec)

Set the solution vector space to match a template vector

Collective

Input Parameters:

  • term - a TaoTerm
  • sol_template - a vector with the desired size, layout, and VecType of solution vectors for TaoTerm

Level: intermediate

Notes: The "solution space" of a TaoTerm is the vector space of the optimization variable x in f(x; p). This is distinct from the "parameter space" (the space of the fixed data p, set with TaoTermSetParametersSizes()). Some TaoTermTypes require the solution and parameter spaces to be related (e.g., have the same size); see the documentation for each type.

When a mapping matrix A is used to add a term to a Tao via TaoAddTerm(), the mapping transforms the Tao solution vector into this term's solution space. For example, if the Tao solution vector is x \in \mathbb{R}^n and the mapping matrix is A \in \mathbb{R}^{m \times n}, then the term evaluates f(Ax; p) with Ax \in \mathbb{R}^m. The term's solution space is therefore \mathbb{R}^m, and TaoTermView() will report N = m for this term.

Alternatively, one may use TaoTermSetSolutionSizes() or TaoTermSetSolutionLayout() to define the vector sizes.

TaoTerm, TaoTermGetSolutionVecType(), TaoTermSetSolutionVecType(), TaoTermSetParametersTemplate(), TaoTermGetSolutionLayout(), TaoTermSetSolutionLayout(), TaoTermCreateSolutionVec()

External Links

source
PETSc.LibPETSc.TaoTermSetSolutionVecType — Method
TaoTermSetSolutionVecType(petsclib::PetscLibType, term::TaoTerm, solution_type::String)

Set the vector types of the solution vector of a TaoTerm

Logically collective

Input Parameters:

  • term - a TaoTerm
  • solution_type - the VecType for the solution space

Options Database Keys:

  • -tao_term_solution_vec_type <type> - VecType for complete list of vector types

Level: advanced

TaoTerm, TaoTermGetSolutionVecType(), TaoTermSetSolutionLayout(), TaoTermGetSolutionLayout(), TaoTermSetSolutionTemplate(), TaoTermSetParametersTemplate(), TaoTermCreateSolutionVec()

External Links

source
PETSc.LibPETSc.TaoTermSetType — Method
TaoTermSetType(petsclib::PetscLibType, term::TaoTerm, type::String)

Set the type of a TaoTerm

Collective

Input Parameters:

  • term - a TaoTerm
  • type - a TaoTermType

Options Database Keys:

  • -tao_term_type <type> - l1, halfl2squared, TaoTermType for complete list

Level: beginner

Notes: Use TaoTermCreateShell() to define a custom term using your own function definition

New types of TaoTerm can be created with TaoTermRegister()

TaoTerm, TaoTermType, TaoTermCreate(), TaoTermGetType(), TaoTermSetFromOptions(), TaoTermSetUp(), TaoTermView(), TaoTermDestroy()

External Links

source
PETSc.LibPETSc.TaoTermSetUp — Method
TaoTermSetUp(petsclib::PetscLibType, term::TaoTerm)

Set up a TaoTerm.

Collective

Input Parameter:

  • term - a TaoTerm

Level: intermediate

TaoTerm, TaoTermCreate(), TaoTermSetType(), TaoTermSetFromOptions(), TaoTermView(), TaoTermDestroy()

External Links

source
PETSc.LibPETSc.TaoTermShellGetContext — Method
ctx::Ptr{Cvoid} = TaoTermShellGetContext(petsclib::PetscLibType, term::TaoTerm)

Get the context for a TAOTERMSHELL

Not collective

Input Parameter:

  • term - a TaoTerm of type TAOTERMSHELL

Output Parameter:

  • ctx - a context

Level: intermediate

See also: TaoTerm, TAOTERMSHELL, TaoTermShellSetContext(), TaoTermShellSetContextDestroy()

External Links

source
PETSc.LibPETSc.TaoTermShellSetContext — Method
TaoTermShellSetContext(petsclib::PetscLibType, term::TaoTerm, ctx::Ptr{Cvoid})

Set a context for a TAOTERMSHELL

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSHELL
  • ctx - a context

Level: intermediate

See also: TaoTerm, TAOTERMSHELL, TaoTermShellGetContext(), TaoTermShellSetContextDestroy()

External Links

source
PETSc.LibPETSc.TaoTermShellSetContextDestroy — Method
TaoTermShellSetContextDestroy(petsclib::PetscLibType, term::TaoTerm, destroy::Ptr{Cvoid})

Set a method to destroy the context resources when a TAOTERMSHELL is destroyed

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSHELL
  • destroy - the context destroy function

Level: intermediate

See also: TaoTerm, TAOTERMSHELL, TaoTermShellSetContext(), TaoTermShellGetContext()

External Links

source
PETSc.LibPETSc.TaoTermShellSetCreateHessianMatrices — Method
TaoTermShellSetCreateHessianMatrices(petsclib::PetscLibType, term::TaoTerm, createmats::external)

Set the routine that creates Hessian matrices for a TaoTerm of type TAOTERMSHELL

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSHELL
  • createmats - a function with the same signature as TaoTermCreateHessianMatrices()

Calling sequence of createmats:

  • f - the TaoTerm
  • H - (optional) a matrix of the appropriate type and size for the Hessian of term
  • Hpre - (optional) a matrix of the appropriate type and size for constructing a preconditioner for the Hessian of term

Level: intermediate

See also: TaoTerm, TAOTERMSHELL, TaoTermShellGetContext(), TaoTermShellSetContextDestroy(), TaoTermShellSetCreateSolutionVec(), TaoTermShellSetCreateParametersVec()

External Links

source
PETSc.LibPETSc.TaoTermShellSetCreateParametersVec — Method
TaoTermShellSetCreateParametersVec(petsclib::PetscLibType, term::TaoTerm, createparametersvec::external)

Set the routine that creates parameters vector for a TaoTerm of type TAOTERMSHELL

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSHELL
  • createparametersvec - a function with the same signature as TaoTermCreateParametersVec()

Calling sequence of createparametersvec:

  • term - the TaoTerm
  • parameters - a parameters vector for term

Level: intermediate

See also: TaoTerm, TAOTERMSHELL, TaoTermShellGetContext(), TaoTermShellSetContextDestroy(), TaoTermShellSetCreateHessianMatrices()

External Links

source
PETSc.LibPETSc.TaoTermShellSetCreateSolutionVec — Method
TaoTermShellSetCreateSolutionVec(petsclib::PetscLibType, term::TaoTerm, createsolutionvec::external)

Set the routine that creates solution vector for a TaoTerm of type TAOTERMSHELL

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSHELL
  • createsolutionvec - a function with the same signature as TaoTermCreateSolutionVec()

Calling sequence of createsolutionvec:

  • term - the TaoTerm
  • solution - a solution vector for term

Level: intermediate

See also: TaoTerm, TAOTERMSHELL, TaoTermShellGetContext(), TaoTermShellSetContextDestroy(), TaoTermShellSetCreateHessianMatrices()

External Links

source
PETSc.LibPETSc.TaoTermShellSetGradient — Method
TaoTermShellSetGradient(petsclib::PetscLibType, term::TaoTerm, gradient::Ptr{Cvoid})

Set the gradient function of a TAOTERMSHELL

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSHELL
  • gradient - a TaoTermGradientFn function pointer

Level: intermediate

See also: TaoTerm, TAOTERMSHELL, TaoTermShellGetContext(), TaoTermShellSetContextDestroy(), TaoTermShellSetObjective(), TaoTermShellSetObjectiveAndGradient(), TaoTermShellSetHessian(), TaoTermShellSetView(), TaoTermGradientFn

External Links

source
PETSc.LibPETSc.TaoTermShellSetHessian — Method
TaoTermShellSetHessian(petsclib::PetscLibType, term::TaoTerm, hessian::Ptr{Cvoid})

Set the Hessian function of a TAOTERMSHELL

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSHELL
  • hessian - a TaoTermHessianFn function pointer

Level: intermediate

See also: TaoTerm, TAOTERMSHELL, TaoTermShellGetContext(), TaoTermShellSetContextDestroy(), TaoTermShellSetObjective(), TaoTermShellSetGradient(), TaoTermShellSetObjectiveAndGradient(), TaoTermShellSetView(), TaoTermHessianFn

External Links

source
PETSc.LibPETSc.TaoTermShellSetIsComputeHessianFDPossible — Method
TaoTermShellSetIsComputeHessianFDPossible(petsclib::PetscLibType, term::TaoTerm, ispossible::PetscBool3)

Set whether this term can compute Hessian with finite differences for a TAOTERMSHELL

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSHELL
  • ispossible - whether Hessian computation with finite differences is possible

Level: intermediate

See also: TaoTerm, TAOTERMSHELL, TaoTermShellGetContext(), TaoTermShellSetContextDestroy(), TaoTermShellSetObjective(), TaoTermShellSetGradient(), TaoTermShellSetObjectiveAndGradient(), TaoTermShellSetHessian(), TaoTermIsComputeHessianFDPossible()

External Links

source
PETSc.LibPETSc.TaoTermShellSetObjective — Method
TaoTermShellSetObjective(petsclib::PetscLibType, term::TaoTerm, objective::Ptr{Cvoid})

Set the objective function of a TAOTERMSHELL

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSHELL
  • objective - a TaoTermObjectiveFn function pointer

Level: intermediate

See also: TaoTerm, TAOTERMSHELL, TaoTermShellGetContext(), TaoTermShellSetContextDestroy(), TaoTermShellSetGradient(), TaoTermShellSetObjectiveAndGradient(), TaoTermShellSetHessian(), TaoTermShellSetView(), TaoTermObjectiveFn

External Links

source
PETSc.LibPETSc.TaoTermShellSetObjectiveAndGradient — Method
TaoTermShellSetObjectiveAndGradient(petsclib::PetscLibType, term::TaoTerm, objandgrad::Ptr{Cvoid})

Set the objective and gradient function of a TAOTERMSHELL

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSHELL
  • objandgrad - a TaoTermObjectiveAndGradientFn function pointer

Level: intermediate

See also: TaoTerm, TAOTERMSHELL, TaoTermShellGetContext(), TaoTermShellSetContextDestroy(), TaoTermShellSetObjective(), TaoTermShellSetGradient(), TaoTermShellSetHessian(), TaoTermShellSetView(), TaoTermObjectiveAndGradientFn

External Links

source
PETSc.LibPETSc.TaoTermShellSetView — Method
TaoTermShellSetView(petsclib::PetscLibType, term::TaoTerm, view::external)

Set the view function of a TAOTERMSHELL

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSHELL
  • view - a function with the same signature as TaoTermView()

Calling sequence of view:

  • term - the TaoTerm
  • viewer - a PetscViewer

Level: intermediate

See also: TaoTerm, TAOTERMSHELL, TaoTermShellGetContext(), TaoTermShellSetContextDestroy(), TaoTermShellSetObjective(), TaoTermShellSetGradient(), TaoTermShellSetObjectiveAndGradient(), TaoTermShellSetHessian()

External Links

source
PETSc.LibPETSc.TaoTermSumAddTerm — Method
index::PetscInt = TaoTermSumAddTerm(petsclib::PetscLibType, sumterm::TaoTerm, prefix::String, scale::PetscReal, term::TaoTerm, map::AbstractPetscMat)

Append a term to the terms being summed

Collective

Input Parameters:

  • sumterm - a TaoTerm of type TAOTERMSUM
  • prefix - (optional) the prefix used for configuring the term (if NULL, the index of the term will be used as a prefix, e.g. term_0_, term_1_, etc.)
  • scale - the coefficient scaling the term in the sum
  • term - the TaoTerm to add
  • map - (optional) a map from the TAOTERMSUM solution space to the term solution space; if NULL the map is assumed to be the identity

Output Parameter:

  • index - (optional) the index of the newly added term

Level: developer

See also: TaoTerm, TAOTERMSUM

External Links

source
PETSc.LibPETSc.TaoTermSumGetLastTermObjectives — Method
values::Ptr{PetscReal} = TaoTermSumGetLastTermObjectives(petsclib::PetscLibType, term::TaoTerm)

Get the contributions from each term to the last evaluation of TaoTermComputeObjective() or TaoTermComputeObjectiveAndGradient()

Not collective

Input Parameter:

  • term - a TaoTerm of type TAOTERMSUM

Output Parameter:

  • values - an array of the contributions to the last computed objective value

Level: developer

TaoTerm, TAOTERMSUM

External Links

source
PETSc.LibPETSc.TaoTermSumGetNumberTerms — Method
n_terms::PetscInt = TaoTermSumGetNumberTerms(petsclib::PetscLibType, term::TaoTerm)

Get the number of terms in the sum

Not collective

Input Parameter:

  • term - a TaoTerm of type TAOTERMSUM

Output Parameter:

  • n_terms - the number of terms that will be in the sum

Level: developer

TaoTerm, TAOTERMSUM, TaoTermSumSetNumberTerms()

External Links

source
PETSc.LibPETSc.TaoTermSumGetTerm — Method
prefix::String,scale::PetscReal,term::TaoTerm,map::PetscMat = TaoTermSumGetTerm(petsclib::PetscLibType, sumterm::TaoTerm, index::PetscInt)

Get the data for a term in a TAOTERMSUM

Not collective

Input Parameters:

  • sumterm - a TaoTerm of type TAOTERMSUM
  • index - a number 0 \leq i < n, where n is the number of terms in TaoTermSumGetNumberTerms()

Output Parameters:

  • prefix - (optional) the prefix used for configuring the term
  • scale - (optional) the coefficient scaling the term in the sum
  • term - the TaoTerm at given index of TAOTERMSUM
  • map - (optional) a map from the TAOTERMSUM solution space to the term solution space; if NULL the map is assumed to be the identity

Level: developer

TaoTerm, TAOTERMSUM, TaoTermSumSetTerm(), TaoTermSumAddTerm()

External Links

source
PETSc.LibPETSc.TaoTermSumGetTermHessianMatrices — Method
unmapped_H::PetscMat,unmapped_Hpre::PetscMat,mapped_H::PetscMat,mapped_Hpre::PetscMat = TaoTermSumGetTermHessianMatrices(petsclib::PetscLibType, term::TaoTerm, index::PetscInt)

Get Hessian matrices set with TaoTermSumSetTermHessianMatrices().

Not collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSUM
  • index - the index for the term from TaoTermSumSetTerm() or TaoTermSumAddTerm()

Output Parameters:

  • unmapped_H - (optional) unmapped Hessian matrix
  • unmapped_Hpre - (optional) unmapped matrix for constructing the preconditioner for unmapped_H
  • mapped_H - (optional) Hessian matrix
  • mapped_Hpre - (optional) matrix for constructing the preconditioner for mapped_H

Level: developer

TaoTerm, TAOTERMSUM, TaoTermComputeHessian(), TaoTermSumSetTermHessianMatrices()

External Links

source
PETSc.LibPETSc.TaoTermSumGetTermMask — Method
mask::TaoTermMask = TaoTermSumGetTermMask(petsclib::PetscLibType, term::TaoTerm, index::PetscInt)

Get the TaoTermMask of a term in the sum

Not collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSUM
  • index - the index for the term from TaoTermSumSetTerm() or TaoTermSumAddTerm()

Output Parameter:

  • mask - a bitmask of TaoTermMask evaluation methods to mask (e.g. just TAOTERM_MASK_OBJECTIVE or a bitwise-or like TAOTERM_MASK_OBJECTIVE | TAOTERM_MASK_GRADIENT)

Level: developer

TaoTerm, TAOTERMSUM, TaoTermSumSetTermMask()

External Links

source
PETSc.LibPETSc.TaoTermSumParametersPack — Method
params::PetscVec = TaoTermSumParametersPack(petsclib::PetscLibType, term::TaoTerm, p_arr::Vector{<:AbstractPetscVec})

Concatenate the parameters for terms into a VECNEST parameter vector for a TAOTERMSUM

Collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSUM
  • p_arr - an array of parameters Vecs, one for each term in the sum. An entry can be NULL for a term that doesn't take parameters.

Output Parameter:

  • params - a Vec of type VECNEST that concatenates all of the parameters

Level: developer

Note: This is a wrapper around VecCreateNest(), but that function does not allow NULL for any of the Vecs in the array. A 0-length vector will be created for each NULL Vec that will be internally ignored by TAOTERMSUM.

TaoTerm, TAOTERMSUM, TaoTermSumParametersUnpack(), VECNEST, VecNestGetTaoTermSumParameters(), VecCreateNest()

External Links

source
PETSc.LibPETSc.TaoTermSumParametersUnpack — Method
TaoTermSumParametersUnpack(petsclib::PetscLibType, term::TaoTerm, params::AbstractPetscVec, p_arr::Vector{<:AbstractPetscVec})

Unpack the concatenated parameters created by TaoTermSumParametersPack() and destroy the VECNEST

Collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSUM
  • params - a Vec created by TaoTermSumParametersPack()

Output Parameter:

  • p_arr - an array of parameters Vecs, one for each term in the sum. An entry will be NULL if NULL was passed in the same position of TaoTermSumParametersPack()

Level: intermediate

TaoTerm, TAOTERMSUM, TaoTermSumParametersPack(), VecNestGetTaoTermSumParameters()

External Links

source
PETSc.LibPETSc.TaoTermSumSetNumberTerms — Method
TaoTermSumSetNumberTerms(petsclib::PetscLibType, term::TaoTerm, n_terms::PetscInt)

Set the number of terms in the sum

Collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSUM
  • n_terms - the number of terms that will be in the sum

Level: developer

Note: If n_terms is smaller than the current number of terms, the trailing terms will be dropped.

TaoTerm, TAOTERMSUM, TaoTermSumGetNumberTerms()

External Links

source
PETSc.LibPETSc.TaoTermSumSetTerm — Method
TaoTermSumSetTerm(petsclib::PetscLibType, sumterm::TaoTerm, index::PetscInt, prefix::String, scale::PetscReal, term::TaoTerm, map::AbstractPetscMat)

Set a term in a sum of terms

Collective

Input Parameters:

  • sumterm - a TaoTerm of type TAOTERMSUM
  • index - a number 0 \leq i < n, where n is the number of terms in TaoTermSumSetNumberTerms()
  • prefix - (optional) the prefix used for configuring the term (if NULL, term_x_ will be the prefix, e.g. "term0", "term1", etc.)
  • scale - the coefficient scaling the term in the sum
  • term - the TaoTerm to be set in TAOTERMSUM
  • map - (optional) a map from the TAOTERMSUM solution space to the term solution space; if NULL the map is assumed to be the identity

Level: developer

TaoTerm, TAOTERMSUM, TaoTermSumGetTerm(), TaoTermSumAddTerm()

External Links

source
PETSc.LibPETSc.TaoTermSumSetTermHessianMatrices — Method
TaoTermSumSetTermHessianMatrices(petsclib::PetscLibType, term::TaoTerm, index::PetscInt, unmapped_H::AbstractPetscMat, unmapped_Hpre::AbstractPetscMat, mapped_H::AbstractPetscMat, mapped_Hpre::AbstractPetscMat)

Set Hessian matrices that can be used internally by a TAOTERMSUM

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSUM
  • index - the index for the term from TaoTermSumSetTerm() or TaoTermSumAddTerm()
  • unmapped_H - (optional) unmapped Hessian matrix
  • unmapped_Hpre - (optional) unmapped matrix for constructing the preconditioner of unmapped_H
  • mapped_H - (optional) Hessian matrix
  • mapped_Hpre - (optional) matrix for constructing the preconditioner of mapped_H

Level: developer

Notes: If the inner term has the form g(x) = \alpha f(Ax; p), the "mapped" Hessians should be able to hold the Hessian \nabla^2 g and the unmapped Hessians should be able to hold the Hessian \nabla_x^2 f. If the term is not mapped, just pass the unmapped Hessians (e.g. TaoTermSumSetTermHessianMatrices(term, 0, H, Hpre, NULL, NULL)).

TaoTerm, TAOTERMSUM, TaoTermComputeHessian(), TaoTermSumGetTermHessianMatrices()

External Links

source
PETSc.LibPETSc.TaoTermSumSetTermMask — Method
TaoTermSumSetTermMask(petsclib::PetscLibType, term::TaoTerm, index::PetscInt, mask::TaoTermMask)

Set a TaoTermMask on a term in the sum

Logically collective

Input Parameters:

  • term - a TaoTerm of type TAOTERMSUM
  • index - the index for the term from TaoTermSumSetTerm() or TaoTermSumAddTerm()
  • mask - a bitmask of TaoTermMask evaluation methods to mask (e.g. just TAOTERM_MASK_OBJECTIVE or a bitwise-or like TAOTERM_MASK_OBJECTIVE | TAOTERM_MASK_GRADIENT)

Options Database Keys:

  • -tao_term_sum_<prefix_>mask - a list containing any of none, objective, gradient, and hessian to indicate which evaluations to mask for a term with a given prefix (see TaoTermSumSetTerm())

Level: developer

Note: Some optimization methods may add a damping term to the Hessian of an objective function without affecting the objective or gradient. If, e.g., the regularizer has index 1, then this can be accomplished with TaoTermSumSetTermMask(term, 1, TAOTERM_MASK_OBJECTIVE | TAOTERM_MASK_GRADIENT).

TaoTerm, TAOTERMSUM, TaoTermSumGetTermMask()

External Links

source
PETSc.LibPETSc.TaoTermView — Method
TaoTermView(petsclib::PetscLibType, term::TaoTerm, viewer::PetscViewer)

View a description of a TaoTerm.

Collective

Input Parameters:

  • term - a TaoTerm
  • viewer - a PetscViewer

Level: beginner

TaoTerm, TaoTermCreate(), TaoTermSetType(), TaoTermSetFromOptions(), TaoTermSetUp(), TaoTermDestroy(), PetscViewer

External Links

source