Skip to content

Commit

Permalink
Fix typos detected by spell-checking GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
emmt committed Oct 23, 2023
1 parent 10d3a56 commit 9760ada
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,7 @@ isrvub
isscalar
isspace
isstruct
issuccess
issymmetric
istp
istr
Expand Down
10 changes: 5 additions & 5 deletions src/PRIMA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ An object, say `info`, of this type has the following properties:
info.nl_ineq # non-linear inequality constraints, empty vector if none
Call `issuccess(info)` or `issuccess(info.status)` to check whether algorithm
was sucessful. Call `PRIMA.reason(info)` or `PRIMA.reason(info.status)` to
was successful. Call `PRIMA.reason(info)` or `PRIMA.reason(info.status)` to
retrieve a textual description of the algorithm termination.
"""
Expand Down Expand Up @@ -62,7 +62,7 @@ LinearAlgebra.issuccess(status::Status) =
PRIMA.reason(info::PRIMA.Info) -> str
PRIMA.reason(status::PRIMA.Status) -> str
yield a textual message explaining `info.statu` or `status`, the status code
yield a textual message explaining `info.status` or `status`, the status code
returned by one of the PRIMA optimizers.
"""
Expand Down Expand Up @@ -521,7 +521,7 @@ function cobyla!(f, x::DenseVector{Cdouble};
A_eq, b_eq = _get_linear_constraints(linear_eq, n, scl)
A_ineq, b_ineq = _get_linear_constraints(linear_ineq, n, scl)

# Alocate vector to store all non-linear constraints (the non-linear
# Allocate vector to store all non-linear constraints (the non-linear
# equalities being implemented as 2 inequalities each).
nl_all = Vector{Cdouble}(undef, 2*length(nl_eq) + length(nl_ineq))

Expand Down Expand Up @@ -655,7 +655,7 @@ struct ObjFun{F,E,I}
c_ineq::I # callable implementing non-linear inequalities as `c_ineq(x) ≤ 0`
n_ineq::Int # number of non-linear inequalities
scl::Vector{Cdouble} # scaling factors or empty
wrk::Vector{Cdouble} # workspace for variables
x::Vector{Cdouble} # workspace for variables
end

unconstrained(x::AbstractVector{T}) where {T} = NullVector{T}()
Expand Down Expand Up @@ -781,7 +781,7 @@ function unsafe_call(f::ObjFun, x_ptr::Ptr{Cdouble}, c_ptr::Ptr{Cdouble})
end

function get_variables(f::ObjFun, x_ptr::Ptr{Cdouble})
n, x, scl = f.n, f.wrk, f.scl
n, x, scl = f.n, f.x, f.scl
length(x) == n || corrupted_structure("invalid number of variables")
if isempty(scl)
# No scaling of variables.
Expand Down
32 changes: 16 additions & 16 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ optimizer(algo::Symbol) =
algo === :prima ? PRIMA.prima :
error("unknown optimizer `:$algo`")

prt_1(x::AbstractVector, info::PRIMA.Info) = prt_1(stdout, x, info)
function prt_1(io::IO, x::AbstractVector, info::PRIMA.Info)
print_1(x::AbstractVector, info::PRIMA.Info) = print_1(stdout, x, info)
function print_1(io::IO, x::AbstractVector, info::PRIMA.Info)
msg = PRIMA.reason(info)
println(io, "x = $x, f(x) = $(info.fx), status = $(info.status), msg = '$msg', evals = $(info.nf)")
end

prt_2(x::AbstractVector, info::PRIMA.Info) = prt_2(stdout, x, info)
function prt_2(io::IO, x::AbstractVector, info::PRIMA.Info)
print_2(x::AbstractVector, info::PRIMA.Info) = print_2(stdout, x, info)
function print_2(io::IO, x::AbstractVector, info::PRIMA.Info)
msg = PRIMA.reason(info)
println(io, "x = $x, f(x) = $(info.fx), cstrv = $(info.cstrv), status = $(info.status), msg = '$msg', evals = $(info.nf)")
end

prt_3(x::AbstractVector, info::PRIMA.Info) = prt_3(stdout, x, info)
function prt_3(io::IO, x::AbstractVector, info::PRIMA.Info)
print_3(x::AbstractVector, info::PRIMA.Info) = print_3(stdout, x, info)
function print_3(io::IO, x::AbstractVector, info::PRIMA.Info)
msg = PRIMA.reason(info)
println("x = $x, f(x) = $(info.fx), cstrv = $(info.cstrv), c(x) = $(info.nl_ineq), status = $(info.status), msg = '$msg', evals = $(info.nf)")
end
Expand Down Expand Up @@ -97,7 +97,7 @@ end
kwds = (rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf,
maxfun = 200n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
x, info = @inferred PRIMA.newuoa(f, x0; kwds...)
prt_1(x, info)
print_1(x, info)
@test x [3,2] atol=2e-2 rtol=0
@test f(x) info.fx
@test x0 == x0_sav
Expand All @@ -117,7 +117,7 @@ end
kwds = (rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf,
maxfun = 200n, iprint = PRIMA.MSG_EXIT)
x, info = @inferred PRIMA.uobyqa(f, x0; kwds...)
prt_1(x, info)
print_1(x, info)
@test x [3,2] atol=2e-2 rtol=0
@test f(x) info.fx
@test x0 == x0_sav
Expand All @@ -134,7 +134,7 @@ end
rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf,
maxfun = 200n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
x, info = @inferred PRIMA.bobyqa(f, x0; kwds...)
prt_1(x, info)
print_1(x, info)
@test x [3,2] atol=2e-2 rtol=0
@test f(x) info.fx
@test x0 == x0_sav
Expand All @@ -158,7 +158,7 @@ end
# First call with just the number of non-linear inequality constraints.
x, info = @inferred PRIMA.cobyla(f, x0; kwds...,
nonlinear_ineq = c_ineq)
prt_3(x, info)
print_3(x, info)
@test x [3,2] atol=2e-2 rtol=0
@test f(x) info.fx
@test x0 == x0_sav
Expand Down Expand Up @@ -188,7 +188,7 @@ end
rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf,
maxfun = 200*n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
x, info = @inferred PRIMA.lincoa(f, x0; kwds...)
prt_2(x, info)
print_2(x, info)
@test x [3,2] atol=2e-2 rtol=0
@test f(x) info.fx
@test x0 == x0_sav
Expand Down Expand Up @@ -279,7 +279,7 @@ end
else
continue
end
prt_1(x, info)
print_1(x, info)
@test x [1,1] rtol=0 atol=(optim == :cobyla ? 3e-2 : 2e-2)
@test f(x) info.fx

Expand All @@ -301,7 +301,7 @@ end
else
continue
end
prt_1(x, info)
print_1(x, info)
@test x [1.095247,1.2] rtol=0 atol=2e-2
@test f(x) info.fx
end
Expand All @@ -320,7 +320,7 @@ end
else
continue
end
prt_1(x, info)
print_1(x, info)
@test x [1.0,1.0] rtol=0 atol=(optim == :cobyla ? 3e-2 : 2e-2)
@test f(x) info.fx

Expand All @@ -337,7 +337,7 @@ end
else
continue
end
prt_1(x, info)
print_1(x, info)
@test x [1.0,1.0] rtol=0 atol=(optim == :cobyla ? 3e-2 : 2e-2)
@test f(x) info.fx

Expand All @@ -355,7 +355,7 @@ end
else
continue
end
prt_1(x, info)
print_1(x, info)
@test x [1.441832,2.077557] rtol=0 atol=(optim == :cobyla ? 3e-2 : 2e-2)
@test f2(x) info.fx
end
Expand Down

0 comments on commit 9760ada

Please sign in to comment.