File tree Expand file tree Collapse file tree 2 files changed +18
-15
lines changed
Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Original file line number Diff line number Diff line change 11export trigb
22
33function trigb (; n:: Int = default_nvar, type:: Type{T} = Float64, kwargs... ) where {T}
4- # Band-limited trigonometric objective
5- # F(x) = sum_{i=1}^n i * [ (1 - cos(x_i)) + sin(x_{i-1}) - sin(x_{i+1}) ]
6- # with boundary values x_0 = x_{n+1} = 0
7-
84 function f (x; n = length (x))
95 n_local = n
106 s = zero (T)
11- for i in 1 : n_local
7+ for i = 1 : n_local
128 xi = x[i]
139 left = (i == 1 ) ? zero (T) : x[i - 1 ]
1410 right = (i == n_local) ? zero (T) : x[i + 1 ]
15- term = T (i) * ( ( one (T) - cos (xi)) + sin (left) - sin (right) )
11+ term = i * (1 - cos (xi) + sin (left) - sin (right))
1612 s += term
1713 end
1814 return s
1915 end
2016
21- # default initial guess: xbar_i = 1 (use type-generic one(T))
22- x0 = fill (one (T), n)
17+ x0 = fill (1 , n)
2318 return ADNLPModels. ADNLPModel (f, x0, name = " trigb" ; kwargs... )
2419end
Original file line number Diff line number Diff line change 1- # # Banded trigonometric problem (Problem 16)
2- # # F(x) = sum_{i=1}^n i * [ (1 - cos(x_i)) + sin(x_{i-1}) - sin(x_{i+1}) ]
3- # # boundary: x_0 = x_{n+1} = 0
4-
1+ # # Banded trigonometric problem
2+ #
3+ # Problem 16 in
4+ # L. Luksan, C. Matonoha and J. Vlcek
5+ # Sparse Test Problems for Unconstrained Optimization,
6+ # Technical Report 1064,
7+ # Institute of Computer Science,
8+ # Academy of Science of the Czech Republic
9+ #
10+ # https://www.researchgate.net/publication/325314400_Sparse_Test_Problems_for_Unconstrained_Optimization
11+ #
512export trigb
613
714function trigb (args... ; n:: Int = default_nvar, kwargs... )
815 model = Model ()
916 @variable (model, x[i = 1 : n], start = 1.0 )
1017
11- @objective (model, Min,
18+ @objective (
19+ model,
20+ Min,
1221 sum (
1322 i * (
14- (1 - cos (x[i])) +
15- ((i == 1 ) ? sin (0.0 ) : sin (x[i - 1 ])) -
23+ (1 - cos (x[i])) + ((i == 1 ) ? sin (0.0 ) : sin (x[i - 1 ])) -
1624 ((i == n) ? sin (0.0 ) : sin (x[i + 1 ]))
1725 ) for i = 1 : n
1826 )
You can’t perform that action at this time.
0 commit comments