Example #1
0
File: ga.cs Project: mykwillis/genX
        /// <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;
        }
Example #2
0
 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;
 }
Example #3
0
 /// <summary>
 /// Creates a new gene.
 /// </summary>
 public Gene(GeneDescriptor geneDescriptor, int label)
 {
     this.Descriptor = geneDescriptor;
     this.label      = label;
 }
Example #4
0
 /// <summary>
 /// Creates a new Gene.
 /// </summary>
 public Gene(GeneDescriptor geneDescriptor) : this(geneDescriptor, 0)
 {
 }
Example #5
0
 public void AddGene(GeneDescriptor geneDescriptor)
 {
     genes.Add(geneDescriptor);
 }
Example #6
0
File: ga.cs Project: mykwillis/genX
        /// <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;
        }
Example #7
0
 public void AddGene(GeneDescriptor geneDescriptor)
 {
     genes.Add(geneDescriptor);
 }
Example #8
0
 /// <summary>
 /// Creates a new gene.
 /// </summary>
 public Gene(GeneDescriptor geneDescriptor, int label)
 {
     this.Descriptor = geneDescriptor;
     this.label = label;
 }
Example #9
0
 /// <summary>
 /// Creates a new Gene.
 /// </summary>
 public Gene(GeneDescriptor geneDescriptor) : this(geneDescriptor, 0) {}