Open nbfazel opened 2 years ago
Hey @nbfazel, thanks for reporting. Please post a simple code example that generates this problem so we can try to reproduce it on our side.
Thank you. I will do that.
Neil
On Sat, May 28, 2022 at 12:08 PM Carlos Cordoba @.***> wrote:
Hey @nbfazel https://github.com/nbfazel, thanks for reporting. Please post a simple code example that generates this problem so we can try to reproduce it on our side.
— Reply to this email directly, view it on GitHub https://github.com/spyder-ide/spyder/issues/18039#issuecomment-1140290075, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADML47EY55JH727FXLAWEPLVMJAIHANCNFSM5XGCZGFQ . You are receiving this because you were mentioned.Message ID: @.***>
Thanks, again. Here's the sample code (I couldn't attach a .py file):
#!/usr/bin/env python3
from scipy import optimize
# used for run 1
x0 = [1.3, 0.7, 0.8, 1.9, 1.2]
# used for runs 2-4
# x0 = [2.3, 1.7, 1.8, 2.9, 2.2]
print("Sample code: Optimization starting...")
OptimizeResult = optimize.minimize(optimize.rosen, x0, method='L-BFGS-B', jac=optimize.rosen_der, options={'disp': True})
print("Sample code: Optimization ended, printing the results next...")
print(OptimizeResult)
Here's are the convergence messages that were actually displayed for each run:
Run 1 (24 iterations): No convergence messages were displayed. Run 2 (33 iterations): Convergences messages for iterations 0-24 from run 1 and iterations 0-26 from run 2 are displayed. Run 3 (33 iterations): No convergence messages were displayed. Run 4 (33 iterations): Convergences messages for iterations 27-33 from run 2, iterations 0-33 from run 3, and iterations 0-1 from run 4 are displayed.
issue_18039_sample_code_output.pdf
I hope this helps diagnose the issue.
Thanks, Neil
Hi Carlos,
I noticed the status is still "Awaiting Followup". Is there any other information I should provide in addition to the above code sample?
Thanks, Neil
I'm sorry, I just haven't had time to test your code sample locally (thanks a lot for it, by the way). I hope to do it before the end of the week.
Great, thank you so much.
On Mon, Jun 6, 2022 at 12:24 PM Carlos Cordoba @.***> wrote:
I'm sorry, I just haven't had time to test your code sample locally (thanks a lot for it, by the way). I hope to do it before the end of the week.
— Reply to this email directly, view it on GitHub https://github.com/spyder-ide/spyder/issues/18039#issuecomment-1147638342, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADML47GTCGK3VOWWG3XJPKLVNYQ33ANCNFSM5XGCZGFQ . You are receiving this because you were mentioned.Message ID: @.***>
Hi Carlos. I was wondering if there were any updates on this. Thanks.
Description
What steps will reproduce the problem?
I'm using scipy.optimize.minimize() as follows:
The "options={'disp': True}" argument tells optimize.minimize() to print optimization convergence messages. However, when I run the program in Spyder with a new kernel, during the very first run, convergence messages are suppressed. When I run again (same kernel), the messages from the previous run are printed along with some of the messages from the current run. If I run a 3rd time, the remaining messages from the previous run and some or all messages from the 3rd run are printed, and so on. When I restart the kernel between runs, convergence messages are suppressed and never printed no matter how many times I run the program.
For example, the following optimization reproducibly converges in 27 iterations each time it's run. The first run printed no convergence messages at all. The 2nd run, reproduced below, printed iterations 0 to 27 from the first run and iterations 0 to 23 (below it) from the 2nd run. (Iteration 24-27 for the 2nd run are missing and would be printed in the 3rd run if I ran again.)
It seems messages are buffered and not flushed out in a timely manner.
Thanks, Neil
Convergence messages from optimize.minimize(). Convergence is alway after 27 iterations
RUNNING THE L-BFGS-B CODE
Machine precision = 2.220D-16 N = 3 M = 10
At X0 0 variables are exactly at the bounds
At iterate 0 f= 7.03337D+05 |proj g|= 4.00718D+06
At iterate 1 f= 8.25333D+03 |proj g|= 1.19944D+04
At iterate 2 f= 7.30713D+03 |proj g|= 8.86422D+03
At iterate 3 f= 5.37744D+03 |proj g|= 3.97451D+03
At iterate 4 f= 4.21818D+03 |proj g|= 2.18222D+03
At iterate 5 f= 3.04832D+03 |proj g|= 1.16546D+03
At iterate 6 f= 2.16928D+03 |proj g|= 6.58421D+02
At iterate 7 f= 1.59417D+03 |proj g|= 3.55064D+02
At iterate 8 f= 1.25258D+03 |proj g|= 1.87290D+02
At iterate 9 f= 1.02133D+03 |proj g|= 1.06669D+02
At iterate 10 f= 8.83831D+02 |proj g|= 4.63954D+02
At iterate 11 f= 8.64742D+02 |proj g|= 9.12474D+01
At iterate 12 f= 8.41545D+02 |proj g|= 4.92149D+01
At iterate 13 f= 8.24391D+02 |proj g|= 1.17475D+02
At iterate 14 f= 8.19805D+02 |proj g|= 3.12590D+01
At iterate 15 f= 8.17839D+02 |proj g|= 8.14758D+00
At iterate 16 f= 8.17382D+02 |proj g|= 8.03946D+00
At iterate 17 f= 8.16350D+02 |proj g|= 9.63922D+00
At iterate 18 f= 8.08699D+02 |proj g|= 1.56648D+01
At iterate 19 f= 7.88834D+02 |proj g|= 2.43618D+01
At iterate 20 f= 7.82030D+02 |proj g|= 1.11805D+01
At iterate 21 f= 7.76987D+02 |proj g|= 2.00426D+01
At iterate 22 f= 7.71927D+02 |proj g|= 1.64120D+01
At iterate 23 f= 7.71681D+02 |proj g|= 1.07082D+01
At iterate 24 f= 7.71619D+02 |proj g|= 7.11228D-01
At iterate 25 f= 7.71618D+02 |proj g|= 8.72199D-02
At iterate 26 f= 7.71618D+02 |proj g|= 3.19921D-02
At iterate 27 f= 7.71618D+02 |proj g|= 2.02636D-04
Tit = total number of iterations Tnf = total number of function evaluations Tnint = total number of segments explored during Cauchy searches Skip = number of BFGS updates skipped Nact = number of active bounds at final generalized Cauchy point Projg = norm of the final projected gradient F = final function value
N Tit Tnf Tnint Skip Nact Projg F 3 27 31 1 0 0 2.026D-04 7.716D+02 F = 771.61838501664488
CONVERGENCE: REL_REDUCTION_OFF<=_FACTR*EPSMCH
RUNNING THE L-BFGS-B CODE
Machine precision = 2.220D-16 N = 3 M = 10
At X0 0 variables are exactly at the bounds
At iterate 0 f= 7.03337D+05 |proj g|= 4.00718D+06
At iterate 1 f= 8.25333D+03 |proj g|= 1.19944D+04
At iterate 2 f= 7.30713D+03 |proj g|= 8.86422D+03
At iterate 3 f= 5.37744D+03 |proj g|= 3.97451D+03
At iterate 4 f= 4.21818D+03 |proj g|= 2.18222D+03
At iterate 5 f= 3.04832D+03 |proj g|= 1.16546D+03
At iterate 6 f= 2.16928D+03 |proj g|= 6.58421D+02
At iterate 7 f= 1.59417D+03 |proj g|= 3.55064D+02
At iterate 8 f= 1.25258D+03 |proj g|= 1.87290D+02
At iterate 9 f= 1.02133D+03 |proj g|= 1.06669D+02
At iterate 10 f= 8.83831D+02 |proj g|= 4.63954D+02
At iterate 11 f= 8.64742D+02 |proj g|= 9.12474D+01
At iterate 12 f= 8.41545D+02 |proj g|= 4.92149D+01
At iterate 13 f= 8.24391D+02 |proj g|= 1.17475D+02
At iterate 14 f= 8.19805D+02 |proj g|= 3.12590D+01
At iterate 15 f= 8.17839D+02 |proj g|= 8.14758D+00
At iterate 16 f= 8.17382D+02 |proj g|= 8.03946D+00
At iterate 17 f= 8.16350D+02 |proj g|= 9.63922D+00
At iterate 18 f= 8.08699D+02 |proj g|= 1.56648D+01
At iterate 19 f= 7.88834D+02 |proj g|= 2.43618D+01
At iterate 20 f= 7.82030D+02 |proj g|= 1.11805D+01
At iterate 21 f= 7.76987D+02 |proj g|= 2.00426D+01
At iterate 22 f= 7.71927D+02 |proj g|= 1.64120D+01
At iterate 23 f= 7.71681D+02 |proj g|= 1.07082D+01
Versions
Dependencies