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. ** This file is part of Dynare.
** **
...@@ -30,62 +30,135 @@ using TestFunctions ...@@ -30,62 +30,135 @@ using TestFunctions
cd("$(rootdir)") cd("$(rootdir)")
@testset "test trust-region-solver" begin ntries = 1
@test begin n = 10
x, info = trustregion(rosenbrock!, rosenbrock!, rosenbrock(), 1.0e-6, 1.0e-6, 50)
info==1 @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 end
@test begin factor = 1.0
x, info = trustregion(powell1!, powell1!, powell1(), 1.0e-6, 1.0e-6, 50) xguess = powell1()
info==1 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 end
@test begin factor = 1.0
x, info = trustregion(powell2!, powell2!, powell2(), 1.0e-6, 1.0e-6, 50) xguess = powell2()
info==1 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 end
@test begin factor = 1.0
x, info = trustregion(wood!, wood!, wood(), 1.0e-6, 1.0e-6, 50) xguess = wood()
info==1 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 end
@test begin factor = 1.0
x, info = trustregion(helicalvalley!, helicalvalley!, helicalvalley(), 1.0e-6, 1.0e-6, 50) xguess = helicalvalley()
info==1 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 end
@test begin factor = 1.0
x, info = trustregion(watson!, watson!, watson(10), 1.0e-6, 1.0e-6, 50) xguess = watson(n)
info==1 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 end
@test begin factor = 1.0
x, info = trustregion(chebyquad!, chebyquad!, chebyquad(10), 1.0e-6, 1.0e-6, 50) xguess = chebyquad(n)
info==1 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 end
@test begin factor = 1.0
x, info = trustregion(brown!, brown!, brown(10), 1.0e-6, 1.0e-6, 50) xguess = brown(n)
info==1 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 end
@test begin factor = 1.0
x, info = trustregion(discreteboundaryvalue!, discreteboundaryvalue!, discreteboundaryvalue(10), 1.0e-6, 1.0e-6, 50) xguess = discreteboundaryvalue(n)
info==1 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 end
@test begin factor = 1.0
x, info = trustregion(discreteintegralequation!, discreteintegralequation!, discreteintegralequation(10), 1.0e-6, 1.0e-6, 50) xguess = discreteintegralequation(n)
info==1 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 end
@test begin factor = 1.0
x, info = trustregion(trigonometric!, trigonometric!, trigonometric(10), 1.0e-6, 1.0e-6, 50) xguess = trigonometric(n)
info==1 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 end
@test begin factor = 1.0
x, info = trustregion(variablydimensioned!, variablydimensioned!, variablydimensioned(10), 1.0e-6, 1.0e-6, 50) xguess = variablydimensioned(n)
info==1 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 end
@test begin factor = 1.0
x, info = trustregion(broydentridiagonal!, broydentridiagonal!, broydentridiagonal(10), 1.0e-6, 1.0e-6, 50) xguess = broydentridiagonal(n)
info==1 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 end
@test begin factor = 1.0
x, info = trustregion(broydenbanded!, broydenbanded!, broydenbanded(10), 1.0e-6, 1.0e-6, 50) xguess = broydenbanded(n)
info==1 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
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