[16644] | 1 | using HeuristicLab.Common;
|
---|
[16426] | 2 | using HeuristicLab.Core;
|
---|
| 3 | using System;
|
---|
| 4 | using System.Collections.Generic;
|
---|
| 5 | using System.Linq;
|
---|
[16800] | 6 | using HeuristicLab.Collections;
|
---|
[16628] | 7 | using HEAL.Attic;
|
---|
[16426] | 8 |
|
---|
| 9 | namespace 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 |
|
---|