Changeset 77 for trunk/sources/HeuristicLab.Permutation
- Timestamp:
- 03/18/08 16:00:00 (17 years ago)
- Location:
- trunk/sources/HeuristicLab.Permutation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Permutation/PermutationCrossoverBase.cs
r2 r77 34 34 35 35 protected sealed override void Cross(IScope scope, IRandom random, IScope parent1, IScope parent2, IScope child) { 36 IVariableInfo permutationInfo = GetVariableInfo("Permutation"); 37 Permutation perm1 = parent1.GetVariableValue<Permutation>(permutationInfo.ActualName, false); 38 Permutation perm2 = parent2.GetVariableValue<Permutation>(permutationInfo.ActualName, false); 36 Permutation perm1 = parent1.GetVariableValue<Permutation>("Permutation", false); 37 Permutation perm2 = parent2.GetVariableValue<Permutation>("Permutation", false); 39 38 40 39 if (perm1.Data.Length != perm2.Data.Length) throw new InvalidOperationException("Cannot apply crossover to permutations of different length."); 41 40 42 41 int[] result = Cross(scope, random, perm1.Data, perm2.Data); 43 child.AddVariable(new Variable( permutationInfo.ActualName, new Permutation(result)));42 child.AddVariable(new Variable(scope.TranslateName("Permutation"), new Permutation(result))); 44 43 } 45 44 -
trunk/sources/HeuristicLab.Permutation/RandomPermutationGenerator.cs
r2 r77 61 61 62 62 int[] perm = Apply(random, length.Data); 63 scope.AddVariable(new Variable( GetVariableInfo("Permutation").ActualName, new Permutation(perm)));63 scope.AddVariable(new Variable(scope.TranslateName("Permutation"), new Permutation(perm))); 64 64 65 65 return null;
Note: See TracChangeset
for help on using the changeset viewer.