bugGNU Octave - Bugs: bug #40101, fminunc outputs - gradient and...

 
 

bug #40101: fminunc outputs - gradient and hessian not always calculated in the solutio

Submitted by:  jose <josombio>
Submitted on:  Wed 25 Sep 2013 04:47:43 PM UTC  
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Jose Open/Closed:  Closed
Release:  3.6.4 Operating System:  GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 12 Nov 2015 01:00:21 AM UTC, comment #2:

Thanks for the patch. I committed it on the development branch here (http://hg.savannah.gnu.org/hgweb/octave/rev/a7dbc4fc3732). It will be a part of the 4.2 release of Octave.

Marking bug as fixed and closing.

Rik <rik5>
Project Administrator
Mon 03 Feb 2014 04:18:13 PM UTC, comment #1:

Here is a Mercurial changeset (fminunc.diff) equivalent to the proposed fminunc2.m with an additional modification that fixes a new problem introduced in fminunc2.m itself. This new problem affected the cases in which the gradient function was supplied by the user as a row vector.

An easier way to reproduce the original problem (compared to session.txt) is as follows:
Before applying the changeset

After applying the changeset

(file #30447)

jose <josombio>
Wed 25 Sep 2013 04:47:43 PM UTC, original submission:

The iteration of fminunc can finish because of several reasons. The particular reason can be checked from the 3rd output (the info).

If I am not mistaken, it seems that when fminunc reaches any of the exit conditions corresponding to info equal to -1, 2 or 3, the gradient is not recalculated after the last modification of x (See lines 283 for the last update of x, and lines 301, 320 and 323 for changes of the variable info that result in exit conditions).

As a consequence, the gradient returned in the output in those cases does not correspond to the gradient calculated in the x returned as output, but to the gradient calculated using the x of the previous iteration.

The file attached (fminunc2.m) is an attempt to fix this. It also recalculates the hessian (using blind copy-paste from the code!!). It has been tested only with a case in which info=3.
Additionally, the fix returns the gradient in the same shape than x.

Find attached (session.txt) one way to reproduce the problem when info=3.

jose <josombio>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #30447:  fminunc.diff added by josombio (1KiB - text/x-patch - Mercurial changeset)
file #29209:  fminunc2.m added by josombio (13KiB - text/x-objcsrc - A fix-attempt)
file #29210:  session.txt added by josombio (1KiB - text/plain - A fix-attempt)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-11-12 rik5 StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
    2014-02-03 josombio Attached File- => Added fminunc.diff, #30447
    2013-10-17 rik5 StatusNone => Patch Submitted
    2013-09-25 josombio Attached File- => Added fminunc2.m, #29209
        Attached File- => Added session.txt, #29210

    Back to the top


    Powered by Savane 3.3