Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Java translation of trstlp #5

Open
rruusu opened this issue Jun 27, 2023 · 0 comments · May be fixed by #6
Open

Error in Java translation of trstlp #5

rruusu opened this issue Jun 27, 2023 · 0 comments · May be fixed by #6

Comments

@rruusu
Copy link

rruusu commented Jun 27, 2023

On line 1078 of Cobyla.java, there is a deviation from the behavior of the original Fortran code:

                    if (mcon == m)
                    {
                        double acca = step + 0.1 * resmax;
                        double accb = step + 0.2 * resmax;
                        if (step >= acca || acca >= accb) break L_70;
                        step = Math.min(step, resmax);
                    }

This corresponds to the following Fortran code:

        if (mcon == m) then
            acca = step + 0.1_wp * resmax
            accb = step + 0.2_wp * resmax
            if (step >= acca .or. acca >= accb) go to 480
            step = min (step, resmax)
        end if

The break L_70 statement takes the Java code to line 1184:

                if (step == stpful) return true;

This is equivalent to a go to statement to the line just above the label 480 in the original Fortran. In this case, the condition step == stpful is always true, resulting in a premature exit from trstlp, causing it to return a step of size zero, while claiming to have taken a full step and thus multiple evaluations of sample points.

In order to match the effects of the go to 480 statement in the Fortran code, the break L_70 statement should instead be continue L_60.

@rruusu rruusu linked a pull request Jun 27, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant