Esempio n. 1
0
        /// <summary>
        /// Gets the averaged data of the given variable from a list of episodes using the track parameters
        /// </summary>
        /// <param name="episodes">The episode list</param>
        /// <param name="trackParameters">The track parameters</param>
        /// <param name="variableIndex">Index of the variable</param>
        /// <returns>A SeriesGroup object with the requested data</returns>
        public static SeriesGroup GetAveragedData(List <Log.Episode> episodes, Report trackParameters, int variableIndex)
        {
            SeriesGroup data     = new SeriesGroup(trackParameters);
            Series      xYSeries = new Series();

            foreach (Log.Episode episode in episodes)
            {
                xYSeries.AddValue(episode.index
                                  , GetEpisodeAverage(episode, variableIndex, trackParameters));
            }
            xYSeries.CalculateStats(trackParameters);
            if (trackParameters.Resample)
            {
                xYSeries.Resample(trackParameters.NumSamples);
            }
            data.AddSeries(xYSeries);
            return(data);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a Track object from a logged experimental unit and a list of reports
        /// </summary>
        /// <param name="expUnit">The logged experimental unit</param>
        /// <param name="reports">The list of reports we want</param>
        /// <returns></returns>
        public static Track LoadTrackData(LoggedExperimentalUnitViewModel expUnit, List <Report> reports)
        {
            Log.Data Log = new Log.Data();
            Log.Load(expUnit.LogFileName);

            if (!Log.SuccessfulLoad || Log.TotalNumEpisodes == 0)
            {
                return(null);
            }

            Track       track = new Track(expUnit.ForkValues, expUnit.LogFileName, expUnit.LogDescriptorFileName, expUnit.ExperimentFileName);
            SeriesGroup dataSeries;
            int         variableIndex;

            foreach (Report report in reports)
            {
                variableIndex = expUnit.GetVariableIndex(report.Variable);
                switch (report.Type)
                {
                case ReportType.LastEvaluation:
                    Log.Episode lastEpisode = Log.EvaluationEpisodes[Log.EvaluationEpisodes.Count - 1];
                    dataSeries = new SeriesGroup(report);
                    Series series = LogFileUtils.GetVariableData(lastEpisode, report, variableIndex);
                    if (series != null)
                    {
                        dataSeries.AddSeries(series);
                        track.AddVariableData(report, dataSeries);
                    }
                    break;

                case ReportType.EvaluationAverages:
                    track.AddVariableData(report
                                          , LogFileUtils.GetAveragedData(Log.EvaluationEpisodes, report, variableIndex));
                    break;

                case ReportType.AllEvaluationEpisodes:
                case ReportType.AllTrainingEpisodes:
                    dataSeries = new SeriesGroup(report);
                    List <Log.Episode> episodes;
                    if (report.Type == ReportType.AllEvaluationEpisodes)
                    {
                        episodes = Log.EvaluationEpisodes;
                    }
                    else
                    {
                        episodes = Log.TrainingEpisodes;
                    }
                    foreach (Log.Episode episode in episodes)
                    {
                        Series subSeries = LogFileUtils.GetVariableData(episode, report, variableIndex);
                        if (subSeries != null)
                        {
                            subSeries.Id = episode.index.ToString();
                            dataSeries.AddSeries(subSeries);
                        }
                    }
                    track.AddVariableData(report, dataSeries);
                    break;
                }
            }
            return(track);
        }