/// <summary> /// Construct a new object. /// </summary> /// <param name="numIterations">Number of iterations per optimization run.</param> /// <param name="numIntervals">Approximate number of intervals to show mean.</param> /// <param name="chainedFitnessTrace">Chained FitnessTrace object.</param> public FeasibleTrace(int numIterations, int numIntervals, FitnessTrace chainedFitnessTrace) : base(chainedFitnessTrace, numIterations, numIntervals, 0) { // Allocate trace. Trace = new StatisticsAccumulator[MaxIntervals]; for (int i = 0; i < MaxIntervals; i++) { Trace[i] = new StatisticsAccumulator(); } }
/// <summary> /// Construct a new object. /// </summary> /// <param name="numRuns">Number of optimization to be performed.</param> /// <param name="numIterations">Number of iterations per optimization run.</param> /// <param name="numIntervals">Approximate number of intervals to show quartiles.</param> /// <param name="chainedFitnessTrace">Chained FitnessTrace object.</param> public FitnessTraceQuartiles(int numRuns, int numIterations, int numIntervals, FitnessTrace chainedFitnessTrace) : base(chainedFitnessTrace, numIterations, numIntervals, 0.5) { NumRuns = numRuns; NumIterations = numIterations; // Allocate trace. Trace = new List<double>[MaxIntervals]; for (int i = 0; i < MaxIntervals; i++) { Trace[i] = new List<double>(numRuns); } }
/// <summary> /// Construct a new object. /// </summary> public FitnessTrace(FitnessTrace chainedFitnessTrace, int numIterations, int numIntervals, double offset) { ChainedFitnessTrace = chainedFitnessTrace; // The number of intervals at which to log/show fitness cannot // be greater than the number of optimization iterations. int intervals = System.Math.Min(numIntervals, numIterations); // The stride is the number of optimization iterations that each // interval is made up of. Stride = numIterations / intervals; // Offset for the first fitness log. Offset = (int)(offset * Stride); // The maximum number of intervals at which to log the fitness. // Consider numIterations==10, Offset==0, Stride==3, this requires // logging at iterations 0, 3, 6, 9. That is, a total of four log // entries. The reason that Ceiling is used is that // (numIterations - Offset) / Stride == 10 / 3 == 3 using integer // rounding. MaxIntervals = (int)System.Math.Ceiling((double)(numIterations - Offset) / Stride); }