File tree Expand file tree Collapse file tree 9 files changed +312
-0
lines changed
Expand file tree Collapse file tree 9 files changed +312
-0
lines changed Original file line number Diff line number Diff line change 1+ export toint
2+
3+ function toint (; n:: Int = default_nvar, type:: Type{T} = Float64, kwargs... ) where {T}
4+ function f (x; n = length (x))
5+ s = zero (T)
6+ for i ∈ 1 : n
7+ ci = 1 + (i // 10 )
8+ jmin = max (1 , i - 2 )
9+ jmax = min (n, i + 2 )
10+ for j ∈ jmin: jmax
11+ aij = 5 * (1 + mod (i, 5 ) + mod (j, 5 ))
12+ bij = (i + j) // 10
13+ cj = 1 + j // 10
14+ s += aij * sin (bij + ci * x[i] + cj * x[j])
15+ end
16+
17+ if iseven (n)
18+ half = n ÷ 2
19+ j1 = i + half
20+ if 1 <= j1 <= n && (j1 < jmin || j1 > jmax)
21+ aij = 5 * (1 + mod (i, 5 ) + mod (j1, 5 ))
22+ bij = (i + j1) // 10
23+ cj = 1 + j1 // 10
24+ s += aij * sin (bij + ci * x[i] + cj * x[j1])
25+ end
26+ j2 = i - half
27+ if 1 <= j2 <= n && j2 != j1 && (j2 < jmin || j2 > jmax)
28+ aij = 5 * (1 + mod (i, 5 ) + mod (j2, 5 ))
29+ bij = (i + j2) // 10
30+ cj = 1 + j2 // 10
31+ s += aij * sin (bij + ci * x[i] + cj * x[j2])
32+ end
33+ end
34+ end
35+ return s / n
36+ end
37+
38+ x0 = fill (one (T), n)
39+ return ADNLPModels. ADNLPModel (f, x0, name = " toint" ; kwargs... )
40+ end
Original file line number Diff line number Diff line change 1+ export trig
2+
3+ function trig (; n:: Int = default_nvar, type:: Type{T} = Float64, kwargs... ) where {T}
4+ function f (x; n = length (x))
5+ s = zero (T)
6+ for i = 1 : n
7+ s += i * (1 - cos (x[i]))
8+
9+ jmin = max (1 , i - 2 )
10+ jmax = min (n, i + 2 )
11+ for j in jmin: jmax
12+ aij = 5 * (1 + mod (i, 5 ) + mod (j, 5 ))
13+ bij = (i + j) // 10
14+ s += aij * sin (x[j]) + bij * cos (x[j])
15+ end
16+
17+ if iseven (n)
18+ half = n ÷ 2
19+ j1 = i + half
20+ if 1 <= j1 <= n && (j1 < jmin || j1 > jmax)
21+ aij = 5 * (1 + mod (i, 5 ) + mod (j1, 5 ))
22+ bij = (i + j1) // 10
23+ s += aij * sin (x[j1]) + bij * cos (x[j1])
24+ end
25+ j2 = i - half
26+ if 1 <= j2 <= n && j2 != j1 && (j2 < jmin || j2 > jmax)
27+ aij = 5 * (1 + mod (i, 5 ) + mod (j2, 5 ))
28+ bij = (i + j2) // 10
29+ s += aij * sin (x[j2]) + bij * cos (x[j2])
30+ end
31+ end
32+ end
33+ return s / n
34+ end
35+
36+ x0 = fill (one (T) / n, n)
37+ return ADNLPModels. ADNLPModel (f, x0, name = " trig" ; kwargs... )
38+ end
Original file line number Diff line number Diff line change 1+ export trigb
2+
3+ function trigb (; n:: Int = default_nvar, type:: Type{T} = Float64, kwargs... ) where {T}
4+ function f (x; n = length (x))
5+ s = zero (T)
6+ for i = 1 : n
7+ xim = (i == 1 ) ? zero (T) : x[i - 1 ]
8+ xip = (i == n) ? zero (T) : x[i + 1 ]
9+ s += i * (1 - cos (x[i]) + sin (xim) - sin (xip))
10+ end
11+ return s
12+ end
13+
14+ x0 = fill (one (T), n)
15+ return ADNLPModels. ADNLPModel (f, x0, name = " trigb" ; kwargs... )
16+ end
Original file line number Diff line number Diff line change 1+ toint_meta = Dict (
2+ :nvar => 100 ,
3+ :variable_nvar => true ,
4+ :ncon => 0 ,
5+ :variable_ncon => false ,
6+ :minimize => true ,
7+ :name => " toint" ,
8+ :has_equalities_only => false ,
9+ :has_inequalities_only => false ,
10+ :has_bounds => false ,
11+ :has_fixed_variables => false ,
12+ :objtype => :other ,
13+ :contype => :unconstrained ,
14+ :best_known_lower_bound => - Inf ,
15+ :best_known_upper_bound => - 0.8598396932382264 ,
16+ :is_feasible => true ,
17+ :defined_everywhere => missing ,
18+ :origin => :unknown ,
19+ )
20+
21+ get_toint_nvar (; n:: Integer = default_nvar, kwargs... ) = n
22+ get_toint_ncon (; n:: Integer = default_nvar, kwargs... ) = 0
23+ get_toint_nlin (; n:: Integer = default_nvar, kwargs... ) = 0
24+ get_toint_nnln (; n:: Integer = default_nvar, kwargs... ) = 0
25+ get_toint_nequ (; n:: Integer = default_nvar, kwargs... ) = 0
26+ get_toint_nineq (; n:: Integer = default_nvar, kwargs... ) = 0
Original file line number Diff line number Diff line change 1+ trig_meta = Dict (
2+ :nvar => 100 ,
3+ :variable_nvar => true ,
4+ :ncon => 0 ,
5+ :variable_ncon => false ,
6+ :minimize => true ,
7+ :name => " trig" ,
8+ :has_equalities_only => false ,
9+ :has_inequalities_only => false ,
10+ :has_bounds => false ,
11+ :has_fixed_variables => false ,
12+ :objtype => :other ,
13+ :contype => :unconstrained ,
14+ :best_known_lower_bound => - Inf ,
15+ :best_known_upper_bound => 61.482500487413226 ,
16+ :is_feasible => true ,
17+ :defined_everywhere => missing ,
18+ :origin => :unknown ,
19+ )
20+
21+ get_trig_nvar (; n:: Integer = default_nvar, kwargs... ) = n
22+ get_trig_ncon (; n:: Integer = default_nvar, kwargs... ) = 0
23+ get_trig_nlin (; n:: Integer = default_nvar, kwargs... ) = 0
24+ get_trig_nnln (; n:: Integer = default_nvar, kwargs... ) = 0
25+ get_trig_nequ (; n:: Integer = default_nvar, kwargs... ) = 0
26+ get_trig_nineq (; n:: Integer = default_nvar, kwargs... ) = 0
Original file line number Diff line number Diff line change 1+ trigb_meta = Dict (
2+ :nvar => 100 ,
3+ :variable_nvar => true ,
4+ :ncon => 0 ,
5+ :variable_ncon => false ,
6+ :minimize => true ,
7+ :name => " trigb" ,
8+ :has_equalities_only => false ,
9+ :has_inequalities_only => false ,
10+ :has_bounds => false ,
11+ :has_fixed_variables => false ,
12+ :objtype => :other ,
13+ :contype => :unconstrained ,
14+ :best_known_lower_bound => - Inf ,
15+ :best_known_upper_bound => 2404.778982861876 ,
16+ :is_feasible => true ,
17+ :defined_everywhere => missing ,
18+ :origin => :unknown ,
19+ )
20+
21+ get_trigb_nvar (; n:: Integer = default_nvar, kwargs... ) = n
22+ get_trigb_ncon (; n:: Integer = default_nvar, kwargs... ) = 0
23+ get_trigb_nlin (; n:: Integer = default_nvar, kwargs... ) = 0
24+ get_trigb_nnln (; n:: Integer = default_nvar, kwargs... ) = 0
25+ get_trigb_nequ (; n:: Integer = default_nvar, kwargs... ) = 0
26+ get_trigb_nineq (; n:: Integer = default_nvar, kwargs... ) = 0
Original file line number Diff line number Diff line change 1+ # Toint trigonometric function
2+ #
3+ # Problem 10 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+ #
12+ export toint
13+
14+ function toint (args... ; n:: Int = default_nvar, kwargs... )
15+ model = Model ()
16+ @variable (model, x[i = 1 : n], start = 1 )
17+
18+ @objective (
19+ model,
20+ Min,
21+ (1 / n) * sum (begin
22+ ci = 1 + (i // 10 )
23+ s = zero (Float64)
24+
25+ jmin = max (1 , i - 2 )
26+ jmax = min (n, i + 2 )
27+ for j in jmin: jmax
28+ aij = 5 * (1 + mod (i, 5 ) + mod (j, 5 ))
29+ bij = (i + j) // 10
30+ cj = 1 + j // 10
31+ s += aij * sin (bij + ci * x[i] + cj * x[j])
32+ end
33+
34+ if iseven (n)
35+ half = n ÷ 2
36+ j1 = i + half
37+ if 1 <= j1 <= n && (j1 < jmin || j1 > jmax)
38+ aij = 5 * (1 + mod (i, 5 ) + mod (j1, 5 ))
39+ bij = (i + j1) // 10
40+ cj = 1 + j1 // 10
41+ s += aij * sin (bij + ci * x[i] + cj * x[j1])
42+ end
43+ j2 = i - half
44+ if 1 <= j2 <= n && j2 != j1 && (j2 < jmin || j2 > jmax)
45+ aij = 5 * (1 + mod (i, 5 ) + mod (j2, 5 ))
46+ bij = (i + j2) // 10
47+ cj = 1 + j2 // 10
48+ s += aij * sin (bij + ci * x[i] + cj * x[j2])
49+ end
50+ end
51+ s
52+ end for i = 1 : n)
53+ )
54+
55+ return model
56+ end
Original file line number Diff line number Diff line change 1+ # Another trigonometric function
2+ #
3+ # Problem 9 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+ #
12+ export trig
13+
14+ function trig (args... ; n:: Int = default_nvar, kwargs... )
15+ model = Model ()
16+ @variable (model, x[i = 1 : n], start = 1 / n)
17+
18+ @objective (
19+ model,
20+ Min,
21+ (1 / n) * sum (
22+ i * (1 - cos (x[i])) +
23+ (
24+ begin
25+ jmin = max (1 , i - 2 )
26+ jmax = min (n, i + 2 )
27+ s = zero (Float64)
28+ for j in jmin: jmax
29+ aij = 5 * (1 + mod (i, 5 ) + mod (j, 5 ))
30+ bij = (i + j) / 10
31+ s += aij * sin (x[j]) + bij * cos (x[j])
32+ end
33+ if iseven (n)
34+ half = n ÷ 2
35+ j1 = i + half
36+ if 1 <= j1 <= n && (j1 < jmin || j1 > jmax)
37+ aij = 5 * (1 + mod (i, 5 ) + mod (j1, 5 ))
38+ bij = (i + j1) / 10
39+ s += aij * sin (x[j1]) + bij * cos (x[j1])
40+ end
41+ j2 = i - half
42+ if 1 <= j2 <= n && j2 != j1 && (j2 < jmin || j2 > jmax)
43+ aij = 5 * (1 + mod (i, 5 ) + mod (j2, 5 ))
44+ bij = (i + j2) / 10
45+ s += aij * sin (x[j2]) + bij * cos (x[j2])
46+ end
47+ end
48+ s
49+ end
50+ ) for i = 1 : n
51+ )
52+ )
53+
54+ return model
55+ end
Original file line number Diff line number Diff line change 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+ #
12+ export trigb
13+
14+ function trigb (args... ; n:: Int = default_nvar, kwargs... )
15+ model = Model ()
16+ @variable (model, x[i = 1 : n], start = 1 )
17+
18+ @objective (
19+ model,
20+ Min,
21+ sum (
22+ i *
23+ ((1 - cos (x[i])) + ((i == 1 ) ? sin (0 ) : sin (x[i - 1 ])) - ((i == n) ? 0 : sin (x[i + 1 ])))
24+ for i = 1 : n
25+ )
26+ )
27+
28+ return model
29+ end
You can’t perform that action at this time.
0 commit comments