/// <summary> /// Creates a new GA object with default values. /// </summary> public GA() { InitializeComponent(); LicenseManager.Validate(this.GetType(), this); Objective = null; Scaler = new ScalingDelegate(new Scaling.LinearFitnessScaler().Scale); Selector = new SelectionDelegate(Selection.RouletteSelector.Select); Recombinator = new RecombinationDelegate(Recombination.SinglePointCrossover.Recombine); //geneDescriptors = new GeneDescriptor[1]; //geneDescriptors[0] = new BinaryGeneDescriptor(); geneDescriptor = new BinaryGeneDescriptor(); highestObjective = System.Int32.MinValue; lowestObjective = System.Int32.MaxValue; license = LicenseManager.Validate(typeof(GA), this); encodingType = defaultEncodingType; selectionMethod = defaultSelectionMethod; recombinationOperator = defaultRecombinationOperator; mutationOperator = defaultMutationOperator; //PreScaler fitnessScaling = defaultFitnessScaling; }
public GeneDescriptor[] ImportType() { GeneDescriptor[] geneDescriptors; FieldInfo[] fields; fields = type.GetFields( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ); geneDescriptors = new GeneDescriptor[fields.Length]; int i=0; foreach(FieldInfo field in fields) { System.Type fieldType = field.FieldType; switch(fieldType.ToString()) { case "System.Int32": geneDescriptors[i] = new IntegerGeneDescriptor(0, 1000); geneDescriptors[i].Name = field.Name; break; case "System.Double": geneDescriptors[i] = new DoubleGeneDescriptor(); geneDescriptors[i].Name = field.Name; break; } System.Diagnostics.Debug.WriteLine(field.ToString() + ": " + field.FieldType.ToString()); i++; } return geneDescriptors; }
/// <summary> /// Creates a new gene. /// </summary> public Gene(GeneDescriptor geneDescriptor, int label) { this.Descriptor = geneDescriptor; this.label = label; }
/// <summary> /// Creates a new Gene. /// </summary> public Gene(GeneDescriptor geneDescriptor) : this(geneDescriptor, 0) { }
public void AddGene(GeneDescriptor geneDescriptor) { genes.Add(geneDescriptor); }
/// <summary> /// Creates a new GA object with default values. /// </summary> public GA() { InitializeComponent(); LicenseManager.Validate( this.GetType(), this ); Objective = null; Scaler = new ScalingDelegate ( new Scaling.LinearFitnessScaler().Scale ); Selector = new SelectionDelegate ( Selection.RouletteSelector.Select ); Recombinator= new RecombinationDelegate ( Recombination.SinglePointCrossover.Recombine ); //geneDescriptors = new GeneDescriptor[1]; //geneDescriptors[0] = new BinaryGeneDescriptor(); geneDescriptor = new BinaryGeneDescriptor(); highestObjective = System.Int32.MinValue; lowestObjective = System.Int32.MaxValue; license = LicenseManager.Validate(typeof(GA), this); encodingType = defaultEncodingType; selectionMethod = defaultSelectionMethod; recombinationOperator = defaultRecombinationOperator; mutationOperator = defaultMutationOperator; //PreScaler fitnessScaling = defaultFitnessScaling; }
/// <summary> /// Creates a new Gene. /// </summary> public Gene(GeneDescriptor geneDescriptor) : this(geneDescriptor, 0) {}