コード例 #1
0
        protected virtual void GetOperationsToMutate(
            ProgramGraph programGraph, ValueNode rootVal, int depth,
            IList operationsToMutate)
        {
            if (depth > 0) {

                if (!rootVal.IsInputValue()) {

                    OperationNode op =
                        (OperationNode) rootVal.ProducingOperation;

                    if (!operationsToMutate.Contains(op)) {
                        operationsToMutate.Add(op);
                        foreach (ValueNode opVal in op.OperandValues) {
                            GetOperationsToMutate(programGraph, opVal, depth - 1,
                                                  operationsToMutate);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: GAInstructionSelector.cs プロジェクト: harnold/cobe
        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);
        }
コード例 #3
0
ファイル: GACodeGenerator.cs プロジェクト: harnold/cobe
 public virtual void Initialize(
     MachineDescription machineDescription,
     ProgramGraph programGraph)
 {
     selector.Initialize(machineDescription, programGraph);
 }