-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added xNES tests (requires fix from #1517).
- Loading branch information
1 parent
6bb0255
commit 6970872
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Change point tests for XNES. | ||
# | ||
# This file is part of PINTS (https://github.com/pints-team/pints/) which is | ||
# released under the BSD 3-clause license. See accompanying LICENSE.md for | ||
# copyright notice and full license details. | ||
# | ||
import pints | ||
import pints.cptests as cpt | ||
|
||
|
||
def bounded_fitzhugh_nagumo(n_iterations=100): | ||
""" | ||
Tests :class:`pints.XNES` on a bounded Fitzhugh-Nagumo model, and returns | ||
a dictionary with ``error`` and ``distance``. | ||
For details of the solved problem, see | ||
:class:`pints.cptests.RunOptimiserOnBoundedUntransformedLogistic`. | ||
""" | ||
problem = cpt.RunOptimiserOnBoundedFitzhughNagumo( | ||
_method, n_iterations, _fguess) | ||
return { | ||
'error': problem.error(), | ||
'distance': problem.distance() | ||
} | ||
|
||
|
||
def bounded_untransformed_logistic(n_iterations=300): | ||
""" | ||
Tests :class:`pints.XNES` on a bounded logistic model without | ||
transformations, and returns a dictionary with ``error`` and ``distance``. | ||
For details of the solved problem, see | ||
:class:`pints.cptests.RunOptimiserOnBoundedUntransformedLogistic`. | ||
""" | ||
problem = cpt.RunOptimiserOnBoundedUntransformedLogistic( | ||
_method, n_iterations, _fguess) | ||
return { | ||
'error': problem.error(), | ||
'distance': problem.distance() | ||
} | ||
|
||
|
||
def rosenbrock(n_iterations=100): | ||
""" | ||
Tests :class:`pints.XNES` on a Rosenbrock error and returns a dictionary | ||
with ``error`` and ``distance``. | ||
For details of the solved problem, see | ||
:class:`pints.cptests.RunOptimiserOnRosenbrockError`. | ||
""" | ||
problem = cpt.RunOptimiserOnRosenbrockError(_method, n_iterations, _fguess) | ||
return { | ||
'error': problem.error(), | ||
'distance': problem.distance() | ||
} | ||
|
||
|
||
def two_dim_parabola(n_iterations=50): | ||
""" | ||
Tests :class:`pints.XNES` on a two-dimensional parabolic error and returns | ||
a dictionary with entries ``error`` and ``distance``. | ||
For details of the solved problem, see | ||
:class:`pints.cptests.RunOptimiserOnTwoDimParabola`. | ||
""" | ||
problem = cpt.RunOptimiserOnTwoDimParabola(_method, n_iterations, _fguess) | ||
return { | ||
'error': problem.error(), | ||
'distance': problem.distance() | ||
} | ||
|
||
|
||
_method = pints.XNES | ||
_fguess = True | ||
_change_point_tests = [ | ||
bounded_fitzhugh_nagumo, | ||
bounded_untransformed_logistic, | ||
rosenbrock, | ||
two_dim_parabola, | ||
] |