@@ -63,6 +63,7 @@ function _extrosenbrockproblem(N::Int;
63
63
extrosenbrock_gradient!,
64
64
extrosenbrock_fun_gradient!,
65
65
extrosenbrock_hessian!,
66
+ nothing , # Constraints
66
67
initial_x,
67
68
ones (initial_x),
68
69
zero (T),
@@ -155,6 +156,7 @@ function _extpowellproblem(N::Int;
155
156
extpowell_gradient!,
156
157
extpowell_fun_gradient!,
157
158
extpowell_hessian!,
159
+ nothing , # Constraints
158
160
initial_x,
159
161
zeros (initial_x),
160
162
zero (T),
@@ -194,7 +196,7 @@ function penfunI_gradient!(storage::AbstractArray,
194
196
end
195
197
196
198
function penfunI_fun_gradient! (storage:: AbstractArray ,
197
- x:: AbstractArray , param)
199
+ x:: AbstractArray , param)
198
200
# TODO : we could do this without the xt storage holder
199
201
xt = param. xt
200
202
@. xt = param. alpha* (x- one (eltype (x)))
@@ -231,6 +233,7 @@ function _penfunIproblem(N::Int;
231
233
penfunI_gradient!,
232
234
penfunI_fun_gradient!,
233
235
penfunI_hessian!,
236
+ nothing , # Constraints
234
237
initial_x,
235
238
xsol,
236
239
fsol,
@@ -273,7 +276,7 @@ function trigonometric_gradient!(storage::AbstractArray,
273
276
end
274
277
275
278
function trigonometric_fun_gradient! (storage:: AbstractArray ,
276
- x:: AbstractArray , param)
279
+ x:: AbstractArray , param)
277
280
# TODO : we could do this without the xt storage holder
278
281
n = length (x)
279
282
xt = param. vec
@@ -298,6 +301,7 @@ function _trigonometricproblem(N::Int;
298
301
trigonometric_gradient!,
299
302
trigonometric_fun_gradient!,
300
303
trigonometric_hessian!,
304
+ nothing , # Constraints
301
305
initial_x,
302
306
zeros (initial_x),
303
307
zero (T),
@@ -307,3 +311,70 @@ function _trigonometricproblem(N::Int;
307
311
end
308
312
309
313
examples[" Trigonometric" ] = _trigonometricproblem (100 )
314
+
315
+
316
+ # #########################################################################
317
+ # ##
318
+ # ## Beale (2D)
319
+ # ##
320
+ # ## Problem 5 in [3]
321
+ # ##
322
+ # ## Sum-of-squares objective, non-convex with g'*inv(H)*g == 0 at the
323
+ # ## initial position.
324
+ # ##
325
+ # #########################################################################
326
+
327
+ # ## General utilities for sum-of-squares functions
328
+ # TODO : Update the other problems that are not Beale to use sumsq as well?
329
+
330
+ # Requires f(x) and J(x) computes the values and jacobian at x of a set of functions, and
331
+ # that H(x, i) computes the hessian of the ith function
332
+
333
+ sumsq_obj (f, x) = sum (f (x).^ 2 )
334
+
335
+ function sumsq_gradient! (g:: AbstractVector , f, J, x:: AbstractVector )
336
+ copy! (g, sum ((2.0 .* f (x)) .* J (x), 1 ))
337
+ end
338
+
339
+ function sumsq_hessian! (h:: AbstractMatrix , f, J, H, x:: AbstractVector )
340
+ fx = f (x)
341
+ Jx = J (x)
342
+ htmp = 2.0 .* (Jx' * Jx)
343
+ for i = 1 : length (fx)
344
+ htmp += (2.0 * fx[i]) * H (x, i)
345
+ end
346
+ copy! (h, htmp)
347
+ end
348
+
349
+ const beale_y = [1.5 , 2.25 , 2.625 ]
350
+
351
+ beale_f (x) = [beale_y[i] - x[1 ]* (1 - x[2 ]^ i) for i = 1 : 3 ]
352
+ beale_J (x) = hcat ([- (1 - x[2 ]^ i) for i = 1 : 3 ],
353
+ [i* x[1 ]* x[2 ]^ (i- 1 ) for i = 1 : 3 ])
354
+ function beale_H (x, i)
355
+ od = i* x[2 ]^ (i- 1 )
356
+ d2 = i > 1 ? i* (i- 1 )* x[1 ]* x[2 ]^ (i- 2 ) : zero (x[2 ])
357
+ [0 od; od d2]
358
+ end
359
+
360
+ beale (x:: AbstractVector ) = sumsq_obj (beale_f, x)
361
+
362
+ function beale_gradient! (g:: AbstractVector , x:: AbstractVector )
363
+ sumsq_gradient! (g, beale_f, beale_J, x)
364
+ end
365
+
366
+ function beale_hessian! (h:: AbstractMatrix , x:: AbstractVector )
367
+ sumsq_hessian! (h, beale_f, beale_J, beale_H, x)
368
+ end
369
+
370
+ examples[" Beale" ] = OptimizationProblem (" Beale" ,
371
+ beale,
372
+ beale_gradient!,
373
+ nothing ,
374
+ beale_hessian!,
375
+ nothing , # Constraints
376
+ [1.0 , 1.0 ],
377
+ [3.0 , 0.5 ],
378
+ beale ([3.0 , 0.5 ]),
379
+ true ,
380
+ true )
0 commit comments