Changeset 8887 for trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers
- Timestamp:
- 11/11/12 22:57:09 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRCrossover.cs
r8603 r8887 27 27 [Item("PWRCrossover", "An operator which crosses two JSM representations.")] 28 28 [StorableClass] 29 public abstract class PWRCrossover : ScheduleCrossover <PWREncoding>, IPWROperator {29 public abstract class PWRCrossover : ScheduleCrossover, IPWROperator { 30 30 31 31 [StorableConstructor] … … 41 41 42 42 public override IOperation Apply() { 43 ItemArray<PWREncoding>parents = ParentsParameter.ActualValue;43 var parents = ParentsParameter.ActualValue; 44 44 45 45 ChildParameter.ActualValue = -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRGOXCrossover.cs
r8603 r8887 31 31 [StorableClass] 32 32 public class PWRGOXCrossover : PWRCrossover { 33 33 34 [StorableConstructor] 34 35 protected PWRGOXCrossover(bool deserializing) : base(deserializing) { } 35 protected PWRGOXCrossover(PWRGOXCrossover original, Cloner cloner) 36 : base(original, cloner) {37 } 36 protected PWRGOXCrossover(PWRGOXCrossover original, Cloner cloner) : base(original, cloner) { } 37 public PWRGOXCrossover() : base() { } 38 38 39 public override IDeepCloneable Clone(Cloner cloner) { 39 40 return new PWRGOXCrossover(this, cloner); 40 41 } 41 public PWRGOXCrossover() : base() { }42 42 43 43 private static int[] GetLookUpForIndividual(List<int> p) { 44 int[]result = new int[p.Count];45 Dictionary<int, int>lookUpTable = new Dictionary<int, int>();44 var result = new int[p.Count]; 45 var lookUpTable = new Dictionary<int, int>(); 46 46 47 47 for (int i = 0; i < p.Count; i++) { … … 54 54 return result; 55 55 } 56 56 57 public static PWREncoding Apply(IRandom random, PWREncoding parent1, PWREncoding parent2) { 57 PWREncodingresult = new PWREncoding();58 var result = new PWREncoding(); 58 59 59 List<int> p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList<int>();60 List<int> p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList<int>();61 List<int>child = new List<int>();60 var p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList(); 61 var p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList(); 62 var child = new List<int>(); 62 63 63 64 int[] lookUpArrayP1 = GetLookUpForIndividual(p1); … … 90 91 } 91 92 92 93 94 95 93 } 96 94 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRPPXCrossover.cs
r8603 r8887 31 31 [StorableClass] 32 32 public class PWRPPXCrossover : PWRCrossover { 33 33 34 [StorableConstructor] 34 35 protected PWRPPXCrossover(bool deserializing) : base(deserializing) { } 35 protected PWRPPXCrossover(PWRPPXCrossover original, Cloner cloner) 36 : base(original, cloner) {37 } 36 protected PWRPPXCrossover(PWRPPXCrossover original, Cloner cloner) : base(original, cloner) { } 37 public PWRPPXCrossover() : base() { } 38 38 39 public override IDeepCloneable Clone(Cloner cloner) { 39 40 return new PWRPPXCrossover(this, cloner); 40 41 } 41 public PWRPPXCrossover() : base() { }42 42 43 43 public static PWREncoding Apply(IRandom random, PWREncoding parent1, PWREncoding parent2) { 44 PWREncodingresult = new PWREncoding();45 List<int> p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList<int>();46 List<int> p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList<int>();47 List<int>child = new List<int>();44 var result = new PWREncoding(); 45 var p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList(); 46 var p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList(); 47 var child = new List<int>(); 48 48 49 bool[]lookUpTable = new bool[parent1.PermutationWithRepetition.Length];49 var lookUpTable = new bool[parent1.PermutationWithRepetition.Length]; 50 50 for (int i = 0; i < lookUpTable.Length; i++) { 51 51 lookUpTable[i] = random.Next(2) == 1; … … 73 73 } 74 74 75 76 75 } 77 76 }
Note: See TracChangeset
for help on using the changeset viewer.