Skip to content

Commit ffaf8fe

Browse files
authored
Update runtests.jl
Use `maxfun = 500n` and `rhoend = 1e-6` instead of `maxfun = 200n` and `rhoend = 1e-3` in the test. Users may use the tests as examples to learn how to set parameters in practice. The original values will render only rough solutions.
1 parent 2714339 commit ffaf8fe

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

test/runtests.jl

+20-20
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ end
8989

9090
@testset "NEWUOA" begin
9191
println("\nNEWUOA:")
92-
kwds = (rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf,
93-
maxfun = 200n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
92+
kwds = (rhobeg = 1.0, rhoend = 1e-6, ftarget = -Inf,
93+
maxfun = 500n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
9494
x, info = @inferred PRIMA.newuoa(f, x0; kwds...)
9595
print_1(x, info)
9696
@test issuccess(info)
@@ -102,34 +102,34 @@ end
102102
@test x1 == x
103103
@test info1 == info
104104
# Solve problem with scaling factors.
105-
kwds = (scale, rhobeg = 1.0/scl, rhoend = 1e-3/scl, ftarget = -Inf,
106-
maxfun = 200n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
105+
kwds = (scale, rhobeg = 1.0/scl, rhoend = 1e-6/scl, ftarget = -Inf,
106+
maxfun = 500n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
107107
x1, info1 = @inferred PRIMA.newuoa(f, x0; kwds...)
108108
@test x1 x
109109
end
110110

111111
@testset "UOBYQA" begin
112112
println("\nUOBYQA:")
113-
kwds = (rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf,
114-
maxfun = 200n, iprint = PRIMA.MSG_EXIT)
113+
kwds = (rhobeg = 1.0, rhoend = 1e-6, ftarget = -Inf,
114+
maxfun = 500n, iprint = PRIMA.MSG_EXIT)
115115
x, info = @inferred PRIMA.uobyqa(f, x0; kwds...)
116116
print_1(x, info)
117117
@test issuccess(info)
118118
@test x [3,2] atol=2e-2 rtol=0
119119
@test f(x) info.fx
120120
@test x0 == x0_sav
121121
# Solve problem with scaling factors.
122-
kwds = (scale, rhobeg = 1.0/scl, rhoend = 1e-3/scl, ftarget = -Inf,
123-
maxfun = 200n, iprint = PRIMA.MSG_EXIT)
122+
kwds = (scale, rhobeg = 1.0/scl, rhoend = 1e-6/scl, ftarget = -Inf,
123+
maxfun = 500n, iprint = PRIMA.MSG_EXIT)
124124
x1, info1 = @inferred PRIMA.uobyqa(f, x0; kwds...)
125125
@test x1 x
126126
end
127127

128128
@testset "BOBYQA" begin
129129
println("\nBOBYQA:")
130130
kwds = (xl = xl, xu = xu,
131-
rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf,
132-
maxfun = 200n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
131+
rhobeg = 1.0, rhoend = 1e-6, ftarget = -Inf,
132+
maxfun = 500n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
133133
x, info = @inferred PRIMA.bobyqa(f, x0; kwds...)
134134
print_1(x, info)
135135
@test issuccess(info)
@@ -142,17 +142,17 @@ end
142142
@test x1 == x
143143
@test info1 == info
144144
# Solve problem with scaling factors.
145-
kwds = (scale, rhobeg = 1.0/scl, rhoend = 1e-3/scl, ftarget = -Inf,
146-
maxfun = 200n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
145+
kwds = (scale, rhobeg = 1.0/scl, rhoend = 1e-6/scl, ftarget = -Inf,
146+
maxfun = 500n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
147147
x1, info1 = @inferred PRIMA.bobyqa(f, x0; kwds...)
148148
@test x1 x
149149
end
150150

151151
@testset "COBYLA" begin
152152
println("\nCOBYLA:")
153153
kwds = (xl = xl, xu = xu, linear_ineq = (A_ineq, b_ineq),
154-
rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf,
155-
maxfun = 200*n, iprint = PRIMA.MSG_EXIT)
154+
rhobeg = 1.0, rhoend = 1e-6, ftarget = -Inf,
155+
maxfun = 500n, iprint = PRIMA.MSG_EXIT)
156156
# First call with just the number of non-linear inequality constraints.
157157
x, info = @inferred PRIMA.cobyla(f, x0; kwds...,
158158
nonlinear_ineq = c_ineq)
@@ -174,8 +174,8 @@ end
174174
@test info1 == info
175175
# Solve problem with scaling factors.
176176
kwds = (xl = xl, xu = xu, linear_ineq = (A_ineq, b_ineq),
177-
scale, rhobeg = 1.0/scl, rhoend = 1e-3/scl, ftarget = -Inf,
178-
maxfun = 200n, iprint = PRIMA.MSG_EXIT)
177+
scale, rhobeg = 1.0/scl, rhoend = 1e-6/scl, ftarget = -Inf,
178+
maxfun = 500n, iprint = PRIMA.MSG_EXIT)
179179
x1, info1 = @inferred PRIMA.cobyla(f, x0; kwds...,
180180
nonlinear_ineq = c_ineq)
181181
@test x1 x
@@ -184,8 +184,8 @@ end
184184
@testset "LINCOA" begin
185185
println("\nLINCOA:")
186186
kwds = (xl = xl, xu = xu, linear_ineq = (A_ineq, b_ineq),
187-
rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf,
188-
maxfun = 200*n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
187+
rhobeg = 1.0, rhoend = 1e-6, ftarget = -Inf,
188+
maxfun = 500n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
189189
x, info = @inferred PRIMA.lincoa(f, x0; kwds...)
190190
print_2(x, info)
191191
@test issuccess(info)
@@ -199,8 +199,8 @@ end
199199
@test info1 == info
200200
# Solve problem with scaling factors.
201201
kwds = (xl = xl, xu = xu, linear_ineq = (A_ineq, b_ineq),
202-
scale, rhobeg = 1.0/scl, rhoend = 1e-3/scl, ftarget = -Inf,
203-
maxfun = 200n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
202+
scale, rhobeg = 1.0/scl, rhoend = 1e-6/scl, ftarget = -Inf,
203+
maxfun = 500n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT)
204204
x1, info1 = @inferred PRIMA.lincoa(f, x0; kwds...)
205205
@test x1 x
206206
end

0 commit comments

Comments
 (0)