This commit is contained in:
elvis
2023-11-19 22:18:28 +01:00
parent 7afb1372f8
commit 671c0371b5
4 changed files with 30 additions and 593 deletions

View File

@ -12,7 +12,7 @@ function NWTN(f;
MInf::Real=-Inf,
mina::Real=1e-16,
plt::Union{Plots.Plot, Nothing}=nothing,
plotatend::Bool=true,
plotatend::Bool=false,
Plotf::Integer=0,
printing::Bool=true)::Tuple{AbstractArray, String}
@ -99,7 +99,7 @@ function NWTN(f;
am = 0
a = as
phipm = phip0
while (feval MaxFeval ) && ((as - am)) > mina && (phips > 1e-12)
while (feval MaxFeval ) && (as - am) > mina && (phips > 1e-12)
# compute the new value by safeguarded quadratic interpolation
a = (am * phips - as * phipm) / (phips - phipm)
@ -107,7 +107,7 @@ function NWTN(f;
# compute phi(a)
phia, phip = f2phi(a, true)
if (phia phi0 + m1 * a * phip0) && (abs(phip) -m2 * phip0)
break # Armijo + strong Wolfe satisfied, we are done
end
@ -372,12 +372,12 @@ function NWTN(f;
end
end
if Plotf 2
plot!(plt, gap)
elseif Plotf == 1 && n == 2
plot!(plt, PXY[1, :], PXY[2, :])
end
if plotatend
if Plotf 2
plot!(plt, gap)
elseif Plotf == 1 && n == 2
plot!(plt, PXY[1, :], PXY[2, :])
end
display(plt)
end

570
11-09/Untitled.ipynb generated

File diff suppressed because one or more lines are too long