Esempio n. 1
0
        private bool checkSuccessStoryCriterionForLastPair(TimeAndReward currentTimeAndReward)
        {
            if (checkpoints.Count < 2)
            {
                return(true);
            }

            int  index = checkpoints.Count - 1;
            bool isCriterionValidForThisPair = isCriterionValidForPair(checkpoints[index - 1], checkpoints[index], currentTimeAndReward);

            return(isCriterionValidForThisPair);
        }
Esempio n. 2
0
        public void invokeCheckpoint(Checkpoint <Type> currentCheckpoint, TimeAndReward currentTimeAndReward)
        {
            bool successStoryCriterionSatisfiedForLastPair;

            while (!(successStoryCriterionSatisfiedForLastPair = checkSuccessStoryCriterionForLastPair(currentTimeAndReward)))
            {
                // undo all changes made since last recent checkpoint and remove checkpoint

                int lastIndex = checkpoints.Count - 1;
                undoAllPolicyModificationsSinceCheckpoint(checkpoints[lastIndex]);
                checkpoints.RemoveAt(lastIndex);
            }

            checkpoints.Add(currentCheckpoint);
        }
Esempio n. 3
0
 private static double calcRatio(Checkpoint <Type> checkpoint, TimeAndReward currentTimeAndReward)
 {
     return((currentTimeAndReward.reward - checkpoint.timeAndReward.reward) / (currentTimeAndReward.time - checkpoint.timeAndReward.time));
 }
Esempio n. 4
0
        private static bool isCriterionValidForPair(Checkpoint <Type> a, Checkpoint <Type> b, TimeAndReward currentTimeAndReward)
        {
            double
                ratioForB = calcRatio(b, currentTimeAndReward),
                ratioForA = calcRatio(a, currentTimeAndReward);

            return(ratioForB > ratioForA);
        }