Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/27/14 14:14:42 (11 years ago)
Author:
bburlacu
Message:

#1837: Added missing license information headers. Added storable constructors and changed properties in SlidingWindowBestSolutionsCollection to return IEnumerables instead of Lists.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SlidingWindowBestSolutionsCollectionView.cs

    r10396 r10402  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Collections.Generic;
    324using System.Linq;
     
    4364      var dataGridView = (DataGridView)sender;
    4465      var cell = dataGridView.SelectedCells[0];
    45       var tree = Content.BestSolutions[cell.RowIndex];
     66      var bestSolutions = Content.BestSolutions.ToList();
     67      var tree = bestSolutions[cell.RowIndex];
    4668      var model = Content.CreateModel(tree, Content.Interpreter);
    4769      var solution = Content.CreateSolution(model, Content.ProblemData);
     
    93115
    94116    private void UpdateQualitiesMap() {
    95       var qualitiesMap = new DoubleMatrix(Content.BestSolutions.Count, Content.SlidingWindowPositions.Count + 1);
     117      var bestSolutions = Content.BestSolutions.ToList();
     118      var swPositions = Content.SlidingWindowPositions.ToList();
     119      var qualitiesMap = new DoubleMatrix(bestSolutions.Count, swPositions.Count + 1);
    96120      qualitiesMap.ColumnNames = Content.SlidingWindowPositions.Select(x => x.Start + "-" + x.End).Concat(new List<string> { "Training" });
    97       qualitiesMap.RowNames = Enumerable.Range(1, Content.BestSolutions.Count).Select(x => "M" + x);
     121      qualitiesMap.RowNames = Enumerable.Range(1, bestSolutions.Count).Select(x => "M" + x);
    98122      double min = 0, max = 0;
    99123
    100124      for (int i = 0; i < qualitiesMap.Columns - 1; ++i) {
    101         var pos = Content.SlidingWindowPositions[i];
     125        var pos = swPositions[i];
    102126        var rows = Enumerable.Range(pos.Start, pos.End - pos.Start).ToList();
    103127
    104128        for (int j = 0; j < qualitiesMap.Rows; ++j) {
    105           var tree = Content.BestSolutions[j];
     129          var tree = bestSolutions[j];
    106130          var q = CalculateQuality(tree, rows);
    107131          if (min > q) min = q;
     
    112136      // deal separately with the last column which represents the whole training partition interval
    113137      for (int j = 0; j < qualitiesMap.Rows; ++j) {
    114         var tree = Content.BestSolutions[j];
     138        var tree = bestSolutions[j];
    115139        var q = CalculateQuality(tree, Content.ProblemData.TrainingIndices);
    116140        if (min > q) min = q;
Note: See TracChangeset for help on using the changeset viewer.