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

Fixed bug in XNES covariance matrix update. #1517

Merged
merged 8 commits into from
Jan 23, 2024

Conversation

MichaelClerx
Copy link
Member

@MichaelClerx MichaelClerx commented Jan 2, 2024

Fixed bug discovered when writing method merge test for xnes. Improves performance hugely on 2d rosenbrock

@MichaelClerx MichaelClerx marked this pull request as ready for review January 2, 2024 16:03
@MichaelClerx
Copy link
Member Author

Currently failing on issue fixed in #1518 so waiting for that to be merged

MichaelClerx added a commit that referenced this pull request Jan 2, 2024
@MichaelClerx
Copy link
Member Author

To see the effect, run

#!/usr/bin/env python3
import numpy as np
import pints
import pints.toy

e = pints.toy.RosenbrockError()
x = [-4, -2]
opt = pints.OptimisationController(e, x, method=pints.XNES)
opt.run()

opt = pints.OptimisationController(e, x, method=pints.XNES)
opt.run()

on main and then on this branch

@MichaelClerx
Copy link
Member Author

MichaelClerx commented Jan 3, 2024

Before:

Minimising error measure
Using Exponential Natural Evolution Strategy (xNES)
Running in sequential mode.
Population size: 6
Iter. Eval. Best      Current   Time    
0     6      9780.755  9780.755   0:00.0
1     12     869.2288  869.2288   0:00.0
2     18     61.46432  61.46432   0:00.0
3     24     61.46432  115.1759   0:00.0
20    126    0.573     1.754395   0:00.0
40    246    0.495     0.495      0:00.0
60    366    0.34      0.349      0:00.0
80    486    0.277     0.277      0:00.0
100   606    0.26      0.26       0:00.0
120   726    0.251     0.251      0:00.1
140   846    0.232     0.232      0:00.1
160   966    0.217     0.217      0:00.1
180   1086   0.208     0.208      0:00.1
200   1206   0.198     0.199      0:00.1
...
6460  38766  0.000162  0.000162   0:02.5
6480  38886  0.000154  0.000154   0:02.5
...
9960  59766  7.51e-06  7.51e-06   0:03.8
9980  59886  7.39e-06  7.39e-06   0:03.8
10000 60000  7.36e-06  7.36e-06   0:03.8
Halting: Maximum number of iterations (10000) reached.
Minimising error measure
Using Exponential Natural Evolution Strategy (xNES)
Running in sequential mode.
Population size: 6
Iter. Eval. Best      Current   Time    
0     6      1593.239  1593.239   0:00.0
1     12     466.5872  466.5872   0:00.0
2     18     435.3209  435.3209   0:00.0
3     24     435.3209  474.9634   0:00.0
20    126    0.627     4.319052   0:00.0
40    246    0.192     0.299      0:00.0
60    366    0.0989    0.125      0:00.0
80    486    0.0989    0.109      0:00.0
100   606    0.0989    0.101      0:00.0
120   726    0.0984    0.0984     0:00.0
140   846    0.0944    0.0944     0:00.1
160   966    0.0926    0.0926     0:00.1
180   1086   0.0917    0.0917     0:00.1
...
4900  29406  0.000354  0.000354   0:01.8
4920  29526  0.00035   0.00035    0:01.8
4940  29646  0.000342  0.000342   0:01.9
4960  29766  0.000339  0.000339   0:01.9
...
9960  59766  3.53e-06  3.53e-06   0:03.9
9980  59886  3.3e-06   3.34e-06   0:03.9
10000 60000  3.2e-06   3.2e-06    0:03.9
Halting: Maximum number of iterations (10000) reached.

@MichaelClerx
Copy link
Member Author

Minimising error measure
Using Exponential Natural Evolution Strategy (xNES)
Running in sequential mode.
Population size: 6
Iter. Eval. Best      Current   Time    
0     6      13308.7   13308.7    0:00.0
1     12     360.1424  360.1424   0:00.0
2     18     61.50246  61.50246   0:00.0
3     24     61.50246  214.1255   0:00.0
20    126    0.226     0.686044   0:00.0
40    246    0.226     0.51       0:00.0
60    366    0.206     0.206      0:00.0
80    486    0.0139    0.0164     0:00.0
100   606    4.73e-07  1.55e-06   0:00.0
120   726    1.52e-09  1.52e-09   0:00.0
140   846    5.65e-12  4.27e-11   0:00.1
160   966    7.55e-15  8.86e-15   0:00.1
180   1086   3.11e-18  4.26e-17   0:00.1
200   1206   1.96e-21  1.96e-21   0:00.1
220   1326   1.85e-23  1.87e-23   0:00.1
240   1446   1.27e-26  1.48e-26   0:00.1
260   1566   2.42e-30  1.09e-29   0:00.1
280   1686   0         0          0:00.1
300   1806   0         1.98e-29   0:00.1
320   1926   0         1.98e-29   0:00.1
338   2028   0         0          0:00.1
Halting: No significant change for 200 iterations.
Minimising error measure
Using Exponential Natural Evolution Strategy (xNES)
Running in sequential mode.
Population size: 6
Iter. Eval. Best      Current   Time    
0     6      727.5197  727.5197   0:00.0
1     12     95.20382  95.20382   0:00.0
2     18     95.20382  106.8003   0:00.0
3     24     95.20382  487.0027   0:00.0
20    126    0.229     0.300461   0:00.0
40    246    0.00203   0.00203    0:00.0
60    366    9.52e-08  2.69e-07   0:00.0
80    486    1.62e-10  3.27e-10   0:00.0
100   606    4.87e-13  4.87e-13   0:00.0
120   726    2.27e-16  1.35e-15   0:00.0
140   846    2.27e-20  6.94e-19   0:00.1
160   966    1.71e-21  1.39e-20   0:00.1
180   1086   1.34e-24  3.14e-24   0:00.1
200   1206   2.14e-26  2.14e-26   0:00.1
220   1326   6.16e-30  6.16e-30   0:00.1
240   1446   0         1.97e-31   0:00.1
260   1566   0         1.97e-31   0:00.1
280   1686   0         0          0:00.1
297   1782   0         0          0:00.1
Halting: No significant change for 200 iterations.

Copy link
Member

@chonlei chonlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted, Michael!

pints/_optimisers/_xnes.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4f52588) 100.00% compared to head (040d3d7) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1517   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           97        97           
  Lines         9577      9577           
=========================================
  Hits          9577      9577           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MichaelClerx MichaelClerx merged commit 13b263a into main Jan 23, 2024
13 checks passed
@MichaelClerx MichaelClerx deleted the xnes-cov-matrix-update-fix branch January 23, 2024 16:38
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 this pull request may close these issues.

None yet

2 participants