File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -31,4 +31,27 @@ macro wrappedallocs(expr)
3131 end
3232end
3333
34- # Construct the brock-rosenberg problem.
34+ # Construct the rosenbrock problem.
35+
36+ function rosenbrock_f (x:: Vector{T} ) where {T <: Real }
37+ 100 * (x[2 ]- x[1 ]^ 2 )^ 2 + (1 - x[1 ])^ 2
38+ end
39+
40+ function rosenbrock_grad! (gx:: Vector{T} , x:: Vector{T} ) where {T <: Real }
41+ gx[1 ] = - 400 * x[1 ]* (x[2 ]- x[1 ]^ 2 )- 2 * (1 - x[1 ])
42+ gx[2 ] = 200 * (x[2 ]- x[1 ]^ 2 )
43+ end
44+
45+ function rosenbrock_hv! (hv:: Vector{T} , x:: Vector{T} , v:: Vector{T} ; obj_weight = 1.0 ) where {T}
46+ hv[1 ] = (1200 * x[1 ]^ 2 - 400 * x[2 ]+ 2 )* v[1 ] - 400 * x[1 ]* v[2 ]
47+ hv[2 ] = - 400 * x[1 ]* v[1 ] + 200 * v[2 ]
48+ end
49+
50+ function construct_rosenbrock_nlp ()
51+ return NLPModel (
52+ zeros (2 ),
53+ rosenbrock_f,
54+ grad = rosenbrock_grad!,
55+ hprod = rosenbrock_hv!
56+ )
57+ end
You can’t perform that action at this time.
0 commit comments