[16830] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2019 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 | using System.Collections.Generic;
|
---|
| 22 | using HeuristicLab.Common;
|
---|
[16426] | 23 | using HeuristicLab.Core;
|
---|
[16800] | 24 | using HeuristicLab.Collections;
|
---|
[16628] | 25 | using HEAL.Attic;
|
---|
[16426] | 26 |
|
---|
[16830] | 27 | namespace HeuristicLab.Problems.DataAnalysis {
|
---|
[16426] | 28 | [Item("NamedIntervals", "Represents variables with their interval ranges.")]
|
---|
[16628] | 29 | [StorableType("230B4E4B-41E5-4D33-9BC3-E2DAADDCA5AE")]
|
---|
[16590] | 30 | public class NamedIntervals : Item {
|
---|
[16851] | 31 | public static new System.Drawing.Image StaticItemImage {
|
---|
| 32 | get => HeuristicLab.Common.Resources.VSImageLibrary.Object;
|
---|
| 33 | }
|
---|
[16800] | 34 | public ObservableDictionary<string, Interval> VariableIntervals { get; } = new ObservableDictionary<string, Interval>();
|
---|
[16426] | 35 |
|
---|
[16548] | 36 | [Storable(Name = "StorableIntervalInformation")]
|
---|
[16590] | 37 | private KeyValuePair<string, double[]>[] StorableIntervalInformation {
|
---|
[16548] | 38 | get {
|
---|
[16590] | 39 | var l = new List<KeyValuePair<string, double[]>>();
|
---|
[16800] | 40 | foreach (var varInt in VariableIntervals)
|
---|
[16590] | 41 |
|
---|
| 42 | l.Add(new KeyValuePair<string, double[]>(varInt.Key,
|
---|
| 43 | new double[] { varInt.Value.LowerBound, varInt.Value.UpperBound }));
|
---|
| 44 | return l.ToArray();
|
---|
[16548] | 45 | }
|
---|
| 46 |
|
---|
| 47 | set {
|
---|
| 48 | foreach (var varInt in value)
|
---|
[16800] | 49 | VariableIntervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1]));
|
---|
[16548] | 50 | }
|
---|
| 51 | }
|
---|
| 52 |
|
---|
[16590] | 53 | public NamedIntervals() : base() { }
|
---|
[16628] | 54 | [StorableConstructor]
|
---|
| 55 | protected NamedIntervals(StorableConstructorFlag _) : base(_) { }
|
---|
[16426] | 56 |
|
---|
[16548] | 57 | protected NamedIntervals(NamedIntervals original, Cloner cloner) : base(original, cloner) {
|
---|
| 58 | foreach (var keyValuePair in original.VariableIntervals) {
|
---|
[16800] | 59 | VariableIntervals.Add(keyValuePair.Key, new Interval(keyValuePair.Value.LowerBound, keyValuePair.Value.UpperBound));
|
---|
[16548] | 60 | }
|
---|
| 61 | }
|
---|
| 62 |
|
---|
[16426] | 63 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 64 | return new NamedIntervals(this, cloner);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
[16545] | 67 | public bool ReadOnly { get; }
|
---|
| 68 |
|
---|
[16426] | 69 | }
|
---|
| 70 | }
|
---|
| 71 |
|
---|