22Type to dispatch constructing data and network structures
33for different cases of hybrid problem setups
44
5- For a specific case , provide functions that specify details
6- - `get_hybridcase_MLapplicator `
7- - `get_hybridcase_PBmodel `
8- - `get_hybridcase_neg_logden_obs `
9- - `get_hybridcase_par_templates `
10- - `get_hybridcase_transforms `
11- - `get_hybridcase_train_dataloader ` (default depends on `gen_hybridcase_synthetic`)
5+ For a specific prob , provide functions that specify details
6+ - `get_hybridproblem_MLapplicator `
7+ - `get_hybridproblem_PBmodel `
8+ - `get_hybridproblem_neg_logden_obs `
9+ - `get_hybridproblem_par_templates `
10+ - `get_hybridproblem_transforms `
11+ - `get_hybridproblem_train_dataloader ` (default depends on `gen_hybridcase_synthetic`)
1212optionally
1313- `gen_hybridcase_synthetic`
14- - `get_hybridcase_n_covar ` (defaults to number of rows in xM in train_dataloader )
15- - `get_hybridcase_float_type ` (defaults to `eltype(θM)`)
16- - `get_hybridcase_cor_starts ` (defaults to include all correlations: `(P=(1,), M=(1,))`)
14+ - `get_hybridproblem_n_covar ` (defaults to number of rows in xM in train_dataloader )
15+ - `get_hybridproblem_float_type ` (defaults to `eltype(θM)`)
16+ - `get_hybridproblem_cor_starts ` (defaults to include all correlations: `(P=(1,), M=(1,))`)
1717"""
18- abstract type AbstractHybridCase end ;
18+ abstract type AbstractHybridProblem end ;
1919
2020
2121"""
22- get_hybridcase_MLapplicator ([rng::AbstractRNG,] ::AbstractHybridCase ; scenario=())
22+ get_hybridproblem_MLapplicator ([rng::AbstractRNG,] ::AbstractHybridProblem ; scenario=())
2323
24- Construct the machine learning model fro given problem case and ML-Framework and
24+ Construct the machine learning model fro given problem prob and ML-Framework and
2525scenario.
2626
2727returns a Tuple of
2828- AbstractModelApplicator
2929- initial parameter vector
3030"""
31- function get_hybridcase_MLapplicator end
31+ function get_hybridproblem_MLapplicator end
3232
33- function get_hybridcase_MLapplicator (case :: AbstractHybridCase ; scenario= ())
34- get_hybridcase_MLapplicator (Random. default_rng (), case ; scenario)
33+ function get_hybridproblem_MLapplicator (prob :: AbstractHybridProblem ; scenario= ())
34+ get_hybridproblem_MLapplicator (Random. default_rng (), prob ; scenario)
3535end
3636
3737"""
38- get_hybridcase_PBmodel (::AbstractHybridCase ; scenario::NTuple=())
38+ get_hybridproblem_PBmodel (::AbstractHybridProblem ; scenario::NTuple=())
3939
4040Construct the process-based model function
4141`f(θP::AbstractVector, θMs::AbstractMatrix, x) -> (AbstractVector, AbstractMatrix)`
@@ -48,59 +48,59 @@ returns a tuple of predictions with components
4848- first, those that are constant across sites
4949- second, those that vary across sites, with a column for each site
5050"""
51- function get_hybridcase_PBmodel end
51+ function get_hybridproblem_PBmodel end
5252
5353"""
54- get_hybridcase_neg_logden_obs (::AbstractHybridCase ; scenario)
54+ get_hybridproblem_neg_logden_obs (::AbstractHybridProblem ; scenario)
5555
5656Provide a `function(y_obs, ypred) -> Real` that computes the negative logdensity
5757of the observations, given the predictions.
5858"""
59- function get_hybridcase_neg_logden_obs end
59+ function get_hybridproblem_neg_logden_obs end
6060
6161
6262"""
63- get_hybridcase_par_templates (::AbstractHybridCase ; scenario)
63+ get_hybridproblem_par_templates (::AbstractHybridProblem ; scenario)
6464
6565Provide tuple of templates of ComponentVectors `θP` and `θM`.
6666"""
67- function get_hybridcase_par_templates end
67+ function get_hybridproblem_par_templates end
6868
6969
7070"""
71- get_hybridcase_transforms (::AbstractHybridCase ; scenario)
71+ get_hybridproblem_transforms (::AbstractHybridProblem ; scenario)
7272
7373Return a NamedTupe of
7474- `transP`: Bijectors.Transform for the global PBM parameters, θP
7575- `transM`: Bijectors.Transform for the single-site PBM parameters, θM
7676"""
77- function get_hybridcase_transforms end
77+ function get_hybridproblem_transforms end
7878
7979# """
80- # get_hybridcase_par_templates (::AbstractHybridCase ; scenario)
80+ # get_hybridproblem_par_templates (::AbstractHybridProblem ; scenario)
8181# Provide a NamedTuple of number of
8282# - n_covar: covariates xM
8383# - n_site: all sites in the data
8484# - n_batch: sites in one minibatch during fitting
8585# - n_θM, n_θP: entries in parameter vectors
8686# """
87- # function get_hybridcase_sizes end
87+ # function get_hybridproblem_sizes end
8888
8989"""
90- get_hybridcase_n_covar (::AbstractHybridCase ; scenario)
90+ get_hybridproblem_n_covar (::AbstractHybridProblem ; scenario)
9191
9292Provide the number of covariates. Default returns the number of rows in `xM` from
93- `get_hybridcase_train_dataloader `.
93+ `get_hybridproblem_train_dataloader `.
9494"""
95- function get_hybridcase_n_covar (case :: AbstractHybridCase ; scenario)
96- train_loader = get_hybridcase_train_dataloader (Random. default_rng (), case ; scenario)
95+ function get_hybridproblem_n_covar (prob :: AbstractHybridProblem ; scenario)
96+ train_loader = get_hybridproblem_train_dataloader (Random. default_rng (), prob ; scenario)
9797 (xM, xP, y_o, y_unc) = first (train_loader)
9898 n_covar = size (xM, 1 )
9999 return (n_covar)
100100end
101101
102102"""
103- gen_hybridcase_synthetic([rng,] ::AbstractHybridCase ; scenario)
103+ gen_hybridcase_synthetic([rng,] ::AbstractHybridProblem ; scenario)
104104
105105Setup synthetic data, a NamedTuple of
106106- xM: matrix of covariates, with one column per site
@@ -114,40 +114,40 @@ Setup synthetic data, a NamedTuple of
114114function gen_hybridcase_synthetic end
115115
116116"""
117- get_hybridcase_float_type (::AbstractHybridCase ; scenario)
117+ get_hybridproblem_float_type (::AbstractHybridProblem ; scenario)
118118
119119Determine the FloatType for given Case and scenario, defaults to Float32
120120"""
121- function get_hybridcase_float_type (case :: AbstractHybridCase ; scenario= ())
122- return eltype (get_hybridcase_par_templates (case ; scenario). θM)
121+ function get_hybridproblem_float_type (prob :: AbstractHybridProblem ; scenario= ())
122+ return eltype (get_hybridproblem_par_templates (prob ; scenario). θM)
123123end
124124
125125"""
126- get_hybridcase_train_dataloader ([rng,] ::AbstractHybridCase ; scenario)
126+ get_hybridproblem_train_dataloader ([rng,] ::AbstractHybridProblem ; scenario)
127127
128128Return a DataLoader that provides a tuple of
129129- `xM`: matrix of covariates, with one column per site
130130- `xP`: Iterator of process-model drivers, with one element per site
131131- `y_o`: matrix of observations with added noise, with one column per site
132132- `y_unc`: matrix `sizeof(y_o)` of uncertainty information
133133"""
134- function get_hybridcase_train_dataloader (rng:: AbstractRNG , case :: AbstractHybridCase ;
134+ function get_hybridproblem_train_dataloader (rng:: AbstractRNG , prob :: AbstractHybridProblem ;
135135 scenario = ())
136- (; xM, xP, y_o, y_unc) = gen_hybridcase_synthetic (rng, case ; scenario)
136+ (; xM, xP, y_o, y_unc) = gen_hybridcase_synthetic (rng, prob ; scenario)
137137 n_batch = 10
138138 xM_gpu = :use_Flux ∈ scenario ? CuArray (xM) : xM
139139 train_loader = MLUtils. DataLoader ((xM_gpu, xP, y_o, y_unc), batchsize = n_batch)
140140 return (train_loader)
141141end
142142
143- function get_hybridcase_train_dataloader (case :: AbstractHybridCase ; scenario = ())
143+ function get_hybridproblem_train_dataloader (prob :: AbstractHybridProblem ; scenario = ())
144144 rng:: AbstractRNG = Random. default_rng ()
145- get_hybridcase_train_dataloader (rng, case ; scenario)
145+ get_hybridproblem_train_dataloader (rng, prob ; scenario)
146146end
147147
148148
149149"""
150- get_hybridcase_cor_starts(case::AbstractHybridCase ; scenario)
150+ get_hybridproblem_cor_starts(prob::AbstractHybridProblem ; scenario)
151151
152152Specify blocks in correlation matrices among parameters.
153153Returns a NamedTuple.
@@ -163,7 +163,7 @@ then the first subrange starts at position 1 and the second subrange starts at p
163163If there is only single block of all ML-predicted parameters being correlated
164164with each other then this block starts at position 1: `(P=(1,3), M=(1,))`.
165165"""
166- function get_hybridcase_cor_starts (case :: AbstractHybridCase ; scenario = ())
166+ function get_hybridproblem_cor_starts (prob :: AbstractHybridProblem ; scenario = ())
167167 (P= (1 ,), M= (1 ,))
168168end
169169
0 commit comments