Commit fa1cfae9 authored by Stéphane Adjemian's avatar Stéphane Adjemian

Added the possibility to rescale the initial guess.

As in MINPACK tests.
parent d78d45b9
#=
** This script performs tests for the trust region nonlinear solver.
** This script performs tests for the trust region nonlinear solver.
**
** Copyright (C) 2018 Dynare Team
** Copyright © 2018, 2019 Dynare Team
**
** This file is part of Dynare.
**
......@@ -30,62 +30,135 @@ using TestFunctions
cd("$(rootdir)")
@testset "test trust-region-solver" begin
@test begin
x, info = trustregion(rosenbrock!, rosenbrock!, rosenbrock(), 1.0e-6, 1.0e-6, 50)
info==1
ntries = 1
n = 10
@time @testset "test trust-region-solver" begin
factor = 1.0
xguess = rosenbrock()
for i=ntries
@test begin
x, info = trustregion(rosenbrock!, rosenbrock!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(powell1!, powell1!, powell1(), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = powell1()
for i=ntries
@test begin
x, info = trustregion(powell1!, powell1!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(powell2!, powell2!, powell2(), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = powell2()
for i=1:ntries
@test begin
x, info = trustregion(powell2!, powell2!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(wood!, wood!, wood(), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = wood()
for i=1:ntries
@test begin
x, info = trustregion(wood!, wood!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(helicalvalley!, helicalvalley!, helicalvalley(), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = helicalvalley()
for i=1:ntries
@test begin
x, info = trustregion(helicalvalley!, helicalvalley!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(watson!, watson!, watson(10), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = watson(n)
for i=1:ntries
@test begin
x, info = trustregion(watson!, watson!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(chebyquad!, chebyquad!, chebyquad(10), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = chebyquad(n)
for i=1:ntries
@test begin
x, info = trustregion(chebyquad!, chebyquad!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(brown!, brown!, brown(10), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = brown(n)
for i=1:ntries
@test begin
x, info = trustregion(brown!, brown!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(discreteboundaryvalue!, discreteboundaryvalue!, discreteboundaryvalue(10), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = discreteboundaryvalue(n)
for i=1:ntries
@test begin
x, info = trustregion(discreteboundaryvalue!, discreteboundaryvalue!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(discreteintegralequation!, discreteintegralequation!, discreteintegralequation(10), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = discreteintegralequation(n)
for i=1:ntries
@test begin
x, info = trustregion(discreteintegralequation!, discreteintegralequation!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(trigonometric!, trigonometric!, trigonometric(10), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = trigonometric(n)
for i=1:ntries
@test begin
x, info = trustregion(trigonometric!, trigonometric!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(variablydimensioned!, variablydimensioned!, variablydimensioned(10), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = variablydimensioned(n)
for i=1:ntries
@test begin
x, info = trustregion(variablydimensioned!, variablydimensioned!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(broydentridiagonal!, broydentridiagonal!, broydentridiagonal(10), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = broydentridiagonal(n)
for i=1:ntries
@test begin
x, info = trustregion(broydentridiagonal!, broydentridiagonal!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
@test begin
x, info = trustregion(broydenbanded!, broydenbanded!, broydenbanded(10), 1.0e-6, 1.0e-6, 50)
info==1
factor = 1.0
xguess = broydenbanded(n)
for i=1:ntries
@test begin
x, info = trustregion(broydenbanded!, broydenbanded!, factor*xguess, 1.0e-6, 1.0e-6, 50*n)
info==1
end
factor *= 2.0
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment