File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -569,8 +569,11 @@ function _batch_affect(dcw::DiscreteCallbackWrapper)
569
569
570
570
(integrator) -> begin
571
571
# Re-evaluate all conditions to determine which affects to execute
572
+ # the affects might mutate p, therfor we ceate a copy to evaluate all
573
+ # conditions on the unaltered state!
572
574
cus = PreallocationTools. get_tmp (cucache, integrator. u)
573
575
cobsf (integrator. u, integrator. p, integrator. t, cus)
576
+ cps = copy (integrator. p)
574
577
575
578
any_uchanged = false
576
579
any_pchanged = false
@@ -580,7 +583,7 @@ function _batch_affect(dcw::DiscreteCallbackWrapper)
580
583
cuv = view (cus, condition_urange (dcw, i))
581
584
c_u = SymbolicView (cuv, dcw. callbacks[i]. condition. sym)
582
585
cpidxsv = view (cpidxs, condition_prange (dcw, i))
583
- cpv = view (integrator . p , cpidxsv)
586
+ cpv = view (cps , cpidxsv)
584
587
c_p = SymbolicView (cpv, dcw. callbacks[i]. condition. psym)
585
588
586
589
# Only execute affect if condition is true
You can’t perform that action at this time.
0 commit comments