Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/NamedIntervals.cs @ 16426

Last change on this file since 16426 was 16426, checked in by chaider, 5 years ago

#2971

  • Added NamedIntervals class
  • Set NamedIntervals Parameter in RegressionProblemData
File size: 1.5 KB
Line 
1using HeuristicLab.Collections;
2using HeuristicLab.Common;
3using HeuristicLab.Core;
4using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
5using System;
6using System.Collections.Generic;
7using System.Drawing;
8using System.Linq;
9using System.Text;
10using System.Threading.Tasks;
11
12namespace HeuristicLab.Problems.DataAnalysis.Implementation {
13  [Item("NamedIntervals", "Represents variables with their interval ranges.")]
14  [StorableClass]
15  public class NamedIntervals : Item {
16    ObservableDictionary<string, Interval> variableIntervals = new ObservableDictionary<string, Interval>();
17
18    public NamedIntervals() : base(){}
19    protected NamedIntervals(bool deserializing) : base(deserializing) { }
20    protected NamedIntervals(NamedIntervals original, Cloner cloner) : base(original, cloner) { }
21
22    public override IDeepCloneable Clone(Cloner cloner) {
23      return new NamedIntervals(this, cloner);
24    }
25
26    public bool InsertMany(IEnumerable<KeyValuePair<string, Interval>> entries) {
27      if (entries == null) throw new ArgumentNullException("The given dataset is null.");
28      if (entries.Count() != 0) {
29        foreach (var entry in entries) {
30          if (variableIntervals.ContainsKey(entry.Key))
31            variableIntervals[entry.Key] = entry.Value;
32          else
33            variableIntervals.Add(entry.Key, entry.Value);
34        }
35      }
36      return true;
37    }
38
39    public bool Add(string key, Interval value) {
40      variableIntervals[key] = value;
41      return true;
42    }
43   
44  }
45}
46
Note: See TracBrowser for help on using the repository browser.