Buggy code:
public class DefaultScheduler { final double MIN_INTERVAL = 0.9 ; public static final String TAG = "DefaultScheduler" ; public LearningData schedule ( LearningData oldData , int newGrade , boolean includeNoise ) { Log . i ( DefaultScheduler . TAG , ( "Old<seq2seq4repair_space>data:<seq2seq4repair_space>" + oldData ) ) ; Date currentDate = new Date ( ) ; double actualInterval = AMUtil . diffDate ( oldData . getLastLearnDate ( ) , currentDate ) ; double scheduleInterval = oldData . getInterval ( ) ; double newInterval = 0.0 ; int oldGrade = oldData . getGrade ( ) ; double oldEasiness = oldData . getEasiness ( ) ; int newLapses = oldData . getLapses ( ) ; int newAcqReps = oldData . getAcqReps ( ) ; int newRetReps = oldData . getRetReps ( ) ; int newAcqRepsSinceLapse = oldData . getAcqRepsSinceLapse ( ) ; int newRetRepsSinceLapse = oldData . getRetRepsSinceLapse ( ) ; float newEasiness = oldData . getEasiness ( ) ; if ( actualInterval <= ( MIN_INTERVAL ) ) { actualInterval = 0.9 ; } if ( newAcqReps == 0 ) { newAcqReps = 1 ; newEasiness = 2.5F ; newAcqRepsSinceLapse = 1 ; newInterval = calculateInitialInterval ( newGrade ) ; } else if ( ( oldGrade <= 1 ) && ( newGrade <= 1 ) ) { newAcqReps += 1 ; newAcqRepsSinceLapse += 1 ; newInterval = 0 ; } else if ( ( oldGrade <= 1 ) && ( newGrade >= 2 ) ) { newAcqReps += 1 ; newAcqRepsSinceLapse += 1 ; newInterval = 1 ; } else if ( ( oldGrade >= 2 ) && ( newGrade <= 1 ) ) { newRetReps += 1 ; newLapses += 1 ; newAcqRepsSinceLapse = 0 ; newRetRepsSinceLapse = 0 ; newInterval = 0 ; } else if ( ( oldGrade >= 2 ) && ( newGrade >= 2 ) ) { newRetReps += 1 ; newRetRepsSinceLapse += 1 ; if ( actualInterval >= scheduleInterval ) { if ( newGrade == 2 ) { newEasiness -= 0.16 ; } if ( newGrade == 3 ) { newEasiness -= 0.14 ; } if ( newGrade == 5 ) { newEasiness += 0.1 ; } if ( oldEasiness < 1.3 ) { newEasiness = 1.3F ; } newInterval = 0 ; if ( actualInterval <= scheduleInterval ) { newInterval = actualInterval * newEasiness ; <START_BUG> newInterval = ( ( actualInterval * newEasiness ) < scheduleInterval ) ? actualInterval * newEasiness : scheduleInterval ; <END_BUG> } else { newInterval = scheduleInterval * newEasiness ; } if ( newInterval <= ( MIN_INTERVAL ) ) { Log . w ( DefaultScheduler . TAG , ( ( ( ( ( "Interval<seq2seq4repair_space>" + newInterval ) + "<seq2seq4repair_space>is<seq2seq4repair_space>less<seq2seq4repair_space>than<seq2seq4repair_space>" ) + ( MIN_INTERVAL ) ) + "<seq2seq4repair_space>for<seq2seq4repair_space>old<seq2seq4repair_space>data:<seq2seq4repair_space>" ) + oldData ) ) ; newInterval = MIN_INTERVAL ; } } } if ( includeNoise ) { newInterval = newInterval + ( calculateIntervalNoise ( newInterval ) ) ; } LearningData newData = new LearningData ( ) ; newData . setId ( oldData . getId ( ) ) ; newData . setAcqReps ( newAcqReps ) ; newData . setAcqRepsSinceLapse ( newAcqRepsSinceLapse ) ; newData . setEasiness ( newEasiness ) ; newData . setGrade ( newGrade ) ; newData . setLapses ( newLapses ) ; newData . setLastLearnDate ( currentDate ) ; newData . setNextLearnDate ( afterDays ( currentDate , newInterval ) ) ; newData . setRetReps ( newRetReps ) ; newData . setRetRepsSinceLapse ( newRetRepsSinceLapse ) ; Log . i ( DefaultScheduler . TAG , ( "New<seq2seq4repair_space>data:<seq2seq4repair_space>" + newData ) ) ; return newData ; } private double calculateIntervalNoise ( double interval ) { } private int calculateInitialInterval ( int grade ) { } private double randomNumber ( double min , double max ) { } private Date afterDays ( Date date , double days ) { } }

Fix:
newInterval = ( ( actualInterval * newEasiness ) > scheduleInterval ) ? actualInterval * newEasiness : scheduleInterval ;