-
Notifications
You must be signed in to change notification settings - Fork 48
/
eg2.jl
38 lines (32 loc) · 954 Bytes
/
eg2.jl
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
# A simple non convex problem with several local minima.
#
# Source: Section 1.2.4 of
# A. R. Conn, N. I. M. Gould and Ph. L. Toint,
# LANCELOT, A Fortran Package for Large-Scale Nonlinear Optimization
# (Release A)
# Springer Verlag, 1992.
#
# See also
#
# problem 25 in
# L. Luksan, C. Matonoha and J. Vlcek
# Modified CUTE problems for sparse unconstrained optimization,
# Technical Report 1081,
# Institute of Computer Science,
# Academy of Science of the Czech Republic
#
# http://www.cs.cas.cz/matonoha/download/V1081.pdf
#
# classification OUR2-AN-1000-0
#
# D. Orban, Montreal, 08/2015.
export eg2
"model in size `n`"
function eg2(args...; n::Int = default_nvar, kwargs...)
n < 2 && @warn("eg2: number of variables must be ≥ 2")
n = max(2, n)
nlp = Model()
@variable(nlp, x[i = 1:n], start = 0)
@NLobjective(nlp, Min, sum(sin(x[1] + x[i]^2 - 1) for i = 1:(n - 1)) + 0.5 * sin(x[n]^2))
return nlp
end