You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`MutatingFunctionalAffect` is a helper for writing affect functions that will compute observed values and
77
+
`ImperativeAffect` is a helper for writing affect functions that will compute observed values and
78
78
ensure that modified values are correctly written back into the system. The affect function `f` needs to have
79
79
one of four signatures:
80
80
* `f(modified::NamedTuple)::NamedTuple` if the function only writes values (unknowns or parameters) to the system,
@@ -93,15 +93,15 @@ then the NamedTuple `(;x=2)` will be passed as `observed` to the affect function
93
93
94
94
The NamedTuple returned from `f` includes the values to be written back to the system after `f` returns. For example, if we want to update the value of `x` to be the result of `x + y` we could write
95
95
96
-
MutatingFunctionalAffect(observed=(; x_plus_y = x + y), modified=(; x)) do m, o
96
+
ImperativeAffect(observed=(; x_plus_y = x + y), modified=(; x)) do m, o
97
97
@set! m.x = o.x_plus_y
98
98
end
99
99
100
100
Where we use Setfield to copy the tuple `m` with a new value for `x`, then return the modified value of `m`. All values updated by the tuple must have names originally declared in
101
101
`modified`; a runtime error will be produced if a value is written that does not appear in `modified`. The user can dynamically decide not to write a value back by not including it
102
102
in the returned tuple, in which case the associated field will not be updated.
103
103
"""
104
-
@kwdefstructMutatingFunctionalAffect
104
+
@kwdefstructImperativeAffect
105
105
f::Any
106
106
obs::Vector
107
107
obs_syms::Vector{Symbol}
@@ -111,50 +111,50 @@ in the returned tuple, in which case the associated field will not be updated.
@@ -219,7 +219,7 @@ Affects (i.e. `affect` and `affect_neg`) can be specified as either:
219
219
+ `read_parameters` is a vector of the parameters that are *used* by `f!`. Their indices are passed to `f` in `p` similarly to the indices of `unknowns` passed in `u`.
220
220
+ `modified_parameters` is a vector of the parameters that are *modified* by `f!`. Note that a parameter will not appear in `p` if it only appears in `modified_parameters`; it must appear in both `parameters` and `modified_parameters` if it is used in the affect definition.
221
221
+ `ctx` is a user-defined context object passed to `f!` when invoked. This value is aliased for each problem.
222
-
* A [`MutatingFunctionalAffect`](@ref); refer to its documentation for details.
222
+
* A [`ImperativeAffect`](@ref); refer to its documentation for details.
223
223
224
224
Callbacks that impact a DAE are applied, then the DAE is reinitialized using `reinitializealg` (which defaults to `SciMLBase.CheckInit`).
225
225
This reinitialization algorithm ensures that the DAE is satisfied after the callback runs. The default value of `CheckInit` will simply validate
@error"User affect function $user_affect needs to implement one of the supported MutatingFunctionalAffect callback forms; see the MutatingFunctionalAffect docstring for more details"
1116
+
@error"User affect function $user_affect needs to implement one of the supported ImperativeAffect callback forms; see the ImperativeAffect docstring for more details"
1117
1117
user_affect(upd_component_array, obs_component_array, integ, ctx) # this WILL error but it'll give a more sensible message
1118
1118
end
1119
1119
@@ -1127,7 +1127,7 @@ function compile_user_affect(affect::MutatingFunctionalAffect, cb, sys, dvs, ps;
0 commit comments