Changeset 3054
- Timestamp:
- 03/16/10 04:24:01 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 added
- 7 deleted
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.SGA/3.3/Tests/HeuristicLab.Algorithms.SGA-3.3.Tests.csproj
r3053 r3054 78 78 </ItemGroup> 79 79 <ItemGroup> 80 <ProjectReference Include="..\..\..\HeuristicLab.Algorithms.TS\3.3\HeuristicLab.Algorithms.TS-3.3.csproj"> 81 <Project>{D58A232D-04BA-4186-B73E-0EC86FD31ABE}</Project> 82 <Name>HeuristicLab.Algorithms.TS-3.3</Name> 83 </ProjectReference> 80 84 <ProjectReference Include="..\..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj"> 81 85 <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project> -
trunk/sources/HeuristicLab.Data/3.3/BoolArray.cs
r3048 r3054 28 28 [Creatable("Test")] 29 29 [StorableClass] 30 public sealedclass BoolArray : ValueTypeArray<bool>, IStringConvertibleArray {30 public class BoolArray : ValueTypeArray<bool>, IStringConvertibleArray { 31 31 public BoolArray() : base() { } 32 32 public BoolArray(int length) : base(length) { } 33 33 public BoolArray(bool[] elements) : base(elements) { } 34 private BoolArray(BoolArray elements) : base(elements) { }35 34 36 35 public override IDeepCloneable Clone(Cloner cloner) { 37 BoolArray clone = new BoolArray( this);36 BoolArray clone = new BoolArray(array); 38 37 cloner.RegisterClonedObject(this, clone); 39 38 return clone; 40 39 } 41 40 42 #region IStringConvertibleArray Members 43 int IStringConvertibleArray.Length { 44 get { return Length; } 45 set { Length = value; } 46 } 47 48 bool IStringConvertibleArray.Validate(string value, out string errorMessage) { 41 protected virtual bool Validate(string value, out string errorMessage) { 49 42 bool val; 50 43 bool valid = bool.TryParse(value, out val); … … 59 52 return valid; 60 53 } 61 string IStringConvertibleArray.GetValue(int index) {54 protected virtual string GetValue(int index) { 62 55 return this[index].ToString(); 63 56 } 64 bool IStringConvertibleArray.SetValue(string value, int index) {57 protected virtual bool SetValue(string value, int index) { 65 58 bool val; 66 59 if (bool.TryParse(value, out val)) { … … 71 64 } 72 65 } 66 67 #region IStringConvertibleArray Members 68 int IStringConvertibleArray.Length { 69 get { return Length; } 70 set { Length = value; } 71 } 72 bool IStringConvertibleArray.Validate(string value, out string errorMessage) { 73 return Validate(value, out errorMessage); 74 } 75 string IStringConvertibleArray.GetValue(int index) { 76 return GetValue(index); 77 } 78 bool IStringConvertibleArray.SetValue(string value, int index) { 79 return SetValue(value, index); 80 } 73 81 #endregion 74 82 } -
trunk/sources/HeuristicLab.Data/3.3/BoolMatrix.cs
r3048 r3054 28 28 [Creatable("Test")] 29 29 [StorableClass] 30 public sealedclass BoolMatrix : ValueTypeMatrix<bool>, IStringConvertibleMatrix {30 public class BoolMatrix : ValueTypeMatrix<bool>, IStringConvertibleMatrix { 31 31 public BoolMatrix() : base() { } 32 32 public BoolMatrix(int rows, int columns) : base(rows, columns) { } 33 33 public BoolMatrix(bool[,] elements) : base(elements) { } 34 private BoolMatrix(BoolMatrix elements) : base(elements) { }35 34 36 35 public override IDeepCloneable Clone(Cloner cloner) { 37 BoolMatrix clone = new BoolMatrix( this);36 BoolMatrix clone = new BoolMatrix(matrix); 38 37 cloner.RegisterClonedObject(this, clone); 39 38 return clone; 40 39 } 41 40 42 #region IStringConvertibleMatrix Members 43 int IStringConvertibleMatrix.Rows { 44 get { return Rows; } 45 set { Rows = value; } 46 } 47 int IStringConvertibleMatrix.Columns { 48 get { return Columns; } 49 set { Columns = value; } 50 } 51 52 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 41 protected virtual bool Validate(string value, out string errorMessage) { 53 42 bool val; 54 43 bool valid = bool.TryParse(value, out val); … … 63 52 return valid; 64 53 } 65 string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {54 protected virtual string GetValue(int rowIndex, int columIndex) { 66 55 return this[rowIndex, columIndex].ToString(); 67 56 } 68 bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {57 protected virtual bool SetValue(string value, int rowIndex, int columnIndex) { 69 58 bool val; 70 59 if (bool.TryParse(value, out val)) { … … 75 64 } 76 65 } 66 67 #region IStringConvertibleMatrix Members 68 int IStringConvertibleMatrix.Rows { 69 get { return Rows; } 70 set { Rows = value; } 71 } 72 int IStringConvertibleMatrix.Columns { 73 get { return Columns; } 74 set { Columns = value; } 75 } 76 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 77 return Validate(value, out errorMessage); 78 } 79 string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) { 80 return GetValue(rowIndex, columIndex); 81 } 82 bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) { 83 return SetValue(value, rowIndex, columnIndex); 84 } 77 85 #endregion 78 86 } -
trunk/sources/HeuristicLab.Data/3.3/BoolValue.cs
r3048 r3054 29 29 [Creatable("Test")] 30 30 [StorableClass] 31 public sealedclass BoolValue : ValueTypeValue<bool>, IComparable, IStringConvertibleValue {31 public class BoolValue : ValueTypeValue<bool>, IComparable, IStringConvertibleValue { 32 32 public BoolValue() : base() { } 33 33 public BoolValue(bool value) : base(value) { } 34 34 35 35 public override IDeepCloneable Clone(Cloner cloner) { 36 BoolValue clone = new BoolValue( Value);36 BoolValue clone = new BoolValue(value); 37 37 cloner.RegisterClonedObject(this, clone); 38 38 return clone; 39 39 } 40 40 41 public int CompareTo(object obj) {41 public virtual int CompareTo(object obj) { 42 42 BoolValue other = obj as BoolValue; 43 43 if (other != null) … … 47 47 } 48 48 49 #region IStringConvertibleValue Members 50 bool IStringConvertibleValue.Validate(string value, out string errorMessage) { 49 protected virtual bool Validate(string value, out string errorMessage) { 51 50 bool val; 52 51 bool valid = bool.TryParse(value, out val); … … 61 60 return valid; 62 61 } 63 string IStringConvertibleValue.GetValue() {62 protected virtual string GetValue() { 64 63 return Value.ToString(); 65 64 } 66 bool IStringConvertibleValue.SetValue(string value) {65 protected virtual bool SetValue(string value) { 67 66 bool val; 68 67 if (bool.TryParse(value, out val)) { … … 73 72 } 74 73 } 74 75 #region IStringConvertibleValue Members 76 bool IStringConvertibleValue.Validate(string value, out string errorMessage) { 77 return Validate(value, out errorMessage); 78 } 79 string IStringConvertibleValue.GetValue() { 80 return GetValue(); 81 } 82 bool IStringConvertibleValue.SetValue(string value) { 83 return SetValue(value); 84 } 75 85 #endregion 76 86 } -
trunk/sources/HeuristicLab.Data/3.3/Comparison.cs
r3048 r3054 28 28 [Creatable("Test")] 29 29 [StorableClass] 30 public sealedclass Comparison : ValueTypeValue<ComparisonType>, IComparable {30 public class Comparison : ValueTypeValue<ComparisonType>, IComparable { 31 31 public Comparison() : base() { } 32 32 public Comparison(ComparisonType value) : base(value) { } 33 33 34 34 public override IDeepCloneable Clone(Cloner cloner) { 35 Comparison clone = new Comparison( Value);35 Comparison clone = new Comparison(value); 36 36 cloner.RegisterClonedObject(this, clone); 37 37 return clone; 38 38 } 39 39 40 public int CompareTo(object obj) {40 public virtual int CompareTo(object obj) { 41 41 Comparison other = obj as Comparison; 42 42 if (other != null) -
trunk/sources/HeuristicLab.Data/3.3/DateTimeValue.cs
r3048 r3054 28 28 [Creatable("Test")] 29 29 [StorableClass] 30 public sealedclass DateTimeValue : ValueTypeValue<DateTime>, IComparable, IStringConvertibleValue {30 public class DateTimeValue : ValueTypeValue<DateTime>, IComparable, IStringConvertibleValue { 31 31 public DateTimeValue() : base() { } 32 32 public DateTimeValue(DateTime value) : base(value) { } 33 33 34 34 public override IDeepCloneable Clone(Cloner cloner) { 35 DateTimeValue clone = new DateTimeValue( Value);35 DateTimeValue clone = new DateTimeValue(value); 36 36 cloner.RegisterClonedObject(this, clone); 37 37 return clone; … … 42 42 } 43 43 44 public int CompareTo(object obj) {44 public virtual int CompareTo(object obj) { 45 45 DateTimeValue other = obj as DateTimeValue; 46 46 if (other != null) … … 50 50 } 51 51 52 #region IStringConvertibleValue Members 53 bool IStringConvertibleValue.Validate(string value, out string errorMessage) { 52 protected virtual bool Validate(string value, out string errorMessage) { 54 53 DateTime val; 55 54 bool valid = DateTime.TryParse(value, out val); … … 57 56 return valid; 58 57 } 59 string IStringConvertibleValue.GetValue() {58 protected virtual string GetValue() { 60 59 return Value.ToString("o"); // round-trip format 61 60 } 62 bool IStringConvertibleValue.SetValue(string value) {61 protected virtual bool SetValue(string value) { 63 62 DateTime val; 64 63 if (DateTime.TryParse(value, out val)) { … … 69 68 } 70 69 } 70 71 #region IStringConvertibleValue Members 72 bool IStringConvertibleValue.Validate(string value, out string errorMessage) { 73 return Validate(value, out errorMessage); 74 } 75 string IStringConvertibleValue.GetValue() { 76 return GetValue(); 77 } 78 bool IStringConvertibleValue.SetValue(string value) { 79 return SetValue(value); 80 } 71 81 #endregion 72 82 } -
trunk/sources/HeuristicLab.Data/3.3/DoubleArray.cs
r3048 r3054 28 28 [Creatable("Test")] 29 29 [StorableClass] 30 public sealedclass DoubleArray : ValueTypeArray<double>, IStringConvertibleArray {30 public class DoubleArray : ValueTypeArray<double>, IStringConvertibleArray { 31 31 public DoubleArray() : base() { } 32 32 public DoubleArray(int length) : base(length) { } 33 33 public DoubleArray(double[] elements) : base(elements) { } 34 private DoubleArray(DoubleArray elements) : base(elements) { }35 34 36 35 public override IDeepCloneable Clone(Cloner cloner) { 37 DoubleArray clone = new DoubleArray( this);36 DoubleArray clone = new DoubleArray(array); 38 37 cloner.RegisterClonedObject(this, clone); 39 38 return clone; 40 39 } 41 40 42 #region IStringConvertibleArray Members 43 int IStringConvertibleArray.Length { 44 get { return Length; } 45 set { Length = value; } 46 } 47 48 bool IStringConvertibleArray.Validate(string value, out string errorMessage) { 41 protected virtual bool Validate(string value, out string errorMessage) { 49 42 double val; 50 43 bool valid = double.TryParse(value, out val); … … 59 52 return valid; 60 53 } 61 string IStringConvertibleArray.GetValue(int index) {54 protected virtual string GetValue(int index) { 62 55 return this[index].ToString(); 63 56 } 64 bool IStringConvertibleArray.SetValue(string value, int index) {57 protected virtual bool SetValue(string value, int index) { 65 58 double val; 66 59 if (double.TryParse(value, out val)) { … … 71 64 } 72 65 } 66 67 #region IStringConvertibleArray Members 68 int IStringConvertibleArray.Length { 69 get { return Length; } 70 set { Length = value; } 71 } 72 bool IStringConvertibleArray.Validate(string value, out string errorMessage) { 73 return Validate(value, out errorMessage); 74 } 75 string IStringConvertibleArray.GetValue(int index) { 76 return GetValue(index); 77 } 78 bool IStringConvertibleArray.SetValue(string value, int index) { 79 return SetValue(value, index); 80 } 73 81 #endregion 74 82 } -
trunk/sources/HeuristicLab.Data/3.3/DoubleMatrix.cs
r3048 r3054 28 28 [Creatable("Test")] 29 29 [StorableClass] 30 public sealedclass DoubleMatrix : ValueTypeMatrix<double>, IStringConvertibleMatrix {30 public class DoubleMatrix : ValueTypeMatrix<double>, IStringConvertibleMatrix { 31 31 public DoubleMatrix() : base() { } 32 32 public DoubleMatrix(int rows, int columns) : base(rows, columns) { } 33 33 public DoubleMatrix(double[,] elements) : base(elements) { } 34 private DoubleMatrix(DoubleMatrix elements) : base(elements) { }35 34 36 35 public override IDeepCloneable Clone(Cloner cloner) { 37 DoubleMatrix clone = new DoubleMatrix( this);36 DoubleMatrix clone = new DoubleMatrix(matrix); 38 37 cloner.RegisterClonedObject(this, clone); 39 38 return clone; 40 39 } 41 40 42 #region IStringConvertibleMatrix Members 43 int IStringConvertibleMatrix.Rows { 44 get { return Rows; } 45 set { Rows = value; } 46 } 47 int IStringConvertibleMatrix.Columns { 48 get { return Columns; } 49 set { Columns = value; } 50 } 51 52 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 41 protected virtual bool Validate(string value, out string errorMessage) { 53 42 double val; 54 43 bool valid = double.TryParse(value, out val); … … 63 52 return valid; 64 53 } 65 string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {54 protected virtual string GetValue(int rowIndex, int columIndex) { 66 55 return this[rowIndex, columIndex].ToString(); 67 56 } 68 bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {57 protected virtual bool SetValue(string value, int rowIndex, int columnIndex) { 69 58 double val; 70 59 if (double.TryParse(value, out val)) { … … 75 64 } 76 65 } 66 67 #region IStringConvertibleMatrix Members 68 int IStringConvertibleMatrix.Rows { 69 get { return Rows; } 70 set { Rows = value; } 71 } 72 int IStringConvertibleMatrix.Columns { 73 get { return Columns; } 74 set { Columns = value; } 75 } 76 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 77 return Validate(value, out errorMessage); 78 } 79 string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) { 80 return GetValue(rowIndex, columIndex); 81 } 82 bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) { 83 return SetValue(value, rowIndex, columnIndex); 84 } 77 85 #endregion 78 86 } -
trunk/sources/HeuristicLab.Data/3.3/DoubleValue.cs
r3048 r3054 29 29 [Creatable("Test")] 30 30 [StorableClass] 31 public sealedclass DoubleValue : ValueTypeValue<double>, IComparable, IStringConvertibleValue {31 public class DoubleValue : ValueTypeValue<double>, IComparable, IStringConvertibleValue { 32 32 public DoubleValue() : base() { } 33 33 public DoubleValue(double value) : base(value) { } 34 34 35 35 public override IDeepCloneable Clone(Cloner cloner) { 36 DoubleValue clone = new DoubleValue( Value);36 DoubleValue clone = new DoubleValue(value); 37 37 cloner.RegisterClonedObject(this, clone); 38 38 return clone; … … 43 43 } 44 44 45 public int CompareTo(object obj) {45 public virtual int CompareTo(object obj) { 46 46 DoubleValue other = obj as DoubleValue; 47 47 if (other != null) … … 51 51 } 52 52 53 #region IStringConvertibleValue Members 54 bool IStringConvertibleValue.Validate(string value, out string errorMessage) { 53 protected virtual bool Validate(string value, out string errorMessage) { 55 54 double val; 56 55 bool valid = double.TryParse(value, out val); … … 65 64 return valid; 66 65 } 67 string IStringConvertibleValue.GetValue() {66 protected virtual string GetValue() { 68 67 return Value.ToString("r"); // round-trip format 69 68 } 70 bool IStringConvertibleValue.SetValue(string value) {69 protected virtual bool SetValue(string value) { 71 70 double val; 72 71 if (double.TryParse(value, out val)) { … … 77 76 } 78 77 } 78 79 #region IStringConvertibleValue Members 80 bool IStringConvertibleValue.Validate(string value, out string errorMessage) { 81 return Validate(value, out errorMessage); 82 } 83 string IStringConvertibleValue.GetValue() { 84 return GetValue(); 85 } 86 bool IStringConvertibleValue.SetValue(string value) { 87 return SetValue(value); 88 } 79 89 #endregion 80 90 } -
trunk/sources/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj
r3047 r3054 95 95 </Reference> 96 96 <Reference Include="System.Data" /> 97 <Reference Include="System.Drawing" />98 <Reference Include="System.Windows.Forms" />99 97 <Reference Include="System.Xml" /> 100 98 </ItemGroup> -
trunk/sources/HeuristicLab.Data/3.3/IntArray.cs
r3048 r3054 28 28 [Creatable("Test")] 29 29 [StorableClass] 30 public sealedclass IntArray : ValueTypeArray<int>, IStringConvertibleArray {30 public class IntArray : ValueTypeArray<int>, IStringConvertibleArray { 31 31 public IntArray() : base() { } 32 32 public IntArray(int length) : base(length) { } 33 33 public IntArray(int[] elements) : base(elements) { } 34 private IntArray(IntArray elements) : base(elements) { }35 34 36 35 public override IDeepCloneable Clone(Cloner cloner) { 37 IntArray clone = new IntArray( this);36 IntArray clone = new IntArray(array); 38 37 cloner.RegisterClonedObject(this, clone); 39 38 return clone; 40 39 } 41 40 42 #region IStringConvertibleArray Members 43 int IStringConvertibleArray.Length { 44 get { return Length; } 45 set { Length = value; } 46 } 47 48 bool IStringConvertibleArray.Validate(string value, out string errorMessage) { 41 protected virtual bool Validate(string value, out string errorMessage) { 49 42 int val; 50 43 bool valid = int.TryParse(value, out val); … … 59 52 return valid; 60 53 } 61 string IStringConvertibleArray.GetValue(int index) {54 protected virtual string GetValue(int index) { 62 55 return this[index].ToString(); 63 56 } 64 bool IStringConvertibleArray.SetValue(string value, int index) {57 protected virtual bool SetValue(string value, int index) { 65 58 int val; 66 59 if (int.TryParse(value, out val)) { … … 71 64 } 72 65 } 66 67 #region IStringConvertibleArray Members 68 int IStringConvertibleArray.Length { 69 get { return Length; } 70 set { Length = value; } 71 } 72 bool IStringConvertibleArray.Validate(string value, out string errorMessage) { 73 return Validate(value, out errorMessage); 74 } 75 string IStringConvertibleArray.GetValue(int index) { 76 return GetValue(index); 77 } 78 bool IStringConvertibleArray.SetValue(string value, int index) { 79 return SetValue(value, index); 80 } 73 81 #endregion 74 82 } -
trunk/sources/HeuristicLab.Data/3.3/IntMatrix.cs
r3048 r3054 28 28 [Creatable("Test")] 29 29 [StorableClass] 30 public sealedclass IntMatrix : ValueTypeMatrix<int>, IStringConvertibleMatrix {30 public class IntMatrix : ValueTypeMatrix<int>, IStringConvertibleMatrix { 31 31 public IntMatrix() : base() { } 32 32 public IntMatrix(int rows, int columns) : base(rows, columns) { } 33 33 public IntMatrix(int[,] elements) : base(elements) { } 34 private IntMatrix(IntMatrix elements) : base(elements) { }35 34 36 35 public override IDeepCloneable Clone(Cloner cloner) { 37 IntMatrix clone = new IntMatrix( this);36 IntMatrix clone = new IntMatrix(matrix); 38 37 cloner.RegisterClonedObject(this, clone); 39 38 return clone; 40 39 } 41 40 42 #region IStringConvertibleMatrix Members 43 int IStringConvertibleMatrix.Rows { 44 get { return Rows; } 45 set { Rows = value; } 46 } 47 int IStringConvertibleMatrix.Columns { 48 get { return Columns; } 49 set { Columns = value; } 50 } 51 52 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 41 protected virtual bool Validate(string value, out string errorMessage) { 53 42 int val; 54 43 bool valid = int.TryParse(value, out val); … … 63 52 return valid; 64 53 } 65 string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {54 protected virtual string GetValue(int rowIndex, int columIndex) { 66 55 return this[rowIndex, columIndex].ToString(); 67 56 } 68 bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {57 protected virtual bool SetValue(string value, int rowIndex, int columnIndex) { 69 58 int val; 70 59 if (int.TryParse(value, out val)) { … … 75 64 } 76 65 } 66 67 #region IStringConvertibleMatrix Members 68 int IStringConvertibleMatrix.Rows { 69 get { return Rows; } 70 set { Rows = value; } 71 } 72 int IStringConvertibleMatrix.Columns { 73 get { return Columns; } 74 set { Columns = value; } 75 } 76 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 77 return Validate(value, out errorMessage); 78 } 79 string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) { 80 return GetValue(rowIndex, columIndex); 81 } 82 bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) { 83 return SetValue(value, rowIndex, columnIndex); 84 } 77 85 #endregion 78 86 } -
trunk/sources/HeuristicLab.Data/3.3/IntValue.cs
r3048 r3054 29 29 [Creatable("Test")] 30 30 [StorableClass] 31 public sealedclass IntValue : ValueTypeValue<int>, IComparable, IStringConvertibleValue {31 public class IntValue : ValueTypeValue<int>, IComparable, IStringConvertibleValue { 32 32 public IntValue() : base() { } 33 33 public IntValue(int value) : base(value) { } 34 34 35 35 public override IDeepCloneable Clone(Cloner cloner) { 36 IntValue clone = new IntValue( Value);36 IntValue clone = new IntValue(value); 37 37 cloner.RegisterClonedObject(this, clone); 38 38 return clone; 39 39 } 40 40 41 public int CompareTo(object obj) {41 public virtual int CompareTo(object obj) { 42 42 IntValue other = obj as IntValue; 43 43 if (other != null) … … 47 47 } 48 48 49 #region IStringConvertibleValue Members 50 bool IStringConvertibleValue.Validate(string value, out string errorMessage) { 49 protected virtual bool Validate(string value, out string errorMessage) { 51 50 int val; 52 51 bool valid = int.TryParse(value, out val); … … 61 60 return valid; 62 61 } 63 string IStringConvertibleValue.GetValue() {62 protected virtual string GetValue() { 64 63 return Value.ToString(); 65 64 } 66 bool IStringConvertibleValue.SetValue(string value) {65 protected virtual bool SetValue(string value) { 67 66 int val; 68 67 if (int.TryParse(value, out val)) { … … 73 72 } 74 73 } 74 75 #region IStringConvertibleValue Members 76 bool IStringConvertibleValue.Validate(string value, out string errorMessage) { 77 return Validate(value, out errorMessage); 78 } 79 string IStringConvertibleValue.GetValue() { 80 return GetValue(); 81 } 82 bool IStringConvertibleValue.SetValue(string value) { 83 return SetValue(value); 84 } 75 85 #endregion 76 86 } -
trunk/sources/HeuristicLab.Data/3.3/StringArray.cs
r3048 r3054 31 31 [Creatable("Test")] 32 32 [StorableClass] 33 public sealedclass StringArray : Item, IEnumerable, IStringConvertibleArray {33 public class StringArray : Item, IEnumerable, IStringConvertibleArray { 34 34 [Storable] 35 pr ivatestring[] array;35 protected string[] array; 36 36 37 public int Length {37 public virtual int Length { 38 38 get { return array.Length; } 39 pr ivateset {39 protected set { 40 40 if (value != Length) { 41 41 Array.Resize<string>(ref array, value); … … 44 44 } 45 45 } 46 public string this[int index] {46 public virtual string this[int index] { 47 47 get { return array[index]; } 48 48 set { … … 70 70 array[i] = elements[i] == null ? string.Empty : elements[i]; 71 71 } 72 private StringArray(StringArray elements) {73 if (elements == null) throw new ArgumentNullException();74 array = (string[])elements.array.Clone();75 }76 72 77 73 public override IDeepCloneable Clone(Cloner cloner) { 78 StringArray clone = new StringArray( this);74 StringArray clone = new StringArray(); 79 75 cloner.RegisterClonedObject(this, clone); 76 clone.array = (string[])array.Clone(); 80 77 return clone; 81 78 } … … 93 90 } 94 91 95 public IEnumerator GetEnumerator() {92 public virtual IEnumerator GetEnumerator() { 96 93 return array.GetEnumerator(); 97 94 } 98 95 99 #region IStringConvertibleArray Members 100 int IStringConvertibleArray.Length { 101 get { return Length; } 102 set { Length = value; } 103 } 104 105 bool IStringConvertibleArray.Validate(string value, out string errorMessage) { 96 protected virtual bool Validate(string value, out string errorMessage) { 106 97 if (value == null) { 107 98 errorMessage = "Invalid Value (string must not be null)"; … … 112 103 } 113 104 } 114 string IStringConvertibleArray.GetValue(int index) {105 protected virtual string GetValue(int index) { 115 106 return this[index]; 116 107 } 117 bool IStringConvertibleArray.SetValue(string value, int index) {108 protected virtual bool SetValue(string value, int index) { 118 109 if (value != null) { 119 110 this[index] = value; … … 123 114 } 124 115 } 116 125 117 public event EventHandler<EventArgs<int>> ItemChanged; 126 pr ivatevoid OnItemChanged(int index) {118 protected virtual void OnItemChanged(int index) { 127 119 if (ItemChanged != null) 128 120 ItemChanged(this, new EventArgs<int>(index)); … … 130 122 } 131 123 public event EventHandler Reset; 132 pr ivatevoid OnReset() {124 protected virtual void OnReset() { 133 125 if (Reset != null) 134 126 Reset(this, EventArgs.Empty); 135 127 OnToStringChanged(); 136 128 } 129 130 #region IStringConvertibleArray Members 131 int IStringConvertibleArray.Length { 132 get { return Length; } 133 set { Length = value; } 134 } 135 bool IStringConvertibleArray.Validate(string value, out string errorMessage) { 136 return Validate(value, out errorMessage); 137 } 138 string IStringConvertibleArray.GetValue(int index) { 139 return GetValue(index); 140 } 141 bool IStringConvertibleArray.SetValue(string value, int index) { 142 return SetValue(value, index); 143 } 137 144 #endregion 138 145 } -
trunk/sources/HeuristicLab.Data/3.3/StringMatrix.cs
r3048 r3054 31 31 [Creatable("Test")] 32 32 [StorableClass] 33 public sealedclass StringMatrix : Item, IEnumerable, IStringConvertibleMatrix {33 public class StringMatrix : Item, IEnumerable, IStringConvertibleMatrix { 34 34 [Storable] 35 pr ivate string[,] array;35 protected string[,] matrix; 36 36 37 public int Rows {38 get { return array.GetLength(0); }39 pr ivateset {37 public virtual int Rows { 38 get { return matrix.GetLength(0); } 39 protected set { 40 40 if (value != Rows) { 41 string[,] new Array= new string[value, Columns];42 Array.Copy( array, newArray, Math.Min(value * Columns, array.Length));43 array = newArray;41 string[,] newMatrix = new string[value, Columns]; 42 Array.Copy(matrix, newMatrix, Math.Min(value * Columns, matrix.Length)); 43 matrix = newMatrix; 44 44 OnReset(); 45 45 } 46 46 } 47 47 } 48 public int Columns {49 get { return array.GetLength(1); }50 pr ivateset {48 public virtual int Columns { 49 get { return matrix.GetLength(1); } 50 protected set { 51 51 if (value != Columns) { 52 string[,] new Array= new string[Rows, value];52 string[,] newMatrix = new string[Rows, value]; 53 53 for (int i = 0; i < Rows; i++) 54 Array.Copy( array, i * Columns, newArray, i * value, Math.Min(value, Columns));55 array = newArray;54 Array.Copy(matrix, i * Columns, newMatrix, i * value, Math.Min(value, Columns)); 55 matrix = newMatrix; 56 56 OnReset(); 57 57 } 58 58 } 59 59 } 60 public string this[int rowIndex, int columnIndex] {61 get { return array[rowIndex, columnIndex]; }60 public virtual string this[int rowIndex, int columnIndex] { 61 get { return matrix[rowIndex, columnIndex]; } 62 62 set { 63 if (value != array[rowIndex, columnIndex]) {64 if ((value != null) || ( array[rowIndex, columnIndex] != string.Empty)) {65 array[rowIndex, columnIndex] = value != null ? value : string.Empty;63 if (value != matrix[rowIndex, columnIndex]) { 64 if ((value != null) || (matrix[rowIndex, columnIndex] != string.Empty)) { 65 matrix[rowIndex, columnIndex] = value != null ? value : string.Empty; 66 66 OnItemChanged(rowIndex, columnIndex); 67 67 } … … 71 71 72 72 public StringMatrix() { 73 array= new string[0, 0];73 matrix = new string[0, 0]; 74 74 } 75 75 public StringMatrix(int rows, int columns) { 76 array= new string[rows, columns];77 for (int i = 0; i < array.GetLength(0); i++) {78 for (int j = 0; j < array.GetLength(1); j++)79 array[i, j] = string.Empty;76 matrix = new string[rows, columns]; 77 for (int i = 0; i < matrix.GetLength(0); i++) { 78 for (int j = 0; j < matrix.GetLength(1); j++) 79 matrix[i, j] = string.Empty; 80 80 } 81 81 } 82 82 public StringMatrix(string[,] elements) { 83 83 if (elements == null) throw new ArgumentNullException(); 84 array= new string[elements.GetLength(0), elements.GetLength(1)];85 for (int i = 0; i < array.GetLength(0); i++) {86 for (int j = 0; j < array.GetLength(1); j++)87 array[i, j] = elements[i, j] == null ? string.Empty : elements[i, j];84 matrix = new string[elements.GetLength(0), elements.GetLength(1)]; 85 for (int i = 0; i < matrix.GetLength(0); i++) { 86 for (int j = 0; j < matrix.GetLength(1); j++) 87 matrix[i, j] = elements[i, j] == null ? string.Empty : elements[i, j]; 88 88 } 89 }90 private StringMatrix(StringMatrix elements) {91 if (elements == null) throw new ArgumentNullException();92 array = (string[,])elements.array.Clone();93 89 } 94 90 95 91 public override IDeepCloneable Clone(Cloner cloner) { 96 StringMatrix clone = new StringMatrix( this);92 StringMatrix clone = new StringMatrix(); 97 93 cloner.RegisterClonedObject(this, clone); 94 clone.matrix = (string[,])matrix.Clone(); 98 95 return clone; 99 96 } … … 102 99 StringBuilder sb = new StringBuilder(); 103 100 sb.Append("["); 104 if ( array.Length > 0) {101 if (matrix.Length > 0) { 105 102 for (int i = 0; i < Rows; i++) { 106 sb.Append("[").Append( array[i, 0]);103 sb.Append("[").Append(matrix[i, 0]); 107 104 for (int j = 1; j < Columns; j++) 108 sb.Append(";").Append( array[i, j]);105 sb.Append(";").Append(matrix[i, j]); 109 106 sb.Append("]"); 110 107 } … … 114 111 } 115 112 116 public IEnumerator GetEnumerator() { 117 return array.GetEnumerator(); 113 public virtual IEnumerator GetEnumerator() { 114 return matrix.GetEnumerator(); 115 } 116 117 protected virtual bool Validate(string value, out string errorMessage) { 118 if (value == null) { 119 errorMessage = "Invalid Value (string must not be null)"; 120 return false; 121 } else { 122 errorMessage = string.Empty; 123 return true; 124 } 125 } 126 protected virtual string GetValue(int rowIndex, int columIndex) { 127 return this[rowIndex, columIndex]; 128 } 129 protected virtual bool SetValue(string value, int rowIndex, int columnIndex) { 130 if (value != null) { 131 this[rowIndex, columnIndex] = value; 132 return true; 133 } else { 134 return false; 135 } 136 } 137 138 public event EventHandler<EventArgs<int, int>> ItemChanged; 139 protected virtual void OnItemChanged(int rowIndex, int columnIndex) { 140 if (ItemChanged != null) 141 ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex)); 142 OnToStringChanged(); 143 } 144 public event EventHandler Reset; 145 protected virtual void OnReset() { 146 if (Reset != null) 147 Reset(this, EventArgs.Empty); 148 OnToStringChanged(); 118 149 } 119 150 … … 127 158 set { Columns = value; } 128 159 } 129 130 160 bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) { 131 if (value == null) { 132 errorMessage = "Invalid Value (string must not be null)"; 133 return false; 134 } else { 135 errorMessage = string.Empty; 136 return true; 137 } 161 return Validate(value, out errorMessage); 138 162 } 139 163 string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) { 140 return this[rowIndex, columIndex];164 return GetValue(rowIndex, columIndex); 141 165 } 142 166 bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) { 143 if (value != null) { 144 this[rowIndex, columnIndex] = value; 145 return true; 146 } else { 147 return false; 148 } 149 } 150 public event EventHandler<EventArgs<int, int>> ItemChanged; 151 private void OnItemChanged(int rowIndex, int columnIndex) { 152 if (ItemChanged != null) 153 ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex)); 154 OnToStringChanged(); 155 } 156 public event EventHandler Reset; 157 private void OnReset() { 158 if (Reset != null) 159 Reset(this, EventArgs.Empty); 160 OnToStringChanged(); 167 return SetValue(value, rowIndex, columnIndex); 161 168 } 162 169 #endregion -
trunk/sources/HeuristicLab.Data/3.3/StringValue.cs
r3048 r3054 28 28 [Creatable("Test")] 29 29 [StorableClass] 30 public sealedclass StringValue : Item, IComparable, IStringConvertibleValue {30 public class StringValue : Item, IComparable, IStringConvertibleValue { 31 31 [Storable] 32 pr ivatestring value;33 public string Value {32 protected string value; 33 public virtual string Value { 34 34 get { return value; } 35 35 set { … … 51 51 52 52 public override IDeepCloneable Clone(Cloner cloner) { 53 StringValue clone = new StringValue( Value);53 StringValue clone = new StringValue(value); 54 54 cloner.RegisterClonedObject(this, clone); 55 55 return clone; … … 60 60 } 61 61 62 public int CompareTo(object obj) {62 public virtual int CompareTo(object obj) { 63 63 StringValue other = obj as StringValue; 64 64 if (other != null) … … 69 69 70 70 public event EventHandler ValueChanged; 71 pr ivatevoid OnValueChanged() {71 protected virtual void OnValueChanged() { 72 72 if (ValueChanged != null) 73 73 ValueChanged(this, EventArgs.Empty); … … 75 75 } 76 76 77 #region IStringConvertibleValue Members 78 bool IStringConvertibleValue.Validate(string value, out string errorMessage) { 77 protected virtual bool Validate(string value, out string errorMessage) { 79 78 if (value == null) { 80 79 errorMessage = "Invalid Value (string must not be null)"; … … 85 84 } 86 85 } 87 string IStringConvertibleValue.GetValue() {86 protected virtual string GetValue() { 88 87 return Value; 89 88 } 90 bool IStringConvertibleValue.SetValue(string value) {89 protected virtual bool SetValue(string value) { 91 90 if (value != null) { 92 91 Value = value; … … 96 95 } 97 96 } 97 98 #region IStringConvertibleValue Members 99 bool IStringConvertibleValue.Validate(string value, out string errorMessage) { 100 return Validate(value, out errorMessage); 101 } 102 string IStringConvertibleValue.GetValue() { 103 return GetValue(); 104 } 105 bool IStringConvertibleValue.SetValue(string value) { 106 return SetValue(value); 107 } 98 108 #endregion 99 109 } -
trunk/sources/HeuristicLab.Data/3.3/TimeSpanValue.cs
r3048 r3054 29 29 [Creatable("Test")] 30 30 [StorableClass] 31 public sealedclass TimeSpanValue : ValueTypeValue<TimeSpan>, IComparable, IStringConvertibleValue {31 public class TimeSpanValue : ValueTypeValue<TimeSpan>, IComparable, IStringConvertibleValue { 32 32 public TimeSpanValue() : base() { } 33 33 public TimeSpanValue(TimeSpan value) : base(value) { } 34 34 35 35 public override IDeepCloneable Clone(Cloner cloner) { 36 TimeSpanValue clone = new TimeSpanValue( Value);36 TimeSpanValue clone = new TimeSpanValue(value); 37 37 cloner.RegisterClonedObject(this, clone); 38 38 return clone; 39 39 } 40 40 41 public int CompareTo(object obj) {41 public virtual int CompareTo(object obj) { 42 42 TimeSpanValue other = obj as TimeSpanValue; 43 43 if (other != null) … … 47 47 } 48 48 49 #region IStringConvertibleValue Members 50 bool IStringConvertibleValue.Validate(string value, out string errorMessage) { 49 protected virtual bool Validate(string value, out string errorMessage) { 51 50 TimeSpan val; 52 51 bool valid = TimeSpan.TryParse(value, out val); … … 61 60 return valid; 62 61 } 63 string IStringConvertibleValue.GetValue() {62 protected virtual string GetValue() { 64 63 return Value.ToString(); 65 64 } 66 bool IStringConvertibleValue.SetValue(string value) {65 protected virtual bool SetValue(string value) { 67 66 TimeSpan val; 68 67 if (TimeSpan.TryParse(value, out val)) { … … 73 72 } 74 73 } 74 75 #region IStringConvertibleValue Members 76 bool IStringConvertibleValue.Validate(string value, out string errorMessage) { 77 return Validate(value, out errorMessage); 78 } 79 string IStringConvertibleValue.GetValue() { 80 return GetValue(); 81 } 82 bool IStringConvertibleValue.SetValue(string value) { 83 return SetValue(value); 84 } 75 85 #endregion 76 86 } -
trunk/sources/HeuristicLab.Data/3.3/ValueTypeArray.cs
r3048 r3054 28 28 29 29 namespace HeuristicLab.Data { 30 [Item("ValueTypeArray<T>", "A base class for representing arrays of value types.")]30 [Item("ValueTypeArray<T>", "An abstract base class for representing arrays of value types.")] 31 31 [StorableClass] 32 public class ValueTypeArray<T> : Item, IEnumerable where T : struct {32 public abstract class ValueTypeArray<T> : Item, IEnumerable where T : struct { 33 33 [Storable] 34 pr ivateT[] array;34 protected T[] array; 35 35 36 public int Length {36 public virtual int Length { 37 37 get { return array.Length; } 38 38 protected set { … … 43 43 } 44 44 } 45 public T this[int index] {45 public virtual T this[int index] { 46 46 get { return array[index]; } 47 47 set { … … 53 53 } 54 54 55 p ublicValueTypeArray() {55 protected ValueTypeArray() { 56 56 array = new T[0]; 57 57 } 58 p ublicValueTypeArray(int length) {58 protected ValueTypeArray(int length) { 59 59 array = new T[length]; 60 60 } 61 p ublicValueTypeArray(T[] elements) {61 protected ValueTypeArray(T[] elements) { 62 62 if (elements == null) throw new ArgumentNullException(); 63 63 array = (T[])elements.Clone(); 64 }65 protected ValueTypeArray(ValueTypeArray<T> elements) {66 if (elements == null) throw new ArgumentNullException();67 array = (T[])elements.array.Clone();68 64 } 69 65 … … 86 82 } 87 83 88 public IEnumerator GetEnumerator() {84 public virtual IEnumerator GetEnumerator() { 89 85 return array.GetEnumerator(); 90 86 } 91 87 92 88 public event EventHandler<EventArgs<int>> ItemChanged; 93 pr ivatevoid OnItemChanged(int index) {89 protected virtual void OnItemChanged(int index) { 94 90 if (ItemChanged != null) 95 91 ItemChanged(this, new EventArgs<int>(index)); … … 97 93 } 98 94 public event EventHandler Reset; 99 pr ivatevoid OnReset() {95 protected virtual void OnReset() { 100 96 if (Reset != null) 101 97 Reset(this, EventArgs.Empty); -
trunk/sources/HeuristicLab.Data/3.3/ValueTypeMatrix.cs
r3048 r3054 28 28 29 29 namespace HeuristicLab.Data { 30 [Item("ValueTypeMatrix<T>", "A base class for representing matrices of value types.")]30 [Item("ValueTypeMatrix<T>", "An abstract base class for representing matrices of value types.")] 31 31 [StorableClass] 32 public class ValueTypeMatrix<T> : Item, IEnumerable where T : struct {32 public abstract class ValueTypeMatrix<T> : Item, IEnumerable where T : struct { 33 33 [Storable] 34 pr ivate T[,] array;34 protected T[,] matrix; 35 35 36 public int Rows {37 get { return array.GetLength(0); }36 public virtual int Rows { 37 get { return matrix.GetLength(0); } 38 38 protected set { 39 39 if (value != Rows) { 40 40 T[,] newArray = new T[value, Columns]; 41 Array.Copy( array, newArray, Math.Min(value * Columns, array.Length));42 array= newArray;41 Array.Copy(matrix, newArray, Math.Min(value * Columns, matrix.Length)); 42 matrix = newArray; 43 43 OnReset(); 44 44 } 45 45 } 46 46 } 47 public int Columns {48 get { return array.GetLength(1); }47 public virtual int Columns { 48 get { return matrix.GetLength(1); } 49 49 protected set { 50 50 if (value != Columns) { 51 51 T[,] newArray = new T[Rows, value]; 52 52 for (int i = 0; i < Rows; i++) 53 Array.Copy( array, i * Columns, newArray, i * value, Math.Min(value, Columns));54 array= newArray;53 Array.Copy(matrix, i * Columns, newArray, i * value, Math.Min(value, Columns)); 54 matrix = newArray; 55 55 OnReset(); 56 56 } 57 57 } 58 58 } 59 public T this[int rowIndex, int columnIndex] {60 get { return array[rowIndex, columnIndex]; }59 public virtual T this[int rowIndex, int columnIndex] { 60 get { return matrix[rowIndex, columnIndex]; } 61 61 set { 62 if (!value.Equals( array[rowIndex, columnIndex])) {63 array[rowIndex, columnIndex] = value;62 if (!value.Equals(matrix[rowIndex, columnIndex])) { 63 matrix[rowIndex, columnIndex] = value; 64 64 OnItemChanged(rowIndex, columnIndex); 65 65 } … … 67 67 } 68 68 69 p ublicValueTypeMatrix() {70 array= new T[0, 0];69 protected ValueTypeMatrix() { 70 matrix = new T[0, 0]; 71 71 } 72 p ublicValueTypeMatrix(int rows, int columns) {73 array= new T[rows, columns];72 protected ValueTypeMatrix(int rows, int columns) { 73 matrix = new T[rows, columns]; 74 74 } 75 p ublicValueTypeMatrix(T[,] elements) {75 protected ValueTypeMatrix(T[,] elements) { 76 76 if (elements == null) throw new ArgumentNullException(); 77 array = (T[,])elements.Clone(); 78 } 79 protected ValueTypeMatrix(ValueTypeMatrix<T> elements) { 80 if (elements == null) throw new ArgumentNullException(); 81 array = (T[,])elements.array.Clone(); 77 matrix = (T[,])elements.Clone(); 82 78 } 83 79 84 80 public override IDeepCloneable Clone(Cloner cloner) { 85 81 ValueTypeMatrix<T> clone = (ValueTypeMatrix<T>)base.Clone(cloner); 86 clone. array = (T[,])array.Clone();82 clone.matrix = (T[,])matrix.Clone(); 87 83 return clone; 88 84 } … … 91 87 StringBuilder sb = new StringBuilder(); 92 88 sb.Append("["); 93 if ( array.Length > 0) {89 if (matrix.Length > 0) { 94 90 for (int i = 0; i < Rows; i++) { 95 sb.Append("[").Append( array[i, 0].ToString());91 sb.Append("[").Append(matrix[i, 0].ToString()); 96 92 for (int j = 1; j < Columns; j++) 97 sb.Append(";").Append( array[i, j].ToString());93 sb.Append(";").Append(matrix[i, j].ToString()); 98 94 sb.Append("]"); 99 95 } … … 103 99 } 104 100 105 public IEnumerator GetEnumerator() {106 return array.GetEnumerator();101 public virtual IEnumerator GetEnumerator() { 102 return matrix.GetEnumerator(); 107 103 } 108 104 109 105 public event EventHandler<EventArgs<int, int>> ItemChanged; 110 pr ivatevoid OnItemChanged(int rowIndex, int columnIndex) {106 protected virtual void OnItemChanged(int rowIndex, int columnIndex) { 111 107 if (ItemChanged != null) 112 108 ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex)); … … 114 110 } 115 111 public event EventHandler Reset; 116 pr ivatevoid OnReset() {112 protected virtual void OnReset() { 117 113 if (Reset != null) 118 114 Reset(this, EventArgs.Empty); -
trunk/sources/HeuristicLab.Data/3.3/ValueTypeValue.cs
r3048 r3054 25 25 26 26 namespace HeuristicLab.Data { 27 [Item("ValueTypeValue<T>", "A base class for representingvalue types.")]27 [Item("ValueTypeValue<T>", "An abstract base class for representing values of value types.")] 28 28 [StorableClass] 29 public class ValueTypeValue<T> : Item where T : struct {29 public abstract class ValueTypeValue<T> : Item where T : struct { 30 30 [Storable] 31 pr ivateT value;32 public T Value {31 protected T value; 32 public virtual T Value { 33 33 get { return value; } 34 34 set { … … 40 40 } 41 41 42 p ublicValueTypeValue() {42 protected ValueTypeValue() { 43 43 this.value = default(T); 44 44 } 45 p ublicValueTypeValue(T value) {45 protected ValueTypeValue(T value) { 46 46 this.value = value; 47 47 } -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj
r3053 r3054 86 86 <ItemGroup> 87 87 <Compile Include="HeuristicLabEncodingsBinaryVectorEncodingPlugin.cs" /> 88 <Compile Include="BinaryVector.cs" /> 88 89 <Compile Include="Interfaces\IBinaryVectorCreator.cs" /> 89 90 <Compile Include="Interfaces\IBinaryVectorCrossover.cs" /> -
trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj
r3053 r3054 96 96 <SubType>Code</SubType> 97 97 </Compile> 98 <Compile Include="IntegerVector.cs" /> 98 99 <Compile Include="Properties\AssemblyInfo.cs" /> 99 100 <Compile Include="IntVectorCreator.cs" /> -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs
r3053 r3054 20 20 #endregion 21 21 22 using System;23 using System.Text;24 using HeuristicLab.Common;25 22 using HeuristicLab.Core; 26 23 using HeuristicLab.Data; … … 31 28 [Item("Permutation", "Represents a permutation of integer values.")] 32 29 [Creatable("Test")] 33 public sealed class Permutation : ValueTypeArray<int>, IStringConvertibleArray {30 public class Permutation : IntArray { 34 31 public Permutation() : base() { } 35 32 public Permutation(int length) … … 42 39 Randomize(random); 43 40 } 44 public Permutation(int[] elements) 45 : base(elements) { 41 public Permutation(int[] elements) : base(elements) { } 42 public Permutation(IntArray elements) 43 : this(elements.Length) { 44 for (int i = 0; i < array.Length; i++) 45 array[i] = elements[i]; 46 46 } 47 private Permutation(Permutation elements) : base(elements) { }48 47 49 48 public override IDeepCloneable Clone(Cloner cloner) { 50 Permutation clone = new Permutation( this);49 Permutation clone = new Permutation(array); 51 50 cloner.RegisterClonedObject(this, clone); 52 51 return clone; 53 52 } 54 53 55 public bool Validate() {54 public virtual bool Validate() { 56 55 bool[] values = new bool[Length]; 57 56 int value; … … 68 67 } 69 68 70 public void Randomize(IRandom random, int startIndex, int length) { // Knuth shuffle 71 int index1, index2; 72 int val; 73 for (int i = length - 1; i > 0; i--) { 74 index1 = startIndex + i; 75 index2 = startIndex + random.Next(i + 1); 76 if (index1 != index2) { 77 val = this[index1]; 78 this[index1] = this[index2]; 79 this[index2] = val; 69 public virtual void Randomize(IRandom random, int startIndex, int length) { 70 if (length > 1) { 71 // Knuth shuffle 72 int index1, index2; 73 int val; 74 for (int i = length - 1; i > 0; i--) { 75 index1 = startIndex + i; 76 index2 = startIndex + random.Next(i + 1); 77 if (index1 != index2) { 78 val = array[index1]; 79 array[index1] = array[index2]; 80 array[index2] = val; 81 } 80 82 } 83 OnReset(); 81 84 } 82 85 } … … 85 88 } 86 89 87 public int GetCircular(int position) {90 public virtual int GetCircular(int position) { 88 91 if (position >= Length) position = position % Length; 89 92 while (position < 0) position += Length; 90 93 return this[position]; 91 94 } 92 93 #region IStringConvertibleArrayData Members94 int IStringConvertibleArray.Length {95 get { return Length; }96 set { Length = value; }97 }98 99 bool IStringConvertibleArray.Validate(string value, out string errorMessage) {100 int val;101 bool valid = int.TryParse(value, out val);102 errorMessage = string.Empty;103 if (!valid) {104 StringBuilder sb = new StringBuilder();105 sb.Append("Invalid Value (Valid Value Format: \"");106 sb.Append(FormatPatterns.GetIntFormatPattern());107 sb.Append("\")");108 errorMessage = sb.ToString();109 }110 return valid;111 }112 string IStringConvertibleArray.GetValue(int index) {113 return this[index].ToString();114 }115 bool IStringConvertibleArray.SetValue(string value, int index) {116 int val;117 if (int.TryParse(value, out val)) {118 this[index] = val;119 return true;120 } else {121 return false;122 }123 }124 #endregion125 95 } 126 96 } -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj
r3053 r3054 103 103 <Compile Include="Crossovers\UniformSomePositionsArithmeticCrossover.cs" /> 104 104 <Compile Include="HeuristicLabEncodingsRealVectorEncodingPlugin.cs" /> 105 <Compile Include="RealVector.cs" /> 105 106 <Compile Include="Manipulators\BreederGeneticAlgorithmManipulator.cs" /> 106 107 <Compile Include="Manipulators\PolynomialAllPositionManipulator.cs" />
Note: See TracChangeset
for help on using the changeset viewer.