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)
569569
570570    (integrator) ->  begin 
571571        #  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!
572574        cus =  PreallocationTools. get_tmp (cucache, integrator. u)
573575        cobsf (integrator. u, integrator. p, integrator. t, cus)
576+         cps =  copy (integrator. p)
574577
575578        any_uchanged =  false 
576579        any_pchanged =  false 
@@ -580,7 +583,7 @@ function _batch_affect(dcw::DiscreteCallbackWrapper)
580583            cuv =  view (cus, condition_urange (dcw, i))
581584            c_u =  SymbolicView (cuv, dcw. callbacks[i]. condition. sym)
582585            cpidxsv =  view (cpidxs, condition_prange (dcw, i))
583-             cpv =  view (integrator . p , cpidxsv)
586+             cpv =  view (cps , cpidxsv)
584587            c_p =  SymbolicView (cpv, dcw. callbacks[i]. condition. psym)
585588
586589            #  Only execute affect if condition is true
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments