API

Numerical methods

ConstrainedRootSolvers.find_zeroFunction

Function to find the first root that gives a target function result of zero. If the root does not exist, the function returns the point where the target function is most close to zero.

find_zero(f, ms, tol; stepping)

defined at /home/runner/work/ConstrainedRootSolvers.jl/ConstrainedRootSolvers.jl/src/find_zero.jl:40.

find_zero(f, ms, tol; stepping)

defined at /home/runner/work/ConstrainedRootSolvers.jl/ConstrainedRootSolvers.jl/src/find_zero.jl:144.

find_zero(f, ms, tol; stepping)

defined at /home/runner/work/ConstrainedRootSolvers.jl/ConstrainedRootSolvers.jl/src/find_zero.jl:258.

find_zero(f, ms, tol; stepping)

defined at /home/runner/work/ConstrainedRootSolvers.jl/ConstrainedRootSolvers.jl/src/find_zero.jl:322.

source
ConstrainedRootSolvers.find_peakFunction
find_peak(f::F,
          ms::AbstractCRSMethod{FT},
          tol::AbstractTolerance{FT}
) where {F<:Function, FT<:AbstractFloat}

Find the solution, given

Note that to compute the lowest value, use -f to make it a peak.

Possible combinations

Method TypeTolerance typePass Test
BisectionMethodSolutionTolerance2 allocs
NelderMeadMethodResidualToleranceN+6 allocs
NelderMeadMethodSolutionToleranceNDN+6 allocs
ReduceStepMethodSolutionToleranceYes
ReduceStepMethodNDSolutionToleranceND4 allocs
source

Method options

ConstrainedRootSolvers.BisectionMethodType

Bisection method for 1D root solvers

mutable struct BisectionMethod{FT<:AbstractFloat} <: ConstrainedRootSolvers.AbstractCRSMethod{FT<:AbstractFloat}

Fields

  • x_min::AbstractFloat

    lower bound

  • x_max::AbstractFloat

    upper bound

  • xy::Matrix{FT} where FT<:AbstractFloat

    matrix that stores x and y

  • history::Vector{T} where T

    history of all simulations

source
ConstrainedRootSolvers.NelderMeadMethodType

Nelder-Mead method for 2D and above solvers

mutable struct NelderMeadMethod{FT<:AbstractFloat} <: ConstrainedRootSolvers.AbstractCRSMethod{FT<:AbstractFloat}

Fields

  • N::Int64

    Number of parameters to optimize

  • x_inis::Vector{FT} where FT<:AbstractFloat

    Initial values

  • simplex::Array{Vector{FT}, 1} where FT<:AbstractFloat

    Simplex array of array with dimension (N+1) * (N+1)

  • cen_x::Vector{FT} where FT<:AbstractFloat

    Centroid

  • ref_x::Vector{FT} where FT<:AbstractFloat

    Reflection

  • exp_x::Vector{FT} where FT<:AbstractFloat

    Expansion

  • con_x::Vector{FT} where FT<:AbstractFloat

    Contraction

source
ConstrainedRootSolvers.NewtonBisectionMethodType

Newton's method constrained by mininum and maximum ranges for 1D root solver

mutable struct NewtonBisectionMethod{FT<:AbstractFloat} <: ConstrainedRootSolvers.AbstractCRSMethod{FT<:AbstractFloat}

Fields

  • x_min::AbstractFloat

    Lower bound

  • x_max::AbstractFloat

    Upper bound

  • x_ini::AbstractFloat

    Initial guess

  • history::Vector{T} where T

    history of all simulations

source
ConstrainedRootSolvers.NewtonRaphsonMethodType

Newton raphson method for 1D root solver

mutable struct NewtonRaphsonMethod{FT<:AbstractFloat} <: ConstrainedRootSolvers.AbstractCRSMethod{FT<:AbstractFloat}

Fields

  • x_ini::AbstractFloat

    Initial guess

  • history::Vector{T} where T

    history of all simulations

source
ConstrainedRootSolvers.ReduceStepMethodType

Reduce step method for 1D root solver. This method increases or decreases from initial guess until no improvement is found. Then the incremantal step decreases, and then the root solver continues.

mutable struct ReduceStepMethod{FT<:AbstractFloat} <: ConstrainedRootSolvers.AbstractCRSMethod{FT<:AbstractFloat}

Fields

  • x_min::AbstractFloat

    Lower bound

  • x_max::AbstractFloat

    Upper bound

  • x_ini::AbstractFloat

    Initial guess

  • Δ_ini::AbstractFloat

    Initial step

  • history::Vector{T} where T

    history of all simulations

source
ConstrainedRootSolvers.ReduceStepMethodNDType

Reduce step method for 2D and above root solver. This method increases or decreases each variable in the initial guess until no improvement is found. Then the incremental steps decreases, and then the root solver continues.

mutable struct ReduceStepMethodND{FT<:AbstractFloat} <: ConstrainedRootSolvers.AbstractCRSMethod{FT<:AbstractFloat}

Fields

  • x_mins::Vector{FT} where FT<:AbstractFloat

    Lower bound

  • x_maxs::Vector{FT} where FT<:AbstractFloat

    Upper bound

  • x_inis::Vector{FT} where FT<:AbstractFloat

    Initial guess

  • x_targ::Vector{FT} where FT<:AbstractFloat

    Target x

  • x_temp::Vector{FT} where FT<:AbstractFloat

    Temporary x

  • Δ_inis::Vector{FT} where FT<:AbstractFloat

    Initial step

  • Δ_oper::Vector{FT} where FT<:AbstractFloat

    Operation step

  • Δjd::Vector{Bool}

    Array of judges

source

Tolerance options

ConstrainedRootSolvers.ResidualToleranceType

Tolerance for target function residual

struct ResidualTolerance{FT} <: ConstrainedRootSolvers.AbstractTolerance{FT}

Fields

  • tol::Any

    Tolerance for residual

  • n_limit::Int64

    limit of iterations

source
ConstrainedRootSolvers.SolutionToleranceNDType

Tolerance for 2D and above solution

struct SolutionToleranceND{FT} <: ConstrainedRootSolvers.AbstractTolerance{FT}

Fields

  • tol::Vector{FT} where FT

    Tolerance for solution

  • n_limit::Int64

    limit of iterations

source
ConstrainedRootSolvers.next_xy!Function
next_xy!(f::F, xy::Array{FT,2}) where {F<:Function, FT<:AbstractFloat}

Determine the next points to, given

  • f Function to find peak
  • xy Array of x and y
source