Ejemplo n.º 1
0
        /// <summary>
        /// When grouping tracks by a fork, this function must be called to select a track inside the group.
        /// We call this "consolidating" the track group.
        /// </summary>
        /// <param name="inGroupSelectionFunction">The function used to compare tracks inside the group</param>
        /// <param name="inGroupSelectionVariable">The variable used to evaluate tracks</param>
        /// <param name="groupBy">The list of forks used to group tracks</param>
        public void Consolidate(string inGroupSelectionFunction, string inGroupSelectionVariable, string inGroupSelectionReportType
                                , BindableCollection <string> groupBy)
        {
            //Consolidation makes only sense if were are using groups
            if (groupBy.Count == 0)
            {
                return;
            }

            EnumDescriptionConverter conv = new EnumDescriptionConverter();
            ReportType orderByReportType  = (ReportType)((IValueConverter)conv).ConvertBack(inGroupSelectionReportType, typeof(ReportType), null, CultureInfo.CurrentCulture);

            if (m_tracks.Count > 1)
            {
                Track  selectedTrack = m_tracks[0];
                double min = double.MaxValue, max = double.MinValue;
                double maxAscBeauty = double.MinValue, maxDscBeauty = double.MaxValue;
                foreach (Track track in m_tracks)
                {
                    SeriesGroup variableData = track.GetDataSeries(inGroupSelectionVariable, orderByReportType);
                    if (variableData != null)
                    {
                        double sortValue = variableData.MainSeries.Stats.avg;
                        if (inGroupSelectionFunction == LogQueryViewModel.FunctionMax && sortValue > max)
                        {
                            max           = sortValue;
                            selectedTrack = track;
                        }
                        else if (inGroupSelectionFunction == LogQueryViewModel.FunctionMin && sortValue < min)
                        {
                            min           = sortValue;
                            selectedTrack = track;
                        }
                        else if (inGroupSelectionFunction == LogQueryViewModel.FunctionAscBeauty &&
                                 variableData.MainSeries.Stats.ascBeauty > maxAscBeauty)
                        {
                            maxAscBeauty  = variableData.MainSeries.Stats.ascBeauty;
                            selectedTrack = track;
                        }
                        else if (inGroupSelectionFunction == LogQueryViewModel.FunctionDscBeauty &&
                                 variableData.MainSeries.Stats.dscBeauty > maxDscBeauty)
                        {
                            maxDscBeauty  = variableData.MainSeries.Stats.dscBeauty;
                            selectedTrack = track;
                        }
                    }
                }
                m_tracks.Clear();
                if (selectedTrack != null)
                {
                    m_tracks.Add(selectedTrack);
                }
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 public void AddVariableData(Report variable, SeriesGroup variableData)
 {
     SeriesGroups.Add(variable, variableData);
 }