Builder
abstract_builder
¶
Base class for application builders.
The MTMLDA takes a list of callables as posterior hierarchy. To enhance flexibility w.r.t. to how these models are generated, and to support parallel chains, we employ a builder pattern for applications. With the prescribed interface, the builder can be used by the run wrapper and trigger MTMLDA run from a variety of use-cases.
Classes:
Name | Description |
---|---|
ApplicationBuilder |
Base class for application builders. |
InverseProblemSettings |
Base data class for inverse problem settings. |
SamplerComponentSettings |
Base data class for sampler component settings. |
InitialStateSettings |
Base data class for initial state settings. |
mtmlda.components.abstract_builder.InverseProblemSettings
dataclass
¶
Empty base data class for inverse problem settings.
mtmlda.components.abstract_builder.SamplerComponentSettings
dataclass
¶
Empty base data class for sampler component settings.
mtmlda.components.abstract_builder.InitialStateSettings
dataclass
¶
Empty base data class for initial state settings.
mtmlda.components.abstract_builder.ApplicationBuilder
¶
Bases: ABC
Base class for application builders.
The class provides a generic interface for application builders, as will be invoked by the run wrapper. The class is purely abstract, implementation must follow in subclasses. The only concrete behavior the class enforces is that the id of the invoking process is provided. This is useful for setting up components in a process-specific way for chain-parallel runs.
Methods:
Name | Description |
---|---|
set_up_models |
Set up a model hierarchy in the form of a list of callables.. |
set_up_sampler_components |
Set up proposal and accept rate estimator. |
generate_initial_state |
Generate the initial state for the Markov chain |
__init__
¶
Base class constructor, assigns process id of calling process as internal attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
process_id
|
int
|
ID of calling process |
required |
set_up_models
abstractmethod
¶
Set up a posterior hierarchy as a sequence of callables.
Within this method, different components can be freely combined to obtain a posterior hierarchy. For instance, an external model server could be called to provide a likelihood, which is then combined with a prior component. This method is the main reason the separate builder exists, to allow for more flexibility in the model setup.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inverse_problem_settings
|
InverseProblemSettings
|
Necessary settings for model setup, can be anything |
required |
Returns:
Type | Description |
---|---|
list[Callable]
|
list[Callable]: Posterior hierarchy for MLDA run |
set_up_sampler_components
abstractmethod
¶
set_up_sampler_components(
sampler_component_settings: SamplerComponentSettings,
) -> tuple[mcmc.BaseProposal, mcmc.BaseAcceptRateEstimator]
Set up the coarse-level proposal and accept rate estimator for MLDA.
Can be used for process-dependent initialization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sampler_component_settings
|
SamplerComponentSettings
|
Necessary settings for component setup, can be anything |
required |
Returns:
Type | Description |
---|---|
tuple[mcmc.BaseProposal, mcmc.BaseAcceptRateEstimator]
|
tuple[mcmc.BaseProposal, mcmc.BaseAcceptRateEstimator]: Proposal and accept rate estimator |
generate_initial_state
abstractmethod
¶
Generate initial state of a Markov chain.
Can be used for process-dependent initialization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
initial_state_settings
|
InitialStateSettings
|
Necessary settings for initial state setup, can be anything |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
np.ndarray: Initial state |