/// <inheritdoc/> void IAcceptBehavior.Accept() { if (_method is IBreakpointMethod method) { // The integration method supports breakpoints, let's see if we need to add one if (_wasBreak || method.Break) { // Calculate the slope reaching this accepted solution double slope1, slope2; if (method.Time.Equals(0.0)) { // The first timepoint is assumed to have a slope of 0 slope1 = 0.0; slope2 = 0.0; } else { var signals = Signals; var delta = signals.GetTime(0) - signals.GetTime(1); slope1 = (signals.GetValue(0, 0) - signals.GetValue(1, 0)) / delta; slope2 = (signals.GetValue(0, 1) - signals.GetValue(1, 1)) / delta; } // If the previous point was a breakpoint, let's decide if we need another in the future if (_wasBreak) { var tol1 = Parameters.RelativeTolerance * Math.Max(Math.Abs(slope1), Math.Abs(_oldSlope1)) + Parameters.AbsoluteTolerance; var tol2 = Parameters.RelativeTolerance * Math.Max(Math.Abs(slope2), Math.Abs(_oldSlope2)) + Parameters.AbsoluteTolerance; if (Math.Abs(slope1 - _oldSlope1) > tol1 || Math.Abs(slope2 - _oldSlope2) > tol2) { method.Breakpoints.SetBreakpoint(Signals.GetTime(1) + Parameters.Delay); } } // Track for the next time _oldSlope1 = slope1; _oldSlope2 = slope2; _wasBreak = method.Break; } } Signals.AcceptProbedValues(); }