Changeset 11949 for branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/BasicProblems/Individuals/Individual.cs
- Timestamp:
- 02/06/15 14:42:48 (10 years ago)
- Location:
- branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/BasicProblems
- Files:
-
- 1 added
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/BasicProblems/Individuals/Individual.cs
r11885 r11949 22 22 using System; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Encodings.BinaryVectorEncoding;25 using HeuristicLab.Encodings.IntegerVectorEncoding;26 using HeuristicLab.Encodings.PermutationEncoding;27 using HeuristicLab.Encodings.RealVectorEncoding;28 24 29 namespace HeuristicLab. Problems.Programmable{25 namespace HeuristicLab.Optimization { 30 26 public abstract class Individual { 31 27 protected IEncoding Encoding { get; private set; } … … 61 57 } 62 58 } 63 64 #region extension methods65 public static class IndividualExtensionMethods {66 public static BinaryVector BinaryVector(this Individual individual) {67 var encoding = individual.GetEncoding<BinaryVectorEncoding>();68 return individual.BinaryVector(encoding.Name);69 }70 public static BinaryVector BinaryVector(this Individual individual, string name) {71 return (BinaryVector)individual[name];72 }73 74 public static IntegerVector IntegerVector(this Individual individual) {75 var encoding = individual.GetEncoding<IntegerVectorEncoding>();76 return individual.IntegerVector(encoding.Name);77 }78 public static IntegerVector IntegerVector(this Individual individual, string name) {79 return (IntegerVector)individual[name];80 }81 82 public static Permutation Permutation(this Individual individual) {83 var encoding = individual.GetEncoding<PermutationEncoding>();84 return individual.Permutation(encoding.Name);85 }86 public static Permutation Permutation(this Individual individual, string name) {87 return (Permutation)individual[name];88 }89 90 public static RealVector RealVector(this Individual individual) {91 var encoding = individual.GetEncoding<RealVectorEncoding>();92 return individual.RealVector(encoding.Name);93 }94 public static RealVector RealVector(this Individual individual, string name) {95 return (RealVector)individual[name];96 }97 }98 #endregion99 59 }
Note: See TracChangeset
for help on using the changeset viewer.