Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/17/12 15:05:11 (12 years ago)
Author:
abeham
Message:

#1775: reintegrated branch

Location:
trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding

  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorCreator.cs

    r7259 r8019  
    4747      get { return (IValueLookupParameter<IntValue>)Parameters["Length"]; }
    4848    }
    49     public IValueLookupParameter<IntValue> MinimumParameter {
    50       get { return (IValueLookupParameter<IntValue>)Parameters["Minimum"]; }
    51     }
    52     public IValueLookupParameter<IntValue> MaximumParameter {
    53       get { return (IValueLookupParameter<IntValue>)Parameters["Maximum"]; }
     49    public IValueLookupParameter<IntMatrix> BoundsParameter {
     50      get { return (IValueLookupParameter<IntMatrix>)Parameters["Bounds"]; }
    5451    }
    5552
     
    6259      Parameters.Add(new LookupParameter<IntegerVector>("IntegerVector", "The vector which should be manipulated."));
    6360      Parameters.Add(new ValueLookupParameter<IntValue>("Length", "The length of the vector."));
    64       Parameters.Add(new ValueLookupParameter<IntValue>("Minimum", "The inclusive lower bound for each element in the vector."));
    65       Parameters.Add(new ValueLookupParameter<IntValue>("Maximum", "The exclusive upper bound for each element in the vector."));
     61      Parameters.Add(new ValueLookupParameter<IntMatrix>("Bounds", "The bounds matrix can contain one row for each dimension with three columns specifying minimum (inclusive), maximum (exclusive), and step size. If less rows are given the matrix is cycled."));
    6662    }
    6763
     64    // BackwardsCompatibility3.3
     65    #region Backwards compatible code, remove with 3.4
     66    [StorableHook(HookType.AfterDeserialization)]
     67    private void AfterDeserialization() {
     68      if (!Parameters.ContainsKey("Bounds")) {
     69        var min = ((IValueLookupParameter<IntValue>)Parameters["Minimum"]).Value as IntValue;
     70        var max = ((IValueLookupParameter<IntValue>)Parameters["Maximum"]).Value as IntValue;
     71        Parameters.Remove("Minimum");
     72        Parameters.Remove("Maximum");
     73        Parameters.Add(new ValueLookupParameter<IntMatrix>("Bounds", "The bounds matrix can contain one row for each dimension with three columns specifying minimum (inclusive), maximum (exclusive), and step size. If less rows are given the matrix is cycled."));
     74        if (min != null && max != null) {
     75          BoundsParameter.Value = new IntMatrix(new int[,] { { min.Value, max.Value, 1 } });
     76        }
     77      }
     78    }
     79    #endregion
     80
    6881    public sealed override IOperation Apply() {
    69       IntegerVectorParameter.ActualValue = Create(RandomParameter.ActualValue, LengthParameter.ActualValue, MinimumParameter.ActualValue, MaximumParameter.ActualValue);
     82      IntegerVectorParameter.ActualValue = Create(RandomParameter.ActualValue, LengthParameter.ActualValue, BoundsParameter.ActualValue);
    7083      return base.Apply();
    7184    }
    7285
    73     protected abstract IntegerVector Create(IRandom random, IntValue length, IntValue minimum, IntValue maximum);
     86    protected abstract IntegerVector Create(IRandom random, IntValue length, IntMatrix bounds);
    7487  }
    7588}
Note: See TracChangeset for help on using the changeset viewer.