-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy path__init__.py
206 lines (186 loc) · 4.74 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#
# Root of the pybop module.
# Provides access to all shared functionality (models, solvers, etc.).
#
# This file is adapted from Pints
# (see https://github.com/pints-team/pints)
#
import sys
from os import path
#
# Multiprocessing
#
try:
import multiprocessing as mp
if sys.platform == "win32":
mp.set_start_method("spawn")
else:
mp.set_start_method("fork")
except Exception as e: # pragma: no cover
error_message = (
"Multiprocessing context could not be set. "
"Continuing import without setting context.\n"
f"Error: {e}"
) # pragma: no cover
print(error_message) # pragma: no cover
pass # pragma: no cover
#
# Version info
#
from pybop._version import __version__
#
# Constants
#
# Float format: a float can be converted to a 17 digit decimal and back without
# loss of information
FLOAT_FORMAT = "{: .17e}"
# Absolute path to the pybop repo
script_path = path.dirname(__file__)
#
# Utilities
#
from ._utils import is_numeric, SymbolReplacer
#
# Experiment class
#
from ._experiment import Experiment
#
# Dataset class
#
from ._dataset import Dataset
#
# Transformation classes
#
from .transformation.base_transformation import Transformation
from .transformation.transformations import (
IdentityTransformation,
ScaledTransformation,
LogTransformation,
ComposedTransformation,
UnitHyperCube,
)
#
# Parameter classes
#
from .parameters.parameter import Parameter, Parameters
from .parameters.parameter_set import ParameterSet
from .parameters.priors import BasePrior, Gaussian, Uniform, Exponential, JointLogPrior
#
# Model classes
#
from .models.base_model import BaseModel
from .models import lithium_ion
from .models import empirical
from .models._exponential_decay import ExponentialDecayModel
from .models.base_model import TimeSeriesState
from .models.base_model import Inputs
#
# Problem classes
#
from .problems.base_problem import BaseProblem
from .problems.fitting_problem import FittingProblem
from .problems.multi_fitting_problem import MultiFittingProblem
from .problems.design_problem import DesignProblem
#
# Cost classes
#
from .costs.base_cost import BaseCost
from .costs.fitting_costs import (
FittingCost,
RootMeanSquaredError,
MeanAbsoluteError,
MeanSquaredError,
SumSquaredError,
Minkowski,
SumofPower,
ObserverCost,
)
from .costs.design_costs import (
DesignCost,
GravimetricEnergyDensity,
VolumetricEnergyDensity,
GravimetricPowerDensity,
VolumetricPowerDensity,
)
from .costs._likelihoods import (
BaseLikelihood,
GaussianLogLikelihood,
GaussianLogLikelihoodKnownSigma,
ScaledLogLikelihood,
LogPosterior,
)
from .costs._weighted_cost import WeightedCost
#
# Experimental
#
from .experimental.jax_costs import BaseJaxCost, JaxSumSquaredError, JaxLogNormalLikelihood, JaxGaussianLogLikelihoodKnownSigma
#
# Evaluation
#
from ._evaluation import SequentialJaxEvaluator, SciPyEvaluator
#
# Optimiser classes
#
from .optimisers._cuckoo import CuckooSearchImpl
from .optimisers._random_search import RandomSearchImpl
from .optimisers._adamw import AdamWImpl
from .optimisers._gradient_descent import GradientDescentImpl
from .optimisers._simulated_annealing import SimulatedAnnealingImpl
from .optimisers._irprop_plus import IRPropPlusImpl
from .optimisers.base_optimiser import BaseOptimiser, OptimisationResult
from .optimisers.base_pints_optimiser import BasePintsOptimiser
from .optimisers.scipy_optimisers import (
BaseSciPyOptimiser,
SciPyMinimize,
SciPyDifferentialEvolution
)
from .optimisers.pints_optimisers import (
GradientDescent,
CMAES,
IRPropMin,
IRPropPlus,
NelderMead,
PSO,
SNES,
XNES,
CuckooSearch,
RandomSearch,
AdamW,
SimulatedAnnealing,
)
from .optimisers.optimisation import Optimisation
#
# Monte Carlo classes
#
from .samplers.base_sampler import BaseSampler
from .samplers.base_pints_sampler import BasePintsSampler
from .samplers.pints_samplers import (
NUTS, DREAM, AdaptiveCovarianceMCMC,
DifferentialEvolutionMCMC, DramACMC,
EmceeHammerMCMC,
HaarioACMC, HaarioBardenetACMC,
HamiltonianMCMC, MALAMCMC,
MetropolisRandomWalkMCMC, MonomialGammaHamiltonianMCMC,
PopulationMCMC, RaoBlackwellACMC,
RelativisticMCMC, SliceDoublingMCMC,
SliceRankShrinkingMCMC, SliceStepoutMCMC,
)
from .samplers.mcmc_sampler import MCMCSampler
#
# Observer classes
#
from .observers.unscented_kalman import UnscentedKalmanFilterObserver
from .observers.observer import Observer
#
# Classification classes
#
from ._classification import classify_using_hessian
#
# Plotting classes
#
from . import plot as plot
from .samplers.mcmc_summary import PosteriorSummary
#
# Remove any imported modules, so we don't expose them as part of pybop
#
del sys