Example #1
0
 public SelectionGenome(SelectionGenomePopulation population)
 {
     this.population = population;
     selection = new Hashtable();
 }
Example #2
0
        public virtual void Initialize(
            MachineDescription machineDescription,
            ProgramGraph programGraph)
        {
            this.machineDescription = machineDescription;
            this.programGraph = programGraph;

            transferInstructions = machineDescription.GetTransferInstructions();
            operationNodes = programGraph.GetOperationNodes();
            valueNodes = programGraph.GetValueNodes();

            coveringDesc =
                programGraph.CreateCoveringDesc(machineDescription.Instructions);

            population = new SelectionGenomePopulation(PopulationSize, this);

            population.ScalingOperator   = new LinearScaling(ScalingFactor, true);
            population.SelectionOperator = new RouletteWheelSelection();
            population.MutationOperator  = new SelectionGenomeMutation();
            population.CrossoverOperator = new SelectionGenomeCrossover();
            population.GenomeEvaluator   = new SelectionGenomeEvaluator(scheduler);

            ga = new SimpleGA(population);

            ga.PMutation = configuration.PMutation;
            ga.PCrossover = configuration.PCrossover;

            ga.ComputeObjectiveStatistics =
                configuration.ComputeObjectiveStatistics;
            ga.ComputeFitnessStatistics =
                configuration.ComputeFitnessStatistics;
            ga.ComputeGenomeDiversity =
                configuration.ComputeGenomeDiversity;

            ga.GenerationComputed +=
                new SimpleGA.EventHandler(UpdateGAMonitor);

            bestObjectiveMonitor = new double[MonitoredGenerations];

            if (Initialized != null)
                Initialized(this);
        }
Example #3
0
        public virtual void Copy(IGenome otherGenome)
        {
            SelectionGenome other = (SelectionGenome) otherGenome;

            population = other.population;
            isValid = other.isValid;
            modified = other.modified;
            objective = other.objective;

            if (other.instructionGraph != null) {

                IDictionary instructionMap;
                IDictionary valueMap;

                instructionGraph =
                    other.instructionGraph.Clone(
                        out instructionMap, out valueMap);

                if (other.registerAssignment != null &&
                    other.instructionSchedule != null) {

                    registerAssignment =
                        other.registerAssignment.Clone(valueMap);

                    instructionSchedule =
                        other.instructionSchedule.Clone(instructionMap);

                    /*
                    bestSchedulingGenome =
                        other.bestSchedulingGenome.Clone(
                            instructionMap, valueMap);
                    */

                } else {
                    registerAssignment = null;
                    instructionSchedule = null;

                    /*
                    bestSchedulingGenome = null;
                    */
                }

            } else {
                instructionGraph = null;
            }

            foreach (OperationNode op in OperationNodes)
                selection[op] = other.selection[op];
        }