@@ -98,6 +98,17 @@ sfidx=4, mhidx=2: 4 should take a value from 2
98
98
sfidx=4, mhidx=3: 4 should take a value from 3
99
99
sfidx=4, mhidx=4: ah = [1;4]
100
100
```
101
+
102
+ Also keeping the default case documented:
103
+ ```
104
+ # the default case where mh==nothing
105
+ # equivalent to mh=[1;1;1] # assuming 3 variables
106
+ sfidx=1, allelements=allidx[nhidx.==0], activehypo=(0,[1;])
107
+ sfidx=2, allelements=allidx[nhidx.==0], activehypo=(0,[2;])
108
+ sfidx=3, allelements=allidx[nhidx.==0], activehypo=(0,[3;])
109
+ ```
110
+
111
+ TODO still need to compensate multihypo case for user nullhypo addition.
101
112
"""
102
113
function assembleHypothesesElements! (mh:: Categorical ,
103
114
maxlen:: Int ,
@@ -111,14 +122,10 @@ function assembleHypothesesElements!(mh::Categorical,
111
122
112
123
allidx = 1 : maxlen
113
124
allmhp, certainidx, uncertnidx = getHypothesesVectors (mh. p)
114
- # allmhp = 1:length(mh.p)
115
- # certainidx = allmhp[mh.p .== 0.0] # TODO remove after gwp removed
116
- # uncertnidx = allmhp[0.0 .< mh.p]
117
125
118
126
# select only hypotheses that can be used (ie variables have been initialized)
119
127
@assert ! (sum (isinit) == 0 && sfidx == certainidx) # cannot init from nothing for any hypothesis
120
128
121
-
122
129
mhh = if sum (isinit) < lenXi - 1
123
130
@assert isLeastOneHypoAvailable (sfidx, certainidx, uncertnidx, isinit)
124
131
@info " not all hypotheses initialized, but at least one available -- see #427"
@@ -142,7 +149,7 @@ function assembleHypothesesElements!(mh::Categorical,
142
149
mhh
143
150
end
144
151
145
- # prep mmultihypothesis selection values
152
+ # prep mm-nultihypothesis selection values
146
153
mhidx = rand (mhh, maxlen) # selection of which hypothesis is correct
147
154
pidx = 0
148
155
if sfidx in uncertnidx
@@ -152,7 +159,7 @@ function assembleHypothesesElements!(mh::Categorical,
152
159
end
153
160
154
161
sfincer = sfidx in certainidx
155
- for pval in mhh. p # mh.p
162
+ for pval in mhh. p
156
163
pidx += 1
157
164
pidxincer = pidx in certainidx # ??
158
165
# permutation vectors for later computation
@@ -181,7 +188,7 @@ function assembleHypothesesElements!(mh::Categorical,
181
188
push! (activehypo, (pidx,iterah))
182
189
end
183
190
184
- # # retroactively add nullhypo compensation for bad-init case (the 0 case)
191
+ # # retroactively add nullhypo case (the 0 case)
185
192
# if sfidx in uncertnidx
186
193
# #
187
194
# end
@@ -192,29 +199,51 @@ function assembleHypothesesElements!(mh::Nothing,
192
199
maxlen:: Int ,
193
200
sfidx:: Int ,
194
201
lenXi:: Int ,
195
- isinit:: Vector{Bool} = ones (Bool, lenXi) )
202
+ isinit:: Vector{Bool} = ones (Bool, lenXi),
203
+ nullhypo:: Real = 0 )
204
+ #
205
+ # the default case where mh==nothing
206
+ # equivalent to mh=[1;1;1] # assuming 3 variables
207
+ # sfidx=1, allelements=allidx[nhidx.==0], activehypo=(0,[1;])
208
+
196
209
#
197
210
allelements = []
198
211
activehypo = []
199
- mhidx = Int[]
212
+
213
+ # TODO add cases where nullhypo occurs, see DFG #536, and IIF #237
214
+ nmhw = [nullhypo; (1 - nullhypo)]
215
+ nhh = Categorical (nmhw)
216
+
217
+ # prep mmultihypothesis selection values
218
+ # mhidx = Int[]
219
+ # NOTE, must do something special to get around Categorical([0;10]) error
220
+ # selection of which hypothesis is correct
221
+ mhidx = nullhypo == 0 ? ones (Int, maxlen) : (rand (nhh, maxlen) .- 1 )
200
222
201
223
allidx = 1 : maxlen
202
224
certainidx = 1 : lenXi
203
- doneall = false
204
- for i in certainidx
205
- if ! doneall
206
- push! (allelements, allidx)
225
+ # zero is nullhypo case, 1 is first sfidx variable
226
+ nullarr = allidx[mhidx .== 0 ]
227
+ # mhidx == 1 case is regular -- this will be all elements if nullhypo=0.0
228
+ reguarr = allidx[mhidx .!= 0 ]
229
+ for i in [0 ;certainidx]
230
+ if i == 0
231
+ # elements that occur during nullhypo active
232
+ push! (allelements, nullarr)
233
+ push! (activehypo, (i,sfidx))
234
+ elseif i == 1
235
+ # elements that occur during regular hypothesis true
236
+ push! (allelements, reguarr)
207
237
push! (activehypo, (i,certainidx))
208
- doneall = true
209
238
else
239
+ # all remaining collections are empty (part of multihypo support)
210
240
push! (allelements, Int[])
211
241
push! (activehypo, (i,Int[]))
212
242
end
213
243
end
214
244
215
- # TODO add cases where nullhypo occurs, see DFG #536, and IIF #237
216
245
217
- return certainidx, allelements, activehypo, mhidx # certainidx = allhp
246
+ return certainidx, allelements, activehypo, mhidx
218
247
end
219
248
220
249
0 commit comments