- Timestamp:
- 11/06/10 01:56:04 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
/branches/CloningRefactoring (added) merged: 4656-4693,4696-4697,4711-4714,4718-4719
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVector.cs
r3431 r4722 29 29 [Item("BinaryVector", "Represents a vector of binary values.")] 30 30 public class BinaryVector : BoolArray { 31 [StorableConstructor] 32 protected BinaryVector(bool deserializing) : base(deserializing) { } 33 protected BinaryVector(BinaryVector original, Cloner cloner) : base(original, cloner) { } 31 34 public BinaryVector() : base() { } 32 35 public BinaryVector(int length) : base(length) { } … … 43 46 44 47 public override IDeepCloneable Clone(Cloner cloner) { 45 BinaryVector clone = new BinaryVector(array); 46 cloner.RegisterClonedObject(this, clone); 47 clone.readOnly = readOnly; 48 return clone; 48 return new BinaryVector(this, cloner); 49 49 } 50 50 -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorCreator.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 47 48 } 48 49 50 [StorableConstructor] 51 protected BinaryVectorCreator(bool deserializing) : base(deserializing) { } 52 protected BinaryVectorCreator(BinaryVectorCreator original, Cloner cloner) : base(original, cloner) { } 49 53 protected BinaryVectorCreator() 50 54 : base() { -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorCrossover.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Operators; … … 46 47 } 47 48 49 [StorableConstructor] 50 protected BinaryVectorCrossover(bool deserializing) : base(deserializing) { } 51 protected BinaryVectorCrossover(BinaryVectorCrossover original, Cloner cloner) : base(original, cloner) { } 48 52 protected BinaryVectorCrossover() 49 53 : base() { -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorManipulator.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Operators; … … 43 44 } 44 45 46 [StorableConstructor] 47 protected BinaryVectorManipulator(bool deserializing) : base(deserializing) { } 48 protected BinaryVectorManipulator(BinaryVectorManipulator original, Cloner cloner) : base(original, cloner) { } 45 49 protected BinaryVectorManipulator() 46 50 : base() { -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Creators/RandomBinaryVectorCreator.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 30 31 [Item("RandomBinaryVectorCreator", "An operator which creates a new random binary vector with each element randomly initialized.")] 31 32 [StorableClass] 32 public class RandomBinaryVectorCreator : BinaryVectorCreator { 33 public sealed class RandomBinaryVectorCreator : BinaryVectorCreator { 34 [StorableConstructor] 35 private RandomBinaryVectorCreator(bool deserializing) : base(deserializing) { } 36 private RandomBinaryVectorCreator(RandomBinaryVectorCreator original, Cloner cloner) : base(original, cloner) { } 37 public RandomBinaryVectorCreator() : base() { } 38 39 public override IDeepCloneable Clone(Cloner cloner) { 40 return new RandomBinaryVectorCreator(this, cloner); 41 } 42 33 43 /// <summary> 34 44 /// Generates a new random binary vector with the given <paramref name="length"/>. -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Crossovers/MultiBinaryVectorCrossover.cs
r3674 r4722 23 23 using System.Linq; 24 24 using HeuristicLab.Collections; 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Operators; … … 50 51 51 52 [StorableConstructor] 52 private MultiBinaryVectorCrossover(bool deserializing) : base(deserializing) { } 53 protected MultiBinaryVectorCrossover(bool deserializing) : base(deserializing) { } 54 protected MultiBinaryVectorCrossover(MultiBinaryVectorCrossover original, Cloner cloner) : base(original, cloner) { } 53 55 public MultiBinaryVectorCrossover() 54 56 : base() { … … 62 64 Operators.Add((IBinaryVectorCrossover)Activator.CreateInstance(type), true); 63 65 } 66 } 67 68 public override IDeepCloneable Clone(Cloner cloner) { 69 return new MultiBinaryVectorCrossover(this, cloner); 64 70 } 65 71 -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Crossovers/NPointCrossover.cs
r4068 r4722 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; … … 36 37 [Item("NPointCrossover", "N point crossover for binary vectors. It is implemented as described in Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg.")] 37 38 [StorableClass] 38 public class NPointCrossover : BinaryVectorCrossover {39 public sealed class NPointCrossover : BinaryVectorCrossover { 39 40 /// <summary> 40 41 /// Number of crossover points. … … 44 45 } 45 46 47 [StorableConstructor] 48 private NPointCrossover(bool deserializing) : base(deserializing) { } 49 private NPointCrossover(NPointCrossover original, Cloner cloner) : base(original, cloner) { } 46 50 /// <summary> 47 51 /// Initializes a new instance of <see cref="NPointCrossover"/> 48 52 /// </summary> 49 public NPointCrossover() { 53 public NPointCrossover() 54 : base() { 50 55 Parameters.Add(new ValueLookupParameter<IntValue>("N", "Number of crossover points", new IntValue(2))); 56 } 57 58 public override IDeepCloneable Clone(Cloner cloner) { 59 return new NPointCrossover(this, cloner); 51 60 } 52 61 -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Crossovers/SinglePointCrossover.cs
r4068 r4722 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; … … 34 35 [Item("SinglePointCrossover", "Single point crossover for binary vectors. It is implemented based on the NPointCrossover.")] 35 36 [StorableClass] 36 public class SinglePointCrossover : BinaryVectorCrossover { 37 public sealed class SinglePointCrossover : BinaryVectorCrossover { 38 39 [StorableConstructor] 40 private SinglePointCrossover(bool deserializing) : base(deserializing) { } 41 private SinglePointCrossover(SinglePointCrossover original, Cloner cloner) : base(original, cloner) { } 42 public SinglePointCrossover() : base() { } 43 44 public override IDeepCloneable Clone(Cloner cloner) { 45 return new SinglePointCrossover(this, cloner); 46 } 47 37 48 /// <summary> 38 49 /// Performs a single point crossover at a randomly chosen position of two -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Crossovers/UniformCrossover.cs
r4068 r4722 21 21 22 22 using System; 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 33 34 [Item("UniformCrossover", "Uniform crossover for binary vectors. It is implemented as described in Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg.")] 34 35 [StorableClass] 35 public class UniformCrossover : BinaryVectorCrossover { 36 public sealed class UniformCrossover : BinaryVectorCrossover { 37 38 [StorableConstructor] 39 private UniformCrossover(bool deserializing) : base(deserializing) { } 40 private UniformCrossover(UniformCrossover original, Cloner cloner) : base(original, cloner) { } 41 public UniformCrossover() : base() { } 42 43 public override IDeepCloneable Clone(Cloner cloner) { 44 return new UniformCrossover(this, cloner); 45 } 46 36 47 /// <summary> 37 48 /// Performs a uniform crossover between two binary vectors. -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Manipulators/SinglePositionBitflipManipulator.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 32 33 [Item("SinglePositionBitflipManipulator", "Flips exactly one bit of a binary vector. It is implemented as described in Michalewicz, Z. 1999. Genetic Algorithms + Data Structures = Evolution Programs. Third, Revised and Extended Edition, Spring-Verlag Berlin Heidelberg.")] 33 34 [StorableClass] 34 public class SinglePositionBitflipManipulator : BinaryVectorManipulator { 35 public sealed class SinglePositionBitflipManipulator : BinaryVectorManipulator { 36 37 [StorableConstructor] 38 private SinglePositionBitflipManipulator(bool deserializing) : base(deserializing) { } 39 private SinglePositionBitflipManipulator(SinglePositionBitflipManipulator original, Cloner cloner) : base(original, cloner) { } 40 public SinglePositionBitflipManipulator() : base() { } 41 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new SinglePositionBitflipManipulator(this, cloner); 44 } 45 35 46 /// <summary> 36 47 /// Performs the single position bitflip mutation on a binary vector. -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Manipulators/SomePositionsBitflipManipulator.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 34 35 [Item("SomePositionsBitflipManipulator", "Flips some bits of a binary vector, each position is flipped with a probability of pm. It is implemented as described in Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg, p. 43.")] 35 36 [StorableClass] 36 public class SomePositionsBitflipManipulator : BinaryVectorManipulator {37 public sealed class SomePositionsBitflipManipulator : BinaryVectorManipulator { 37 38 /// <summary> 38 39 /// Mmutation probability for each position. … … 42 43 } 43 44 45 [StorableConstructor] 46 private SomePositionsBitflipManipulator(bool deserializing) : base(deserializing) { } 47 private SomePositionsBitflipManipulator(SomePositionsBitflipManipulator original, Cloner cloner) : base(original, cloner) { } 44 48 /// <summary> 45 49 /// Initializes a new instance of <see cref="NPointCrossover"/> 46 50 /// </summary> 47 public SomePositionsBitflipManipulator() { 51 public SomePositionsBitflipManipulator() 52 : base() { 48 53 Parameters.Add(new ValueLookupParameter<DoubleValue>("MutationProbability", "The mutation probability for each position", new DoubleValue(0.2))); 54 } 55 56 public override IDeepCloneable Clone(Cloner cloner) { 57 return new SomePositionsBitflipManipulator(this, cloner); 49 58 } 50 59 -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/ExhaustiveOneBitflipMoveGenerator.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Optimization; … … 27 28 [Item("ExhaustiveBitflipMoveGenerator", "Generates all possible one bitflip moves from a given binaryVector.")] 28 29 [StorableClass] 29 public class ExhaustiveOneBitflipMoveGenerator : OneBitflipMoveGenerator, IExhaustiveMoveGenerator { 30 public sealed class ExhaustiveOneBitflipMoveGenerator : OneBitflipMoveGenerator, IExhaustiveMoveGenerator { 31 [StorableConstructor] 32 private ExhaustiveOneBitflipMoveGenerator(bool deserializing) : base(deserializing) { } 33 private ExhaustiveOneBitflipMoveGenerator(ExhaustiveOneBitflipMoveGenerator original, Cloner cloner) : base(original, cloner) { } 34 public ExhaustiveOneBitflipMoveGenerator() : base() { } 35 36 public override IDeepCloneable Clone(Cloner cloner) { 37 return new ExhaustiveOneBitflipMoveGenerator(this, cloner); 38 } 39 30 40 public static OneBitflipMove[] Apply(BinaryVector binaryVector) { 31 41 int length = binaryVector.Length; -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/OneBitflipMove.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 27 28 [StorableClass] 28 29 public class OneBitflipMove : OneIndexMove { 29 public OneBitflipMove() 30 : base() { 31 } 30 [StorableConstructor] 31 protected OneBitflipMove(bool deserializing) : base(deserializing) { } 32 protected OneBitflipMove(OneBitflipMove original, Cloner cloner) : base(original, cloner) { } 33 public OneBitflipMove() : base() { } 34 public OneBitflipMove(int index) : this(index, null) { } 35 public OneBitflipMove(int index, BinaryVector binaryVector) : base(index, binaryVector) { } 32 36 33 public OneBitflipMove(int index) 34 : base(index, null) { 35 } 36 37 public OneBitflipMove(int index, BinaryVector binaryVector) 38 : base(index, binaryVector) { 37 public override IDeepCloneable Clone(Cloner cloner) { 38 return new OneBitflipMove(this, cloner); 39 39 } 40 40 } -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/OneBitflipMoveAttribute.cs
r3376 r4722 25 25 26 26 namespace HeuristicLab.Encodings.BinaryVectorEncoding { 27 [Item("OneBitflipMoveAttribute", " Base class for specifying a move attribute.")]27 [Item("OneBitflipMoveAttribute", "Describes the attributes (move quality and index) of a single bitflip move.")] 28 28 [StorableClass] 29 29 public class OneBitflipMoveAttribute : Item { … … 33 33 public int Index { get; protected set; } 34 34 35 public OneBitflipMoveAttribute() 36 : this(-1, 0) { 35 [StorableConstructor] 36 protected OneBitflipMoveAttribute(bool deserializing) : base(deserializing) { } 37 protected OneBitflipMoveAttribute(OneBitflipMoveAttribute original, Cloner cloner) 38 : base(original, cloner) { 39 this.MoveQuality = original.MoveQuality; 40 this.Index = original.Index; 37 41 } 38 42 public OneBitflipMoveAttribute() : this(-1, 0) { } 39 43 public OneBitflipMoveAttribute(int index, double moveQuality) 40 44 : base() { … … 44 48 45 49 public override IDeepCloneable Clone(Cloner cloner) { 46 OneBitflipMoveAttribute clone = (OneBitflipMoveAttribute)base.Clone(cloner); 47 clone.MoveQuality = MoveQuality; 48 clone.Index = Index; 49 return clone; 50 return new OneBitflipMoveAttribute(this, cloner); 50 51 } 51 52 } -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/OneBitflipMoveGenerator.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Operators; … … 43 44 } 44 45 46 [StorableConstructor] 47 protected OneBitflipMoveGenerator(bool deserializing) : base(deserializing) { } 48 protected OneBitflipMoveGenerator(OneBitflipMoveGenerator original, Cloner cloner) : base(original, cloner) { } 45 49 public OneBitflipMoveGenerator() 46 50 : base() { -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/OneBitflipMoveMaker.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 47 48 } 48 49 50 [StorableConstructor] 51 protected OneBitflipMoveMaker(bool deserializing) : base(deserializing) { } 52 protected OneBitflipMoveMaker(OneBitflipMoveMaker original, Cloner cloner) : base(original, cloner) { } 49 53 public OneBitflipMoveMaker() 50 54 : base() { … … 53 57 Parameters.Add(new LookupParameter<OneBitflipMove>("OneBitflipMove", "The move to evaluate.")); 54 58 Parameters.Add(new LookupParameter<BinaryVector>("BinaryVector", "The solution as BinaryVector.")); 59 } 60 61 public override IDeepCloneable Clone(Cloner cloner) { 62 return new OneBitflipMoveMaker(this, cloner); 55 63 } 56 64 -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/OneBitflipMoveTabuChecker.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 61 62 } 62 63 64 [StorableConstructor] 65 protected OneBitflipMoveTabuChecker(bool deserializing) : base(deserializing) { } 66 protected OneBitflipMoveTabuChecker(OneBitflipMoveTabuChecker original, Cloner cloner) : base(original, cloner) { } 63 67 public OneBitflipMoveTabuChecker() 64 68 : base() { … … 70 74 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, else if it is a minimization problem.")); 71 75 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The quality of the current move.")); 76 } 77 78 public override IDeepCloneable Clone(Cloner cloner) { 79 return new OneBitflipMoveTabuChecker(this, cloner); 72 80 } 73 81 -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/OneBitflipMoveTabuMaker.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Optimization.Operators; … … 36 37 } 37 38 39 [StorableConstructor] 40 protected OneBitflipMoveTabuMaker(bool deserializing) : base(deserializing) { } 41 protected OneBitflipMoveTabuMaker(OneBitflipMoveTabuMaker original, Cloner cloner) : base(original, cloner) { } 38 42 public OneBitflipMoveTabuMaker() 39 43 : base() { 40 44 Parameters.Add(new LookupParameter<BinaryVector>("BinaryVector", "The solution as BinaryVector.")); 41 45 Parameters.Add(new LookupParameter<OneBitflipMove>("OneBitflipMove", "The move that was made.")); 46 } 47 48 public override IDeepCloneable Clone(Cloner cloner) { 49 return new OneBitflipMoveTabuMaker(this, cloner); 42 50 } 43 51 -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/StochasticOneBitflipMultiMoveGenerator.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; … … 42 43 } 43 44 45 [StorableConstructor] 46 protected StochasticOneBitflipMultiMoveGenerator(bool deserializing) : base(deserializing) { } 47 protected StochasticOneBitflipMultiMoveGenerator(StochasticOneBitflipMultiMoveGenerator original, Cloner cloner) : base(original, cloner) { } 44 48 public StochasticOneBitflipMultiMoveGenerator() 45 49 : base() { 46 50 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 47 51 Parameters.Add(new ValueLookupParameter<IntValue>("SampleSize", "The number of moves to generate.")); 52 } 53 54 public override IDeepCloneable Clone(Cloner cloner) { 55 return new StochasticOneBitflipMultiMoveGenerator(this, cloner); 48 56 } 49 57 -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/StochasticOneBitflipSingleMoveGenerator.cs
r4068 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Optimization; … … 33 34 } 34 35 36 [StorableConstructor] 37 protected StochasticOneBitflipSingleMoveGenerator(bool deserializing) : base(deserializing) { } 38 protected StochasticOneBitflipSingleMoveGenerator(StochasticOneBitflipSingleMoveGenerator original, Cloner cloner) : base(original, cloner) { } 35 39 public StochasticOneBitflipSingleMoveGenerator() 36 40 : base() { 37 41 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 42 } 43 44 public override IDeepCloneable Clone(Cloner cloner) { 45 return new StochasticOneBitflipSingleMoveGenerator(this, cloner); 38 46 } 39 47 -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneIndexMove.cs
r3376 r4722 33 33 public BinaryVector BinaryVector { get; protected set; } 34 34 35 public OneIndexMove() 36 : base() { 37 Index = -1; 38 BinaryVector = null; 35 [StorableConstructor] 36 protected OneIndexMove(bool deserializing) : base(deserializing) { } 37 protected OneIndexMove(OneIndexMove original, Cloner cloner) 38 : base(original, cloner) { 39 this.Index = original.Index; 40 if (original.BinaryVector != null) 41 this.BinaryVector = cloner.Clone(original.BinaryVector); 39 42 } 40 43 public OneIndexMove() : this(-1, null) { } 41 44 public OneIndexMove(int index, BinaryVector binaryVector) 42 45 : base() { … … 46 49 47 50 public override IDeepCloneable Clone(Cloner cloner) { 48 OneIndexMove clone = (OneIndexMove)base.Clone(cloner); 49 clone.Index = Index; 50 if (BinaryVector != null) 51 clone.BinaryVector = (BinaryVector)BinaryVector.Clone(cloner); 52 return clone; 51 return new OneIndexMove(this, cloner); 53 52 } 54 53 }
Note: See TracChangeset
for help on using the changeset viewer.