@@ -82,14 +82,24 @@ struct MCMCSerial <: AbstractMCMCEnsemble end
82
82
83
83
"""
84
84
getparams(model::AbstractModel, state)
85
+ getparams(logdensity, state)
85
86
getparams(state)
86
87
87
88
Retrieve the values of parameters from the sampler's `state` as a `Vector{<:Real}`.
88
89
"""
89
90
function getparams end
90
91
92
+ function getparams (logdensity, state)
93
+ return getparams (_model (logdensity), state)
94
+ end
95
+
96
+ function getparams (model:: AbstractModel , state)
97
+ return getparams (state)
98
+ end
99
+
91
100
"""
92
101
setparams!!(model::AbstractModel, state, params)
102
+ setparams!!(logdensity, state, params)
93
103
setparams!!(state, params)
94
104
95
105
Set the values of parameters in the sampler's `state` from a `Vector{<:Real}`.
@@ -103,9 +113,19 @@ and the vector representation of the parameter values.
103
113
104
114
Sometimes, to maintain the consistency of the log density and parameter values, a `model::AbstractModel`
105
115
should be provided. This is useful for samplers that need to evaluate the log density at the new parameter values.
116
+ If `model` is not an `AbstractMCMC.AbstractModel`, by default, it is assumed to be a log density function following
117
+ the `LogDensityProblems.jl` interface, and will be wrapped with [`AbstractMCMC.LogDensityModel`](@ref).
106
118
"""
107
119
function setparams!! end
108
120
121
+ function setparams!! (logdensity, state, params)
122
+ return setparams!! (_model (logdensity), state, params)
123
+ end
124
+
125
+ function setparams!! (model:: AbstractModel , state, params)
126
+ return setparams!! (state, params)
127
+ end
128
+
109
129
include (" samplingstats.jl" )
110
130
include (" logging.jl" )
111
131
include (" interface.jl" )
0 commit comments