[ 
https://issues.apache.org/jira/browse/MATH-1137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14059061#comment-14059061
 ] 

Nigel Goodwin commented on MATH-1137:
-------------------------------------

Easy enough to say, but it is now in commercial production code....

I have spent a few hours trying to understand the Powell paper and see where 
the code is described, but I haven't made much progress. I think it is to do 
with adjusting RHO, equations 6.8 - 6.11.

Implement from scratch from the paper? You must be joking!!! Have you tried to 
read the paper? [I think you must have because you did the original conversion?]

To be honest, we can talk about unit tests and test cases for ever, but can't 
you just read the code and confirm by manual inspection it is incorrect? That 
is one of the messages of Myers - most bugs are found by reading.

I think I found this bug by visual inspection rather than any particular 
problem/symptom.

If the original code had (J + J*J)/2 and looped around J from 1 to N, then with 
a 0 index we have

(J+1 + (J+1)*(J+1))/2 -1 = (J+J*J)/2 + J

with a loop around J from 0 to (N-1). It is dimensioned to 

new ArrayRealVector(dimension * (dimension + 1) / 2);

so when J = N-1 we are looking at the element

(N + N*N)/2 -1 

which seems pretty sensible to me, it is the last element of the array, which 
is of course the last diagonal of the triangular system.

It's obvious, surely? It was just something missed in the original conversion, 
you don't have a test case for every single conversion. Myers also said testing 
is a matter of economics - in this case the economics and common sense says 
just fix it, it is obviously wrong.

Another mental check you can do is to check there are no array bound 
exceptions. You don't need to write any code, just test by hand and visually. 
Do a walk through.

Is there an apache rule 'for every bug correction there shalt be an individual 
specific test case'? I think we can all agree BOBYQA is one of the most complex 
classes in apache, and there was some debate whether it should be released or 
not. So some 'rules' need to be treated with some common sense.

But the reality is it is very useful to me, at least, and I use it in 
production commercial code, and never had a problem.

> BOBYQA incorrect indexing
> -------------------------
>
>                 Key: MATH-1137
>                 URL: https://issues.apache.org/jira/browse/MATH-1137
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.3
>            Reporter: Nigel Goodwin
>




--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to