/// <summary> /// Write fitness-trace to a TextWriter stream. /// </summary> public override void Write(TextWriter writer) { writer.WriteLine("Mean feasibility 0 means all solutions were infeasible."); writer.WriteLine("Mean feasibility 1 means all solutions were feasible."); writer.WriteLine(); writer.WriteLine("# Iteration\tMean Feasibility"); writer.WriteLine(); for (int i = 0; i < Trace.Length; i++) { StatisticsAccumulator trace = Trace[i]; if (trace.Count > 0) { double mean = trace.Mean; writer.WriteLine( "{0} {1}", Iteration(i), Tools.FormatNumber(mean)); } else { break; } } writer.Close(); }
/// <summary> /// Write fitness-trace to a TextWriter stream. /// </summary> public override void Write(TextWriter writer) { writer.WriteLine("# Iteration\tMean Fitness\tStdError\tMin\tMax"); writer.WriteLine(); for (int i = 0; i < Trace.Length; i++) { StatisticsAccumulator trace = Trace[i]; if (trace.Count > 0) { double mean = trace.Mean; double stdDev = trace.StandardDeviation; double min = trace.Min; double max = trace.Max; writer.WriteLine( "{0} {1} {2} {3} {4}", Iteration(i), Tools.FormatNumber(mean), Tools.FormatNumber(stdDev), Tools.FormatNumber(min), Tools.FormatNumber(max)); } else { break; } } writer.Close(); }
/// <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(); } }