No BSD License  

Highlights from
Unconstrained optimization using Hooke & Jeeves

2.0

2.0 | 3 ratings Rate this file 9 Downloads (last 30 days) File Size: 4.29 KB File ID: #15070
image thumbnail

Unconstrained optimization using Hooke & Jeeves

by Giovani Tonel

 

21 May 2007 (Updated 24 May 2007)

Deterministic Unconstrained optimization

| Watch this File

File Information
Description

Unconstrained optimization method using Hooke & Jeeves.

MATLAB release MATLAB 5.3 (R11)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
24 May 2007 John D'Errico

Again, this SEEMS to be a reasonably crafted code. I wish it had better documentation, that explicitly said what the parameters did and what shape and size they should be. Some examples of use would be helpful. For example, this simple test case should be absolutely trivial to solve:

[xopt,Opt,Nav]=hkjeeves(@norm,[1 1])
Optimization by hkjeeves terminated!
xopt =
  -2.4633e-16 1
Opt =
     1
Nav =
    40

Clearly the minimum should happen at [0 0]. It was not obvious to me why it failed, at least not until I read the code fairly carefully. The starting guess MUST be a column vector for this code to work on a multivariate function. This was completely undocumented of course.

A good coding job does not stop when you write the last line of code. It becomes good code only when the help is complete. Only when the documentation fully describes how to use that code. To be excellent, code should not only be good, it should be robust against simple things like whether a variable specified only as a "vector" must a row or column vector. Excellent code should be friendly to the user.

24 May 2007 Giovani Tonel

Re: For example, this simple test case should be absolutely trivial to solve: [xopt,Opt,Nav]=hkjeeves(@norm,[1 1]) Optimization by hkjeeves terminated! xopt = -2.4633e-16 1 Opt = 1 Nav = 40 Clearly the minimum should happen at [0 0]...

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I've made this [xopt, Opt, Nav] = hkjeeves('norm',[1; 1])

Optimization by hkjeeves terminated!

xopt = 1.0e-015 *
   -0.2463
   -0.2463

Opt = 3.4836e-016

Nav = 79

24 May 2007 John D'Errico

Your code fails when called with a row vector as starting values instead of a colum vector. This is completely undocumented behavior, and rather unfriendly.

Rather than showing that with knowledge of the internal workings of your own code you can solve this trivial problem, why not make the code insensitive to such trivial differences? At the very least, DOCUMENT the requirements of your code.

My rating this time is reduced to a 2 because I felt the correct rating for this submission really was about a 2.5. Undocumented code that fails to run has bugs in it.

29 May 2007 Zhijun Wang

[xopt,Opt,Nav]=hkjeeves(@norm,[1 1])
should be used as:
[xopt,Opt,Nav]=hkjeeves(@norm,[1; 1])

And

legend([h1,h2],'start point','optimum'); should be removed from the hkjeeves.m

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
optimization Giovani Tonel 22 Oct 2008 09:13:26
unconstrained Giovani Tonel 22 Oct 2008 09:13:26
optimizatio Giovani Tonel 22 Oct 2008 09:13:26
jeeves Giovani Tonel 22 Oct 2008 09:13:26
hooke Giovani Tonel 22 Oct 2008 09:13:26
hooke kolya kolya 27 May 2010 06:01:40
hooke CARLOS GUSTAVO 15 Sep 2011 15:01:30

Contact us at files@mathworks.com