Changeset 8887 for trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers
- Timestamp:
- 11/11/12 22:57:09 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMCrossover.cs
r8603 r8887 27 27 [Item("JSMCrossover", "An operator which crosses two JSM representations.")] 28 28 [StorableClass] 29 public abstract class JSMCrossover : ScheduleCrossover <JSMEncoding>, IJSMOperator {29 public abstract class JSMCrossover : ScheduleCrossover, IJSMOperator { 30 30 31 31 [StorableConstructor] … … 41 41 42 42 public override IOperation Apply() { 43 ItemArray<JSMEncoding>parents = ParentsParameter.ActualValue;43 var parents = ParentsParameter.ActualValue; 44 44 45 45 ChildParameter.ActualValue = -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMJOXCrossover.cs
r8603 r8887 30 30 [StorableClass] 31 31 public class JSMJOXCrossover : JSMCrossover { 32 32 33 [StorableConstructor] 33 34 protected JSMJOXCrossover(bool deserializing) : base(deserializing) { } 34 protected JSMJOXCrossover(JSMJOXCrossover original, Cloner cloner) 35 : base(original, cloner) {36 } 35 protected JSMJOXCrossover(JSMJOXCrossover original, Cloner cloner) : base(original, cloner) { } 36 public JSMJOXCrossover() : base() { } 37 37 38 public override IDeepCloneable Clone(Cloner cloner) { 38 39 return new JSMJOXCrossover(this, cloner); 39 40 } 40 public JSMJOXCrossover() : base() { }41 42 41 43 42 public static JSMEncoding Apply(IRandom random, JSMEncoding p1, JSMEncoding p2) { 44 JSMEncodingresult = new JSMEncoding();43 var result = new JSMEncoding(); 45 44 46 45 int nrOfResources = p1.JobSequenceMatrix.Count; … … 48 47 49 48 //Determine randomly which jobindexes persist 50 BoolArraypersist = new BoolArray(nrOfJobs);49 var persist = new BoolArray(nrOfJobs); 51 50 for (int i = 0; i < persist.Length; i++) { 52 51 persist[i] = random.Next(2) == 1; -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMOXCrossover.cs
r8603 r8887 28 28 [StorableClass] 29 29 public class JSMOXCrossover : JSMCrossover { 30 30 31 [StorableConstructor] 31 32 protected JSMOXCrossover(bool deserializing) : base(deserializing) { } 32 protected JSMOXCrossover(JSMOXCrossover original, Cloner cloner) 33 : base(original, cloner) {34 } 33 protected JSMOXCrossover(JSMOXCrossover original, Cloner cloner) : base(original, cloner) { } 34 public JSMOXCrossover() : base() { } 35 35 36 public override IDeepCloneable Clone(Cloner cloner) { 36 37 return new JSMOXCrossover(this, cloner); 37 38 } 38 public JSMOXCrossover() : base() { }39 40 39 41 40 public static JSMEncoding Apply(IRandom random, JSMEncoding parent1, JSMEncoding parent2) { 42 JSMEncodingresult = new JSMEncoding();41 var result = new JSMEncoding(); 43 42 44 43 for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) { -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMSXXCrossover.cs
r8603 r8887 29 29 [StorableClass] 30 30 public class JSMSXXCrossover : JSMCrossover { 31 31 32 [StorableConstructor] 32 33 protected JSMSXXCrossover(bool deserializing) : base(deserializing) { } 33 protected JSMSXXCrossover(JSMSXXCrossover original, Cloner cloner) 34 : base(original, cloner) {35 } 34 protected JSMSXXCrossover(JSMSXXCrossover original, Cloner cloner) : base(original, cloner) { } 35 public JSMSXXCrossover() : base() { } 36 36 37 public override IDeepCloneable Clone(Cloner cloner) { 37 38 return new JSMSXXCrossover(this, cloner); 38 39 } 39 public JSMSXXCrossover() : base() { }40 41 40 42 41 public static JSMEncoding Apply(IRandom random, JSMEncoding parent1, JSMEncoding parent2) { 43 JSMEncodingresult = new JSMEncoding();42 var result = new JSMEncoding(); 44 43 int subSequenceLength = random.Next(parent1.JobSequenceMatrix[0].Length); 45 44 for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) { 46 Permutationp1 = (Permutation)parent1.JobSequenceMatrix[i].Clone();47 Permutationp2 = (Permutation)parent2.JobSequenceMatrix[i].Clone();45 var p1 = (Permutation)parent1.JobSequenceMatrix[i].Clone(); 46 var p2 = (Permutation)parent2.JobSequenceMatrix[i].Clone(); 48 47 FindAndExchangeSubsequences(p1, p2, subSequenceLength); 49 48 result.JobSequenceMatrix.Add(p1); … … 51 50 return result; 52 51 } 52 53 53 private static void FindAndExchangeSubsequences(Permutation p1, Permutation p2, int subSequenceLength) { 54 54 for (int i = 0; i <= p1.Length - subSequenceLength; i++) { … … 63 63 } 64 64 } 65 65 66 private static void ExchangeSubsequences(Permutation p1, int index1, Permutation p2, int index2, int subSequenceLength) { 66 Permutationaux = (Permutation)p1.Clone();67 var aux = (Permutation)p1.Clone(); 67 68 for (int i = 0; i < subSequenceLength; i++) { 68 69 p1[i + index1] = p2[i + index2]; … … 70 71 } 71 72 } 73 72 74 private static bool AreEqualSubsequences(int[] ss1, int[] ss2) { 73 75 int counter = 0; … … 80 82 return counter == ss1.Length; 81 83 } 84 82 85 private static int[] GetSubSequenceAtPosition(Permutation p1, int index, int subSequenceLength) { 83 int[]result = new int[subSequenceLength];86 var result = new int[subSequenceLength]; 84 87 for (int i = 0; i < subSequenceLength; i++) 85 88 result[i] = p1[i + index];
Note: See TracChangeset
for help on using the changeset viewer.