@@ -63,6 +63,7 @@ function _extrosenbrockproblem(N::Int;
6363 extrosenbrock_gradient!,
6464 extrosenbrock_fun_gradient!,
6565 extrosenbrock_hessian!,
66+ nothing , # Constraints
6667 initial_x,
6768 ones (initial_x),
6869 zero (T),
@@ -155,6 +156,7 @@ function _extpowellproblem(N::Int;
155156 extpowell_gradient!,
156157 extpowell_fun_gradient!,
157158 extpowell_hessian!,
159+ nothing , # Constraints
158160 initial_x,
159161 zeros (initial_x),
160162 zero (T),
@@ -194,7 +196,7 @@ function penfunI_gradient!(storage::AbstractArray,
194196end
195197
196198function penfunI_fun_gradient! (storage:: AbstractArray ,
197- x:: AbstractArray , param)
199+ x:: AbstractArray , param)
198200 # TODO : we could do this without the xt storage holder
199201 xt = param. xt
200202 @. xt = param. alpha* (x- one (eltype (x)))
@@ -231,6 +233,7 @@ function _penfunIproblem(N::Int;
231233 penfunI_gradient!,
232234 penfunI_fun_gradient!,
233235 penfunI_hessian!,
236+ nothing , # Constraints
234237 initial_x,
235238 xsol,
236239 fsol,
@@ -273,7 +276,7 @@ function trigonometric_gradient!(storage::AbstractArray,
273276end
274277
275278function trigonometric_fun_gradient! (storage:: AbstractArray ,
276- x:: AbstractArray , param)
279+ x:: AbstractArray , param)
277280 # TODO : we could do this without the xt storage holder
278281 n = length (x)
279282 xt = param. vec
@@ -298,6 +301,7 @@ function _trigonometricproblem(N::Int;
298301 trigonometric_gradient!,
299302 trigonometric_fun_gradient!,
300303 trigonometric_hessian!,
304+ nothing , # Constraints
301305 initial_x,
302306 zeros (initial_x),
303307 zero (T),
@@ -307,3 +311,70 @@ function _trigonometricproblem(N::Int;
307311end
308312
309313examples[" 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