Changeset 16548


Ignore:
Timestamp:
01/23/19 12:45:26 (2 years ago)
Author:
chaider
Message:

#2971

  • Removed Storable from Intervals
  • Changed copy constructor from NamedIntervals class
Location:
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval.cs

    r16547 r16548  
    2828
    2929namespace HeuristicLab.Problems.DataAnalysis {
    30   [StorableClass]
    31   public class Interval :Item, IEquatable<Interval> {
    32     [Storable]
     30  public class Interval : IEquatable<Interval> {
    3331    public double LowerBound { get; private set; }
    34     [Storable]
    3532    public double UpperBound { get; private set; }
    3633
    37     [StorableConstructor]
    38     protected Interval(bool deserializing) : base(deserializing) { }
    39     protected Interval(Interval original, Cloner cloner)
    40       : base(original, cloner) {
    41     }
     34
    4235    public Interval(double lowerBound, double upperBound) {
    4336      if (lowerBound > upperBound)
     
    5043    public bool Contains(double value) {
    5144      return LowerBound <= value && value <= UpperBound;
    52     }
    53 
    54     public override IDeepCloneable Clone(Cloner cloner) {
    55       return new Interval(this, cloner);
    5645    }
    5746
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/NamedIntervals.cs

    r16545 r16548  
    1313  [Item("NamedIntervals", "Represents variables with their interval ranges.")]
    1414  [StorableClass]
    15   public class NamedIntervals : Item {
     15  public class NamedIntervals : Item {   
    1616    ObservableDictionary<string, Interval> variableIntervals = new ObservableDictionary<string, Interval>();
     17    public ObservableDictionary<string, Interval> VariableIntervals {
     18      get { return variableIntervals; }
     19    }
     20
     21    [Storable(Name = "StorableIntervalInformation")]
     22    private IEnumerable<Tuple<string, double, double>> StorableIntervalInformation {
     23      get {
     24        foreach (var varInt in variableIntervals)
     25          yield return Tuple.Create(varInt.Key, varInt.Value.LowerBound, varInt.Value.UpperBound);
     26      }
     27
     28      set {
     29        foreach (var varInt in value)
     30          variableIntervals.Add(varInt.Item1,new Interval(varInt.Item2,varInt.Item3));
     31      }
     32    }
    1733
    1834    public NamedIntervals() : base(){}
    1935    protected NamedIntervals(bool deserializing) : base(deserializing) { }
    20     protected NamedIntervals(NamedIntervals original, Cloner cloner) : base(original, cloner) { }
     36
     37    protected NamedIntervals(NamedIntervals original, Cloner cloner) : base(original, cloner) {
     38      foreach (var keyValuePair in original.VariableIntervals) {
     39        variableIntervals.Add(keyValuePair.Key, keyValuePair.Value);
     40      }
     41    }
    2142
    2243    public override IDeepCloneable Clone(Cloner cloner) {
    2344      return new NamedIntervals(this, cloner);
    2445    }
    25 
    26     public ObservableDictionary<string, Interval> VariableIntervals => variableIntervals;
    2746
    2847    public bool ReadOnly { get; }
Note: See TracChangeset for help on using the changeset viewer.