-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathwatson.jl
More file actions
48 lines (42 loc) · 1.23 KB
/
watson.jl
File metadata and controls
48 lines (42 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# Watson problem in varaible dimension ( 2 <= n <= 31 ).
# This function is a nonlinear least squares with 31 groups.
#
# Source: problem 20 in
# J.J. More', B.S. Garbow and K.E. Hillstrom,
# "Testing Unconstrained Optimization Software",
# ACM Transactions on Mathematical Software, vol. 7(1), pp. 17-41, 1981.
# Also problem 128 (p. 100) in
# A.R. Buckley,
# "Test functions for unconstrained minimization",
# TR 1989CS-3, Mathematics, statistics and computing centre,
# Dalhousie University, Halifax (CDN), 1989.
#
# SUR2-AN-V-0
export watson
function watson(args...; n::Int = default_nvar, kwargs...)
n = min(max(n, 2), 31)
m = 31
nlp = Model()
@variable(nlp, x[j = 1:n], start = 0.0)
@objective(
nlp,
Min,
0.5 * sum(
(
sum((j - 1) * x[j] * (i / 29)^(j - 2) for j = 2:n) -
sum(x[j] * (i / 29)^(j - 1) for j = 1:n)^2 - 1
)^2 for i = 1:29
) +
0.5 *
(
sum((j - 1) * x[j] * x[1]^(j - 2) for j = 2:n) - sum(x[j] * x[1]^(j - 1) for j = 1:n)^2 - 1
)^2 +
0.5 *
(
sum((j - 1) * x[j] * (x[2] - x[1]^2 - 1)^(j - 2) for j = 2:n) -
sum(x[j] * (x[2] - x[1]^2 - 1)^(j - 1) for j = 1:n)^2 - 1
)^2
)
return nlp
end