Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/29/10 17:53:12 (14 years ago)
Author:
abeham
Message:

Added a permutation type property specifying whether it's a relative (directed or undirected) or absolute permutation #889

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs

    r3160 r3231  
    2525
    2626namespace HeuristicLab.Encodings.PermutationEncoding {
     27  [Item("Permutation", "Represents a permutation of integer values.")]
    2728  [StorableClass]
    28   [Item("Permutation", "Represents a permutation of integer values.")]
    2929  public class Permutation : IntArray {
    30     public Permutation() : base() { }
    31     public Permutation(int length)
     30    [Storable]
     31    private PermutationTypes permutationType;
     32    /// <summary>
     33    /// Gets the type of the permutation (see <see cref="PermutationType"/>).
     34    /// </summary>
     35    public PermutationTypes PermutationType {
     36      get { return permutationType; }
     37    }
     38
     39    public Permutation() : base() {
     40      permutationType = PermutationTypes.RelativeUndirected;
     41    }
     42    public Permutation(PermutationTypes type) : base() {
     43      permutationType = type;
     44    }
     45
     46    public Permutation(PermutationTypes type, int length)
    3247      : base(length) {
    3348      for (int i = 0; i < length; i++)
    3449        this[i] = i;
     50      permutationType = type;
    3551    }
    36     public Permutation(int length, IRandom random)
    37       : this(length) {
     52    public Permutation(PermutationTypes type, int length, IRandom random)
     53      : this(type, length) {
    3854      Randomize(random);
    3955    }
    40     public Permutation(int[] elements) : base(elements) { }
    41     public Permutation(IntArray elements)
    42       : this(elements.Length) {
     56    public Permutation(PermutationTypes type, int[] elements) : base(elements) {
     57      permutationType = type;
     58    }
     59    public Permutation(PermutationTypes type, IntArray elements) : this(type, elements.Length) {
    4360      for (int i = 0; i < array.Length; i++)
    4461        array[i] = elements[i];
     
    4663
    4764    public override IDeepCloneable Clone(Cloner cloner) {
    48       Permutation clone = new Permutation(array);
     65      Permutation clone = new Permutation(permutationType, array);
    4966      cloner.RegisterClonedObject(this, clone);
    5067      return clone;
Note: See TracChangeset for help on using the changeset viewer.