-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
Right now values_as_in_model
always re-evaluates the model.
DynamicPPL.jl/src/values_as_in_model.jl
Lines 125 to 129 in 2074657
function values_as_in_model(model::Model, include_colon_eq::Bool, varinfo::AbstractVarInfo) | |
varinfo = setaccs!!(deepcopy(varinfo), (ValuesAsInModelAccumulator(include_colon_eq),)) | |
varinfo = last(evaluate!!(model, varinfo)) | |
return getacc(varinfo, Val(:ValuesAsInModel)).values | |
end |
This is obviously inefficient. We should:
- Make
ValuesAsInModelAccumulator
a default one. It costs almost zero time to do this. Not sure if this will meddle with type stability, but if it does I imagine it should be possible to find a workaround. (cough cough VarNamedTuple...) - Make a new method
values_as_in_model(::VarInfo)
that just takes the values out from the accumulator. - Check for usage of
values_as_in_model(model, vi)
in the code base that can be simplified to justvalues_as_in_model(vi)
.
I would also prefer renaming one of the two to something else to indicate that one does not evaluate and the other re-evaluates.
Metadata
Metadata
Assignees
Labels
No labels