using HeuristicLab.Common; using HeuristicLab.Core; using System; using System.Collections.Generic; using System.Linq; using HeuristicLab.Collections; using HEAL.Attic; namespace HeuristicLab.Problems.DataAnalysis.Implementation { [Item("NamedIntervals", "Represents variables with their interval ranges.")] [StorableType("230B4E4B-41E5-4D33-9BC3-E2DAADDCA5AE")] public class NamedIntervals : Item { public ObservableDictionary VariableIntervals { get; } = new ObservableDictionary(); [Storable(Name = "StorableIntervalInformation")] private KeyValuePair[] StorableIntervalInformation { get { var l = new List>(); foreach (var varInt in VariableIntervals) l.Add(new KeyValuePair(varInt.Key, new double[] { varInt.Value.LowerBound, varInt.Value.UpperBound })); return l.ToArray(); } set { foreach (var varInt in value) VariableIntervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1])); } } public NamedIntervals() : base() { } [StorableConstructor] protected NamedIntervals(StorableConstructorFlag _) : base(_) { } protected NamedIntervals(NamedIntervals original, Cloner cloner) : base(original, cloner) { foreach (var keyValuePair in original.VariableIntervals) { VariableIntervals.Add(keyValuePair.Key, new Interval(keyValuePair.Value.LowerBound, keyValuePair.Value.UpperBound)); } } public override IDeepCloneable Clone(Cloner cloner) { return new NamedIntervals(this, cloner); } public bool ReadOnly { get; } } }