Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 16824 was 16800, checked in by chaider, 6 years ago

#2971 Several chanages regarding review comments

File size: 1.7 KB
RevLine 
[16644]1using HeuristicLab.Common;
[16426]2using HeuristicLab.Core;
3using System;
4using System.Collections.Generic;
5using System.Linq;
[16800]6using HeuristicLab.Collections;
[16628]7using HEAL.Attic;
[16426]8
9namespace HeuristicLab.Problems.DataAnalysis.Implementation {
10  [Item("NamedIntervals", "Represents variables with their interval ranges.")]
[16628]11  [StorableType("230B4E4B-41E5-4D33-9BC3-E2DAADDCA5AE")]
[16590]12  public class NamedIntervals : Item {
[16800]13    public ObservableDictionary<string, Interval> VariableIntervals { get; } = new ObservableDictionary<string, Interval>();
[16426]14
[16548]15    [Storable(Name = "StorableIntervalInformation")]
[16590]16    private KeyValuePair<string, double[]>[] StorableIntervalInformation {
[16548]17      get {
[16590]18        var l = new List<KeyValuePair<string, double[]>>();
[16800]19        foreach (var varInt in VariableIntervals)
[16590]20
21          l.Add(new KeyValuePair<string, double[]>(varInt.Key,
22            new double[] { varInt.Value.LowerBound, varInt.Value.UpperBound }));
23        return l.ToArray();
[16548]24      }
25
26      set {
27        foreach (var varInt in value)
[16800]28          VariableIntervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1]));
[16548]29      }
30    }
31
[16590]32    public NamedIntervals() : base() { }
[16628]33    [StorableConstructor]
34    protected NamedIntervals(StorableConstructorFlag _) : base(_) { }
[16426]35
[16548]36    protected NamedIntervals(NamedIntervals original, Cloner cloner) : base(original, cloner) {
37      foreach (var keyValuePair in original.VariableIntervals) {
[16800]38        VariableIntervals.Add(keyValuePair.Key, new Interval(keyValuePair.Value.LowerBound, keyValuePair.Value.UpperBound));
[16548]39      }
40    }
41
[16426]42    public override IDeepCloneable Clone(Cloner cloner) {
43      return new NamedIntervals(this, cloner);
44    }
45
[16545]46    public bool ReadOnly { get; }
47
[16426]48  }
49}
50
Note: See TracBrowser for help on using the repository browser.