bugGNU Octave - Bugs: bug #64179, [octave forge] (optim) bfgsmin...


bug #64179: [octave forge] (optim) bfgsmin function does not use analytic gradient

Submitter:  None
Submitted:  Wed 10 May 2023 08:26:01 PM UTC
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  None Assigned to:  None
Originator Name:  Eugeniy Mikhailov Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * 6.2.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Wed 10 May 2023 08:26:01 PM UTC, original submission:  

The `bsgmin` function in `optim` package does not confirm to behavior prescribed in its description. It always use the numerical gradient even if the objective function is calculating the analytic version of the gradient.

Steps to reproduce, run `bfgsmin_example`
and observe the output related to EXAPLE 3, the result is correct but the output says "used numeric gradient" while the expected behavior is to use "analytical gradient".

As far as I can see, the bug is in `__bfgsmin.cc` file.

There is a heuristic which check that the objective function returns more then 1 output (2nd one is the analytic gradient). However the way it is called within `int __bfgsmin_gradient` function always gets only 1 output.

f_return = OCTAVE__FEVAL (f, f_args)

The bug can be fixed if in `__bfgsmin.cc`  file all call like above replaced with

f_return = OCTAVE__FEVAL (f, f_args, 2)

since the 3rd arguments specifies the expected number of outputs.
Without 3rd argument, it defaults to 1.

P.S. I surprised that it even compiles since `OCTAVE__FEVAL` macro calls `octave::feval` which requires 3 input arguments.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by nrjank
  • -email is unavailable- added by nrjank (Updated the item)
  • -email is unavailable- added by None (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.


    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-10-19 nrjank Carbon-Copy- Added i7tiol
    2023-10-19 nrjank Carbon-CopyRemoved -email is unavailable- -
    2023-10-19 nrjank Carbon-Copy- Added -email is unavailable-
    2023-10-19 nrjank Summary(optim) bfgsmin function does not use analytic gradient [octave forge] (optim) bfgsmin function does not use analytic gradient

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code