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

Implement FD step size adaptation #671

Merged
merged 11 commits into from
May 18, 2021
Merged

Implement FD step size adaptation #671

merged 11 commits into from
May 18, 2021

Conversation

yannikschaelte
Copy link
Member

@yannikschaelte yannikschaelte commented May 18, 2021

Step sizes adaptation for finite differences, realized via a pypesto.objective.finite_difference.FDDelta class.

  • "distance": Update when sufficiently far away from last update point (as in PESTO)
  • "steps": Update when gone a number of steps.
  • "constant": Only update initially.

Also, some simplifications of grad+hess+sres derivative calculations (i.e. rather interpret those as 1st or 2nd order derivatives with code reuse).

Reference: https://github.com/ICB-DCM/PESTO/blob/master/private/getStepSizeFD.m

@codecov-commenter
Copy link

codecov-commenter commented May 18, 2021

Codecov Report

Merging #671 (3cdf9ba) into develop (160c2a8) will increase coverage by 2.16%.
The diff coverage is 88.90%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #671      +/-   ##
===========================================
+ Coverage    88.16%   90.33%   +2.16%     
===========================================
  Files           79       96      +17     
  Lines         5257     6363    +1106     
===========================================
+ Hits          4635     5748    +1113     
+ Misses         622      615       -7     
Impacted Files Coverage Δ
pypesto/ensemble/covariance_analysis.py 18.36% <0.00%> (-0.39%) ⬇️
pypesto/optimize/__init__.py 100.00% <ø> (ø)
pypesto/ensemble/utils.py 57.57% <22.22%> (-5.59%) ⬇️
pypesto/predict/task.py 43.75% <43.75%> (ø)
pypesto/petab/__init__.py 63.63% <50.00%> (ø)
pypesto/objective/amici.py 83.67% <51.85%> (-6.16%) ⬇️
pypesto/problem.py 91.57% <58.33%> (+0.34%) ⬆️
pypesto/objective/amici_util.py 84.21% <66.66%> (+8.31%) ⬆️
pypesto/engine/mpi_pool.py 68.18% <68.18%> (ø)
pypesto/visualize/misc.py 82.41% <72.22%> (-2.52%) ⬇️
... and 82 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 72488fb...3cdf9ba. Read the comment docs.

Copy link
Contributor

@paulstapor paulstapor left a comment

Choose a reason for hiding this comment

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

Overall good, some minor stuff left

Comment on lines 42 to 45
CONSTANT = "constant"
SPACE = "space"
STEPS = "steps"
UPDATE_CONDITIONS = [CONSTANT, SPACE, STEPS]
Copy link
Contributor

Choose a reason for hiding this comment

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

-> constants.py

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd rather leave these here, s.t. one has to call them pypesto.FDDelta.CONSTANT, as they are only used in this specific context.

pypesto/objective/finite_difference.py Outdated Show resolved Hide resolved
pypesto/objective/finite_difference.py Outdated Show resolved Hide resolved
assert np.allclose(val, v, atol=atol, rtol=rtol), attr
# cannot completely coincide
assert (val != v).any(), attr
assert np.allclose(val, val_fd, atol=atol, rtol=rtol), attr
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we maybe double check, whether we achieve better accuracies when using adaptive FDs than when using static FDs? Maybe even down to 1e-5?

Copy link
Member Author

Choose a reason for hiding this comment

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

The default is 1e-6, which already gives quite a good approximation (automatically chosen are 1e-7 to 1e-8), so on this problem not much gain, rather a "automatic detection does not screw things up" check.

pypesto/objective/finite_difference.py Outdated Show resolved Hide resolved
pypesto/objective/finite_difference.py Outdated Show resolved Hide resolved
pypesto/objective/finite_difference.py Outdated Show resolved Hide resolved
pypesto/objective/finite_difference.py Show resolved Hide resolved
@yannikschaelte yannikschaelte merged commit 5cce409 into develop May 18, 2021
@yannikschaelte yannikschaelte deleted the fixes_ys branch May 18, 2021 16:58
@yannikschaelte yannikschaelte mentioned this pull request Aug 2, 2021
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.

4 participants