Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17564


Ignore:
Timestamp:
05/27/20 15:45:50 (4 years ago)
Author:
mkommend
Message:

#2971: Minor changes in interval collection and interval interpreter.

Location:
branches/2971_named_intervals
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs

    r17555 r17564  
    200200      var problemData = solution.ProblemData;
    201201      var model = solution.Model;
    202       var variableRanges = problemData.VariableRanges.GetIntervals();
     202      var variableRanges = problemData.VariableRanges.GetReadonlyDictionary();
    203203
    204204      intervalEvaluation.AddInterval($"Target {problemData.TargetVariable}", new Interval(variableRanges[problemData.TargetVariable].LowerBound, variableRanges[problemData.TargetVariable].UpperBound));
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r17538 r17564  
    215215          if (regressionProblemData != null) {
    216216            var interpreter = new IntervalInterpreter();
    217             var variableRanges = regressionProblemData.VariableRanges.GetIntervals();
     217            var variableRanges = regressionProblemData.VariableRanges.GetReadonlyDictionary();
    218218            IDictionary<ISymbolicExpressionTreeNode, Interval> intervals;
    219219            interpreter.GetSymbolicExpressionTreeIntervals(tree, variableRanges, out intervals);
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalInterpreter.cs

    r17562 r17564  
    8080    }
    8181
    82     public Interval GetSymbolicExpressionTreeInterval(ISymbolicExpressionTree tree, IDictionary<string, Interval> variableRanges) {
     82    public Interval GetSymbolicExpressionTreeInterval(ISymbolicExpressionTree tree, IReadOnlyDictionary<string, Interval> variableRanges) {
    8383      lock (syncRoot) {
    8484        EvaluatedSolutions++;
     
    9797
    9898    public Interval GetSymbolicExpressionTreeIntervals(ISymbolicExpressionTree tree,
    99       IDictionary<string, Interval> variableRanges, out IDictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals) {
     99      IReadOnlyDictionary<string, Interval> variableRanges, out IDictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals) {
    100100      lock (syncRoot) {
    101101        EvaluatedSolutions++;
     
    124124
    125125
    126     private static Instruction[] PrepareInterpreterState(ISymbolicExpressionTree tree, IDictionary<string, Interval> variableRanges) {
     126    private static Instruction[] PrepareInterpreterState(ISymbolicExpressionTree tree, IReadOnlyDictionary<string, Interval> variableRanges) {
    127127      if (variableRanges == null)
    128128        throw new ArgumentNullException("No variablew ranges are present!", nameof(variableRanges));
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalCollectionView.cs

    r17145 r17564  
    2121
    2222
    23 using System.Linq;
    2423using System.Windows.Forms;
    2524using HeuristicLab.MainForm;
     
    6968
    7069
    71       var variablesCount = Content.GetIntervals().Count;
     70      var variablesCount = Content.Count;
    7271
    7372      DataGridViewRow[] rows = new DataGridViewRow[variablesCount];
     
    7877      dataGridView.Rows.AddRange(rows);
    7978
    80       SetRowsHeader();
    81       FillRows();
     79      int j = 0;
     80      foreach (var variableInterval in Content.GetVariableIntervals()) {
     81        dataGridView.Rows[j].HeaderCell.Value = variableInterval.Item1;
     82        dataGridView.Rows[j].Cells[0].Value = variableInterval.Item2.LowerBound;
     83        dataGridView.Rows[j].Cells[1].Value = variableInterval.Item2.UpperBound;
     84        j++;
     85      }
    8286
    8387      dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
     
    8791      foreach (DataGridViewColumn column in dataGridView.Columns) {
    8892        column.SortMode = DataGridViewColumnSortMode.NotSortable;
    89       }
    90     }
    91 
    92     private void FillRows() {
    93       for (var i = 0; i < dataGridView.RowCount; ++i) {
    94         var key = (string)dataGridView.Rows[i].HeaderCell.Value;
    95         dataGridView.Rows[i].Cells[0].Value = Content.GetInterval(key).LowerBound;
    96         dataGridView.Rows[i].Cells[1].Value = Content.GetInterval(key).UpperBound;
    97       }
    98     }
    99 
    100     private void SetRowsHeader() {
    101       for (var i = 0; i < Content.GetIntervals().Count; ++i) {
    102         var item = Content.GetIntervals().ElementAt(i);
    103         dataGridView.Rows[i].HeaderCell.Value = item.Key;
    10493      }
    10594    }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalCollection.cs

    r17506 r17564  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using HEAL.Attic;
    2526using HeuristicLab.Common;
     
    5152      }
    5253    }
     54
     55    public int Count => intervals.Count;
    5356
    5457    public IntervalCollection() : base() { }
     
    8790    }
    8891
    89     public IDictionary<string, Interval> GetIntervals() {
    90       return intervals;
     92    public IReadOnlyDictionary<string, Interval> GetReadonlyDictionary() {
     93      return intervals.ToDictionary(pair => pair.Key, pair => pair.Value);
     94    }
     95
     96    public IEnumerable<Tuple<string, Interval>> GetVariableIntervals() {
     97      foreach (var variableInterval in intervals)
     98        yield return Tuple.Create(variableInterval.Key, variableInterval.Value);
    9199    }
    92100  }
Note: See TracChangeset for help on using the changeset viewer.