コード例 #1
0
ファイル: GACodeGenerator.cs プロジェクト: harnold/cobe
 public virtual bool Optimize(
     out InstructionGraph instructionGraph,
     out RegisterAssignment registerAssignment,
     out InstructionSchedule instructionSchedule)
 {
     return selector.Optimize(out instructionGraph,
                              out registerAssignment,
                              out instructionSchedule);
 }
コード例 #2
0
ファイル: InstructionSchedule.cs プロジェクト: harnold/cobe
        public virtual InstructionSchedule Clone(IDictionary instructionMap)
        {
            InstructionSchedule clone = new InstructionSchedule();

            foreach (InstructionNode[] step in instructions) {

                InstructionNode[] cloneStep = new InstructionNode[step.Length];

                for (int i = 0; i < step.Length; i++) {
                    if (step[i] != null)
                        cloneStep[i] = (InstructionNode) instructionMap[step[i]];
                    else
                        cloneStep[i] = null;
                }

                clone.instructions.Add(cloneStep);
            }

            return clone;
        }
コード例 #3
0
ファイル: GAInstructionSelector.cs プロジェクト: harnold/cobe
        public virtual bool Optimize(
            out InstructionGraph instructionGraph,
            out RegisterAssignment registerAssignment,
            out InstructionSchedule instructionSchedule)
        {
            Run();

            if (Done != null)
                Done(this);

            if (BestGenome.IsValid) {
                instructionGraph    = BestGenome.InstructionGraph;
                registerAssignment  = BestGenome.RegisterAssignment;
                instructionSchedule = BestGenome.InstructionSchedule;
                return true;

            } else {
                instructionGraph    = null;
                instructionSchedule = null;
                registerAssignment  = null;
                return false;
            }
        }
コード例 #4
0
ファイル: GAScheduler.cs プロジェクト: harnold/cobe
        public virtual bool Optimize(
            out RegisterAssignment registerAssignment,
            out InstructionSchedule instructionSchedule)
        {
            Run();

            if (Done != null)
                Done(this);

            registerAssignment = BestGenome.GetRegisterAssignment();
            instructionSchedule = BestGenome.GetInstructionSchedule();

            return BestGenome.IsValid;
        }
コード例 #5
0
ファイル: SelectionGenome.cs プロジェクト: harnold/cobe
        public virtual void Initialize()
        {
            IDictionary valueInitialized = new Hashtable();

            foreach (ValueNode val in ValueNodes)
                valueInitialized[val] = false;

            foreach (ValueNode val in ProgramGraph.OutputValues)
                InitializeValue(val, valueInitialized);

            instructionSchedule = null;
            registerAssignment = null;
            instructionGraph = null;

            /*
            bestSchedulingGenome = null;
            */
        }
コード例 #6
0
ファイル: SelectionGenome.cs プロジェクト: harnold/cobe
        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];
        }
コード例 #7
0
ファイル: SchedulingGenome.cs プロジェクト: harnold/cobe
        public virtual InstructionSchedule GetInstructionSchedule()
        {
            InstructionSchedule instructionSchedule =
                new InstructionSchedule();

            for (int i = 0; i < ScheduleLength; i++) {

                InstructionNode[] step = new InstructionNode[
                    MachineDescription.ExecutionUnits];

                for (int j = 0; j < step.Length; j++)
                    step[j] = Schedule[i, j];

                instructionSchedule.Instructions.Add(step);
            }

            return instructionSchedule;
        }